20 Protobuf2RosPublisher::Protobuf2RosPublisher(
ros::NodeHandle& nh,
const string& topic,
const string& pbMsgType,
21 const string& frame_id_prefix)
22 : _tfPrefix(frame_id_prefix)
24 if (pbMsgType ==
"Imu")
28 else if (pbMsgType ==
"Frame")
30 pub = nh.
advertise<geometry_msgs::PoseStamped>(topic, 1000);
35 msg <<
"Protobuf message type '" << pbMsgType <<
"' not supported!";
36 throw runtime_error(
msg.str());
47 string msg_name = pbMsg->GetDescriptor()->name();
49 if (msg_name ==
"Imu")
53 shared_ptr<roboception::msgs::Imu> protoImu = dynamic_pointer_cast<roboception::msgs::Imu>(pbMsg);
56 throw runtime_error(
"Given protobuf message was not of type Imu!");
60 rosImu->header.frame_id =
_tfPrefix + rosImu->header.frame_id;
63 else if (msg_name ==
"Frame")
67 shared_ptr<roboception::msgs::Frame> protoFrame = dynamic_pointer_cast<roboception::msgs::Frame>(pbMsg);
70 throw runtime_error(
"Given protobuf message was not of type Frame!");
74 rosPose->header.frame_id =
_tfPrefix + rosPose->header.frame_id;
80 msg <<
"Protobuf message type '" << msg_name <<
"' not supported!";
81 throw runtime_error(
msg.str());