RobWorkProject  23.9.11-
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
Constraint Class Reference

A constraint is a mathematical model that constrain the movement between two arbitrary bodies in a dynamic simulation. More...

#include <Constraint.hpp>

Inherits StateData.

Classes

struct  Limit
 Definition of a limit for one single degree of freedom. More...
 
struct  SpringParams
 Parameters for a spring. More...
 

Public Types

enum  ConstraintType {
  Fixed , Prismatic , Revolute , Universal ,
  Spherical , Piston , PrismaticRotoid , PrismaticUniversal ,
  Free
}
 The different constraint types. More...
 
typedef rw::core::Ptr< ConstraintPtr
 smart pointer type to this class
 

Public Member Functions

 Constraint (const std::string &name, const ConstraintType &type, Body *b1, Body *b2)
 Construct new constraint. More...
 
virtual ~Constraint ()
 Destructor.
 
ConstraintType getType () const
 Get the type of constraint. More...
 
BodygetBody1 () const
 Get a pointer to Body 1. More...
 
BodygetBody2 () const
 Get a pointer to Body 2. More...
 
size_t getDOF () const
 Get the degrees of freedom of the constraint. More...
 
size_t getDOFLinear () const
 Get the linear degrees of freedom of the constraint. More...
 
size_t getDOFAngular () const
 Get the angular degrees of freedom of the constraint. More...
 
rw::math::Transform3D getTransform () const
 Get the transform of the constraint, relative to the parents body frame. More...
 
void setTransform (const rw::math::Transform3D<> &parentTconstraint)
 Set the transform of the constraint, relative to the parents body frame. More...
 
SpringParams getSpringParams () const
 Get the spring parameters. More...
 
void setSpringParams (const SpringParams &params)
 Set spring parameters. More...
 
Limit getLimit (std::size_t i) const
 Get limit information. More...
 
void setLimit (std::size_t i, const Limit &limit)
 Set limit. More...
 
- Public Member Functions inherited from StateData
virtual ~StateData ()
 destructor
 
int getID () const
 An integer ID for the StateData. More...
 
const std::string & getName () const
 The name of the state data. More...
 
int size () const
 The number of doubles allocated by this StateData in each State object. More...
 
const double * getData (const rw::kinematics::State &state) const
 An array of length size() containing the values for the state data. More...
 
double * getData (rw::kinematics::State &state)
 An array of length size() containing the values for the state data. More...
 
void setData (rw::kinematics::State &state, const double *vals) const
 Assign for state data the size() of values of the array vals. More...
 
void setData (rw::kinematics::State &state, const std::vector< double > &vals) const
 Assign for state data the size() of values of the array vals. More...
 
void setData (rw::kinematics::State &state, const double &val) const
 Assign for state data the size() of values of the array vals. More...
 
bool hasCache () const
 Check is state data includes a cache. More...
 
rw::core::Ptr< rw::kinematics::StateCachegetCache (const rw::kinematics::State &state) const
 Get the cache. More...
 
rw::core::Ptr< rw::kinematics::StateCachegetCache (rw::kinematics::State &state)
 Get the cache. . More...
 
rw::core::Ptr< rw::kinematics::StateCachegetDefaultCache ()
 Get default cache. More...
 
void setCache (rw::core::Ptr< rw::kinematics::StateCache > cache, rw::kinematics::State &state)
 Set the cache values. More...
 
class rw::kinematics::StateStructuregetStateStructure ()
 Get the state structure. More...
 
bool operator== (const StateData &rhs)
 Compares the state data to see if they are the same Checks the ID, name and which statetrucure they belong to. More...
 
bool operator!= (const StateData &rhs)
 Check if not equal. More...
 
 StateData (int size, const std::string &name)
 A state with size number of doubles in the State vector. More...
 
 StateData (int size, const std::string &name, rw::core::Ptr< rw::kinematics::StateCache > cache)
 A state with size number of doubles in the State vector. More...
 

Static Public Member Functions

