imarker.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 *
00003 * Software License Agreement (BSD License)
00004 *
00005 *  Copyright (c) 2013, Willow Garage, Inc.
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 *   * Redistributions of source code must retain the above copyright
00013 *     notice, this list of conditions and the following disclaimer.
00014 *   * Redistributions in binary form must reproduce the above
00015 *     copyright notice, this list of conditions and the following
00016 *     disclaimer in the documentation and/or other materials provided
00017 *     with the distribution.
00018 *   * Neither the name of Willow Garage, Inc. nor the names of its
00019 *     contributors may be used to endorse or promote products derived
00020 *     from this software without specific prior written permission.
00021 *
00022 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 *  POSSIBILITY OF SUCH DAMAGE.
00034 *
00035 * Author: Acorn Pooley
00036 *********************************************************************/
00037 
00038 // This code goes with the interactivity tutorial
00039 //    http://moveit.ros.org/wiki/index.php/Groovy/InteractiveRobot/InteractivityTutorial
00040 
00041 #ifndef PR2_MOVEIT_TUTORIALS_INTERACTIVITY_SRC_IMARKER_H_
00042 #define PR2_MOVEIT_TUTORIALS_INTERACTIVITY_SRC_IMARKER_H_
00043 
00044 #include <interactive_markers/interactive_marker_server.h>
00045 #include <Eigen/Geometry>
00046 
00047 
00048 /* Interactive marker.
00049  *
00050  * Constructing creates an interactive marker with either 3 or 6 DOF controls.
00051  *
00052  * name - name of marker and text of marker description
00053  * pose - starting position of marker
00054  * callback - called when marker is moved
00055  * dof - POS = 3DOF positional, ORIENT = 3DOF orientation, BOTH = 6DOF
00056  */
00057 class IMarker
00058 {
00059 public:
00060   /* degrees of freedom (3d position, 3d orientation, or both) */
00061   enum Dof { BOTH, POS, ORIENT };
00062 
00064   IMarker(interactive_markers::InteractiveMarkerServer& server,
00065           const std::string& name,
00066           const std::string& frame_id = "/base_footprint",
00067           boost::function<void (const visualization_msgs::InteractiveMarkerFeedbackConstPtr &)> callback = printFeedback,
00068           Dof dof = BOTH) :
00069     imarker_()
00070   {
00071     initialize(server, name, Eigen::Vector3d(0,0,0), Eigen::Quaterniond(1,0,0,0), frame_id, callback, dof);
00072   }
00073 
00075   IMarker(interactive_markers::InteractiveMarkerServer& server,
00076           const std::string& name,
00077           const Eigen::Affine3d& pose,
00078           const std::string& frame_id = "/base_footprint",
00079           boost::function<void (const visualization_msgs::InteractiveMarkerFeedbackConstPtr &)> callback = printFeedback,
00080           Dof dof = BOTH) :
00081     imarker_()
00082   {
00083     Eigen::Quaterniond q(pose.linear());
00084     Eigen::Vector3d p = pose.translation();
00085 
00086     initialize(server, name, p, q, frame_id, callback, dof);
00087   }
00088 
00090   IMarker(interactive_markers::InteractiveMarkerServer& server,
00091           const std::string& name,
00092           const Eigen::Vector3d& position,
00093           const Eigen::Quaterniond& orientation,
00094           const std::string& frame_id = "/base_footprint",
00095           boost::function<void (const visualization_msgs::InteractiveMarkerFeedbackConstPtr &)> callback = printFeedback,
00096           Dof dof = BOTH) :
00097     imarker_()
00098   {
00099     initialize(server, name, position, orientation, frame_id, callback, dof);
00100   }
00101 
00103   IMarker(interactive_markers::InteractiveMarkerServer& server,
00104           const std::string& name,
00105           const Eigen::Vector3d& position,
00106           const std::string& frame_id = "/base_footprint",
00107           boost::function<void (const visualization_msgs::InteractiveMarkerFeedbackConstPtr &)> callback = printFeedback,
00108           Dof dof = BOTH) :
00109     imarker_()
00110   {
00111     initialize(server, name, position, Eigen::Quaterniond(1,0,0,0), frame_id, callback, dof);
00112   }
00113 
00115   void move(const Eigen::Affine3d& pose);
00116 
00118   static void printFeedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &);
00119 
00120 private:
00121 
00122   /* called by constructors */
00123   void initialize(
00124           interactive_markers::InteractiveMarkerServer& server,
00125           const std::string& name,
00126           const Eigen::Vector3d& position,
00127           const Eigen::Quaterniond& orientation,
00128           const std::string& frame_id,
00129           boost::function<void (const visualization_msgs::InteractiveMarkerFeedbackConstPtr &)> callback,
00130           Dof dof);
00131 
00132   enum Axis { X, Y, Z };
00133   visualization_msgs::Marker makeAxisCyl( Axis axis );
00134   visualization_msgs::Marker makeBall();
00135   void makeBallControl();
00136   void makeAxisControl();
00137 
00138   visualization_msgs::InteractiveMarker imarker_;
00139   interactive_markers::InteractiveMarkerServer* server_;
00140 };
00141 
00142 #endif // PR2_MOVEIT_TUTORIALS_INTERACTIVITY_SRC_IMARKER_H_


pr2_moveit_tutorials
Author(s): Sachin Chitta
autogenerated on Mon Oct 6 2014 11:15:31