marker_msgs.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
18 #include "mrpt_bridge/time.h"
19 #include <marker_msgs/MarkerDetection.h>
20 #include <mrpt/obs/CObservationBearingRange.h>
21 
22 #include <iostream>
23 using namespace std;
24 
25 namespace mrpt_bridge
26 {
27 bool convert(
28  const marker_msgs::MarkerDetection& src, const mrpt::poses::CPose3D& pose,
29  mrpt::obs::CObservationBearingRange& des)
30 {
31  convert(src.header.stamp, des.timestamp);
32  des.setSensorPose(pose);
33  des.minSensorDistance = src.distance_min;
34  des.maxSensorDistance = src.distance_max;
35 
36  des.sensedData.resize(src.markers.size());
37  for (size_t i = 0; i < src.markers.size(); i++)
38  {
39  const marker_msgs::Marker& marker = src.markers[i];
40  mrpt::obs::CObservationBearingRange::TMeasurement& measurment =
41  des.sensedData[i];
42  measurment.range = sqrt(
43  marker.pose.position.x * marker.pose.position.x +
44  marker.pose.position.y * marker.pose.position.y);
45  measurment.yaw = atan2(marker.pose.position.y, marker.pose.position.x);
46  measurment.pitch = 0.0;
47  if (marker.ids.size() > 0)
48  {
49  measurment.landmarkID = marker.ids[0];
50  }
51  else
52  {
53  measurment.landmarkID = -1;
54  }
55  }
56  return true;
57 };
58 bool convert(
59  const marker_msgs::MarkerDetection& src, const mrpt::poses::CPose3D& pose,
60  mrpt::obs::CObservationBeaconRanges& des)
61 {
62  convert(src.header.stamp, des.timestamp);
63  des.setSensorPose(pose);
64  des.minSensorDistance = src.distance_min;
65  des.maxSensorDistance = src.distance_max;
66 
67  des.sensedData.resize(src.markers.size());
68  for (size_t i = 0; i < src.markers.size(); i++)
69  {
70  const marker_msgs::Marker& marker = src.markers[i];
71  mrpt::obs::CObservationBeaconRanges::TMeasurement& measurment =
72  des.sensedData[i];
73  measurment.sensedDistance = sqrt(
74  marker.pose.position.x * marker.pose.position.x +
75  marker.pose.position.y * marker.pose.position.y);
76  measurment.sensorLocationOnRobot.m_coords = pose.m_coords;
77  if (marker.ids.size() > 0)
78  {
79  measurment.beaconID = marker.ids[0];
80  }
81  else
82  {
83  measurment.beaconID = -1;
84  }
85  }
86  return true;
87 };
88 } // namespace mrpt_bridge
marker_msgs.h
Funtions to convert marker_msgs to mrpt msgs.
time.h
marker_msgs::MarkerDetection_
Definition: marker_msgs.h:41
mrpt_bridge::convert
bool convert(const mrpt_msgs::ObservationRangeBeacon &_msg, const mrpt::poses::CPose3D &_pose, mrpt::obs::CObservationBeaconRanges &_obj)
std
mrpt_bridge
File includes methods for converting CNetworkOfPoses*DInf <=> NetworkOfPoses message types.
Definition: include/mrpt_bridge/beacon.h:52


mrpt_bridge
Author(s): Markus Bader , Raphael Zack
autogenerated on Sun Mar 6 2022 03:48:10