static bool toConstraintType (const std::string &string, ConstraintType &type)
 Convert a string to a ConstraintType. More...
 

Detailed Description

A constraint is a mathematical model that constrain the movement between two arbitrary bodies in a dynamic simulation.

For a device the Link and Joint types should be used to specify the constraints.

The Constraint type can however be used between any two bodies. For instance between two free bodies, or between a free body and a link of a device.

All functions in this class are thread-safe. Only the transform of the constraint and the spring parameters can be changed after creation of the constraint.

Member Enumeration Documentation

◆ ConstraintType

The different constraint types.

Enumerator
Fixed 

bodies will not be able to move relative to eachother (0 DOF).

Prismatic 

bodies will be able to move in the z-direction only (1 DOF).

Revolute 

bodies will be able to rotate around the z-direction only (1 DOF).

Universal 

bodies will be able to both rotate around the x- and y- directions (2 DOF).

Spherical 

bodies will be able to rotate relative to eachother, but not move linearly (3 DOF).

Piston 

bodies will be able to translate and rotate around the z-axis (2 DOF).

PrismaticRotoid 

bodies will be able to translate along the z-axis and rotate around the x-axis (2 DOF).

PrismaticUniversal 

bodies will be able to translate along the z-axis and rotate around both the x- and y-axes (3 DOF).

Free 

bodies are not constrained (6 DOF) - can be used for 6D springs.

Constructor & Destructor Documentation

◆ Constraint()

Constraint ( const std::string &  name,
const ConstraintType type,
Body b1,
Body b2 
)

Construct new constraint.

Parameters
name[in] a unique name identifying the constraint.
type[in] the type of constraint.
b1[in] the parent body to attach the constraint to.
b2[in] the child body to attach the constraint to.

Member Function Documentation

◆ getBody1()

Body* getBody1 ( ) const

Get a pointer to Body 1.

Returns
pointer to body 1.

◆ getBody2()

Body* getBody2 ( ) const

Get a pointer to Body 2.

Returns
pointer to body 2.

◆ getDOF()

size_t getDOF ( ) const

Get the degrees of freedom of the constraint.

Returns
the degrees of freedom.

◆ getDOFAngular()

size_t getDOFAngular ( ) const

Get the angular degrees of freedom of the constraint.

Returns
the angular degrees of freedom.

◆ getDOFLinear()

size_t getDOFLinear ( ) const

Get the linear degrees of freedom of the constraint.

Returns
the linear degrees of freedom.

◆ getLimit()

Limit getLimit ( std::size_t  i) const

Get limit information.

Parameters
i[in] the degree of freedom to get limit information for.
Returns
the limit.

◆ getSpringParams()

SpringParams getSpringParams ( ) const

Get the spring parameters.

Returns
SpringParams structure.

◆ getTransform()

rw::math::Transform3D getTransform ( ) const

Get the transform of the constraint, relative to the parents body frame.

Returns
the transform relative to the parent, \(\bf{T}_{parent}^{constraint}\).

◆ getType()

ConstraintType getType ( ) const

Get the type of constraint.

Returns
the ConstraintType

◆ setLimit()

void setLimit ( std::size_t  i,
const Limit limit 
)

Set limit.

Parameters
i[in] the degree of freedom to set limit information for.
limit[in] the limit information.

◆ setSpringParams()

void setSpringParams ( const SpringParams params)

Set spring parameters.

Parameters
params[in] SpringParams structure.

◆ setTransform()

void setTransform ( const rw::math::Transform3D<> &  parentTconstraint)

Set the transform of the constraint, relative to the parents body frame.

Parameters
parentTconstraint[in] the transform relative to the parent, \(\bf{T}_{parent}^{constraint}\).

◆ toConstraintType()

static bool toConstraintType ( const std::string &  string,
ConstraintType type 
)
static

Convert a string to a ConstraintType.

Parameters
string[in] the string to convert.
type[in/out] the result of the convertion.
Returns
true if string was converted, false otherwise.

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