moveit2
The MoveIt Motion Planning Framework for ROS 2.
robot_state_visualization.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2008, 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 #pragma once
38 
42 #include <rviz_default_plugins/robot/robot.hpp>
43 
44 namespace moveit_rviz_plugin
45 {
46 MOVEIT_CLASS_FORWARD(RenderShapes); // Defines RenderShapesPtr, ConstPtr, WeakPtr... etc
47 MOVEIT_CLASS_FORWARD(RobotStateVisualization); // Defines RobotStateVisualizationPtr, ConstPtr, WeakPtr... etc
48 
51 {
52 public:
53  RobotStateVisualization(Ogre::SceneNode* root_node, rviz_common::DisplayContext* context, const std::string& name,
54  rviz_common::properties::Property* parent_property);
55 
56  rviz_default_plugins::robot::Robot& getRobot()
57  {
58  return robot_;
59  }
60 
61  void load(const urdf::ModelInterface& descr, bool visual = true, bool collision = true);
62  void clear();
63 
64  void update(const moveit::core::RobotStateConstPtr& kinematic_state);
65  void update(const moveit::core::RobotStateConstPtr& kinematic_state,
66  const std_msgs::msg::ColorRGBA& default_attached_object_color);
67  void update(const moveit::core::RobotStateConstPtr& kinematic_state,
68  const std_msgs::msg::ColorRGBA& default_attached_object_color,
69  const std::map<std::string, std_msgs::msg::ColorRGBA>& color_map);
70  void updateKinematicState(const moveit::core::RobotStateConstPtr& kinematic_state);
71  void setDefaultAttachedObjectColor(const std_msgs::msg::ColorRGBA& default_attached_object_color);
73  void updateAttachedObjectColors(const std_msgs::msg::ColorRGBA& attached_object_color);
74 
75  bool isVisible() const
76  {
77  return visible_;
78  }
79 
84  void setVisible(bool visible);
85 
90  void setVisualVisible(bool visible);
91 
96  void setCollisionVisible(bool visible);
97 
98  void setAlpha(float alpha);
99 
100 private:
101  void updateHelper(const moveit::core::RobotStateConstPtr& kinematic_state,
102  const std_msgs::msg::ColorRGBA& default_attached_object_color,
103  const std::map<std::string, std_msgs::msg::ColorRGBA>* color_map);
104  rviz_default_plugins::robot::Robot robot_;
105  RenderShapesPtr render_shapes_;
106  std_msgs::msg::ColorRGBA default_attached_object_color_;
107  OctreeVoxelRenderMode octree_voxel_render_mode_;
108  OctreeVoxelColorMode octree_voxel_color_mode_;
109 
110  bool visible_;
111  bool visual_visible_;
112  bool collision_visible_;
113 };
114 } // namespace moveit_rviz_plugin
Update the links of an rviz::Robot using a moveit::core::RobotState.
rviz_default_plugins::robot::Robot & getRobot()
void setCollisionVisible(bool visible)
Set whether the collision meshes/primitives of the robot should be visible.
void setVisualVisible(bool visible)
Set whether the visual meshes of the robot should be visible.
void setVisible(bool visible)
Set the robot as a whole to be visible or not.
RobotStateVisualization(Ogre::SceneNode *root_node, rviz_common::DisplayContext *context, const std::string &name, rviz_common::properties::Property *parent_property)
void load(const urdf::ModelInterface &descr, bool visual=true, bool collision=true)
void setDefaultAttachedObjectColor(const std_msgs::msg::ColorRGBA &default_attached_object_color)
void updateAttachedObjectColors(const std_msgs::msg::ColorRGBA &attached_object_color)
update color of all attached object shapes
void update(const moveit::core::RobotStateConstPtr &kinematic_state)
void updateKinematicState(const moveit::core::RobotStateConstPtr &kinematic_state)
MOVEIT_CLASS_FORWARD(RobotStateVisualization)
name
Definition: setup.py:7