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 the 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: Wim Meeussen */
36 
37 #ifndef URDF_INTERFACE_JOINT_H
38 #define URDF_INTERFACE_JOINT_H
39 
40 #include <string>
41 #include <vector>
42 
43 #include "urdf_model/pose.h"
44 #include "urdf_model/types.h"
45 
46 
47 namespace urdf{
48 
49 class Link;
50 
51 class JointDynamics
52 {
53 public:
JointDynamics()54   JointDynamics() { this->clear(); };
55   double damping;
56   double friction;
57 
clear()58   void clear()
59   {
60     damping = 0;
61     friction = 0;
62   };
63 };
64 
65 class JointLimits
66 {
67 public:
JointLimits()68   JointLimits() { this->clear(); };
69   double lower;
70   double upper;
71   double effort;
72   double velocity;
73 
clear()74   void clear()
75   {
76     lower = 0;
77     upper = 0;
78     effort = 0;
79     velocity = 0;
80   };
81 };
82 
83 /// \brief Parameters for Joint Safety Controllers
84 class JointSafety
85 {
86 public:
87   /// clear variables on construction
JointSafety()88   JointSafety() { this->clear(); };
89 
90   ///
91   /// IMPORTANT:  The safety controller support is very much PR2 specific, not intended for generic usage.
92   ///
93   /// Basic safety controller operation is as follows
94   ///
95   /// current safety controllers will take effect on joints outside the position range below:
96   ///
97   /// position range: [JointSafety::soft_lower_limit  + JointLimits::velocity / JointSafety::k_position,
98   ///                  JointSafety::soft_uppper_limit - JointLimits::velocity / JointSafety::k_position]
99   ///
100   /// if (joint_position is outside of the position range above)
101   ///     velocity_limit_min = -JointLimits::velocity + JointSafety::k_position * (joint_position - JointSafety::soft_lower_limit)
102   ///     velocity_limit_max =  JointLimits::velocity + JointSafety::k_position * (joint_position - JointSafety::soft_upper_limit)
103   /// else
104   ///     velocity_limit_min = -JointLimits::velocity
105   ///     velocity_limit_max =  JointLimits::velocity
106   ///
107   /// velocity range: [velocity_limit_min + JointLimits::effort / JointSafety::k_velocity,
108   ///                  velocity_limit_max - JointLimits::effort / JointSafety::k_velocity]
109   ///
110   /// if (joint_velocity is outside of the velocity range above)
111   ///     effort_limit_min = -JointLimits::effort + JointSafety::k_velocity * (joint_velocity - velocity_limit_min)
112   ///     effort_limit_max =  JointLimits::effort + JointSafety::k_velocity * (joint_velocity - velocity_limit_max)
113   /// else
114   ///     effort_limit_min = -JointLimits::effort
115   ///     effort_limit_max =  JointLimits::effort
116   ///
117   /// Final effort command sent to the joint is saturated by [effort_limit_min,effort_limit_max]
118   ///
119   /// Please see wiki for more details: http://www.ros.org/wiki/pr2_controller_manager/safety_limits
120   ///
121   double soft_upper_limit;
122   double soft_lower_limit;
123   double k_position;
124   double k_velocity;
125 
clear()126   void clear()
127   {
128     soft_upper_limit = 0;
129     soft_lower_limit = 0;
130     k_position = 0;
131     k_velocity = 0;
132   };
133 };
134 
135 
136 class JointCalibration
137 {
138 public:
JointCalibration()139   JointCalibration() { this->clear(); };
140   double reference_position;
141   DoubleSharedPtr rising, falling;
142 
clear()143   void clear()
144   {
145     reference_position = 0;
146   };
147 };
148 
149 class JointMimic
150 {
151 public:
JointMimic()152   JointMimic() { this->clear(); };
153   double offset;
154   double multiplier;
155   std::string joint_name;
156 
clear()157   void clear()
158   {
159     offset = 0.0;
160     multiplier = 0.0;
161     joint_name.clear();
162   };
163 };
164 
165 
166 class Joint
167 {
168 public:
169 
Joint()170   Joint() { this->clear(); };
171 
172   std::string name;
173   enum
174   {
175     UNKNOWN, REVOLUTE, CONTINUOUS, PRISMATIC, FLOATING, PLANAR, FIXED
176   } type;
177 
178   /// \brief     type_       meaning of axis_
179   /// ------------------------------------------------------
180   ///            UNKNOWN     unknown type
181   ///            REVOLUTE    rotation axis
182   ///            PRISMATIC   translation axis
183   ///            FLOATING    N/A
184   ///            PLANAR      plane normal axis
185   ///            FIXED       N/A
186   Vector3 axis;
187 
188   /// child Link element
189   ///   child link frame is the same as the Joint frame
190   std::string child_link_name;
191 
192   /// parent Link element
193   ///   origin specifies the transform from Parent Link to Joint Frame
194   std::string parent_link_name;
195   /// transform from Parent Link frame to Joint frame
196   Pose  parent_to_joint_origin_transform;
197 
198   /// Joint Dynamics
199   JointDynamicsSharedPtr dynamics;
200 
201   /// Joint Limits
202   JointLimitsSharedPtr limits;
203 
204   /// Unsupported Hidden Feature
205   JointSafetySharedPtr safety;
206 
207   /// Unsupported Hidden Feature
208   JointCalibrationSharedPtr calibration;
209 
210   /// Option to Mimic another Joint
211   JointMimicSharedPtr mimic;
212 
clear()213   void clear()
214   {
215     this->axis.clear();
216     this->child_link_name.clear();
217     this->parent_link_name.clear();
218     this->parent_to_joint_origin_transform.clear();
219     this->dynamics.reset();
220     this->limits.reset();
221     this->safety.reset();
222     this->calibration.reset();
223     this->mimic.reset();
224     this->type = UNKNOWN;
225   };
226 };
227 
228 }
229 
230 #endif
231