00001 /************************************************************************************************** 00002 Software License Agreement (BSD License) 00003 00004 Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without modification, are permitted 00008 provided that the following conditions are met: 00009 00010 *Redistributions of source code must retain the above copyright notice, this list of 00011 conditions and the following disclaimer. 00012 *Redistributions in binary form must reproduce the above copyright notice, this list of 00013 conditions and the following disclaimer in the documentation and/or other materials provided 00014 with the distribution. 00015 *Neither the name of the University of Aveiro nor the names of its contributors may be used to 00016 endorse or promote products derived from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 00019 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00020 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00021 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00024 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00025 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 ***************************************************************************************************/ 00027 #ifndef _MANAGER_H_ 00028 #define _MANAGER_H_ 00029 00035 #include <ros/ros.h> 00036 #include <iostream> 00037 00038 #include <atlascar_base/ManagerStatus.h> 00039 #include <atlascar_base/ManagerCommand.h> 00040 00041 #include <atlascar_base/GearboxStatus.h> 00042 #include <atlascar_base/GearboxCommand.h> 00043 00044 #include <human_driver_monitor/HumanDriverMonitorStatus.h> 00045 #include <odometer/OdometerStatus.h> 00046 00047 #include <atlascar_base/ThrottleStatus.h> 00048 #include <atlascar_base/ThrottleCommand.h> 00049 00050 #include <atlascar_base/PlcStatus.h> 00051 #include <atlascar_base/PlcCommand.h> 00052 00053 #include <topic_priority/topic_priority.h> 00054 00055 namespace atlascar_base 00056 { 00057 00070 class Manager 00071 { 00072 public: 00093 Manager(const ros::NodeHandle& nh); 00094 00100 ~Manager(); 00101 00107 void init(); 00108 00115 void setupMessaging(); 00116 00122 void loop(); 00127 private: 00128 00134 void commandCallback(const atlascar_base::ManagerCommandPtr& command); 00135 00141 void plcStatusCallback(const atlascar_base::PlcStatusPtr& status); 00142 00148 void driverStatusCallback(const human_driver_monitor::HumanDriverMonitorStatusPtr& status); 00149 00155 void odometerStatusCallback(const odometer::OdometerStatusPtr& status); 00156 00162 void gearboxStatusCallback(const atlascar_base::GearboxStatusPtr& status); 00163 00169 void throttleStatusCallback(const atlascar_base::ThrottleStatusPtr& status); 00170 00171 void toOutgoingMessages(const atlascar_base::ManagerCommandPtr& command); 00172 00173 void stateManager(const atlascar_base::ManagerCommandPtr& command); 00174 00176 ros::NodeHandle nh_; 00178 ros::Subscriber command_sub_; 00180 ros::Subscriber status_plc_sub_; 00182 ros::Subscriber status_driver_sub_; 00184 ros::Subscriber status_odometer_sub_; 00186 ros::Subscriber status_gearbox_sub_; 00188 ros::Subscriber status_throttle_sub_; 00190 ros::Publisher status_pub_; 00192 ros::Publisher command_plc_pub_; 00194 ros::Publisher command_gearbox_pub_; 00196 ros::Publisher command_throttle_pub_; 00198 TopicQueuePriority<atlascar_base::ManagerCommandPtr> command_queue_; 00200 bool verbose_; 00202 atlascar_base::ManagerCommandPtr command_; 00204 atlascar_base::ManagerCommandPtr safety_command_; 00206 atlascar_base::ManagerStatus status_; 00208 atlascar_base::GearboxCommand gearbox_command_; 00210 atlascar_base::GearboxStatus gearbox_status_; 00212 atlascar_base::PlcCommand plc_command_; 00214 atlascar_base::PlcStatus plc_status_; 00216 human_driver_monitor::HumanDriverMonitorStatus driver_status_; 00218 atlascar_base::ThrottleCommand throttle_command_; 00220 atlascar_base::ThrottleStatus throttle_status_; 00222 odometer::OdometerStatus odometer_status_; 00223 }; 00224 00225 } 00226 00227 #endif