17 #include <marker_msgs/MarkerDetection.h> 18 #include <mrpt/obs/CObservationBearingRange.h> 19 #include <mrpt/ros1bridge/time.h> 23 const marker_msgs::MarkerDetection& src,
24 const mrpt::poses::CPose3D& sensorPoseOnRobot,
25 mrpt::obs::CObservationBearingRange& des)
28 des.setSensorPose(sensorPoseOnRobot);
29 des.minSensorDistance = src.distance_min;
30 des.maxSensorDistance = src.distance_max;
32 des.sensedData.resize(src.markers.size());
33 for (
size_t i = 0; i < src.markers.size(); i++)
35 const marker_msgs::Marker& marker = src.markers[i];
37 auto& m = des.sensedData[i];
39 marker.pose.position.x * marker.pose.position.x +
40 marker.pose.position.y * marker.pose.position.y);
41 m.yaw = atan2(marker.pose.position.y, marker.pose.position.x);
43 if (marker.ids.size() > 0)
45 m.landmarkID = marker.ids[0];
56 const marker_msgs::MarkerDetection& src,
57 const mrpt::poses::CPose3D& sensorPoseOnRobot,
58 mrpt::obs::CObservationBeaconRanges& des)
62 des.setSensorPose(sensorPoseOnRobot);
63 des.minSensorDistance = src.distance_min;
64 des.maxSensorDistance = src.distance_max;
66 des.sensedData.resize(src.markers.size());
67 for (
size_t i = 0; i < src.markers.size(); i++)
69 const marker_msgs::Marker& marker = src.markers[i];
71 auto& m = des.sensedData[i];
72 m.sensedDistance = sqrt(
73 marker.pose.position.x * marker.pose.position.x +
74 marker.pose.position.y * marker.pose.position.y);
75 m.sensorLocationOnRobot.m_coords = sensorPoseOnRobot.m_coords;
76 if (marker.ids.size() > 0)
78 m.beaconID = marker.ids[0];
Funtions to convert marker_msgs to mrpt msgs.
bool fromROS(const mrpt_msgs::ObservationRangeBeacon &_msg, const mrpt::poses::CPose3D &_pose, mrpt::obs::CObservationBeaconRanges &_obj)