AGX Dynamics  2.37.3.2
agxModel::InverseDynamics Class Reference

Class for computing forces/torques which can be used to reach a desired configuration. More...

#include <InverseDynamics.h>

+ Inheritance diagram for agxModel::InverseDynamics:

Classes

struct  MoveOperation
 Struct for defining a move operation during one call to one of the solve functions of InverseDynamics. More...
 

Public Types

enum  InverseDynamicsStatus {
  ID_SUCCESS, ID_INVALID_TIME, ID_BAD_ARGUMENTS, ID_BODY_NOT_FOUND,
  ID_VALID_POSE_NOT_FOUND, ID_COLLISION_OCCURRED
}
 Enumeration with status values returned from InverseDynamics. More...
 
typedef agx::Vector< InverseDynamics::MoveOperation > MoveOperationVector
 
enum  SyncLevel { INTERNAL = 0, MOTION = 1 << 0, DYNAMIC = 1 << 1, FULL = MOTION + DYNAMIC }
 

Public Member Functions

 InverseDynamics (const agxSDK::Simulation *sim, const agx::RigidBodyRefVector &bodies, const agx::ConstraintRefVector &constraints)
 Create an InverseDynamics instance holding structures matching the input bodies and constraints. More...
 
 InverseDynamics (const agxSDK::Simulation *sim, const agx::RigidBodyRefVector &bodies, const agx::ConstraintRefVector &constraints, const agx::ConstraintRefVector &otherConstraints)
 This constructor is similar to the three argument constructor but also includes an additional vector with constraints. More...
 
 InverseDynamics (const agxSDK::Simulation *sim, const agx::RigidBodyRefVector &bodies, const agx::ConstraintRefVector &constraints, const agxPowerLine::PowerLineRefVector &powerlines, const agxPowerLine::UnitRefVector &units)
 Create an InverseDynamics instance holding structures matching the input bodies, constraints and powerlines. More...
 
 InverseDynamics (const agxSDK::Simulation *sim, const agx::RigidBodyRefVector &bodies, const agx::ConstraintRefVector &constraints, const agx::ConstraintRefVector &otherConstraints, const agxPowerLine::PowerLineRefVector &powerlines, const agxPowerLine::UnitRefVector &units)
 Create an InverseDynamics instance holding structures matching the input bodies, constraints and powerlines. More...
 
agx::Real computeRotationalDifference (const agx::RigidBody *body) const
 Compute the rotational difference between body and the matching internal clone that is used in dynamics computations. More...
 
agx::Real computeRotationalDifference (const agx::RigidBody *body, const agx::AffineMatrix4x4 &transform) const
 Compute the rotational difference between input transform and the internal body used for dynamics computation matching the input body. More...
 
agx::Real computeTranslationalDifference (const agx::RigidBody *body) const
 Compute the translational difference between body and the matching internal clone that is used in dynamics computations. More...
 
agx::Real computeTranslationalDifference (const agx::RigidBody *body, const agx::AffineMatrix4x4 &transform) const
 Compute the translational difference between input transform and the internal body used for dynamics computation matching the input body. More...
 
InverseDynamics::InverseDynamicsStatus finalizeAdaptiveSolveN ()
 End the adaptive solve. More...
 
void forceStepDynamicsSimulation ()
 Will step the dynamics simulation one time step. More...
 
void forceStepMotionSimulation ()
 Will step the motion simulation one time step. More...
 
agx::UInt getCurrentFrameIndex () const
 Return the internal frame count. More...
 
const agxSDK::Assembly * getDynamicsData () const
 Fetch the internal Collection holding the cloned bodies and constraints that are used for dynamics/force/torque computations. More...
 
IDJointValueView getJointAngles (size_t frameIndex)
 If solve saved angles, fetch the values for specified frame. More...
 
IDJointValueView getJointForces (size_t frameIndex)
 Fetch joint forces produced by solve call or gravityCompensation. More...
 
agx::Real getLastDynamicsTimeStamp () const
 Returns the last timestamp reached during the force computations. More...
 
agx::AffineMatrix4x4 getLastDynamicsTransform ()
 Return the last transform the solve method reached during the force computations. More...
 
