robot_state_display.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Ioan Sucan */
36 
37 #ifndef MOVEIT_VISUALIZATION_ROBOT_STATE_DISPLAY_RVIZ_ROBOT_STATE_DISPLAY_
38 #define MOVEIT_VISUALIZATION_ROBOT_STATE_DISPLAY_RVIZ_ROBOT_STATE_DISPLAY_
39 
40 #include <rviz/display.h>
41 
42 #ifndef Q_MOC_RUN
45 #include <moveit_msgs/DisplayRobotState.h>
46 #include <ros/ros.h>
47 #endif
48 
49 namespace Ogre
50 {
51 class SceneNode;
52 }
53 
54 namespace rviz
55 {
56 class Robot;
57 class StringProperty;
58 class BoolProperty;
59 class FloatProperty;
60 class RosTopicProperty;
61 class ColorProperty;
62 }
63 
64 namespace moveit_rviz_plugin
65 {
66 class RobotStateVisualization;
67 
69 {
70  Q_OBJECT
71 
72 public:
74  virtual ~RobotStateDisplay();
75 
76  virtual void update(float wall_dt, float ros_dt);
77  virtual void reset();
78 
79  const robot_model::RobotModelConstPtr& getRobotModel() const
80  {
81  return kmodel_;
82  }
83 
84  void setLinkColor(const std::string& link_name, const QColor& color);
85  void unsetLinkColor(const std::string& link_name);
86 
87 private Q_SLOTS:
88 
89  // ******************************************************************************************
90  // Slot Event Functions
91  // ******************************************************************************************
92  void changedRobotDescription();
93  void changedRootLinkName();
94  void changedRobotSceneAlpha();
95  void changedAttachedBodyColor();
96  void changedRobotStateTopic();
97  void changedEnableLinkHighlight();
98  void changedEnableVisualVisible();
99  void changedEnableCollisionVisible();
100  void changedAllLinks();
101 
102 protected:
103  void loadRobotModel();
104 
108  void calculateOffsetPosition();
109 
110  void setLinkColor(rviz::Robot* robot, const std::string& link_name, const QColor& color);
111  void unsetLinkColor(rviz::Robot* robot, const std::string& link_name);
112 
113  void newRobotStateCallback(const moveit_msgs::DisplayRobotState::ConstPtr& state);
114 
115  void setRobotHighlights(const moveit_msgs::DisplayRobotState::_highlight_links_type& highlight_links);
116  void setHighlight(const std::string& link_name, const std_msgs::ColorRGBA& color);
117  void unsetHighlight(const std::string& link_name);
118 
119  // overrides from Display
120  virtual void onInitialize();
121  virtual void onEnable();
122  virtual void onDisable();
123  virtual void fixedFrameChanged();
124 
125  // render the robot
128 
129  RobotStateVisualizationPtr robot_;
130  rdf_loader::RDFLoaderPtr rdf_loader_;
131  robot_model::RobotModelConstPtr kmodel_;
132  robot_state::RobotStatePtr kstate_;
133  std::map<std::string, std_msgs::ColorRGBA> highlights_;
135  bool load_robot_model_; // for delayed robot initialization
136 
146 };
147 
148 } // namespace moveit_rviz_plugin
149 
150 #endif
rviz::StringProperty * root_link_name_property_
void loadRobotModel(urdf::ModelInterfaceSharedPtr &robot_model_out)
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
const robot_model::RobotModelConstPtr & getRobotModel() const
rviz::StringProperty * robot_description_property_
rviz::RosTopicProperty * robot_state_topic_property_
std::map< std::string, std_msgs::ColorRGBA > highlights_
rviz::ColorProperty * attached_body_color_property_
robot_model::RobotModelConstPtr kmodel_


visualization
Author(s): Ioan Sucan , Dave Coleman , Sachin Chitta
autogenerated on Sun Oct 18 2020 13:19:09