oem7_log_nodelet.cpp
Go to the documentation of this file.
1 //
3 // Copyright (c) 2020 NovAtel Inc.
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 //
24 
25 #include <ros/ros.h>
26 #include <nodelet/nodelet.h>
27 
28 #include <message_handler.hpp>
29 
30 #include "novatel_oem7_msgs/Oem7RawMsg.h"
32 
33 #include <boost/scoped_ptr.hpp>
34 
35 namespace novatel_oem7_driver
36 {
37 
38  /*
39  * Adapter: novatel_oem7_msgs::Oem7RawMsg and Oem7RawMsgIf
40  */
42  {
43  public:
44  const novatel_oem7_msgs::Oem7RawMsg::ConstPtr msg_;
45 
46  RawMsgAdapter(const novatel_oem7_msgs::Oem7RawMsg::ConstPtr& msg):
47  msg_(msg)
48  {
49  }
50 
52  {
53  assert(false);
54  return Oem7RawMessageIf::OEM7MSGTYPE_UNKNOWN;
55  }
56 
58  {
59  assert(false);
60  return Oem7RawMessageIf::OEM7MSGFMT_UNKNOWN;
61  }
62 
63  int getMessageId() const
64  {
65  const Oem7MessageCommonHeaderMem* mem =
66  reinterpret_cast<const Oem7MessageCommonHeaderMem*>(getMessageData(0));
67  return mem->message_id;
68  }
69 
70  const uint8_t* getMessageData(size_t offset) const
71  {
72  return const_cast<uint8_t*>(msg_->message_data.data()); // FIXME
73  }
74 
75  size_t getMessageDataLength() const
76  {
77  return msg_->message_data.size();
78  }
79  };
80  /*
81  * Nodelet responsible for decoding raw Oem7 messages and generating specific ROS and novatel_oem7_msg messages.
82  * Subscribes to "oem7_raw_msg", and loads plugins which advertise specific messages.
83  * Raw oem7 messages are dispatched to plugins for decoding.
84  */
86  {
87  boost::scoped_ptr<MessageHandler> msg_handler_;
88 
90 
91 
92  public:
94  {
95  }
96 
97  void onInit()
98  {
99  ros::NodeHandle nh = getNodeHandle();
100  ros::NodeHandle priv_nh = getPrivateNodeHandle();
101  msg_handler_.reset(new MessageHandler(priv_nh));
102 
103  oem7_raw_msg_sub_ = nh.subscribe("oem7_raw_msg", 100, &Oem7LogNodelet::oem7RawMsgCb, this);
104  }
105 
109  void oem7RawMsgCb(const novatel_oem7_msgs::Oem7RawMsg::ConstPtr& msg)
110  {
111  boost::shared_ptr<RawMsgAdapter> raw_msg = boost::make_shared<RawMsgAdapter>(msg);
112  msg_handler_->handleMessage(raw_msg);
113  }
114  };
115 }
116 
117 
Oem7MessageType getMessageType() const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
PLUGINLIB_EXPORT_CLASS(novatel_oem7_driver::Oem7LogNodelet, nodelet::Nodelet)
const novatel_oem7_msgs::Oem7RawMsg::ConstPtr msg_
const uint8_t * getMessageData(size_t offset) const
RawMsgAdapter(const novatel_oem7_msgs::Oem7RawMsg::ConstPtr &msg)
Oem7MessageFormat getMessageFormat() const
boost::scoped_ptr< MessageHandler > msg_handler_
void oem7RawMsgCb(const novatel_oem7_msgs::Oem7RawMsg::ConstPtr &msg)


novatel_oem7_driver
Author(s):
autogenerated on Tue Mar 9 2021 03:48:00