agx::Real getLastTrajectoryTimeStamp () const
 Returns the last timestamp used during trajectory computation. More...
 
agx::AffineMatrix4x4 getLastTrajectoryTransform ()
 Return the last transform the solve method reached during the trajectory computation. More...
 
const agxSDK::Assembly * getMotionData () const
 Fetch the internal Collection holding the cloned bodies and constraints that are used for motion/trajectory computations. More...
 
size_t getNumFrames () const
 Return the number of frames worth of force data that is available. More...
 
IDUnitValueView getPowerLineValues (size_t frameIndex)
 Fetch possible values for agxPowerLine Units. More...
 
const agxSDK::Assembly * getSourceData () const
 Fetch the internal Collection holding the input bodies and constraints. More...
 
InverseDynamicsStatus gravityCompensation ()
 Compute joint forces needed to compensate for gravity. More...
 
InverseDynamics::InverseDynamicsStatus initializeAdaptiveSolveN (const InverseDynamics::MoveOperationVector &moves, agx::Real time)
 Initialize a solve for N bodies, with desired end transforms. More...
 
bool setMotionControl (const agx::RigidBody *body, agx::RigidBody::MotionControl mc)
 Update the motion control to specified value for the internal bodies that are mirroring the specified body. More...
 
InverseDynamicsStatus solve (const agx::RigidBody *body, agx::AffineMatrix4x4 transform, agx::Real time, agx::Real positionThreshold, agx::Real rotationThreshold, const bool stopAtCollision=false, const bool onlyMotionSimulation=false)
 Try to find a pose for the structure so the specified body has the requested transform after the specified delta time has elapsed. More...
 
InverseDynamicsStatus solve (const agx::RigidBody *body, const agx::AffineMatrix4x4Vector &transforms, const agx::RealVector &timestamps, agx::Real positionThreshold, agx::Real rotationThreshold, const bool stopAtCollision=false, const bool onlyMotionSimulation=false)
 Similar to solve, but with a series of transforms and delta timestamps. More...
 
InverseDynamicsStatus solveLinear (const agx::RigidBody *body, agx::AffineMatrix4x4 transform, agx::Real time, agx::Real positionThreshold, agx::Real rotationThreshold, const bool stopAtCollision=false, const bool onlyMotionSimulation=false)
 Try to find a pose for the structure so the specified body has the requested transform after the specified delta time has elapsed. More...
 
InverseDynamics::InverseDynamicsStatus solveLinearN (const InverseDynamics::MoveOperationVector &moves, agx::Real time, const bool stopAtCollision=false, const bool onlyMotionSimulation=false)
 This solve method will try to move the specified bodies along individual linear paths, where feasible, between the initial pose and the end pose. More...
 
InverseDynamics::InverseDynamicsStatus stepAdaptiveSolveN ()
 Step the adaptive solve one timestep. More...
 
bool sync (agxModel::InverseDynamics::SyncLevel level=agxModel::InverseDynamics::FULL)
 This method will synchronize transforms and velocities so that solve calls operate on data that is in a known state. More...
 
InverseDynamics::InverseDynamicsStatus updateAdaptiveSolveN (const InverseDynamics::MoveOperationVector &moves, agx::Real time)
 This update will define new target transforms for the moves already assigned at intitializeAdaptiveSolveN. More...
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor. More...
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor. More...
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- 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. More...
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Class for computing forces/torques which can be used to reach a desired configuration.

It can also be used to compensate for gravity by computing forces/torques needed to keep current pose and have zero velocity.

This class is intended for use with constrained systems. There is also partial powerline support:

  • Gravity compensation can provide which force/torque that should be applied at a PowerLine Unit.
  • Trajectory computations via solve only provide value/gradient for specified powerline units and these units are not used to drive the motion.
Note
Controlling a powerline unit to control a constraint to reach a certain pose is likely to have worse precision compared to working on the contraints unless all the powerline connections are stiff.

The InverseDynamics class is agnostic to what the powerline units actually represents and how the value and gradient should be used depends on the actual unit.

Warning
The API for this class is not finalized and breaking changes can occur.

Definition at line 171 of file InverseDynamics.h.

Member Typedef Documentation

◆ MoveOperationVector

Member Enumeration Documentation

