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         }
00036 
00037         /************************************************************************
00038         *                                               mrpt2ros                                                                *
00039         ************************************************************************/
00040         bool mrpt2ros(const CObservationRange &obj,
00041                       const std_msgs::Header &msg_header,
00042                       sensor_msgs::Range *msg)
00043         {
00044             long num_range = obj.sensedData.size();
00045 
00046             // 1) sensor_msgs::Range:: header
00047             for(int i=0 ; i<num_range ; i++)
00048                 msg[i].header = msg_header;
00049 
00050             // 2) sensor_msg::Range parameters
00051             for(int i=0 ; i<num_range ; i++)
00052             {
00053                 msg[i].max_range = obj.maxSensorDistance;
00054                 msg[i].min_range = obj.minSensorDistance;
00055                 msg[i].field_of_view = obj.sensorConeApperture;
00056             }
00057 
00060             for (int i = 0; i < num_range; i++)
00061                 msg[i].range = obj.sensedData.at(i).sensedDistance;
00062 
00065             //msg.radiation_type
00066         }
00067     }
00068 }
00069 
00071 /*
00072 uint8 ULTRASOUND=0
00073 uint8 INFRARED=1
00074 std_msgs/Header header
00075 uint8 radiation_type
00076 float32 field_of_view
00077 float32 min_range
00078 float32 max_range
00079 float32 range
00080 */


mrpt_bridge
Author(s): Markus Bader , Raphael Zack
autogenerated on Mon Sep 18 2017 03:12:06