range.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-2017, 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 
10 /*---------------------------------------------------------------
11  APPLICATION: mrpt_ros bridge
12  FILE: range.cpp
13  AUTHOR: Raghavender Sahdev <raghavendersahdev@gmail.com>
14  ---------------------------------------------------------------*/
15 #include "mrpt_bridge/range.h"
16 #include <iostream>
17 using namespace std;
18 
19 
20 namespace mrpt_bridge
21 {
22  namespace range
23  {
24  /************************************************************************
25  * ros2mrpt *
26  ************************************************************************/
27  bool ros2mrpt(const sensor_msgs::Range &msg,
28  CObservationRange &obj) {
29  obj.minSensorDistance = msg.min_range;
30  obj.maxSensorDistance = msg.max_range;
31  obj.sensorConeApperture = msg.field_of_view;
32 
34  obj.sensedData.at(0).sensedDistance = msg.range;
35  return true;
36  }
37 
38  /************************************************************************
39  * mrpt2ros *
40  ************************************************************************/
41  bool mrpt2ros(const CObservationRange &obj,
42  const std_msgs::Header &msg_header,
43  sensor_msgs::Range *msg)
44  {
45  long num_range = obj.sensedData.size();
46 
47  // 1) sensor_msgs::Range:: header
48  for(int i=0 ; i<num_range ; i++)
49  msg[i].header = msg_header;
50 
51  // 2) sensor_msg::Range parameters
52  for(int i=0 ; i<num_range ; i++)
53  {
54  msg[i].max_range = obj.maxSensorDistance;
55  msg[i].min_range = obj.minSensorDistance;
56  msg[i].field_of_view = obj.sensorConeApperture;
57  }
58 
61  for (int i = 0; i < num_range; i++)
62  msg[i].range = obj.sensedData.at(i).sensedDistance;
63 
66  //msg.radiation_type
67  return true;
68  }
69  }
70 }
71 
73 /*
74 uint8 ULTRASOUND=0
75 uint8 INFRARED=1
76 std_msgs/Header header
77 uint8 radiation_type
78 float32 field_of_view
79 float32 min_range
80 float32 max_range
81 float32 range
82 */
bool mrpt2ros(const CObservationGPS &obj, const std_msgs::Header &msg_header, sensor_msgs::NavSatFix &msg)
Definition: GPS.cpp:57
File includes methods for converting CNetworkOfPoses*DInf <=> NetworkOfPoses message types...
const std::string header
bool ros2mrpt(const sensor_msgs::NavSatFix &msg, CObservationGPS &obj)
Definition: GPS.cpp:24


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