◆ InverseDynamicsStatus

Enumeration with status values returned from InverseDynamics.

Enumerator
ID_SUCCESS 

Return value for successful operation.

ID_INVALID_TIME 

Invalid timestamp provided as argument.

ID_BAD_ARGUMENTS 

Problem with timestamp and/or transform input values.

ID_BODY_NOT_FOUND 

Provided body argument not found.

ID_VALID_POSE_NOT_FOUND 

A valid pose could not be found with provided thresholds.

ID_COLLISION_OCCURRED 

A body part of the jointed structure collided with something.

Definition at line 177 of file InverseDynamics.h.

◆ SyncLevel

Enumerator
INTERNAL 

Update Motion body transforms from Dynamic.

MOTION 

Update Motion body transforms with the source.

DYNAMIC 

Update Dynamic body transforms with the source.

FULL 

Sync everything given the source.

Definition at line 186 of file InverseDynamics.h.

Constructor & Destructor Documentation

◆ InverseDynamics() [1/4]

agxModel::InverseDynamics::InverseDynamics ( const agxSDK::Simulation *  sim,
const agx::RigidBodyRefVector &  bodies,
const agx::ConstraintRefVector &  constraints 
)

Create an InverseDynamics instance holding structures matching the input bodies and constraints.

Some settings will also be copied from the simulation to be able to have a matching configuration (timestep, collision groups from space).

The source data will not be changed by InverseDynamics when computations are performed.

Parameters
simThe simulation from which settings should be read.
bodiesA container with bodies
constraintsA container with constraints for which InverseDynamics will find force/torque values

The following is required for later computations to be valid:

  • The constraints must act on RigidBodies present in the bodies container

To detect possible problems, check output from the logger or compare the sizes of the containers for bodies and constraints in getSourceData.

◆ InverseDynamics() [2/4]

agxModel::InverseDynamics::InverseDynamics ( const agxSDK::Simulation *  sim,
const agx::RigidBodyRefVector &  bodies,
const agx::ConstraintRefVector &  constraints,
const agx::ConstraintRefVector &  otherConstraints 
)

This constructor is similar to the three argument constructor but also includes an additional vector with constraints.

The first vector with constraints are "controlled" by InverseDynamics and force/torque values are to be found for these constraints.

The second vector with constraints are included in the internal calculations but the controllers for these constraints are left as is.

This can for example be used for a robot where the end effector is attached to a tool that can perform grasping and the inverse dynamics calculations should not change the fingers.

Parameters
simThe simulation from which settings should be read.
bodiesA container with bodies
constraintsA container with constraints for which InverseDynamics will find force/torque values
otherConstraintsA container with constraints that InverseDynamics will include in the computations, but not adjust the values for the controllers.

◆ InverseDynamics() [3/4]

agxModel::InverseDynamics::InverseDynamics ( const agxSDK::Simulation *  sim,
const agx::RigidBodyRefVector &  bodies,
const agx::ConstraintRefVector &  constraints,
const agxPowerLine::PowerLineRefVector &  powerlines,
const agxPowerLine::UnitRefVector &  units 
)

Create an InverseDynamics instance holding structures matching the input bodies, constraints and powerlines.

Some settings will also be copied from the simulation to be able to have a matching configuration (timestep, collision groups from space).

The source data will not be changed by InverseDynamics when computations are performed.

Note
solve and solveLinear do include powerlines in the simulations, but the constraints are currently used for driving the motion and not the actual powerlines. Accessing the force- and torque data for the constraints can be done with getJointForces. Data for specified powerline units can be accessed via getPowerLineValue to see value and gradient.
Parameters
simThe simulation from which settings should be read.
bodiesA container with bodies.
constraintsA container with constraints.
powerlinesA container with powerlines.
unitsA container with powerline units.

The following is required for later computations to be valid:

  • The constraints must act on RigidBodies present in the bodies container
  • PowerLine Actuators must act on constraints available in the constraint container
  • PowerLine Units must belong to powerlines present in the powerline container

◆ InverseDynamics() [4/4]

