rviz_scan_tool.cpp
Go to the documentation of this file.
00001 /*
00002  *  Software License Agreement (BSD License)
00003  *
00004  *  Robot Operating System code by the University of Osnabrück
00005  *  Copyright (c) 2015, University of Osnabrück
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  *   1. Redistributions of source code must retain the above 
00013  *      copyright notice, this list of conditions and the following
00014  *      disclaimer.
00015  *
00016  *   2. Redistributions in binary form must reproduce the above 
00017  *      copyright notice, this list of conditions and the following
00018  *      disclaimer in the documentation and/or other materials provided
00019  *      with the distribution.
00020  *
00021  *   3. Neither the name of the copyright holder nor the names of its
00022  *      contributors may be used to endorse or promote products derived
00023  *      from this software without specific prior written permission.
00024  *
00025  *
00026  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00027  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00028  *  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029  *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
00030  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00033  *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00034  *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00035  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00036  *  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  *
00039  *
00040  *  uos_rotunit_teleop_rviz.h
00041  *
00042  *  author: Sebastian Pütz <spuetz@uni-osnabrueck.de>
00043  */
00044 
00045 
00046 #include "rviz_scan_tool.h"
00047 
00048 #include <pluginlib/class_list_macros.h>
00049 PLUGINLIB_EXPORT_CLASS(uos_rotunit_teleop::RvizScanTool, rviz::Tool)
00050 
00051 namespace uos_rotunit_teleop{
00052 
00053 
00054 RvizScanTool::RvizScanTool()
00055  :ac_("rotunit_snapshotter", true)
00056 {
00057 }
00058 
00059 RvizScanTool::~RvizScanTool(){};
00060 
00061 void RvizScanTool::onInitialize(){
00062   ros::NodeHandle nh;
00063 
00064   nh.param("timeout", timeout_, 30.0);    // waiting time for a snapshot to be finished
00065   rot_vel_client_ = nh.serviceClient<uos_rotunit_driver::RotVelSrv>("rotunit_velocity");
00066   setName("Assemble Cloud");
00067 }
00068 
00069 int RvizScanTool::processMouseEvent( rviz::ViewportMouseEvent& event ){
00070   return flags_;
00071 }
00072 
00073 void RvizScanTool::deactivate(){
00074 
00075 }
00076 
00077 void RvizScanTool::activate(){
00078   flags_ = Render;
00079 
00080   bool connected = ac_.isServerConnected();
00081   
00082   if(!connected){
00083     ROS_INFO("Try to connect to the uos_rotunit_snapshotter action server.");
00084     connected = ac_.waitForServer(ros::Duration(1)); 
00085     if(connected){
00086         ROS_INFO("Connected to uos_rotunit_snapshotter server.");
00087     }else{
00088         ROS_WARN("Please start the uos_rotunit_snapshotter!");
00089     }
00090   }
00091   
00092   if(connected){
00093     uos_rotunit_snapshotter::RotunitSnapshotGoal goal;
00094     goal.angle = 2 * M_PI;
00095     ac_.sendGoal(goal);
00096     ac_.sendGoal(goal,
00097       boost::bind(&RvizScanTool::doneCb, this, _1, _2),
00098       actionlib::SimpleActionClient<uos_rotunit_snapshotter::RotunitSnapshotAction>::SimpleActiveCallback(),
00099       actionlib::SimpleActionClient<uos_rotunit_snapshotter::RotunitSnapshotAction>::SimpleFeedbackCallback());
00100     ROS_INFO("Assembling cloud.");
00101     setName("Assembling Cloud...");
00102 
00103   }
00104 }
00105 
00106 void RvizScanTool::doneCb(
00107   const actionlib::SimpleClientGoalState& state,
00108   const uos_rotunit_snapshotter::RotunitSnapshotResultConstPtr& result)
00109   {
00110     ROS_INFO("Finished in state [%s]", state.toString().c_str());
00111         setName("Assemble Cloud");
00112         flags_ = (Finished|Render);
00113 
00114   }
00115 
00116 
00117 } /* namespace uos_rotunit_teleop */


uos_rotunit_teleop
Author(s):
autogenerated on Thu Jun 6 2019 19:07:33