Fawkes API
Fawkes Development Version
|
00001 /*************************************************************************** 00002 * cmdvel_thread.h - Translate ROS Twist messages to Navgiator transrot 00003 * 00004 * Created: Fri Jun 1 13:29:39 CEST 2012 00005 * Copyright 2012 Sebastian Reuter 00006 ****************************************************************************/ 00007 00008 /* This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Library General Public License for more details. 00017 * 00018 * Read the full text in the LICENSE.GPL file in the doc directory. 00019 */ 00020 00021 #ifndef __PLUGINS_ROS_CMDVEL_THREAD_H_ 00022 #define __PLUGINS_ROS_CMDVEL_THREAD_H_ 00023 00024 #include <core/threading/thread.h> 00025 #include <core/utils/lockptr.h> 00026 #include <aspect/logging.h> 00027 #include <aspect/configurable.h> 00028 #include <aspect/blocked_timing.h> 00029 #include <aspect/blackboard.h> 00030 #include <plugins/ros/aspect/ros.h> 00031 #include <ros/subscriber.h> 00032 #include <geometry_msgs/Twist.h> 00033 00034 00035 namespace fawkes { 00036 class MotorInterface; 00037 } 00038 00039 class ROSCmdVelThread 00040 : public fawkes::Thread, 00041 public fawkes::LoggingAspect, 00042 public fawkes::ConfigurableAspect, 00043 public fawkes::BlackBoardAspect, 00044 public fawkes::ROSAspect 00045 { 00046 public: 00047 ROSCmdVelThread(); 00048 00049 virtual void init(); 00050 virtual void loop(); 00051 virtual bool prepare_finalize_user(); 00052 virtual void finalize(); 00053 00054 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */ 00055 protected: virtual void run() { Thread::run(); } 00056 00057 private: 00058 void stop(); //stops all Motors 00059 void send_transrot(float vx, float vy, float omega); //sends Controls to the Motors 00060 void twist_msg_cb(const geometry_msgs::Twist::ConstPtr &msg); 00061 00062 private: 00063 fawkes::MotorInterface *motor_if_; 00064 ros::Subscriber sub_; 00065 }; 00066 00067 #endif