MRPT  1.9.9
range.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 /*---------------------------------------------------------------
11  APPLICATION: mrpt_ros bridge
12  FILE: range.cpp
13  AUTHOR: Raghavender Sahdev <raghavendersahdev@gmail.com>
14  ---------------------------------------------------------------*/
15 
16 #include <mrpt/ros1bridge/range.h>
17 
18 namespace mrpt::ros1bridge
19 {
20 bool fromROS(const sensor_msgs::Range& msg, mrpt::obs::CObservationRange& obj)
21 {
22  obj.minSensorDistance = msg.min_range;
23  obj.maxSensorDistance = msg.max_range;
24  obj.sensorConeApperture = msg.field_of_view;
25 
26  /// again this is amibiguous as can't be certain of number of measurement
27  /// from corresponding ROS message
28  obj.sensedData.at(0).sensedDistance = msg.range;
29  return true;
30 }
31 
32 bool toROS(
33  const mrpt::obs::CObservationRange& obj, const std_msgs::Header& msg_header,
34  sensor_msgs::Range* msg)
35 {
36  long num_range = obj.sensedData.size();
37 
38  // 1) sensor_msgs::Range:: header
39  for (long i = 0; i < num_range; i++) msg[i].header = msg_header;
40 
41  // 2) sensor_msg::Range parameters
42  for (long i = 0; i < num_range; i++)
43  {
44  msg[i].max_range = obj.maxSensorDistance;
45  msg[i].min_range = obj.minSensorDistance;
46  msg[i].field_of_view = obj.sensorConeApperture;
47  }
48 
49  /// following part needs to be double checked, it looks incorrect
50  /// ROS has single number float for range, MRPT has a list of
51  /// sensedDistances
52  for (long i = 0; i < num_range; i++)
53  msg[i].range = obj.sensedData.at(i).sensedDistance;
54 
55  /// currently the following are not available in MRPT for corresponding
56  /// range ROS message NO corresponding value for MRPT radiation_type at
57  /// http://mrpt.ual.es/reference/devel/_c_observation_range_8h_source.html
58  // msg.radiation_type
59  return true;
60 }
61 
62 } // namespace mrpt::ros1bridge
63 
64 /// Range ROS message
65 /*
66 uint8 ULTRASOUND=0
67 uint8 INFRARED=1
68 std_msgs/Header header
69 uint8 radiation_type
70 float32 field_of_view
71 float32 min_range
72 float32 max_range
73 float32 range
74 */
Declares a class derived from "CObservation" that encapsules a single range measurement, and associated parameters.
float minSensorDistance
The data members.
float sensorConeApperture
Cone aperture of each ultrasonic beam, in radians.
nv_oem6_header_t header
Novatel frame: NV_OEM6_BESTPOS.
bool toROS(const mrpt::obs::CObservationGPS &obj, const std_msgs::Header &msg_header, sensor_msgs::NavSatFix &msg)
Convert mrpt::obs::CObservationGPS -> sensor_msgs/NavSatFix The user must supply the "msg_header" fie...
Definition: gps.cpp:48
ROS message: http://docs.ros.org/api/sensor_msgs/html/msg/NavSatFix.html MRPT message: https://github...
Definition: gps.h:28
bool fromROS(const sensor_msgs::NavSatFix &msg, mrpt::obs::CObservationGPS &obj)
Convert sensor_msgs/NavSatFix -> mrpt::obs::CObservationGPS.
Definition: gps.cpp:20
TMeasurementList sensedData
All the measurements.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020