Constraints

RaiSim currently has two types of constraints:

Both constraints offer three stretch types: STRETCH_RESISTANT_ONLY, COMPRESSION_RESISTANT_ONLY, BOTH. The first two are unilateral constraints (i.e., acting only in one direction) and BOTH is a bilateral constraint (i.e., acting in both directions). The stretch types are explained in StiffLengthConstraint.

You can find a short example in examples/src/server/newtonsCradle.cpp. This code simulates the following dynamics

../_images/constraints.gif

API

LengthConstraint

class raisim::LengthConstraint : public raisim::Constraints

Subclassed by raisim::CompliantLengthConstraint, raisim::CustomLengthConstraint, raisim::StiffLengthConstraint

Public Functions

void update(contact::ContactProblems &contact_problems)

update internal variables (called by World::integrate1())

double getLength() const

Return

the length of the wire

double getDistance() const

Return

the distance between the two mounting points

const Vec<3> &getP1() const

Return

the first attachment point in the World frame

const Vec<3> &getP2() const

Return

the second attachment point in the World frame

Object *getBody1() const

Return

the first object to which the wire is attached

Object *getBody2() const

Return

the second object to which the wire is attached

const Vec<3> &getNorm() const

Return

the direction of the normal (i.e., p2-p1 normalized)

size_t getLocalIdx1() const

Return

the local index of object1

size_t getLocalIdx2() const

Return

the local index of object2

double getStretch() const

Return

the stretch length (i.e., constraint violation)

void setName(const std::string &name)

set name of the wire

Parameters
  • name: the constraint’s name

const std::string &getName() const

get name of the wire

Return

the wire name

void setStretchType(StretchType type)

set stretch type of the wire Check http://raisim.com/sections/StiffLengthConstraint.html

Parameters
  • the: wire stretch type. Available types: STRETCH_RESISTANT_ONLY, COMPRESSION_RESISTANT_ONLY, BOTH

StretchType getStretchType() const

get the constraint’s stretch type

Return

the wire stretch type