|
AGX Dynamics 2.38.0.2
|
A Serial Kinematic Chain is a KinematicChain where there are no loops or branches. More...
#include <KinematicChain.h>
Inheritance diagram for agxModel::SerialKinematicChain:Public Member Functions | |
| SerialKinematicChain (agxSDK::Simulation &simulation, const agx::RigidBody &base, const agx::RigidBody &end, const agx::AffineMatrix4x4 *endLocalTransform=nullptr) | |
| Create a serial chain from "base" to "end" by traversing the bodies and constraints in the simulation. | |
| SerialKinematicChain (const agx::RigidBodyPtrVector &bodies, const agx::ConstraintPtrVector &constraints, const agx::AffineMatrix4x4 *endLocalTransform=nullptr) | |
| Create a serial chain from the input bodies and constraints which are provided in the correct order. | |
| KinematicChainStatus | computeForwardKinematics (const agx::RealVector &jointPositions, agx::AffineMatrix4x4 &outputTransform, bool clampToJointLimits=false) |
| Compute the transform for the end of the chain relative the base given the provided joint values. | |
| KinematicChainStatus | computeForwardKinematicsAll (const agx::RealVector &jointPositions, agx::AffineMatrix4x4Vector &outputTransforms, bool clampToJointLimits=false) |
| Compute the transform for all links in the chain relative the base given provided joint values. | |
| KinematicChainStatus | computeForwardKinematicsAll (const agx::RealVector &jointPositions, const agx::RealVector &jointVelocities, agx::AffineMatrix4x4Vector &outputTransforms, agx::Vec3Vector &outputLinearVelocities, agx::Vec3Vector &outputAngularVelocities, bool clampToJointLimits=false) |
| Compute the transforms and velocities for all links in the chain relative the base given provided joint values. | |
| KinematicChainStatus | computeInverseDynamics (const agx::RealVector &jointAcceleration, agx::RealVector &tau) |
| Compute the torque/forces needed to get the specified jointAccelerations. | |
| KinematicChainStatus | computeInverseDynamics (const agx::RealVector &jointAcceleration, const agx::RealVector &externalForces, agx::RealVector &tau) |
| Compute the torque/forces needed to get the specified jointAccelerations. | |
| KinematicChainStatus | computeInverseKinematics (const agx::AffineMatrix4x4 &transform, const agx::RealVector ¤tJointPositions, agx::RealVector &outputJointPositions, agx::Real solverEpsilon=1e-5) |
| Compute joint positions needed for the end body in the chain to get the specified transform relative the base. | |
| KinematicChainStatus | computeManipulatorJacobian (const agx::RealVector &jointPositions, agx::RealVector &jacobian) |
| Compute the manipulator jacobian relative the base. | |
| const agx::ConstraintRefVector & | getJoints () const |
| Get the joints that are in the chain. | |
| const agx::RigidBodyRefVector & | getLinks () const |
| Get the links that are in the chain. | |
| agx::UInt | getNumJoints () const |
| Returns number of joints in the chain where motion can occur. | |
| agx::UInt | getNumLinks () const |
| Returns number of links in the chain. | |
| bool | isValid () const |
| Check if the chain was valid at time of creation. | |
| void | setSimulation (agxSDK::Simulation *sim) |
| Set the Simulation that is used to read certain values needed for inverse dynamics computations. | |
Public Member Functions inherited from agx::Referenced | |
| Referenced () | |
| Default constructor. | |
| Referenced (const Referenced &) | |
| template<typename T > | |
| T * | as () |
| Subclass casting. | |
| template<typename T > | |
| const T * | as () const |
| template<typename T > | |
| T * | asSafe () |
| Safe subclass casting, return nullptr if template type does not match. | |
| template<typename T > | |
| const T * | asSafe () const |
| int | getReferenceCount () const |
| template<typename T > | |
| bool | is () const |
| Subclass test. | |
| Referenced & | operator= (const Referenced &) |
| Assignment operator. Will increment the number of references to the referenced object. | |
| void | reference (void *ptr=nullptr) const |
| Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. | |
| void | unreference (void *ptr=nullptr) const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. | |
| void | unreference_nodelete () const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. | |
Protected Member Functions | |
| SerialKinematicChain () | |
| ~SerialKinematicChain () | |
Protected Member Functions inherited from agx::Referenced | |
| virtual | ~Referenced () |
| Destructor. | |
| void | allocateObserverVector () const |
| void | deleteUsingDeleteHandler () const |
Additional Inherited Members | |
Public Types inherited from agxModel::KinematicChain | |
| enum | KinematicChainStatus { SUCCESS , INVALID_CHAIN , BAD_INPUT_ARGUMENTS , SOLVER_FAILURE , NO_SIMULATION } |
Static Public Member Functions inherited from agx::Referenced | |
| template<typename T > | |
| static bool | ValidateCast (const Referenced *object) |
Static Protected Member Functions inherited from agx::Referenced | |
| static DeleteHandler * | getDeleteHandler () |
| static void | setDeleteHandler (DeleteHandler *handler) |
| Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. | |
Protected Attributes inherited from agx::Referenced | |
| Mutex | m_mutex |
| ObserverContainer | m_observers |
| AtomicValue | m_refCount |
A Serial Kinematic Chain is a KinematicChain where there are no loops or branches.
When a chain is specified, it is via a series of agx::RigidBody and agx::Constraint objects where the number of rigid bodies is one more than number of constraints.
Bodies are expected to be handled as 6-dof bodies and having setHandleAsParticle enabled is not supported.
The constraint types that are supported are:
The first two constraint types remove 5 degrees of freedom (dof) each where as the lock removes 6 dofs.
After the chain representation is created, querying the number of joints in the chain will give the number of constraints that leave 1 degree of freedom (rotation or sliding) for the connected body. This is the same number of joint values which should be provided to the computeForwardKinematics function or are outputted from computeInverseKinematics or computeInverseDynamics.
If the coordinate frame of interest does not align with the model coordinate system for the final body/link/segment in the chain, then there is a possibility to append a local transform in the end links coordinate system. The appended transform will be the final transform from the chain. This optional appended transform is fixed relative the last body and does not increase the number of joint values that are expected as input or produced as output. It does increase the number of link outputs with one.
Definition at line 98 of file KinematicChain.h.
| agxModel::SerialKinematicChain::SerialKinematicChain | ( | agxSDK::Simulation & | simulation, |
| const agx::RigidBody & | base, | ||
| const agx::RigidBody & | end, | ||
| const agx::AffineMatrix4x4 * | endLocalTransform = nullptr |
||
| ) |
Create a serial chain from "base" to "end" by traversing the bodies and constraints in the simulation.
The chain will contain relative transforms from when it was created. Any changes to e.g. a constraint attachment frame will not be seen. If the kinematic structure is changed, then the chain must be recreated.
| simulation | The simulation in which to traverse bodies and constraints to find a chain between "base" and "end". |
| base | The first body in the chain |
| end | The last body in the chain |
| endLocalTransform | An optional transform expressed in the last bodies frame which extends the chain with one additional link. |
| agxModel::SerialKinematicChain::SerialKinematicChain | ( | const agx::RigidBodyPtrVector & | bodies, |
| const agx::ConstraintPtrVector & | constraints, | ||
| const agx::AffineMatrix4x4 * | endLocalTransform = nullptr |
||
| ) |
Create a serial chain from the input bodies and constraints which are provided in the correct order.
The chain will contain relative transforms from when it was created. Any changes to e.g. a constraint attachment frame will not be seen. If the kinematic structure is changed, then the chain must be recreated.
| bodies | A vector with the bodies in the chain |
| constraints | A vector with constraints that connect the bodies |
| endLocalTransform | An optional transform expressed in the last bodies frame which extends the chain with one additional link. |
|
protected |
|
protected |
| KinematicChainStatus agxModel::SerialKinematicChain::computeForwardKinematics | ( | const agx::RealVector & | jointPositions, |
| agx::AffineMatrix4x4 & | outputTransform, | ||
| bool | clampToJointLimits = false |
||
| ) |
Compute the transform for the end of the chain relative the base given the provided joint values.
By default, the pose is computed given the provided values as is regardless if the joints have limits or not.
| jointPositions | Vector with the same number of joint values as there are joints in the chain. |
| outputTransform | The transform for the end body relative the base. Only written if method returns success. |
| clampToJointLimits | If true, then each value in jointPositions will be clamped to corresponding joints range before computing the pose. |
| KinematicChainStatus agxModel::SerialKinematicChain::computeForwardKinematicsAll | ( | const agx::RealVector & | jointPositions, |
| agx::AffineMatrix4x4Vector & | outputTransforms, | ||
| bool | clampToJointLimits = false |
||
| ) |
Compute the transform for all links in the chain relative the base given provided joint values.
For a chain with N links, there will be N AffineMatrix4x4 in the output vector. The first item for "base" will be an identity matrix.
By default, the poses are computed given the provided values as is regardless if the joints have limits or not.
| jointPositions | Vector with the same number of joint positions as there are joints in the chain. |
| outputTransforms | Vector with transforms. Only written if method returns success. |
| clampToJointLimits | If true, then each value in jointPositions will be clamped to corresponding joints range before computing the pose. |
| KinematicChainStatus agxModel::SerialKinematicChain::computeForwardKinematicsAll | ( | const agx::RealVector & | jointPositions, |
| const agx::RealVector & | jointVelocities, | ||
| agx::AffineMatrix4x4Vector & | outputTransforms, | ||
| agx::Vec3Vector & | outputLinearVelocities, | ||
| agx::Vec3Vector & | outputAngularVelocities, | ||
| bool | clampToJointLimits = false |
||
| ) |
Compute the transforms and velocities for all links in the chain relative the base given provided joint values.
By default, the poses are computed given the provided values as is regardless if the joints have limits or not.
| jointPositions | Vector with the same number of joint positions as there are joints in the chain. |
| jointVelocities | Vector with the same number of joint velocities as there are joints in the chain. |
| outputTransforms | Vector with transforms. Only written if method returns success. |
| outputLinearVelocities | Vector with computed linear velocity for each link. |
| outputAngularVelocities | Vector with computed angular velocity for each link. |
| clampToJointLimits | If true, then each value in jointPositions will be clamped to corresponding joints range before computing the pose. |
| KinematicChainStatus agxModel::SerialKinematicChain::computeInverseDynamics | ( | const agx::RealVector & | jointAcceleration, |
| agx::RealVector & | tau | ||
| ) |
Compute the torque/forces needed to get the specified jointAccelerations.
Current joint positions and velocities are read from bodies and constraints forming the chain.
| jointAcceleration | Desired joint acceleration. |
| tau | Output torques/forces. |
| KinematicChainStatus agxModel::SerialKinematicChain::computeInverseDynamics | ( | const agx::RealVector & | jointAcceleration, |
| const agx::RealVector & | externalForces, | ||
| agx::RealVector & | tau | ||
| ) |
Compute the torque/forces needed to get the specified jointAccelerations.
Current joint positions and velocities are read from bodies and constraints forming the chain.
| jointAcceleration | Desired joint acceleration. |
| tau | Output torques/forces. |
| externalForces | Extra external forces acting on the bodies. This vector should have 6 elements (3 force, 3 torque) for each body in the chain. |
| KinematicChainStatus agxModel::SerialKinematicChain::computeInverseKinematics | ( | const agx::AffineMatrix4x4 & | transform, |
| const agx::RealVector & | currentJointPositions, | ||
| agx::RealVector & | outputJointPositions, | ||
| agx::Real | solverEpsilon = 1e-5 |
||
| ) |
Compute joint positions needed for the end body in the chain to get the specified transform relative the base.
| transform | Desired transform for the end body relative the base. |
| currentJointPositions | Vector with current positions for each joint which has a degree of freedom. |
| outputJointPositions | Vector to which joint values will be stored. |
| solverEpsilon | precision for IK solution |
| KinematicChainStatus agxModel::SerialKinematicChain::computeManipulatorJacobian | ( | const agx::RealVector & | jointPositions, |
| agx::RealVector & | jacobian | ||
| ) |
Compute the manipulator jacobian relative the base.
This jacobian gives a relationship between end effector velocities and joint velocities.
| jointPositions | Joint positions for which the jacobian should be evaluated |
| jacobian | A vector where the output 6xN jacobian is stored by row. |
| const agx::ConstraintRefVector & agxModel::SerialKinematicChain::getJoints | ( | ) | const |
Get the joints that are in the chain.
| const agx::RigidBodyRefVector & agxModel::SerialKinematicChain::getLinks | ( | ) | const |
Get the links that are in the chain.
| agx::UInt agxModel::SerialKinematicChain::getNumJoints | ( | ) | const |
Returns number of joints in the chain where motion can occur.
This number does not have to match the input number of constraints since it only includes joints which have 1 degree of freedom (rotation or sliding).
Inputs and outputs in joint space should have this number of elements.
| agx::UInt agxModel::SerialKinematicChain::getNumLinks | ( | ) | const |
Returns number of links in the chain.
This number often corresponds to the number of bodies that were used when creating the chain representation. If a final "end transform" was specified, then the link count is increased by 1.
| bool agxModel::SerialKinematicChain::isValid | ( | ) | const |
Check if the chain was valid at time of creation.
Modifying bodies (e.g. enabling treat as particle) or constraints (e.g. adding additional elementary constraints) will in many cases cause compute methods to return INVALID_CHAIN regardless of if this method returns true or not.
| void agxModel::SerialKinematicChain::setSimulation | ( | agxSDK::Simulation * | sim | ) |
Set the Simulation that is used to read certain values needed for inverse dynamics computations.
Calling this method is needed if a constructor was used that did not take a Simulation as argument.