range.cpp
Go to the documentation of this file.
00001 /* +------------------------------------------------------------------------+
00002    |                     Mobile Robot Programming Toolkit (MRPT)            |
00003    |                          http://www.mrpt.org/                          |
00004    |                                                                        |
00005    | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file     |
00006    | See: http://www.mrpt.org/Authors - All rights reserved.                |
00007    | Released under BSD License. See details in http://www.mrpt.org/License |
00008    +------------------------------------------------------------------------+ */
00009 
00010 /*---------------------------------------------------------------
00011         APPLICATION: mrpt_ros bridge
00012         FILE: range.cpp
00013         AUTHOR: Raghavender Sahdev <raghavendersahdev@gmail.com>
00014   ---------------------------------------------------------------*/
00015 #include "mrpt_bridge/range.h"
00016 #include <iostream>
00017 using namespace std;
00018 
00019 
00020 namespace mrpt_bridge
00021 {
00022     namespace range
00023     {
00024         /************************************************************************
00025         *                                               ros2mrpt                                                                *
00026         ************************************************************************/
00027         bool ros2mrpt(const sensor_msgs::Range &msg,
00028                       CObservationRange &obj) {
00029             obj.minSensorDistance = msg.min_range;
00030             obj.maxSensorDistance = msg.max_range;
00031             obj.sensorConeApperture = msg.field_of_view;
00032 
00034             obj.sensedData.at(0).sensedDistance = msg.range;
00035             return true;
00036         }
00037 
00038         /************************************************************************
00039         *                                               mrpt2ros                                                                *
00040         ************************************************************************/
00041         bool mrpt2ros(const CObservationRange &obj,
00042                       const std_msgs::Header &msg_header,
00043                       sensor_msgs::Range *msg)
00044         {
00045             long num_range = obj.sensedData.size();
00046 
00047             // 1) sensor_msgs::Range:: header
00048             for(int i=0 ; i<num_range ; i++)
00049                 msg[i].header = msg_header;
00050 
00051             // 2) sensor_msg::Range parameters
00052             for(int i=0 ; i<num_range ; i++)
00053             {
00054                 msg[i].max_range = obj.maxSensorDistance;
00055                 msg[i].min_range = obj.minSensorDistance;
00056                 msg[i].field_of_view = obj.sensorConeApperture;
00057             }
00058 
00061             for (int i = 0; i < num_range; i++)
00062                 msg[i].range = obj.sensedData.at(i).sensedDistance;
00063 
00066             //msg.radiation_type
00067             return true;
00068         }
00069     }
00070 }
00071 
00073 /*
00074 uint8 ULTRASOUND=0
00075 uint8 INFRARED=1
00076 std_msgs/Header header
00077 uint8 radiation_type
00078 float32 field_of_view
00079 float32 min_range
00080 float32 max_range
00081 float32 range
00082 */


mrpt_bridge
Author(s): Markus Bader , Raphael Zack
autogenerated on Fri Apr 27 2018 05:10:54