marker_msgs.cpp
Go to the documentation of this file.
1 
10 #include "mrpt_bridge/time.h"
11 #include <marker_msgs/MarkerDetection.h>
12 #include <mrpt/obs/CObservationBearingRange.h>
13 
14 
15 
16 #include <iostream>
17 using namespace std;
18 
19 
20 namespace mrpt_bridge
21 {
22 bool convert(const marker_msgs::MarkerDetection& src, const mrpt::poses::CPose3D& pose, mrpt::obs::CObservationBearingRange& des) {
23 
24  convert(src.header.stamp, des.timestamp);
25  des.setSensorPose(pose);
26  des.minSensorDistance = src.distance_min;
27  des.maxSensorDistance = src.distance_max;
28 
29  des.sensedData.resize(src.markers.size());
30  for(size_t i = 0; i < src.markers.size(); i++) {
31  const marker_msgs::Marker &marker = src.markers[i];
32  mrpt::obs::CObservationBearingRange::TMeasurement &measurment = des.sensedData[i];
33  measurment.range = sqrt(marker.pose.position.x * marker.pose.position.x + marker.pose.position.y * marker.pose.position.y);
34  measurment.yaw = atan2(marker.pose.position.y, marker.pose.position.x);
35  measurment.pitch = 0.0;
36  if(marker.ids.size() > 0) {
37  measurment.landmarkID = marker.ids[0];
38  } else {
39  measurment.landmarkID = -1;
40  }
41  }
42  return true;
43 };
44 bool convert(const marker_msgs::MarkerDetection& src, const mrpt::poses::CPose3D& pose, mrpt::obs::CObservationBeaconRanges& des) {
45 
46  convert(src.header.stamp, des.timestamp);
47  des.setSensorPose(pose);
48  des.minSensorDistance = src.distance_min;
49  des.maxSensorDistance = src.distance_max;
50 
51  des.sensedData.resize(src.markers.size());
52  for(size_t i = 0; i < src.markers.size(); i++) {
53  const marker_msgs::Marker &marker = src.markers[i];
54  mrpt::obs::CObservationBeaconRanges::TMeasurement &measurment = des.sensedData[i];
55  measurment.sensedDistance = sqrt(marker.pose.position.x * marker.pose.position.x + marker.pose.position.y * marker.pose.position.y);
56  measurment.sensorLocationOnRobot.m_coords = pose.m_coords;
57  if(marker.ids.size() > 0) {
58  measurment.beaconID = marker.ids[0];
59  } else {
60  measurment.beaconID = -1;
61  }
62  }
63  return true;
64 };
65 }
Funtions to convert marker_msgs to mrpt msgs.
File includes methods for converting CNetworkOfPoses*DInf <=> NetworkOfPoses message types...
bool convert(const mrpt_msgs::ObservationRangeBeacon &_msg, const mrpt::poses::CPose3D &_pose, mrpt::obs::CObservationBeaconRanges &_obj)


mrpt_bridge
Author(s): Markus Bader , Raphael Zack
autogenerated on Sat Apr 28 2018 02:49:17