00001 // Copyright (C) 2010-2011 Institut de Robotica i Informatica Industrial, CSIC-UPC. 00002 // Author 00003 // All rights reserved. 00004 // 00005 // This file is part of iri-ros-pkg 00006 // iri-ros-pkg is free software: you can redistribute it and/or modify 00007 // it under the terms of the GNU Lesser General Public License as published by 00008 // the Free Software Foundation, either version 3 of the License, or 00009 // at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 // 00019 // IMPORTANT NOTE: This code has been generated through a script from the 00020 // iri_ros_scripts. Please do NOT delete any comments to guarantee the correctness 00021 // of the scripts. ROS topics can be easly add by using those scripts. Please 00022 // refer to the IRI wiki page for more information: 00023 // http://wikiri.upc.es/index.php/Robotics_Lab 00024 00025 #ifndef _safe_cmd_alg_node_h_ 00026 #define _safe_cmd_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "safe_cmd_alg.h" 00030 00031 // [publisher subscriber headers] 00032 #include <geometry_msgs/Twist.h> 00033 #include <sensor_msgs/LaserScan.h> 00034 00035 #include <algorithm> 00036 00037 // [service client headers] 00038 00039 // [action server client headers] 00040 00045 class SafeCmdAlgNode : public algorithm_base::IriBaseAlgorithm<SafeCmdAlgorithm> 00046 { 00047 private: 00048 // [publisher attributes] 00049 ros::Publisher cmd_vel_safe_publisher_; 00050 geometry_msgs::Twist Twist_msg_; 00051 geometry_msgs::Twist last_twist_; 00052 00053 // [subscriber attributes] 00054 ros::Subscriber cmd_vel_subscriber_; 00055 void cmd_vel_callback(const geometry_msgs::Twist::ConstPtr& msg); 00056 CMutex cmd_vel_mutex_; 00057 ros::Subscriber rear_laser_subscriber_; 00058 void rear_laser_callback(const sensor_msgs::LaserScan::ConstPtr& msg); 00059 CMutex rear_laser_mutex_; 00060 ros::Subscriber front_laser_subscriber_; 00061 void front_laser_callback(const sensor_msgs::LaserScan::ConstPtr& msg); 00062 CMutex front_laser_mutex_; 00063 00064 // [service attributes] 00065 00066 // [client attributes] 00067 00068 // [action server attributes] 00069 00070 // [action client attributes] 00071 float collision_time_; 00072 float min_dist_; 00073 float max_vel_front_; 00074 float max_vel_rear_; 00075 float limit_vel_front_; 00076 float limit_vel_rear_; 00077 float compute_max_velocity_(const sensor_msgs::LaserScan::ConstPtr& scan) const; 00078 00079 public: 00086 SafeCmdAlgNode(void); 00087 00094 ~SafeCmdAlgNode(void); 00095 00096 protected: 00109 void mainNodeThread(void); 00110 00123 void node_config_update(Config &config, uint32_t level); 00124 00131 void addNodeDiagnostics(void); 00132 00133 // [diagnostic functions] 00134 00135 // [test functions] 00136 }; 00137 00138 #endif