sensor_base.h
Go to the documentation of this file.
00001 /******************************************************************************
00002    STDR Simulator - Simple Two DImensional Robot Simulator
00003    Copyright (C) 2013 STDR Simulator
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 3 of the License, or
00007    (at your option) any later version.
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software Foundation,
00014    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015    
00016    Authors : 
00017    * Manos Tsardoulias, etsardou@gmail.com
00018    * Aris Thallas, aris.thallas@gmail.com
00019    * Chris Zalidis, zalidis@gmail.com 
00020 ******************************************************************************/
00021 
00022 #ifndef SENSOR_H
00023 #define SENSOR_H
00024 
00025 #include <ros/ros.h>
00026 #include <tf/transform_listener.h>
00027 #include <nav_msgs/OccupancyGrid.h>
00028 #include <geometry_msgs/Pose2D.h>
00029 
00034 namespace stdr_robot {
00035 
00040   class Sensor {
00041     
00042     public:
00043       
00049       virtual void updateSensorCallback(void) = 0;
00050       
00055       inline geometry_msgs::Pose2D getSensorPose(void) const
00056       {
00057         return _sensorPose;
00058       }
00059       
00064       inline std::string getFrameId(void) const
00065       {
00066         return _namespace + "_" + _sensorFrameId;
00067       } 
00068       
00073       virtual ~Sensor(void) 
00074       {
00075       }
00076     
00077     protected:
00078       
00089       Sensor(
00090             const nav_msgs::OccupancyGrid& map,
00091             const std::string& name,
00092             ros::NodeHandle& n,
00093             const geometry_msgs::Pose2D& sensorPose,
00094             const std::string& sensorFrameId,
00095             float updateFrequency);
00096       
00102       void checkAndUpdateSensor(const ros::TimerEvent& ev);
00103       
00109       void updateTransform(const ros::TimerEvent& ev);
00110       
00111     protected:
00112     
00114       const std::string& _namespace;
00116       const nav_msgs::OccupancyGrid& _map;
00117       
00119       const geometry_msgs::Pose2D _sensorPose;
00121       const float _updateFrequency;
00123       const std::string _sensorFrameId;
00124       
00126       ros::Timer _timer;
00128       ros::Timer _tfTimer;
00129       
00131       ros::Publisher _publisher;
00133       tf::TransformListener _tfListener;
00135       tf::StampedTransform _sensorTransform;
00136       
00138       bool _gotTransform;
00139   };
00140 
00141   typedef boost::shared_ptr<Sensor> SensorPtr;
00142   typedef std::vector<SensorPtr> SensorPtrVector;
00143     
00144 }
00145 
00146 #endif


stdr_robot
Author(s): Manos Tsardoulias, Chris Zalidis, Aris Thallas
autogenerated on Wed Sep 2 2015 03:36:25