agxModel::InverseDynamics::InverseDynamics ( const agxSDK::Simulation *  sim,
const agx::RigidBodyRefVector &  bodies,
const agx::ConstraintRefVector &  constraints,
const agx::ConstraintRefVector &  otherConstraints,
const agxPowerLine::PowerLineRefVector &  powerlines,
const agxPowerLine::UnitRefVector &  units 
)

Create an InverseDynamics instance holding structures matching the input bodies, constraints and powerlines.

Some settings will also be copied from the simulation to be able to have a matching configuration (timestep, collision groups from space).

The source data will not be changed by InverseDynamics when computations are performed.

Note
solve and solveLinear do include powerlines in the simulations, but the constraints are currently used for driving the motion and not the actual powerlines. Accessing the force- and torque data for the constraints can be done with getJointForces. Data for specified powerline units can be accessed via getPowerLineValue to see value and gradient.
Parameters
simThe simulation from which settings should be read.
bodiesA container with bodies.
constraintsA container with constraints.
otherConstraintsA container with constraints that InverseDynamics will include in the computations, but not adjust the values for the controllers.
powerlinesA container with powerlines.
unitsA container with powerline units.

The following is required for later computations to be valid:

  • The constraints must act on RigidBodies present in the bodies container
  • PowerLine Actuators must act on constraints available in the constraint container
  • PowerLine Units must belong to powerlines present in the powerline container

Member Function Documentation

◆ computeRotationalDifference() [1/2]

agx::Real agxModel::InverseDynamics::computeRotationalDifference ( const agx::RigidBody *  body) const

Compute the rotational difference between body and the matching internal clone that is used in dynamics computations.

Note
This is an optional computation of an error that can be used after gravity compensation.
  If this method is used directly after solve or solveLinear, the return value
  is likely a large difference due to one is comparing the body's current transform
  with the end transform after the solve computations.

  The other computeRotationalDifference method that has two arguments
  is suitable for use after solve.
Parameters
bodyA rigidbody whose transform should be compared with the matching internal dynamics body.
Returns
Difference in rotation in radians. Range is [-PI,PI]. Negative 2*PI if body was not found.

◆ computeRotationalDifference() [2/2]

agx::Real agxModel::InverseDynamics::computeRotationalDifference ( const agx::RigidBody *  body,
const agx::AffineMatrix4x4 &  transform 
) const

Compute the rotational difference between input transform and the internal body used for dynamics computation matching the input body.

Note
This is an optional computation of an error measurement that can be used after solve or solveLinear.
Parameters
bodyA rigidbody whose transform should be compared with the input transform
transformThe transform to use in the difference computation.
Returns
Difference in rotation in radians. Range is [-PI,PI]. Negative 2*PI if body was not found.

◆ computeTranslationalDifference() [1/2]

agx::Real agxModel::InverseDynamics::computeTranslationalDifference ( const agx::RigidBody *  body) const

Compute the translational difference between body and the matching internal clone that is used in dynamics computations.

Note
This is an optional computation of an error that can be used after gravity compensation.
  If this method is used directly after solve or solveLinear, the return value
  is likely a large difference due to one is comparing the body's current transform
  with the end transform after the solve computations.

  The other computeTranslationalDifference method that has two arguments
  is suitable for use after solve.
Parameters
bodyA rigidbody whose transform should be compared with the matching internal dynamics body.
Returns
Magnitude of difference in position. Negative value if body was not found.

◆ computeTranslationalDifference() [2/2]

agx::Real agxModel::InverseDynamics::computeTranslationalDifference ( const agx::RigidBody *  body,
const agx::AffineMatrix4x4 &  transform 
) const

Compute the translational difference between input transform and the internal body used for dynamics computation matching the input body.

Note
This is an optional computation of an error measurement that can be used after solve or solveLinear.
Parameters
bodyA rigidbody whose transform should be compared with the input transform
transformThe transform to use in the difference computation.
Returns
Magnitude of difference in position. Negative value if body was not found.

◆ finalizeAdaptiveSolveN()

InverseDynamics::InverseDynamicsStatus agxModel::InverseDynamics::finalizeAdaptiveSolveN ( )

End the adaptive solve.

◆ forceStepDynamicsSimulation()

void agxModel::InverseDynamics::forceStepDynamicsSimulation ( )

Will step the dynamics simulation one time step.

◆ forceStepMotionSimulation()

