Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "flyer_controller/control_mode.h"
00035
00036 using namespace flyer_controller::ControlModeTypes;
00037
00038 namespace flyer_controller
00039 {
00040 class ControlModeIdle : public ControlMode
00041 {
00042
00043 public:
00044 ControlModeIdle()
00045 {
00046 }
00047
00048 void onInit()
00049 {
00050 ROS_INFO("ControlModeIdle onInit() called");
00051 ControlMode::onInit();
00052 requestRegistration("idle");
00053 ready = true;
00054 }
00055
00056 private:
00057 void controlModeCmdCallback(const control_mode_cmdConstPtr& msg)
00058 {
00059 NODELET_INFO_STREAM("Heard command: " << msg->cmd);
00060 if (msg->cmd == "mode idle")
00061 {
00062 state = IDLE;
00063 info = "";
00064 }
00065 else if (msg->cmd == "mode standby")
00066 {
00067 state = STANDBY;
00068 info = "";
00069 }
00070 else if (msg->cmd == "mode active")
00071 {
00072 if (state == STANDBY)
00073 {
00074 state = ACTIVE;
00075 info = "";
00076 }
00077 else
00078 {
00079 ROS_ERROR("Invalid transition");
00080 }
00081 }
00082 else
00083 {
00084 ROS_ERROR_STREAM("Command unknown: " << msg->cmd);
00085 }
00086 }
00087
00088 void outputControl()
00089 {
00090
00091 control_mode_outputPtr output_msg(new control_mode_output);
00092 output_msg->control_mode = "idle";
00093 output_msg->motors_on = false;
00094 output_msg->direct_yaw_rate_commands = false;
00095 output_msg->yaw_cmd = 0;
00096 output_msg->yaw_rate_cmd = 0;
00097 output_msg->direct_thrust_commands = true;
00098 output_msg->thrust_cmd = 0;
00099 output_msg->alt_cmd = 0;
00100 output_msg->header.stamp = ros::Time::now();
00101 switch (state)
00102 {
00103 case ControlModeTypes::STANDBY:
00104 output_pub.publish(output_msg);
00105 break;
00106 case ControlModeTypes::ACTIVE:
00107 output_pub.publish(output_msg);
00108 break;
00109 default:
00110 break;
00111 }
00112 }
00113
00114 };
00115 PLUGINLIB_DECLARE_CLASS(flyer_controller, ControlModeIdle, flyer_controller::ControlModeIdle, nodelet::Nodelet)
00116 ;
00117
00118 }