beacon.cpp
Go to the documentation of this file.
1 
2 #include <geometry_msgs/Pose.h>
3 #include "mrpt_bridge/time.h"
4 #include "mrpt_bridge/pose.h"
5 #include <mrpt_msgs/ObservationRangeBeacon.h>
8 #include "mrpt_bridge/beacon.h"
9 
10 #include <mrpt/version.h>
11 #include <mrpt/obs/CObservationBeaconRanges.h>
12 using namespace mrpt::obs;
13 
14 namespace mrpt_bridge
15 {
16 bool convert(
18  const mrpt::poses::CPose3D& _pose, CObservationBeaconRanges& _obj)
19 {
20  mrpt_bridge::convert(_msg.header.stamp, _obj.timestamp);
21  mrpt::poses::CPose3D cpose_obj;
22 
23  _obj.stdError = _msg.sensor_std_range;
24  _obj.sensorLabel = _msg.header.frame_id;
25  _obj.maxSensorDistance = _msg.max_sensor_distance;
26  _obj.minSensorDistance = _msg.min_sensor_distance;
27 
28  if (_pose.empty())
29  {
30  convert(_msg.sensor_pose_on_robot, cpose_obj);
31  _obj.setSensorPose(cpose_obj);
32  }
33  else
34  {
35  _obj.setSensorPose(_pose);
36  }
37 
38  ASSERT_(_msg.sensed_data.size() >= 1);
39  const size_t N = _msg.sensed_data.size();
40 
41  _obj.sensedData.resize(N);
42 
43  for (std::size_t i_mrpt = 0; i_mrpt < N; i_mrpt++)
44  {
45  _obj.sensedData[i_mrpt].sensedDistance = _msg.sensed_data[i_mrpt].range;
46  _obj.sensedData[i_mrpt].beaconID = _msg.sensed_data[i_mrpt].id;
47  }
48  return true;
49 }
50 
51 bool convert(
52  const CObservationBeaconRanges& _obj,
54 {
55  mrpt::poses::CPose3D cpose_obj;
56 
57  mrpt_bridge::convert(_obj.timestamp, _msg.header.stamp);
58  _obj.getSensorPose(cpose_obj);
59  convert(cpose_obj, _msg.sensor_pose_on_robot);
60 
61  _msg.sensor_std_range = _obj.stdError;
62  _msg.header.frame_id = _obj.sensorLabel;
63  _msg.max_sensor_distance = _obj.maxSensorDistance;
64  _msg.min_sensor_distance = _obj.minSensorDistance;
65 
66  ASSERT_(_obj.sensedData.size() >= 1);
67  const size_t N = _obj.sensedData.size();
68 
69  _msg.sensed_data.resize(N);
70 
71  for (std::size_t i_msg = 0; i_msg < N; i_msg++)
72  {
73  _msg.sensed_data[i_msg].range = _obj.sensedData[i_msg].sensedDistance;
74  _msg.sensed_data[i_msg].id = _obj.sensedData[i_msg].beaconID;
75  }
76  return true;
77 }
78 
79 bool convert(
80  const CObservationBeaconRanges& _obj,
82 {
83  convert(_obj, _msg);
84  mrpt::poses::CPose3D pose;
85  _obj.getSensorPose(pose);
86  convert(pose, _pose);
87  return true;
88 }
89 } // end namespace
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)
bool convert(const CObservationBeaconRanges &_obj, mrpt_msgs::ObservationRangeBeacon &_msg, geometry_msgs::Pose &_pose)
Definition: beacon.cpp:79


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