interactive_marker_display.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef RVIZ_INTERACTIVE_MARKER_DISPLAY_H
00031 #define RVIZ_INTERACTIVE_MARKER_DISPLAY_H
00032 
00033 #include "rviz/default_plugin/interactive_markers/interactive_marker.h"
00034 #include "rviz/default_plugin/interactive_markers/interactive_marker_client.h"
00035 
00036 #include "rviz/display.h"
00037 #include "rviz/selection/forwards.h"
00038 #include "rviz/properties/forwards.h"
00039 
00040 #include <map>
00041 #include <set>
00042 
00043 #include <visualization_msgs/InteractiveMarker.h>
00044 #include <visualization_msgs/InteractiveMarkerUpdate.h>
00045 #include <visualization_msgs/InteractiveMarkerInit.h>
00046 
00047 #include <message_filters/subscriber.h>
00048 #include <tf/message_filter.h>
00049 
00050 namespace Ogre
00051 {
00052 class SceneManager;
00053 class SceneNode;
00054 }
00055 
00056 namespace rviz
00057 {
00058 class Object;
00059 }
00060 
00061 namespace rviz
00062 {
00063 
00064 class MarkerSelectionHandler;
00065 typedef boost::shared_ptr<MarkerSelectionHandler> MarkerSelectionHandlerPtr;
00066 
00067 class MarkerBase;
00068 typedef boost::shared_ptr<MarkerBase> MarkerBasePtr;
00069 
00070 typedef std::pair<std::string, int32_t> MarkerID;
00071 
00078 class InteractiveMarkerDisplay : public Display, public InteractiveMarkerReceiver
00079 {
00080 public:
00081   InteractiveMarkerDisplay();
00082   virtual ~InteractiveMarkerDisplay();
00083 
00084   virtual void onInitialize();
00085 
00086   virtual void update(float wall_dt, float ros_dt);
00087 
00088   virtual void fixedFrameChanged();
00089   virtual void reset();
00090 
00091   void setMarkerUpdateTopic(const std::string& topic);
00092   const std::string& getMarkerUpdateTopic() { return marker_update_topic_; }
00093 
00094   virtual void createProperties();
00095 
00096   bool getShowDescriptions() { return show_descriptions_; }
00097   void setShowDescriptions( bool show );
00098 
00099   bool getShowToolTips() { return show_tool_tips_; }
00100   void setShowToolTips( bool show );
00101 
00102   bool getShowAxes() { return show_axes_; }
00103   void setShowAxes( bool show );
00104 
00106   void setStatusOk(const std::string& name, const std::string& text);
00107   void setStatusWarn(const std::string& name, const std::string& text);
00108   void setStatusError(const std::string& name, const std::string& text);
00109 
00114   bool subscribeToInit();
00115 
00116   // Clear the marker display stuff from the visual scene.
00117   void clearMarkers();
00118 
00119   // Update the display's versions of the markers.
00120   void processMarkerChanges( const std::vector<visualization_msgs::InteractiveMarker>* markers = NULL,
00121                              const std::vector<visualization_msgs::InteractiveMarkerPose>* poses = NULL,
00122                              const std::vector<std::string>* erases = NULL );
00123 
00124   void unsubscribeFromInit();
00125 
00127   virtual void hideVisible();
00128 
00130   virtual void restoreVisible();
00131 
00132 protected:
00133 
00134   virtual void onEnable();
00135   virtual void onDisable();
00136 
00137   // Subscribe to all message topics
00138   void subscribe();
00139 
00140   // Unsubscribe from all message topics
00141   void unsubscribe();
00142 
00143   // put the marker into the message queue where it can be read out by the main thread (in update())
00144   void tfMarkerSuccess(const visualization_msgs::InteractiveMarker::ConstPtr& marker);
00145 
00146   // message filter callback for failed marker transformation
00147   void tfMarkerFail(const visualization_msgs::InteractiveMarker::ConstPtr& marker, tf::FilterFailureReason reason);
00148 
00149   // put the pose update into the message queue where it can be read out by the main thread (in update())
00150   void tfPoseSuccess(const visualization_msgs::InteractiveMarkerPose::ConstPtr& marker_pose);
00151 
00152   // message filter callback for failed pose transformation
00153   void tfPoseFail(const visualization_msgs::InteractiveMarkerPose::ConstPtr& marker_pose, tf::FilterFailureReason reason);
00154 
00155   void updateMarker( visualization_msgs::InteractiveMarker::ConstPtr& marker );
00156   void updatePose( visualization_msgs::InteractiveMarkerPose::ConstPtr& pose );
00157 
00158   InteractiveMarkerClient im_client_;
00159 
00160   // Ogre objects
00161   Ogre::SceneNode* scene_node_;
00162 
00163   typedef boost::shared_ptr<InteractiveMarker> InteractiveMarkerPtr;
00164   typedef std::map< std::string, InteractiveMarkerPtr > M_StringToInteractiveMarkerPtr;
00165   M_StringToInteractiveMarkerPtr interactive_markers_;
00166 
00167   // Message interface
00168 
00169   tf::MessageFilter<visualization_msgs::InteractiveMarker>* tf_filter_;
00170   tf::MessageFilter<visualization_msgs::InteractiveMarkerPose>* tf_pose_filter_;
00171 
00172   ros::Subscriber marker_update_sub_;
00173   ros::Subscriber marker_init_sub_;
00174 
00175   // messages are placed here before being processed in update()
00176   typedef std::vector<visualization_msgs::InteractiveMarker::ConstPtr> V_InteractiveMarkerMessage;
00177   V_InteractiveMarkerMessage marker_queue_;
00178   typedef std::vector<visualization_msgs::InteractiveMarkerPose::ConstPtr> V_InteractiveMarkerPoseMessage;
00179   V_InteractiveMarkerPoseMessage pose_queue_;
00180   boost::mutex queue_mutex_;
00181 
00182   unsigned num_publishers_;
00183 
00184   std::string client_id_;
00185 
00186   // Properties
00187 
00188   std::string marker_update_topic_;
00189   ROSTopicStringPropertyWPtr marker_update_topic_property_;
00190 
00191   bool show_descriptions_;
00192   BoolPropertyWPtr show_descriptions_property_;
00193 
00194   bool show_tool_tips_;
00195   BoolPropertyWPtr show_tool_tips_property_;
00196 
00197   bool show_axes_;
00198   BoolPropertyWPtr show_axes_property_;
00199 
00200 };
00201 
00202 } // namespace rviz
00203 
00204 #endif /* RVIZ_MARKER_DISPLAY_H */


rviz
Author(s): Dave Hershberger, Josh Faust
autogenerated on Mon Jan 6 2014 11:54:32