robot_state_display.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2012, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 /* Author: Ioan Sucan */
00036 
00037 #ifndef MOVEIT_VISUALIZATION_ROBOT_STATE_DISPLAY_RVIZ_ROBOT_STATE_DISPLAY_
00038 #define MOVEIT_VISUALIZATION_ROBOT_STATE_DISPLAY_RVIZ_ROBOT_STATE_DISPLAY_
00039 
00040 #include <rviz/display.h>
00041 
00042 #ifndef Q_MOC_RUN
00043 #include <moveit/rdf_loader/rdf_loader.h>
00044 #include <moveit/rviz_plugin_render_tools/robot_state_visualization.h>
00045 #include <moveit_msgs/DisplayRobotState.h>
00046 #include <ros/ros.h>
00047 #endif
00048 
00049 namespace Ogre
00050 {
00051 class SceneNode;
00052 }
00053 
00054 namespace rviz
00055 {
00056 class Robot;
00057 class StringProperty;
00058 class BoolProperty;
00059 class FloatProperty;
00060 class RosTopicProperty;
00061 class ColorProperty;
00062 }
00063 
00064 namespace moveit_rviz_plugin
00065 {
00066 class RobotStateVisualization;
00067 
00068 class RobotStateDisplay : public rviz::Display
00069 {
00070   Q_OBJECT
00071 
00072 public:
00073   RobotStateDisplay();
00074   virtual ~RobotStateDisplay();
00075 
00076   virtual void update(float wall_dt, float ros_dt);
00077   virtual void reset();
00078 
00079   const robot_model::RobotModelConstPtr& getRobotModel() const
00080   {
00081     return kmodel_;
00082   }
00083 
00084   void setLinkColor(const std::string& link_name, const QColor& color);
00085   void unsetLinkColor(const std::string& link_name);
00086 
00087 private Q_SLOTS:
00088 
00089   // ******************************************************************************************
00090   // Slot Event Functions
00091   // ******************************************************************************************
00092   void changedRobotDescription();
00093   void changedRootLinkName();
00094   void changedRobotSceneAlpha();
00095   void changedAttachedBodyColor();
00096   void changedRobotStateTopic();
00097   void changedEnableLinkHighlight();
00098   void changedEnableVisualVisible();
00099   void changedEnableCollisionVisible();
00100   void changedAllLinks();
00101 
00102 protected:
00103   void loadRobotModel();
00104 
00108   void calculateOffsetPosition();
00109 
00110   void setLinkColor(rviz::Robot* robot, const std::string& link_name, const QColor& color);
00111   void unsetLinkColor(rviz::Robot* robot, const std::string& link_name);
00112 
00113   void newRobotStateCallback(const moveit_msgs::DisplayRobotState::ConstPtr& state);
00114 
00115   void setRobotHighlights(const moveit_msgs::DisplayRobotState::_highlight_links_type& highlight_links);
00116   void setHighlight(const std::string& link_name, const std_msgs::ColorRGBA& color);
00117   void unsetHighlight(const std::string& link_name);
00118 
00119   // overrides from Display
00120   virtual void onInitialize();
00121   virtual void onEnable();
00122   virtual void onDisable();
00123   virtual void fixedFrameChanged();
00124 
00125   // render the robot
00126   ros::NodeHandle root_nh_;
00127   ros::Subscriber robot_state_subscriber_;
00128 
00129   RobotStateVisualizationPtr robot_;
00130   rdf_loader::RDFLoaderPtr rdf_loader_;
00131   robot_model::RobotModelConstPtr kmodel_;
00132   robot_state::RobotStatePtr kstate_;
00133   std::map<std::string, std_msgs::ColorRGBA> highlights_;
00134   bool update_state_;
00135 
00136   rviz::StringProperty* robot_description_property_;
00137   rviz::StringProperty* root_link_name_property_;
00138   rviz::RosTopicProperty* robot_state_topic_property_;
00139   rviz::FloatProperty* robot_alpha_property_;
00140   rviz::ColorProperty* attached_body_color_property_;
00141   rviz::BoolProperty* enable_link_highlight_;
00142   rviz::BoolProperty* enable_visual_visible_;
00143   rviz::BoolProperty* enable_collision_visible_;
00144   rviz::BoolProperty* show_all_links_;
00145 };
00146 
00147 }  // namespace moveit_rviz_plugin
00148 
00149 #endif


visualization
Author(s): Ioan Sucan , Dave Coleman , Sachin Chitta
autogenerated on Mon Jul 24 2017 02:22:14