rviz_buttons.cpp
Go to the documentation of this file.
00001 /****************************************************************
00002  *
00003  * Copyright (c) 2010
00004  *
00005  * Fraunhofer Institute for Manufacturing Engineering
00006  * and Automation (IPA)
00007  *
00008  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00009  *
00010  * Project name: care-o-bot
00011  * ROS stack name: cob_3d_environment_perception_intern
00012  * ROS package name: cob_3d_mapping_demonstrator
00013  * Description: Feature Map for storing and handling geometric features
00014  *
00015  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00016  *
00017  * Author: Georg Arbeiter, email:georg.arbeiter@ipa.fhg.de
00018  * Supervised by: Georg Arbeiter, email:georg.arbeiter@ipa.fhg.de
00019  *
00020  * Date of creation: 03/2012
00021  * ToDo:
00022  *
00023  *
00024  *
00025  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00026  *
00027  * Redistribution and use in source and binary forms, with or without
00028  * modification, are permitted provided that the following conditions are met:
00029  *
00030  *     * Redistributions of source code must retain the above copyright
00031  *       notice, this list of conditions and the following disclaimer.
00032  *     * Redistributions in binary form must reproduce the above copyright
00033  *       notice, this list of conditions and the following disclaimer in the
00034  *       documentation and/or other materials provided with the distribution.
00035  *     * Neither the name of the Fraunhofer Institute for Manufacturing
00036  *       Engineering and Automation (IPA) nor the names of its
00037  *       contributors may be used to endorse or promote products derived from
00038  *       this software without specific prior written permission.
00039  *
00040  * This program is free software: you can redistribute it and/or modify
00041  * it under the terms of the GNU Lesser General Public License LGPL as
00042  * published by the Free Software Foundation, either version 3 of the
00043  * License, or (at your option) any later version.
00044  *
00045  * This program is distributed in the hope that it will be useful,
00046  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00047  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00048  * GNU Lesser General Public License LGPL for more details.
00049  *
00050  * You should have received a copy of the GNU Lesser General Public
00051  * License LGPL along with this program.
00052  * If not, see <http://www.gnu.org/licenses/>.
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      // Fill in goal here
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      // Fill in goal here
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      // Fill in goal here
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      // Fill in goal here
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      // Fill in goal here
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 


cob_3d_mapping_demonstrator
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:03:46