void agxModel::InverseDynamics::forceStepMotionSimulation ( )

Will step the motion simulation one time step.

◆ getCurrentFrameIndex()

agx::UInt agxModel::InverseDynamics::getCurrentFrameIndex ( ) const

Return the internal frame count.

◆ getDynamicsData()

const agxSDK::Assembly* agxModel::InverseDynamics::getDynamicsData ( ) const

Fetch the internal Collection holding the cloned bodies and constraints that are used for dynamics/force/torque computations.

Returns
Collection of internal clones used for dynamics computations.

◆ getJointAngles()

IDJointValueView agxModel::InverseDynamics::getJointAngles ( size_t  frameIndex)

If solve saved angles, fetch the values for specified frame.

Parameters
frameIndexWhich data to access.
Returns
A view with data. Valid if size() on returned instance is >0.

◆ getJointForces()

IDJointValueView agxModel::InverseDynamics::getJointForces ( size_t  frameIndex)

Fetch joint forces produced by solve call or gravityCompensation.

The resulting structure, IDJointValue, contains [joint index, angle index, value] where the joint index refers to the index among the constraints in the container given to the constructor for this class.

Parameters
frameIndexWhich data to access.
Returns
A view with data. Valid if size() on returned instance is >0.

◆ getLastDynamicsTimeStamp()

agx::Real agxModel::InverseDynamics::getLastDynamicsTimeStamp ( ) const

Returns the last timestamp reached during the force computations.

The timestamp is a delta value and starts from zero when a solve call is performed.

On a successful solve this timestamp will be n*dt >= input_time where the integer n is the least amounts of steps.

On failure, e.g. collision, this timestamps can indicate when the problem occurred.

Returns
Current timestamp in internal dynamics simulation.

◆ getLastDynamicsTransform()

agx::AffineMatrix4x4 agxModel::InverseDynamics::getLastDynamicsTransform ( )

Return the last transform the solve method reached during the force computations.

On successful solve, this transform should be similar to the solve input transform.

Returns
The last transform for specified body in the dynamics simulation used by solve

◆ getLastTrajectoryTimeStamp()

agx::Real agxModel::InverseDynamics::getLastTrajectoryTimeStamp ( ) const

Returns the last timestamp used during trajectory computation.

The timestamp is a delta value and starts from zero when a solve call is performed.

On a successful solve this timestamp will be n*dt >= input_time where the integer n is the least amounts of steps.

On failure, e.g. collision, this timestamps can indicate when the problem occurred.

Returns
Current timestamp in internal trajectory simulation.

◆ getLastTrajectoryTransform()

agx::AffineMatrix4x4 agxModel::InverseDynamics::getLastTrajectoryTransform ( )

Return the last transform the solve method reached during the trajectory computation.

On successful solve, this transform should be similar to the solve input transform

Returns
The last transform for specified body in the trajectorysimulation used by solve

◆ getMotionData()

const agxSDK::Assembly* agxModel::InverseDynamics::getMotionData ( ) const

Fetch the internal Collection holding the cloned bodies and constraints that are used for motion/trajectory computations.

Returns
Collection of internal clones used for motion/trajectory computations.

◆ getNumFrames()

size_t agxModel::InverseDynamics::getNumFrames ( ) const

Return the number of frames worth of force data that is available.

If gravityCompensation has been called sucessfully, 1 is returned. If a solve-method has been used, the amount of output depends on the given delta time.

The value used when requesting data from

See also
getJointForces,
getJointAngles and
getPowerLineValues should be less than the return value from this method.
Returns
Number of frames worth of data that is available.

◆ getPowerLineValues()

IDUnitValueView agxModel::InverseDynamics::getPowerLineValues ( size_t  frameIndex)

Fetch possible values for agxPowerLine Units.

  • Output after a solve call has value and gradient from the unit stored in the corresponding variables.
  • Output after gravityCompensation has the load stored as value and gradient set to 0.
Parameters
frameIndexWhich data to access.
Returns
A view with data. Valid if size() on returned instance is >0.

◆ getSourceData()

const agxSDK::Assembly* agxModel::InverseDynamics::getSourceData ( ) const

Fetch the internal Collection holding the input bodies and constraints.

