00001 /********************************************************************* 00002 * 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2010, ISR University of Coimbra. 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * * Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * * Redistributions in binary form must reproduce the above 00015 * copyright notice, this list of conditions and the following 00016 * disclaimer in the documentation and/or other materials provided 00017 * with the distribution. 00018 * * Neither the name of the ISR University of Coimbra nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 * Author: Gonçalo Cabrita on 11/10/2010 00036 *********************************************************************/ 00037 #include <ros/ros.h> 00038 #include <actionlib/server/simple_action_server.h> 00039 #include <tf/transform_broadcaster.h> 00040 #include <geometry_msgs/Twist.h> // cmd_vel 00041 #include <roomba_500_series/IRCharacter.h> // ir_character 00042 #include <roomba_500_series/Battery.h> // battery 00043 #include <roomba_500_series/GoDockAction.h> 00044 00045 // IR Characters 00046 #define FORCE_FIELD 161 00047 #define GREEN_BUOY 164 00048 #define GREEN_BUOY_FORCE_FIELD 165 00049 #define RED_BUOY 168 00050 #define RED_BUOY_FORCE_FIELD 169 00051 #define RED_BUOY_GREEN_BUOY 172 00052 #define RED_BUOY_GREEN_BUOY_FORCE_FIELD 173 00053 #define VIRTUAL_WALL 162 00054 00060 class GoDockAction 00061 { 00062 protected: 00064 ros::NodeHandle nh_; 00066 actionlib::SimpleActionServer<roomba_500_series::GoDockAction> as_; 00068 std::string action_name_; 00069 00071 roomba_500_series::GoDockFeedback feedback_; 00073 roomba_500_series::GoDockResult result_; 00074 00075 private: 00077 ros::Publisher cmd_vel_pub_; 00078 00080 ros::Subscriber ir_sub_; 00082 ros::Subscriber bat_sub_; 00083 00085 roomba_500_series::IRCharacter ir_character_; 00087 bool dock_; 00088 00090 00097 void sendCmdVel(float linear, float angular); 00098 00099 public: 00101 00106 GoDockAction(std::string name); 00108 ~GoDockAction(); 00109 00111 00117 void goalCallback(const roomba_500_series::GoDockGoalConstPtr & goal); 00119 00125 void irCallback(const roomba_500_series::IRCharacterConstPtr & ir); 00127 00133 void batteryCallback(const roomba_500_series::BatteryConstPtr & bat); 00134 }; 00135 00136 // EOF