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
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 #include <OgrePrerequisites.h>
52 
53 namespace Ogre
54 {
55 class Any;
56 }
57 
58 namespace rviz
59 {
60 class Shape;
61 class Arrow;
62 class Axes;
63 class DisplayContext;
64 class FloatProperty;
65 class Property;
66 class BoolProperty;
67 class QuaternionProperty;
68 class Robot;
69 class RobotLinkSelectionHandler;
70 class VectorProperty;
71 class RobotJoint;
72 class StringProperty;
73 
74 
79 class RobotJoint : public QObject
80 {
81  Q_OBJECT
82 public:
83  RobotJoint(Robot* robot, const urdf::JointConstSharedPtr& joint);
84  ~RobotJoint() override;
85 
86 
87  void setTransforms(const Ogre::Vector3& parent_link_position,
88  const Ogre::Quaternion& parent_link_orientation);
89 
90  const std::string& getName() const
91  {
92  return name_;
93  }
94  const std::string& getParentLinkName() const
95  {
96  return parent_link_name_;
97  }
98  const std::string& getChildLinkName() const
99  {
100  return child_link_name_;
101  }
102  const Property* getJointProperty() const
103  {
104  return joint_property_;
105  }
107  {
108  return joint_property_;
109  }
111  void hideSubProperties(bool hide);
112 
113  // Remove joint_property_ from its old parent and add to new_parent. If new_parent==NULL then leav
114  // unparented.
115  void setParentProperty(Property* new_parent);
116 
117  Ogre::Vector3 getPosition();
118  Ogre::Quaternion getOrientation();
119 
120  void setRobotAlpha(float /*unused*/)
121  {
122  }
123 
125  {
127  }
128 
129  // place subproperties as children of details_ or joint_property_
130  void useDetailProperty(bool use_detail);
131 
132  // expand all sub properties
133  void expandDetails(bool expand);
134 
135  // Set the description for the joint.
136  // Also sets the checkbox.
137  // Also sets has_decendent_links_with_geometry_.
138  // Called when the link_tree style changes.
140 
141  // set checkboxes based on state of descendent link enables
142  // Should only be called by Robot::calculateJointCheckboxes()
144  int& links_with_geom, // returns # of children with geometry
145  int& links_with_geom_checked, // returns # of enabled children with geometry
146  int& links_with_geom_unchecked); // returns # of disabled children with geometry
147 
148 
149 private Q_SLOTS:
150  void updateAxes();
151  void updateAxis();
152  void updateChildVisibility();
153 
154 private:
155  bool getEnabled() const;
156 
157  // true if displaying in a tree style. False if list style.
158  bool styleIsTree() const;
159 
160  // determine the state of child link(s)
161  void
162  getChildLinkState(int& links_with_geom, // returns # of children with geometry
163  int& links_with_geom_checked, // returns # of enabled children with geometry
164  int& links_with_geom_unchecked, // returns # of disabled children with geometry
165  bool recursive) const; // True: all descendant links. False: just single child link.
166 
167  // set the value of the enable checkbox without touching child joints/links
168  void setJointCheckbox(const QVariant& val);
169 
170 
171 protected:
173  std::string name_;
174  std::string parent_link_name_;
175  std::string child_link_name_;
176 
177  // properties
183  // The joint axis if any, as opposed to the frame in which the joint exists above
189 
190 private:
191  Ogre::Vector3 joint_origin_pos_;
192  Ogre::Quaternion joint_origin_rot_;
194 
195  bool doing_set_checkbox_; // prevents updateChildVisibility() from touching children
196 
199 };
200 
201 } // namespace rviz
202 
203 #endif // RVIZ_ROBOT_LINK_H
rviz::RobotJoint::axes_
Axes * axes_
Definition: robot_joint.h:197
rviz::RobotJoint::name_
std::string name_
Name of this joint.
Definition: robot_joint.h:173
rviz::RobotJoint::show_axis_property_
Property * show_axis_property_
Definition: robot_joint.h:185
rviz::RobotJoint::setTransforms
void setTransforms(const Ogre::Vector3 &parent_link_position, const Ogre::Quaternion &parent_link_orientation)
Definition: robot_joint.cpp:407
rviz::RobotJoint::getJointProperty
Property * getJointProperty()
Definition: robot_joint.h:106
Ogre
Definition: axes_display.h:35
rviz::Arrow
An arrow consisting of a cylinder and a cone.
Definition: arrow.h:57
forwards.h
rviz::RobotJoint::getOrientation
Ogre::Quaternion getOrientation()
Definition: robot_joint.cpp:442
rviz::RobotJoint::upper_limit_property_
FloatProperty * upper_limit_property_
Definition: robot_joint.h:188
rviz::RobotJoint::setParentProperty
void setParentProperty(Property *new_parent)
Definition: robot_joint.cpp:447
rviz::RobotJoint::lower_limit_property_
FloatProperty * lower_limit_property_
Definition: robot_joint.h:187
rviz::RobotJoint::getEnabled
bool getEnabled() const
Definition: robot_joint.cpp:306
rviz::RobotJoint::position_property_
VectorProperty * position_property_
Definition: robot_joint.h:180
rviz::RobotJoint::getChildLinkName
const std::string & getChildLinkName() const
Definition: robot_joint.h:98
rviz::RobotJoint::getParentLinkName
const std::string & getParentLinkName() const
Definition: robot_joint.h:94
rviz::RobotJoint::expandDetails
void expandDetails(bool expand)
Definition: robot_joint.cpp:491
rviz::RobotJoint::type_property_
StringProperty * type_property_
Definition: robot_joint.h:186
rviz::RobotJoint::getChildLinkState
void getChildLinkState(int &links_with_geom, int &links_with_geom_checked, int &links_with_geom_unchecked, bool recursive) const
Definition: robot_joint.cpp:265
rviz::RobotJoint::robot_
Robot * robot_
Definition: robot_joint.h:172
rviz::RobotJoint::axes_property_
Property * axes_property_
Definition: robot_joint.h:182
rviz::RobotJoint::child_link_name_
std::string child_link_name_
Definition: robot_joint.h:175
rviz::QuaternionProperty
Definition: quaternion_property.h:38
rviz::FloatProperty
Property specialized to enforce floating point max/min.
Definition: float_property.h:37
rviz::Property
A single element of a property tree, with a name, value, description, and possibly children.
Definition: property.h:100
rviz::RobotJoint::updateAxes
void updateAxes()
Definition: robot_joint.cpp:352
rviz::RobotJoint::calculateJointCheckboxesRecursive
void calculateJointCheckboxesRecursive(int &links_with_geom, int &links_with_geom_checked, int &links_with_geom_unchecked)
Definition: robot_joint.cpp:206
rviz::RobotJoint::axis_
Arrow * axis_
Definition: robot_joint.h:198
rviz::RobotJoint::~RobotJoint
~RobotJoint() override
Definition: robot_joint.cpp:132
rviz::RobotJoint::hasDescendentLinksWithGeometry
bool hasDescendentLinksWithGeometry() const
Definition: robot_joint.h:124
rviz
Definition: add_display_dialog.cpp:54
rviz::RobotJoint::setJointCheckbox
void setJointCheckbox(const QVariant &val)
Definition: robot_joint.cpp:184
rviz::RobotJoint::getJointProperty
const Property * getJointProperty() const
Definition: robot_joint.h:102
rviz::StringProperty
Property specialized for string values.
Definition: string_property.h:39
model.h
rviz::RobotJoint::useDetailProperty
void useDetailProperty(bool use_detail)
Definition: robot_joint.cpp:463
rviz::RobotJoint::setJointPropertyDescription
void setJointPropertyDescription()
Definition: robot_joint.cpp:141
rviz::RobotJoint::joint_origin_rot_
Ogre::Quaternion joint_origin_rot_
Definition: robot_joint.h:192
rviz::RobotJoint::updateChildVisibility
void updateChildVisibility()
Definition: robot_joint.cpp:318
ogre_vector.h
rviz::RobotJoint
Contains any data we need from a joint in the robot.
Definition: robot_joint.h:79
rviz::RobotJoint::setRobotAlpha
void setRobotAlpha(float)
Definition: robot_joint.h:120
rviz::RobotJoint::orientation_property_
QuaternionProperty * orientation_property_
Definition: robot_joint.h:181
Robot
rviz::Axes
An object that displays a set of X/Y/Z axes, with X=Red, Y=Green, Z=Blue.
Definition: axes.h:57
rviz::RobotJoint::hideSubProperties
void hideSubProperties(bool hide)
Definition: robot_joint.cpp:428
rviz::RobotJoint::details_
Property * details_
Definition: robot_joint.h:179
rviz::RobotJoint::getParentJoint
RobotJoint * getParentJoint()
Definition: robot_joint.cpp:193
rviz::RobotJoint::RobotJoint
RobotJoint(Robot *robot, const urdf::JointConstSharedPtr &joint)
Definition: robot_joint.cpp:46
rviz::RobotJoint::doing_set_checkbox_
bool doing_set_checkbox_
Definition: robot_joint.h:195
rviz::RobotJoint::updateAxis
void updateAxis()
Definition: robot_joint.cpp:378
rviz::RobotJoint::parent_link_name_
std::string parent_link_name_
Definition: robot_joint.h:174
rviz::RobotJoint::joint_property_
Property * joint_property_
Definition: robot_joint.h:178
rviz::RobotJoint::axis_property_
VectorProperty * axis_property_
Definition: robot_joint.h:184
rviz::RobotJoint::styleIsTree
bool styleIsTree() const
Definition: robot_joint.cpp:313
rviz::RobotJoint::has_decendent_links_with_geometry_
bool has_decendent_links_with_geometry_
Definition: robot_joint.h:193
rviz::RobotJoint::getName
const std::string & getName() const
Definition: robot_joint.h:90
rviz::RobotJoint::joint_origin_pos_
Ogre::Vector3 joint_origin_pos_
Definition: robot_joint.h:191
rviz::VectorProperty
Definition: vector_property.h:39
rviz::RobotJoint::getPosition
Ogre::Vector3 getPosition()
Definition: robot_joint.cpp:437
rviz::Robot
Definition: robot.h:79
object.h


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:10