Returns
Collection holding references to input data.

◆ gravityCompensation()

InverseDynamicsStatus agxModel::InverseDynamics::gravityCompensation ( )

Compute joint forces needed to compensate for gravity.

This computation will use the internal dynamics bodies and compute forces/torques needed for the robot to behave as if there is zero gravity.

If PowerLine(s) are present and the following conditions are fulfilled, then matching constraints will not be used to keep the speed at 0, but instead the PowerLine:

  • PowerLine P is present among the powerlines given to the InverseDynamics constructor
  • PowerLine P has a Unit U given to the InverseDynamics constructor
  • PowerLine P has an Actuator A
  • Actuator A is connected to a Constraint C in the jointed structure.
  • Constraint C will then be controlled via PowerLine instead of SecondaryConstraints
  • Output will be the torque/force needed at Unit U to maintain zero velocity.

If needed, use sync to have the inverse dynamics system and source simulation in matching states.

On success, getNumFrames() will have 1 frame worth of data and the results are available via getJointForces(0) and getPowerLineValues(0).

Note
The source- and internal simulation must match if the computed force/torque should be valid and able to hold the robot at zero velocity.

If incompatible changes are made to the robot after the InverseDynamics instance has been created, then the computed results are likely not usable. See the

See also
sync method for a list of items that are not synced.
Returns
The return value from gravityCompensation can currently be ignored, but will be revised in a future release.

◆ initializeAdaptiveSolveN()

InverseDynamics::InverseDynamicsStatus agxModel::InverseDynamics::initializeAdaptiveSolveN ( const InverseDynamics::MoveOperationVector &  moves,
agx::Real  time 
)

Initialize a solve for N bodies, with desired end transforms.

Parameters
moves- All wanted move operations
time- The time in seconds to solve the system

◆ setMotionControl()

bool agxModel::InverseDynamics::setMotionControl ( const agx::RigidBody *  body,
agx::RigidBody::MotionControl  mc 
)

Update the motion control to specified value for the internal bodies that are mirroring the specified body.

Parameters
bodyA rigidbody that should have be part of the input bodies to InverseDynamics.
mcThe motion control value to set.
Returns
True if mirroring bodies were found and motioncontrol could be set

◆ solve() [1/2]

InverseDynamicsStatus agxModel::InverseDynamics::solve ( const agx::RigidBody *  body,
agx::AffineMatrix4x4  transform,
agx::Real  time,
agx::Real  positionThreshold,
agx::Real  rotationThreshold,
const bool  stopAtCollision = false,
const bool  onlyMotionSimulation = false 
)

Try to find a pose for the structure so the specified body has the requested transform after the specified delta time has elapsed.

This solve method will monotonically change the joint angles from the ones in the initial pose until they reach the values in the end pose. The computed trajectory aims for landing on the target transform with zero velocity.

The computations are performed in two steps, first a kinematic configuration is found and then forces/torques are computed that can be applied to reach specified transform.

The state of the internal bodies that are used in the computations should be considered unknown after solve.

Parameters
bodyA body from one of the input source bodies.
transformThe desired transform for the body.
timeDelta time from now, amount of simulated time it should take for the body to reach the desired transform.
positionThresholdValue used to determine if final kinematic configuration in the motion trajectory is close enough to requested transform. Value in meters.
rotationThresholdSimilar to positionThreshold, but for rotation. Value in radians.
stopAtCollisionset true will exit the inverse dynamics solve at a collision, default false, no effect if onlyMotionSimulation is true.
onlyMotionSimulationset true will not generate torques as a result, default false
Returns
A status value indicating the result of the computation.

◆ solve() [2/2]

InverseDynamicsStatus agxModel::InverseDynamics::solve ( const agx::RigidBody *  body,
const agx::AffineMatrix4x4Vector &  transforms,
const agx::RealVector &  timestamps,
agx::Real  positionThreshold,
agx::Real  rotationThreshold,
const bool  stopAtCollision = false,
const bool  onlyMotionSimulation = false 
)

Similar to solve, but with a series of transforms and delta timestamps.

The deltas are relative when the solve method is called, not the previous timestamp. So if transform X1 is desired after 1s and transform X2 after 1.5s, then the vectors should contain transforms: [X1, X2] and timestamps [1, 1.5].

