Gazebo Physics

API Reference

5.4.0
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 
23 #include <gz/physics/Geometry.hh>
24 
25 namespace ignition
26 {
27  namespace physics
28  {
34  class IGNITION_PHYSICS_VISIBLE GetBasicJointState : public virtual Feature
35  {
37  public: template <typename PolicyT, typename FeaturesT>
38  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
39  {
40  public: using Scalar = typename PolicyT::Scalar;
41  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
42 
49  public: Scalar GetPosition(const std::size_t _dof) const;
50 
57  public: Scalar GetVelocity(const std::size_t _dof) const;
58 
65  public: Scalar GetAcceleration(const std::size_t _dof) const;
66 
73  public: Scalar GetForce(const std::size_t _dof) const;
74 
79  public: Pose GetTransform() const;
80  };
81 
83  public: template <typename PolicyT>
84  class Implementation : public virtual Feature::Implementation<PolicyT>
85  {
86  public: using Scalar = typename PolicyT::Scalar;
87  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
88 
89  // see Joint::GetPosition above
90  public: virtual Scalar GetJointPosition(
91  const Identity &_id, std::size_t _dof) const = 0;
92 
93  // see Joint::GetVelocity above
94  public: virtual Scalar GetJointVelocity(
95  const Identity &_id, std::size_t _dof) const = 0;
96 
97  // see Joint::GetAcceleration above
98  public: virtual Scalar GetJointAcceleration(
99  const Identity &_id, std::size_t _dof) const = 0;
100 
101  // see Joint::GetForce above
102  public: virtual Scalar GetJointForce(
103  const Identity &_id, std::size_t _dof) const = 0;
104 
105  // see Joint::GetTransform above
106  public: virtual Pose GetJointTransform(const Identity &_id) const = 0;
107  };
108  };
109 
114  class IGNITION_PHYSICS_VISIBLE SetBasicJointState : public virtual Feature
115  {
117  public: template <typename PolicyT, typename FeaturesT>
118  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
119  {
120  public: using Scalar = typename PolicyT::Scalar;
121 
130  public: void SetPosition(const std::size_t _dof, const Scalar _value);
131 
140  public: void SetVelocity(const std::size_t _dof, const Scalar _value);
141 
150  public: void SetAcceleration(
151  const std::size_t _dof, const Scalar _value);
152 
161  public: void SetForce(const std::size_t _dof, const Scalar _value);
162  };
163 
165  public: template <typename PolicyT>
166  class Implementation : public virtual Feature::Implementation<PolicyT>
167  {
168  public: using Scalar = typename PolicyT::Scalar;
169 
170  // see Joint::SetPosition above
171  public: virtual void SetJointPosition(
172  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
173 
174  // See Joint::SetVelocity above
175  public: virtual void SetJointVelocity(
176  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
177 
178  // See Joint::SetAcceleration above
179  public: virtual void SetJointAcceleration(
180  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
181 
182  // See Joint::SetForce above
183  public: virtual void SetJointForce(
184  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
185  };
186  };
187 
193  class IGNITION_PHYSICS_VISIBLE GetBasicJointProperties
194  : public virtual Feature
195  {
197  public: template <typename PolicyT, typename FeaturesT>
198  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
199  {
200  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
201 
206 
219  public: Pose GetTransformFromParent() const;
220 
233  public: Pose GetTransformToChild() const;
234  };
235 
237  public: template <typename PolicyT>
238  class Implementation : public virtual Feature::Implementation<PolicyT>
239  {
240  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
241 
243  const Identity &_id) const = 0;
244 
246  const Identity &_id) const = 0;
247 
249  const Identity &_id) const = 0;
250  };
251  };
252 
254  class IGNITION_PHYSICS_VISIBLE SetJointTransformFromParentFeature
255  : public virtual Feature
256  {
258  public: template <typename PolicyT, typename FeaturesT>
259  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
260  {
261  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
262 
276  public: void SetTransformFromParent(const Pose &_pose);
277  };
278 
281  public: template <typename PolicyT>
282  class Implementation : public virtual Feature::Implementation<PolicyT>
283  {
284  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
285 
286  // see Joint::SetTransformFromParent above
287  public: virtual void SetJointTransformFromParent(
288  const Identity &_id, const Pose &_pose) = 0;
289  };
290  };
291 
293  class IGNITION_PHYSICS_VISIBLE SetJointTransformToChildFeature
294  : public virtual Feature
295  {
297  public: template <typename PolicyT, typename FeaturesT>
298  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
299  {
300  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
301 
315  public: void SetTransformToChild(const Pose &_pose);
316  };
317 
319  public: template <typename PolicyT>
320  class Implementation : public virtual Feature::Implementation<PolicyT>
321  {
322  public: using Pose = typename FromPolicy<PolicyT>::template Use<Pose>;
323 
324  // see Joint::SetTransformToChild above
325  public: virtual void SetJointTransformToChild(
326  const Identity &_id, const Pose &_pose) = 0;
327  };
328  };
329 
333  class IGNITION_PHYSICS_VISIBLE SetJointVelocityCommandFeature
334  : public virtual Feature
335  {
341  public: template <typename PolicyT, typename FeaturesT>
342  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
343  {
344  public: using Scalar = typename PolicyT::Scalar;
345 
354  public: void SetVelocityCommand(
355  const std::size_t _dof, const Scalar _value);
356  };
357 
359  public: template <typename PolicyT>
360  class Implementation : public virtual Feature::Implementation<PolicyT>
361  {
362  public: using Scalar = typename PolicyT::Scalar;
363 
364  // See Joint::SetVelocityCommand above
365  public: virtual void SetJointVelocityCommand(
366  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
367  };
368  };
369 
373  class IGNITION_PHYSICS_VISIBLE SetJointPositionLimitsFeature
374  : public virtual Feature
375  {
377  public: template <typename PolicyT, typename FeaturesT>
378  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
379  {
380  public: using Scalar = typename PolicyT::Scalar;
381 
390  public: void SetMinPosition(
391  const std::size_t _dof, const Scalar _value);
392 
401  public: void SetMaxPosition(
402  const std::size_t _dof, const Scalar _value);
403  };
404 
406  public: template <typename PolicyT>
407  class Implementation : public virtual Feature::Implementation<PolicyT>
408  {
409  public: using Scalar = typename PolicyT::Scalar;
410 
411  // See Joint::SetMinPositionCommand above
412  public: virtual void SetJointMinPosition(
413  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
414 
415  // See Joint::SetMaxPositionCommand above
416  public: virtual void SetJointMaxPosition(
417  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
418  };
419  };
420 
424  class IGNITION_PHYSICS_VISIBLE SetJointVelocityLimitsFeature
425  : public virtual Feature
426  {
429  public: template <typename PolicyT, typename FeaturesT>
430  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
431  {
432  public: using Scalar = typename PolicyT::Scalar;
433 
442  public: void SetMinVelocity(
443  const std::size_t _dof, const Scalar _value);
444 
453  public: void SetMaxVelocity(
454  const std::size_t _dof, const Scalar _value);
455  };
456 
458  public: template <typename PolicyT>
459  class Implementation : public virtual Feature::Implementation<PolicyT>
460  {
461  public: using Scalar = typename PolicyT::Scalar;
462 
463  // See Joint::SetMinVelocityCommand above
464  public: virtual void SetJointMinVelocity(
465  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
466 
467  // See Joint::SetMaxVelocityCommand above
468  public: virtual void SetJointMaxVelocity(
469  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
470  };
471  };
472 
475  class IGNITION_PHYSICS_VISIBLE SetJointEffortLimitsFeature
476  : public virtual Feature
477  {
481  public: template <typename PolicyT, typename FeaturesT>
482  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
483  {
484  public: using Scalar = typename PolicyT::Scalar;
485 
493  public: void SetMinEffort(const std::size_t _dof, const Scalar _value);
494 
502  public: void SetMaxEffort(const std::size_t _dof, const Scalar _value);
503  };
504 
506  public: template <typename PolicyT>
507  class Implementation : public virtual Feature::Implementation<PolicyT>
508  {
509  public: using Scalar = typename PolicyT::Scalar;
510 
511  // See Joint::SetMinEffortCommand above
512  public: virtual void SetJointMinEffort(
513  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
514 
515  // See Joint::SetMaxEffortCommand above
516  public: virtual void SetJointMaxEffort(
517  const Identity &_id, std::size_t _dof, Scalar _value) = 0;
518  };
519  };
520 
521  class IGNITION_PHYSICS_VISIBLE DetachJointFeature
522  : public virtual Feature
523  {
524  public: template <typename PolicyT, typename FeaturesT>
525  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
526  {
528  public: void Detach();
529  };
530 
531  public: template <typename PolicyT>
532  class Implementation : public virtual Feature::Implementation<PolicyT>
533  {
534  public: virtual void DetachJoint(const Identity &_jointID) = 0;
535  };
536  };
537 
538  class IGNITION_PHYSICS_VISIBLE GetJointTransmittedWrench
539  : public virtual FeatureWithRequirements<JointFrameSemantics>
540  {
541  public: template <typename PolicyT, typename FeaturesT>
542  class Joint
543  : public virtual JointFrameSemantics::Joint<PolicyT, FeaturesT>
544  {
545  public: using Wrench = typename FromPolicy<
546  PolicyT>::template Use<Wrench>;
547 
556  public: Wrench GetTransmittedWrench() const;
557 
573  const FrameID &_relativeTo,
574  const FrameID &_inCoordinatesOf) const;
575  };
576 
577  public: template <typename PolicyT>
578  class Implementation : public virtual Feature::Implementation<PolicyT>
579  {
580  public: using Wrench = typename FromPolicy<
581  PolicyT>::template Use<Wrench>;
583  const Identity &_jointID) const = 0;
584  };
585  };
586 
587  }
588 }
589 
590 #include <gz/physics/detail/Joint.hh>
591 
592 #endif
virtual void DetachJoint(const Identity &_jointID)=0
Definition: gz/physics/Joint.hh:526
Definition: gz/physics/Joint.hh:523
Definition: gz/physics/Feature.hh:93
Placeholder class in case a Feature does not define its own Joint API.
Definition: gz/physics/Feature.hh:77
This class defines the concept of a Feature. It should be inherited by classes that define some plugi...
Definition: gz/physics/Feature.hh:36
Container for specifying Frame IDs. We do not want to use a generic integer type for this,...
Definition: gz/physics/FrameID.hh:47
Base class for the API of a Frame. This will be inherited by any objects that are able to express Fra...
Definition: gz/physics/FrameSemantics.hh:101
The implementation API for getting basic joint properties.
Definition: gz/physics/Joint.hh:239
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:240
virtual Pose GetJointTransformFromParent(const Identity &_id) const =0
virtual std::size_t GetJointDegreesOfFreedom(const Identity &_id) const =0
virtual Pose GetJointTransformToChild(const Identity &_id) const =0
The Joint API for getting basic joint properties.
Definition: gz/physics/Joint.hh:199
std::size_t GetDegreesOfFreedom() const
Get the number of degrees of freedom (a.k.a. number of generalized coordinates) within this joint.
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:200
Pose GetTransformFromParent() const
Get the transformation matrix from the parent link (or world) to the base of the joint transform....
Pose GetTransformToChild() const
Get the transformation matrix from the tip of the joint transform to the child link....
This feature retrieves the generalized joint properties such as Degrees Of Freedom (DoF),...
Definition: gz/physics/Joint.hh:195
The implementation API for getting basic joint state.
Definition: gz/physics/Joint.hh:85
virtual Scalar GetJointPosition(const Identity &_id, std::size_t _dof) const =0
virtual Scalar GetJointForce(const Identity &_id, std::size_t _dof) const =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:87
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:86
virtual Pose GetJointTransform(const Identity &_id) const =0
virtual Scalar GetJointVelocity(const Identity &_id, std::size_t _dof) const =0
The Joint API for getting basic joint state.
Definition: gz/physics/Joint.hh:39
Scalar GetVelocity(const std::size_t _dof) const
Get the generalized velocity of a specific generalized coordinate within this joint.
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:41
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:40
Scalar GetAcceleration(const std::size_t _dof) const
Get the generalized acceleration of a specific generalized coordinate within this joint.
Pose GetTransform() const
Get the transformation from the joint's parent to the joint's child produced by the current generaliz...
Scalar GetPosition(const std::size_t _dof) const
Get the generalized position of a specific generalized coordinate within this joint.
Scalar GetForce(const std::size_t _dof) const
Get the generalized force of a specific generalized coordinate within this joint.
This feature retrieves the generalized joint states such as position, velocity, acceleration of the j...
Definition: gz/physics/Joint.hh:35
virtual Wrench GetJointTransmittedWrenchInJointFrame(const Identity &_jointID) const =0
typename FromPolicy< PolicyT >::template Use< Wrench > Wrench
Definition: gz/physics/Joint.hh:581
Definition: gz/physics/Joint.hh:544
Wrench GetTransmittedWrench(const FrameID &_relativeTo, const FrameID &_inCoordinatesOf) const
Get the transmitted wrench of this joint at the specified reference frame and expressed in the specif...
Wrench GetTransmittedWrench() const
Get the transmitted wrench at the Joint frame.
typename FromPolicy< PolicyT >::template Use< Wrench > Wrench
Definition: gz/physics/Joint.hh:546
Definition: gz/physics/Joint.hh:540
The implementation API for setting basic joint state.
Definition: gz/physics/Joint.hh:167
virtual void SetJointAcceleration(const Identity &_id, std::size_t _dof, Scalar _value)=0
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:168
virtual void SetJointPosition(const Identity &_id, std::size_t _dof, Scalar _value)=0
virtual void SetJointForce(const Identity &_id, std::size_t _dof, Scalar _value)=0
virtual void SetJointVelocity(const Identity &_id, std::size_t _dof, Scalar _value)=0
The Joint API for setting basic joint state.
Definition: gz/physics/Joint.hh:119
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:120
void SetAcceleration(const std::size_t _dof, const Scalar _value)
Set the generalized acceleration of a specific generalized coordinate within this joint.
void SetVelocity(const std::size_t _dof, const Scalar _value)
Set the generalized velocity of a specific generalized coordinate within this joint.
void SetForce(const std::size_t _dof, const Scalar _value)
Set the generalized force of a specific generalized coordinate within this joint.
void SetPosition(const std::size_t _dof, const Scalar _value)
Set the generalized position of a specific generalized coordinate within this joint.
This feature sets the generalized joint states such as position, velocity, acceleration of the joint ...
Definition: gz/physics/Joint.hh:115
The implementation API for setting effort limit commands.
Definition: gz/physics/Joint.hh:508
virtual void SetJointMaxEffort(const Identity &_id, std::size_t _dof, Scalar _value)=0
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:509
virtual void SetJointMinEffort(const Identity &_id, std::size_t _dof, Scalar _value)=0
The Joint API for setting effort limits of a joint. These limits are applied to joints controlled via...
Definition: gz/physics/Joint.hh:483
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:484
void SetMaxEffort(const std::size_t _dof, const Scalar _value)
Set the maximum value of effort of a specific generalized coordinate within this joint.
This feature sets the min and max value of effort of this Joint.
Definition: gz/physics/Joint.hh:477
The implementation API for setting position limit commands.
Definition: gz/physics/Joint.hh:408
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:409
virtual void SetJointMinPosition(const Identity &_id, std::size_t _dof, Scalar _value)=0
virtual void SetJointMaxPosition(const Identity &_id, std::size_t _dof, Scalar _value)=0
The Joint API for setting position limits of a joint.
Definition: gz/physics/Joint.hh:379
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:380
void SetMinPosition(const std::size_t _dof, const Scalar _value)
Set the minimum allowed value of the generalized coordinate within this joint.
void SetMaxPosition(const std::size_t _dof, const Scalar _value)
Set the maximum allowed value of the generalized coordinate within this joint.
This feature sets the min and max generalized position of this Joint.
Definition: gz/physics/Joint.hh:375
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:284
virtual void SetJointTransformFromParent(const Identity &_id, const Pose &_pose)=0
The Joint API for setting the transform from the joint's parent.
Definition: gz/physics/Joint.hh:260
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:261
void SetTransformFromParent(const Pose &_pose)
Set the transformation matrix from the parent link (or world) to the base of the joint transform....
The implementation API for setting the transform to the child.
Definition: gz/physics/Joint.hh:321
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:322
virtual void SetJointTransformToChild(const Identity &_id, const Pose &_pose)=0
The Joint API for setting the transform to the joint's child.
Definition: gz/physics/Joint.hh:299
typename FromPolicy< PolicyT >::template Use< Pose > Pose
Definition: gz/physics/Joint.hh:300
void SetTransformToChild(const Pose &_pose)
Set the transformation matrix from the tip of the joint transform to the child link....
Definition: gz/physics/Joint.hh:295
The implementation API for setting joint velocity commands.
Definition: gz/physics/Joint.hh:361
virtual void SetJointVelocityCommand(const Identity &_id, std::size_t _dof, Scalar _value)=0
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:362
The Joint API for setting velocity commands (target velocity). This is different from SetVelocity in ...
Definition: gz/physics/Joint.hh:343
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...
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:344
This feature sets the commanded value of generalized velocity of this Joint.
Definition: gz/physics/Joint.hh:335
The implementation API for setting velocity limit commands.
Definition: gz/physics/Joint.hh:460
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:461
virtual void SetJointMinVelocity(const Identity &_id, std::size_t _dof, Scalar _value)=0
virtual void SetJointMaxVelocity(const Identity &_id, std::size_t _dof, Scalar _value)=0
The Joint API for setting velocity limits of a joint. These limits apply to joints commanded via velo...
Definition: gz/physics/Joint.hh:431
typename PolicyT::Scalar Scalar
Definition: gz/physics/Joint.hh:432
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.
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.
This feature sets the min and max value of generalized velocity of this Joint.
Definition: gz/physics/Joint.hh:426
If your feature is known to require any other features, then you should have your feature class inher...
Definition: gz/physics/FeatureList.hh:118
This struct is used to conveniently convert from a policy to a geometric type. Example usage:
Definition: gz/physics/Geometry.hh:78