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 _laser_navigation_alg_node_h_ 00026 #define _laser_navigation_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "laser_navigation_alg.h" 00030 00031 // read bag headers 00032 #include <rosbag/bag.h> 00033 #include <rosbag/view.h> 00034 #include <boost/foreach.hpp> 00035 00036 // read pose 00037 #include <tf/transform_datatypes.h> 00038 #include <tf/transform_broadcaster.h> 00039 00040 // [publisher subscriber headers] 00041 #include <visualization_msgs/Marker.h> 00042 #include <sensor_msgs/LaserScan.h> 00043 #include <nav_msgs/Odometry.h> 00044 00045 // [service client headers] 00046 #include <iri_laser_localisation/DoLocalisation.h> 00047 #include <iri_laser_localisation/DoEstimation.h> 00048 00049 // [action server client headers] 00050 #include <actionlib/client/simple_action_client.h> 00051 #include <actionlib/client/terminal_state.h> 00052 #include <move_base_msgs/MoveBaseAction.h> 00053 00058 class LaserNavigationAlgNode : public algorithm_base::IriBaseAlgorithm<LaserNavigationAlgorithm> 00059 { 00060 private: 00061 // [publisher attributes] 00062 ros::Publisher scans_map_publisher_; 00063 sensor_msgs::LaserScan LaserScan_msg_; 00064 ros::Publisher pose_ref_publisher_; 00065 ros::Publisher checkpoints_publisher_; 00066 visualization_msgs::Marker Marker_msg_; 00067 00068 // [subscriber attributes] 00069 ros::Subscriber scan_subscriber_; 00070 void scan_callback(const sensor_msgs::LaserScan::ConstPtr& msg); 00071 CMutex scan_mutex_; 00072 00073 // [service attributes] 00074 00075 // [client attributes] 00076 ros::ServiceClient localise_client_; 00077 iri_laser_localisation::DoLocalisation localise_srv_; 00078 ros::ServiceClient estimate_client_; 00079 iri_laser_localisation::DoEstimation estimate_srv_; 00080 00081 // [action server attributes] 00082 00083 // [action client attributes] 00084 actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> send_goal_client_; 00085 void send_goalMakeActionRequest(const geometry_msgs::PoseStamped & new_goal); 00086 void send_goalDone(const actionlib::SimpleClientGoalState& state, const move_base_msgs::MoveBaseResultConstPtr& result); 00087 void send_goalActive(); 00088 void send_goalFeedback(const move_base_msgs::MoveBaseFeedbackConstPtr& feedback); 00089 00090 // read bag 00091 bool load_path_(const std::string & bag_path); 00092 00093 sensor_msgs::LaserScan scan_sens_; 00094 std::vector<sensor_msgs::LaserScan> scan_path_; 00095 std::vector<geometry_msgs::PoseStamped> pose_path_; 00096 uint current_; 00097 bool new_scan_; 00098 bool waiting_; 00099 bool first_; 00100 void publish_marker(const geometry_msgs::PoseStamped & pose, const int & type); 00101 tf::TransformBroadcaster tfb_; 00102 00103 public: 00110 LaserNavigationAlgNode(void); 00111 00118 ~LaserNavigationAlgNode(void); 00119 00120 protected: 00133 void mainNodeThread(void); 00134 00147 void node_config_update(Config &config, uint32_t level); 00148 00155 void addNodeDiagnostics(void); 00156 00157 void ROS_INFO_PRESS(const std::string & str); 00158 void ROS_INFO_XYR(const std::string & str,const float & x,const float & y,const geometry_msgs::Quaternion & r); 00159 void ROS_INFO_XYR(const std::string & str,const tf::Transform & tftrans); 00160 00161 // [diagnostic functions] 00162 00163 // [test functions] 00164 }; 00165 00166 #endif