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
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 #include <QPushButton>
00057 #include <QVBoxLayout>
00058
00059 #include "cob_3d_mapping_demonstrator/rviz_buttons.h"
00060
00061
00062 using namespace std;
00063
00064
00065 namespace cob_environment_perception
00066 {
00067
00068
00072 RvizButtons::RvizButtons( QWidget* parent )
00073 : rviz::Panel( parent )
00074 {
00075
00076 QPushButton* start_button = new QPushButton("Start Movement");
00077 start_button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
00078 QPushButton* stop_button = new QPushButton("Stop Movement");
00079 stop_button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
00080 QPushButton* step_button = new QPushButton("Down");
00081 step_button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
00082 QPushButton* reset_button = new QPushButton("Stop Processing");
00083 reset_button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
00084 QPushButton* clear_button = new QPushButton("Clear");
00085 clear_button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
00086 QPushButton* recover_button = new QPushButton("Start Processing");
00087 recover_button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
00088
00089 QVBoxLayout* layout = new QVBoxLayout;
00090 layout->addWidget(recover_button);
00091 layout->addWidget(reset_button);
00092 layout->addWidget(start_button);
00093 layout->addWidget(stop_button);
00094 layout->addWidget(step_button);
00095 layout->addWidget(clear_button);
00096 setLayout( layout );
00097
00098 connect( start_button, SIGNAL( clicked() ), this, SLOT( onStart() ));
00099 connect( stop_button, SIGNAL( clicked() ), this, SLOT( onStop() ));
00100 connect( step_button, SIGNAL( clicked() ), this, SLOT( onStep() ));
00101 connect( reset_button, SIGNAL( clicked() ), this, SLOT( onReset() ));
00102 connect( clear_button, SIGNAL( clicked() ), this, SLOT( onClear() ));
00103 connect( recover_button, SIGNAL( clicked() ), this, SLOT( onRecover() ));
00104
00105 action_client_ = new actionlib::SimpleActionClient<cob_script_server::ScriptAction>("cob_3d_mapping_demonstrator", true);
00106 }
00107
00108
00109 RvizButtons::~RvizButtons() {
00110
00111 }
00112
00113 void RvizButtons::onStart()
00114 {
00115 ROS_INFO("On start");
00116 cob_script_server::ScriptGoal goal;
00117 goal.function_name = "start";
00118
00119 action_client_->sendGoal(goal);
00120 action_client_->waitForResult(ros::Duration(1.0));
00121 if (action_client_->getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
00122 ROS_INFO("Demonstrator was started");
00123 ROS_INFO("Current State: %s\n", action_client_->getState().toString().c_str());
00124 }
00125
00126 void RvizButtons::onStop()
00127 {
00128 ROS_INFO("On stop");
00129 action_client_->cancelGoal();
00130 }
00131
00132 void RvizButtons::onStep()
00133 {
00134 ROS_INFO("On step");
00135 cob_script_server::ScriptGoal goal;
00136 goal.function_name = "step";
00137
00138 action_client_->sendGoal(goal);
00139 action_client_->waitForResult(ros::Duration(1.0));
00140 if (action_client_->getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
00141 ROS_INFO("Demonstrator step");
00142 ROS_INFO("Current State: %s\n", action_client_->getState().toString().c_str());
00143 }
00144
00145 void RvizButtons::onReset()
00146 {
00147 ROS_INFO("On reset");
00148 cob_script_server::ScriptGoal goal;
00149 goal.function_name = "reset";
00150
00151 action_client_->sendGoal(goal);
00152 action_client_->waitForResult(ros::Duration(1.0));
00153 if (action_client_->getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
00154 ROS_INFO("Demonstrator was recovered");
00155 ROS_INFO("Current State: %s\n", action_client_->getState().toString().c_str());
00156 }
00157
00158 void RvizButtons::onClear()
00159 {
00160 ROS_INFO("On clear");
00161 cob_script_server::ScriptGoal goal;
00162 goal.function_name = "clear";
00163
00164 action_client_->sendGoal(goal);
00165 action_client_->waitForResult(ros::Duration(1.0));
00166 if (action_client_->getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
00167 ROS_INFO("Demonstrator was recovered");
00168 ROS_INFO("Current State: %s\n", action_client_->getState().toString().c_str());
00169 }
00170
00171 void RvizButtons::onRecover()
00172 {
00173 ROS_INFO("On recover");
00174 cob_script_server::ScriptGoal goal;
00175 goal.function_name = "recover";
00176
00177 action_client_->sendGoal(goal);
00178 action_client_->waitForResult(ros::Duration(1.0));
00179 if (action_client_->getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
00180 ROS_INFO("Demonstrator was recovered");
00181 ROS_INFO("Current State: %s\n", action_client_->getState().toString().c_str());
00182
00183 }
00184
00185 }
00186
00187 #include <pluginlib/class_list_macros.h>
00188 PLUGINLIB_DECLARE_CLASS( cob_3d_mapping_demonstrator, Buttons, cob_environment_perception::RvizButtons, rviz::Panel )
00189