Gazebo Physics

API Reference

2.6.2
gz/physics/Joint.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GZ_PHYSICS_JOINT_HH_
19 #define GZ_PHYSICS_JOINT_HH_
20 
22 #include <gz/physics/Geometry.hh>
23 
24 namespace ignition
25 {
26  namespace physics
27  {
33  class IGNITION_PHYSICS_VISIBLE GetBasicJointState : public virtual Feature
34  {
36  public: template <typename PolicyT, typename FeaturesT>
37  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
38  {
39  public: using Scalar = typename PolicyT::Scalar;
40  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
41 
48  public: Scalar GetPosition(const std::size_t _dof) const;
49 
56  public: Scalar GetVelocity(const std::size_t _dof) const;
57 
64  public: Scalar GetAcceleration(const std::size_t _dof) const;
65 
72  public: Scalar GetForce(const std::size_t _dof) const;
73 
78  public: Pose GetTransform() const;
79  };
80 
82  public: template <typename PolicyT>
83  class Implementation : public virtual Feature::Implementation<PolicyT>
84  {
85  public: using Scalar = typename PolicyT::Scalar;
86  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
87 
88  // see Joint::GetPosition above
89  public: virtual Scalar GetJointPosition(
90  const Identity &_id, std::size_t _dof) const = 0;
91 
92  // see Joint::GetVelocity above
93  public: virtual Scalar GetJointVelocity(
94  const Identity &_id, std::size_t _dof) const = 0;
95 
96  // see Joint::GetAcceleration above
97  public: virtual Scalar GetJointAcceleration(
98  const Identity &_id, std::size_t _dof) const = 0;
99 
100  // see Joint::GetForce above
101  public: virtual Scalar GetJointForce(
102  const Identity &_id, std::size_t _dof) const = 0;
103 
104  // see Joint::GetTransform above
105  public: virtual Pose GetJointTransform(const Identity &_id) const = 0;
106  };
107  };
108 
113  class IGNITION_PHYSICS_VISIBLE SetBasicJointState : public virtual Feature
114  {
116  public: template <typename PolicyT, typename FeaturesT>
117  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
118  {
119  public: using Scalar = typename PolicyT::Scalar;
120 
129  public: void SetPosition(const std::size_t _dof, const Scalar _value);
130 
139  public: void SetVelocity(const std::size_t _dof, const Scalar _value);
140 
149  public: void SetAcceleration(
150  const std::size_t _dof, const Scalar _value);
151 
160  public: void SetForce(const std::size_t _dof, const Scalar _value);
161  };
162 
164  public: template <typename PolicyT>
165  class Implementation : public virtual Feature::Implementation<PolicyT>
166  {
167  public: using Scalar = typename PolicyT::Scalar;
168 
169  // see Joint::SetPosition above
170  public: virtual void SetJointPosition(
171  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
172 
173  // See Joint::SetVelocity above
174  public: virtual void SetJointVelocity(
175  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
176 
177  // See Joint::SetAcceleration above
178  public: virtual void SetJointAcceleration(
179  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
180 
181  // See Joint::SetForce above
182  public: virtual void SetJointForce(
183  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
184  };
185  };
186 
192  class IGNITION_PHYSICS_VISIBLE GetBasicJointProperties
193  : public virtual Feature
194  {
196  public: template <typename PolicyT, typename FeaturesT>
197  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
198  {
199  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
200 
204  public: std::size_t GetDegreesOfFreedom() const;
205 
218  public: Pose GetTransformFromParent() const;
219 
232  public: Pose GetTransformToChild() const;
233  };
234 
236  public: template <typename PolicyT>
237  class Implementation : public virtual Feature::Implementation<PolicyT>
238  {
239  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
240 
241  public: virtual std::size_t GetJointDegreesOfFreedom(
242  const Identity &_id) const = 0;
243 
244  public: virtual Pose GetJointTransformFromParent(
245  const Identity &_id) const = 0;
246 
247  public: virtual Pose GetJointTransformToChild(
248  const Identity &_id) const = 0;
249  };
250  };
251 
253  class IGNITION_PHYSICS_VISIBLE SetJointTransformFromParentFeature
254  : public virtual Feature
255  {
257  public: template <typename PolicyT, typename FeaturesT>
258  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
259  {
260  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
261 
275  public: void SetTransformFromParent(const Pose &_pose);
276  };
277 
280  public: template <typename PolicyT>
281  class Implementation : public virtual Feature::Implementation<PolicyT>
282  {
283  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
284 
285  // see Joint::SetTransformFromParent above
286  public: virtual void SetJointTransformFromParent(
287  const Identity &_id, const Pose &_pose) = 0;
288  };
289  };
290 
292  class IGNITION_PHYSICS_VISIBLE SetJointTransformToChildFeature
293  : public virtual Feature
294  {
296  public: template <typename PolicyT, typename FeaturesT>
297  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
298  {
299  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
300 
314  public: void SetTransformToChild(const Pose &_pose);
315  };
316 
318  public: template <typename PolicyT>
319  class Implementation : public virtual Feature::Implementation<PolicyT>
320  {
321  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
322 
323  // see Joint::SetTransformToChild above
324  public: virtual void SetJointTransformToChild(
325  const Identity &_id, const Pose &_pose) = 0;
326  };
327  };
328 
332  class IGNITION_PHYSICS_VISIBLE SetJointVelocityCommandFeature
333  : public virtual Feature
334  {
340  public: template <typename PolicyT, typename FeaturesT>
341  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
342  {
343  public: using Scalar = typename PolicyT::Scalar;
344 
353  public: void SetVelocityCommand(
354  const std::size_t _dof, const Scalar _value);
355  };
356 
358  public: template <typename PolicyT>
359  class Implementation : public virtual Feature::Implementation<PolicyT>
360  {
361  public: using Scalar = typename PolicyT::Scalar;
362 
363  // See Joint::SetVelocityCommand above
364  public: virtual void SetJointVelocityCommand(
365  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
366  };
367  };
368 
372  class IGNITION_PHYSICS_VISIBLE SetJointPositionLimitsFeature
373  : public virtual Feature
374  {
376  public: template <typename PolicyT, typename FeaturesT>
377  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
378  {
379  public: using Scalar = typename PolicyT::Scalar;
380 
389  public: void SetMinPosition(
390  const std::size_t _dof, const Scalar _value);
391 
400  public: void SetMaxPosition(
401  const std::size_t _dof, const Scalar _value);
402  };
403 
405  public: template <typename PolicyT>
406  class Implementation : public virtual Feature::Implementation<PolicyT>
407  {
408  public: using Scalar = typename PolicyT::Scalar;
409 
410  // See Joint::SetMinPositionCommand above
411  public: virtual void SetJointMinPosition(
412  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
413 
414  // See Joint::SetMaxPositionCommand above
415  public: virtual void SetJointMaxPosition(
416  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
417  };
418  };
419 
423  class IGNITION_PHYSICS_VISIBLE SetJointVelocityLimitsFeature
424  : public virtual Feature
425  {
428  public: template <typename PolicyT, typename FeaturesT>
429  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
430  {
431  public: using Scalar = typename PolicyT::Scalar;
432 
441  public: void SetMinVelocity(
442  const std::size_t _dof, const Scalar _value);
443 
452  public: void SetMaxVelocity(
453  const std::size_t _dof, const Scalar _value);
454  };
455 
457  public: template <typename PolicyT>
458  class Implementation : public virtual Feature::Implementation<PolicyT>
459  {
460  public: using Scalar = typename PolicyT::Scalar;
461 
462  // See Joint::SetMinVelocityCommand above
463  public: virtual void SetJointMinVelocity(
464  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
465 
466  // See Joint::SetMaxVelocityCommand above
467  public: virtual void SetJointMaxVelocity(
468  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
469  };
470  };
471 
474  class IGNITION_PHYSICS_VISIBLE SetJointEffortLimitsFeature
475  : public virtual Feature
476  {
480  public: template <typename PolicyT, typename FeaturesT>
481  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
482  {
483  public: using Scalar = typename PolicyT::Scalar;
484 
492  public: void SetMinEffort(const std::size_t _dof, const Scalar _value);
493 
501  public: void SetMaxEffort(const std::size_t _dof, const Scalar _value);
502  };
503 
505  public: template <typename PolicyT>
506  class Implementation : public virtual Feature::Implementation<PolicyT>
507  {
508  public: using Scalar = typename PolicyT::Scalar;
509 
510  // See Joint::SetMinEffortCommand above
511  public: virtual void SetJointMinEffort(
512  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
513 
514  // See Joint::SetMaxEffortCommand above
515  public: virtual void SetJointMaxEffort(
516  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
517  };
518  };
519 
520  class IGNITION_PHYSICS_VISIBLE DetachJointFeature
521  : public virtual Feature
522  {
523  public: template <typename PolicyT, typename FeaturesT>
524  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
525  {
527  public: void Detach();
528  };
529 
530  public: template <typename PolicyT>
531  class Implementation : public virtual Feature::Implementation<PolicyT>
532  {
533  public: virtual void DetachJoint(const Identity &_jointID) = 0;
534  };
535  };
536  }
537 }
538 
539 #include <gz/physics/detail/Joint.hh>
540 
541 #endif
The Joint API for setting effort limits of a joint. These limits are applied to joints controlled via...
Definition: gz/physics/Joint.hh:481
The Joint API for getting basic joint properties.
Definition: gz/physics/Joint.hh:197
This feature sets the min and max value of effort of this Joint.
Definition: gz/physics/Joint.hh:474
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:361
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:199
virtual void SetJointVelocityCommand(const Identity &_id, std::size_t _dof, Scalar _value)=0
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:508
void SetTransformToChild(const Pose &_pose)
Set the transformation matrix from the tip of the joint transform to the child link....
Scalar GetAcceleration(const std::size_t _dof) const
Get the generalized acceleration of a specific generalized coordinate within this joint.
virtual void SetJointVelocity(const Identity &_id, std::size_t _dof, Scalar _value)=0
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:408
This struct is used to conveniently convert from a policy to a geometric type. Example usage:
Definition: gz/physics/Geometry.hh:69
Pose GetTransformFromParent() const
Get the transformation matrix from the parent link (or world) to the base of the joint transform....
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:39
virtual Pose GetJointTransform(const Identity &_id) const =0
void SetVelocityCommand(const std::size_t _dof, const Scalar _value)
Set the commanded value of generalized velocity of a specific generalized coordinate within this join...
void SetForce(const std::size_t _dof, const Scalar _value)
Set the generalized force of a specific generalized coordinate within this joint.
The implementation API for setting basic joint state.
Definition: gz/physics/Joint.hh:165
This feature sets the min and max generalized position of this Joint.
Definition: gz/physics/Joint.hh:372
void SetMinVelocity(const std::size_t _dof, const Scalar _value)
Set the minimum value of generalized velocity of a specific generalized coordinate within this joint.
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:379
The implementation API for setting the transform to the child.
Definition: gz/physics/Joint.hh:319
virtual void SetJointAcceleration(const Identity &_id, std::size_t _dof, Scalar _value)=0
Scalar GetPosition(const std::size_t _dof) const
Get the generalized position of a specific generalized coordinate within this joint.
The implementation API for setting joint velocity commands.
Definition: gz/physics/Joint.hh:359
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:460
virtual Scalar GetJointForce(const Identity &_id, std::size_t _dof) const =0
void SetMinPosition(const std::size_t _dof, const Scalar _value)
Set the minimum allowed value of the generalized coordinate within this joint.
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:321
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:239
void SetMaxVelocity(const std::size_t _dof, const Scalar _value)
Set the maximum value of generalized velocity of a specific generalized coordinate within this joint.
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:119
The Joint API for setting velocity commands (target velocity). This is different from SetVelocity in ...
Definition: gz/physics/Joint.hh:341
std::size_t GetDegreesOfFreedom() const
Get the number of degrees of freedom (a.k.a. number of generalized coordinates) within this joint.
virtual void SetJointPosition(const Identity &_id, std::size_t _dof, Scalar _value)=0
virtual Scalar GetJointAcceleration(const Identity &_id, std::size_t _dof) const =0
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:40
virtual void SetJointTransformToChild(const Identity &_id, const Pose &_pose)=0
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:167
The Joint API for setting the transform from the joint's parent.
Definition: gz/physics/Joint.hh:258
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:299
This feature retrieves the generalized joint properties such as Degrees Of Freedom (DoF),...
Definition: gz/physics/Joint.hh:192
virtual void SetJointMaxEffort(const Identity &_id, std::size_t _dof, Scalar _value)=0
Pose GetTransformToChild() const
Get the transformation matrix from the tip of the joint transform to the child link....
virtual Pose GetJointTransformFromParent(const Identity &_id) const =0
void SetAcceleration(const std::size_t _dof, const Scalar _value)
Set the generalized acceleration of a specific generalized coordinate within this joint.
Definition: gz/physics/Feature.hh:92
This class defines the concept of a Feature. It should be inherited by classes that define some plugi...
Definition: gz/physics/Feature.hh:35
Pose GetTransform() const
Get the transformation from the joint's parent to the joint's child produced by the current generaliz...
Placeholder class in case a Feature does not define its own Joint API.
Definition: gz/physics/Feature.hh:76
The implementation API for getting basic joint properties.
Definition: gz/physics/Joint.hh:237
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:85
virtual Pose GetJointTransformToChild(const Identity &_id) const =0
The implementation API for setting position limit commands.
Definition: gz/physics/Joint.hh:406
void SetMinEffort(const std::size_t _dof, const Scalar _value)
Set the minimum value of effort of a specific generalized coordinate within this joint.
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:431
void SetTransformFromParent(const Pose &_pose)
Set the transformation matrix from the parent link (or world) to the base of the joint transform....
Scalar GetForce(const std::size_t _dof) const
Get the generalized force of a specific generalized coordinate within this joint.
virtual Scalar GetJointPosition(const Identity &_id, std::size_t _dof) const =0
void SetMaxEffort(const std::size_t _dof, const Scalar _value)
Set the maximum value of effort of a specific generalized coordinate within this joint.
virtual void SetJointMinEffort(const Identity &_id, std::size_t _dof, Scalar _value)=0
Definition: gz/physics/Joint.hh:292
virtual void DetachJoint(const Identity &_jointID)=0
virtual void SetJointMaxPosition(const Identity &_id, std::size_t _dof, Scalar _value)=0
This feature sets the commanded value of generalized velocity of this Joint.
Definition: gz/physics/Joint.hh:332
The implementation API for setting effort limit commands.
Definition: gz/physics/Joint.hh:506
This feature retrieves the generalized joint states such as position, velocity, acceleration of the j...
Definition: gz/physics/Joint.hh:33
virtual void SetJointTransformFromParent(const Identity &_id, const Pose &_pose)=0
The Joint API for setting velocity limits of a joint. These limits apply to joints commanded via velo...
Definition: gz/physics/Joint.hh:429
This feature sets the generalized joint states such as position, velocity, acceleration of the joint ...
Definition: gz/physics/Joint.hh:113
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:343
Definition: gz/physics/Joint.hh:520
The implementation API for getting basic joint state.
Definition: gz/physics/Joint.hh:83
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:283
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:86
virtual void SetJointMinPosition(const Identity &_id, std::size_t _dof, Scalar _value)=0
virtual std::size_t GetJointDegreesOfFreedom(const Identity &_id) const =0
This feature sets the min and max value of generalized velocity of this Joint.
Definition: gz/physics/Joint.hh:423
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:260
virtual Scalar GetJointVelocity(const Identity &_id, std::size_t _dof) const =0
Definition: gz/physics/Joint.hh:524
virtual void SetJointForce(const Identity &_id, std::size_t _dof, Scalar _value)=0
Scalar GetVelocity(const std::size_t _dof) const
Get the generalized velocity of a specific generalized coordinate within this joint.
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:483
virtual void SetJointMaxVelocity(const Identity &_id, std::size_t _dof, Scalar _value)=0
void SetMaxPosition(const std::size_t _dof, const Scalar _value)
Set the maximum allowed value of the generalized coordinate within this joint.
The Joint API for getting basic joint state.
Definition: gz/physics/Joint.hh:37
void SetVelocity(const std::size_t _dof, const Scalar _value)
Set the generalized velocity of a specific generalized coordinate within this joint.
The Joint API for setting basic joint state.
Definition: gz/physics/Joint.hh:117
The Joint API for setting the transform to the joint's child.
Definition: gz/physics/Joint.hh:297
virtual void SetJointMinVelocity(const Identity &_id, std::size_t _dof, Scalar _value)=0
void SetPosition(const std::size_t _dof, const Scalar _value)
Set the generalized position of a specific generalized coordinate within this joint.
The Joint API for setting position limits of a joint.
Definition: gz/physics/Joint.hh:377
The implementation API for setting velocity limit commands.
Definition: gz/physics/Joint.hh:458