robot_joint.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef RVIZ_ROBOT_JOINT_H
31 #define RVIZ_ROBOT_JOINT_H
32 
33 #include <string>
34 #include <map>
35 
36 #include <QObject>
37 
38 #ifndef Q_MOC_RUN
39 #include <OgreVector3.h>
40 #include <OgreQuaternion.h>
41 #include <OgreAny.h>
42 #include <OgreMaterial.h>
43 #endif
44 
45 #include <urdf/model.h>
46 #include <urdf_model/pose.h>
47 
50 
51 namespace Ogre
52 {
53 class SceneManager;
54 class Entity;
55 class SubEntity;
56 class SceneNode;
57 class Vector3;
58 class Quaternion;
59 class Any;
60 class RibbonTrail;
61 } // namespace Ogre
62 
63 namespace rviz
64 {
65 class Shape;
66 class Arrow;
67 class Axes;
68 class DisplayContext;
69 class FloatProperty;
70 class Property;
71 class BoolProperty;
72 class QuaternionProperty;
73 class Robot;
74 class RobotLinkSelectionHandler;
75 class VectorProperty;
76 class RobotJoint;
77 class StringProperty;
78 
79 
84 class RobotJoint : public QObject
85 {
86  Q_OBJECT
87 public:
88  RobotJoint(Robot* robot, const urdf::JointConstSharedPtr& joint);
89  ~RobotJoint() override;
90 
91 
92  void setTransforms(const Ogre::Vector3& parent_link_position,
93  const Ogre::Quaternion& parent_link_orientation);
94 
95  const std::string& getName() const
96  {
97  return name_;
98  }
99  const std::string& getParentLinkName() const
100  {
101  return parent_link_name_;
102  }
103  const std::string& getChildLinkName() const
104  {
105  return child_link_name_;
106  }
107  const Property* getJointProperty() const
108  {
109  return joint_property_;
110  }
112  {
113  return joint_property_;
114  }
115  RobotJoint* getParentJoint();
116  void hideSubProperties(bool hide);
117 
118  // Remove joint_property_ from its old parent and add to new_parent. If new_parent==NULL then leav
119  // unparented.
120  void setParentProperty(Property* new_parent);
121 
122  Ogre::Vector3 getPosition();
123  Ogre::Quaternion getOrientation();
124 
125  void setRobotAlpha(float /*alpha*/)
126  {
127  }
128 
130  {
131  return has_decendent_links_with_geometry_;
132  }
133 
134  // place subproperties as children of details_ or joint_property_
135  void useDetailProperty(bool use_detail);
136 
137  // expand all sub properties
138  void expandDetails(bool expand);
139 
140  // Set the description for the joint.
141  // Also sets the checkbox.
142  // Also sets has_decendent_links_with_geometry_.
143  // Called when the link_tree style changes.
144  void setJointPropertyDescription();
145 
146  // set checkboxes based on state of descendent link enables
147  // Should only be called by Robot::calculateJointCheckboxes()
148  void calculateJointCheckboxesRecursive(
149  int& links_with_geom, // returns # of children with geometry
150  int& links_with_geom_checked, // returns # of enabled children with geometry
151  int& links_with_geom_unchecked); // returns # of disabled children with geometry
152 
153 
154 private Q_SLOTS:
155  void updateAxes();
156  void updateAxis();
157  void updateChildVisibility();
158 
159 private:
160  bool getEnabled() const;
161 
162  // true if displaying in a tree style. False if list style.
163  bool styleIsTree() const;
164 
165  // determine the state of child link(s)
166  void
167  getChildLinkState(int& links_with_geom, // returns # of children with geometry
168  int& links_with_geom_checked, // returns # of enabled children with geometry
169  int& links_with_geom_unchecked, // returns # of disabled children with geometry
170  bool recursive) const; // True: all descendant links. False: just single child link.
171 
172  // set the value of the enable checkbox without touching child joints/links
173  void setJointCheckbox(QVariant val);
174 
175 
176 protected:
178  std::string name_;
179  std::string parent_link_name_;
180  std::string child_link_name_;
181 
182  // properties
188  // The joint axis if any, as opposed to the frame in which the joint exists above
194 
195 private:
196  Ogre::Vector3 joint_origin_pos_;
197  Ogre::Quaternion joint_origin_rot_;
199 
200  bool doing_set_checkbox_; // prevents updateChildVisibility() from touching children
201 
204 };
205 
206 } // namespace rviz
207 
208 #endif // RVIZ_ROBOT_LINK_H
VectorProperty * axis_property_
Definition: robot_joint.h:189
const Property * getJointProperty() const
Definition: robot_joint.h:107
StringProperty * type_property_
Definition: robot_joint.h:191
Ogre::Quaternion joint_origin_rot_
Definition: robot_joint.h:197
Property * details_
Definition: robot_joint.h:184
void setRobotAlpha(float)
Definition: robot_joint.h:125
const std::string & getParentLinkName() const
Definition: robot_joint.h:99
QuaternionProperty * orientation_property_
Definition: robot_joint.h:186
std::string parent_link_name_
Definition: robot_joint.h:179
A single element of a property tree, with a name, value, description, and possibly children...
Definition: property.h:100
bool hasDescendentLinksWithGeometry() const
Definition: robot_joint.h:129
Property * joint_property_
Definition: robot_joint.h:183
Ogre::Vector3 joint_origin_pos_
Definition: robot_joint.h:196
Property specialized to enforce floating point max/min.
VectorProperty * position_property_
Definition: robot_joint.h:185
Property * show_axis_property_
Definition: robot_joint.h:190
Property * axes_property_
Definition: robot_joint.h:187
const std::string & getName() const
Definition: robot_joint.h:95
bool doing_set_checkbox_
Definition: robot_joint.h:200
const std::string & getChildLinkName() const
Definition: robot_joint.h:103
FloatProperty * upper_limit_property_
Definition: robot_joint.h:193
std::string name_
Name of this joint.
Definition: robot_joint.h:178
Contains any data we need from a joint in the robot.
Definition: robot_joint.h:84
An object that displays a set of X/Y/Z axes, with X=Red, Y=Green, Z=Blue.
Definition: axes.h:59
FloatProperty * lower_limit_property_
Definition: robot_joint.h:192
Property specialized for string values.
std::string child_link_name_
Definition: robot_joint.h:180
An arrow consisting of a cylinder and a cone.
Definition: arrow.h:59
Property * getJointProperty()
Definition: robot_joint.h:111
bool has_decendent_links_with_geometry_
Definition: robot_joint.h:198


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:25