This method can be seen as using the solve-method that takes one delta time and one transform multiple times after each other.

Parameters
bodyA body from one of the input source bodies.
transformsA vector with desired transforms for the body.
timestampsA vector with delta times from now when the matching desired transforms should be reached.
positionThresholdValue used to determine if final kinematic configuration in the motion trajectory is close enough to requested transform. Value in meters.
rotationThresholdSimilar to positionThreshold, but for rotation. Value in radians.
stopAtCollisionset true will exit the inverse dynamics solve at a collision, default false, no effect if onlyMotionSimulation is true.
onlyMotionSimulationset true will not generate torques as a result, default false
Returns
A status value indicating the result of the computation.

◆ solveLinear()

InverseDynamicsStatus agxModel::InverseDynamics::solveLinear ( const agx::RigidBody *  body,
agx::AffineMatrix4x4  transform,
agx::Real  time,
agx::Real  positionThreshold,
agx::Real  rotationThreshold,
const bool  stopAtCollision = false,
const bool  onlyMotionSimulation = false 
)

Try to find a pose for the structure so the specified body has the requested transform after the specified delta time has elapsed.

This solve method will try to move the specified body along a linear path, where feasible, between the initial pose and the end pose. The computed trajectory aims for landing on the target transform with zero velocity.

Parameters
bodyA body from one of the input source bodies.
transformThe desired transform for the body.
timeDelta time from now, amount of simulated time it should take for the body to reach the desired transform.
positionThresholdValue used to determine if final kinematic configuration in the motion trajectory is close enough to requested transform. Value in meters.
rotationThresholdSimilar to positionThreshold, but for rotation. Value in radians.
stopAtCollisionset true will stop the inverse dynamics solve at a collision, default false, no effect if onlyMotionSimulation is true.
onlyMotionSimulationset true will not generate torques as a result, default false
Returns
A status value indicating the result of the computation.

◆ solveLinearN()

InverseDynamics::InverseDynamicsStatus agxModel::InverseDynamics::solveLinearN ( const InverseDynamics::MoveOperationVector &  moves,
agx::Real  time,
const bool  stopAtCollision = false,
const bool  onlyMotionSimulation = false 
)

This solve method will try to move the specified bodies along individual linear paths, where feasible, between the initial pose and the end pose.

Another difference with the solveLinear method is that each move can have individual thresholds and compliance of the trajectory constraints. Initialize a solve for N bodies, with desired end transforms.

Parameters
moves- All wanted move operations
time- The time in seconds to solve the system

◆ stepAdaptiveSolveN()

InverseDynamics::InverseDynamicsStatus agxModel::InverseDynamics::stepAdaptiveSolveN ( )

Step the adaptive solve one timestep.

◆ sync()

bool agxModel::InverseDynamics::sync ( agxModel::InverseDynamics::SyncLevel  level = agxModel::InverseDynamics::FULL)

This method will synchronize transforms and velocities so that solve calls operate on data that is in a known state.

Using this method between calls to solve is strongly advised to get expected results.

See InverseDynamics::SyncLevel for the different options.

Note
This method should not be called to do a InverseDynamics::FULL sync while the source simulation is being stepped to avoid threadding issues.

Only body and powerline data will be synced. Other changes to the source simulation such as for example:

  • changed compliance/damping for constraints
  • changes to materials/contact materials
  • changes to collision groups will not be synced.
Parameters
leveldefine which InverseDynamics::SyncLevel to sync
Returns
True if sync could be performed successfully.

◆ updateAdaptiveSolveN()

InverseDynamics::InverseDynamicsStatus agxModel::InverseDynamics::updateAdaptiveSolveN ( const InverseDynamics::MoveOperationVector &  moves,
agx::Real  time 
)

This update will define new target transforms for the moves already assigned at intitializeAdaptiveSolveN.

Assume the moves come in the same order as the adaptive solve was initialized with regarding the bodies in the MoveOperation's. If not, you first need to finalize the adaptive solve and then initialize it again with the new order of moves.

Parameters
moves- All wanted move operations
time- The time in seconds to solve the system

The documentation for this class was generated from the following file: