Skip to content

raisim::LengthConstraint ​

abstract class · #include <raisim/constraints/LengthConstraint.hpp>

Inherits: raisim::Constraints
Derived by: raisim::CompliantLengthConstraint, raisim::CustomLengthConstraint, raisim::StiffLengthConstraint

Base class of the legacy distance constraints ("wires") between two points on two objects. Create them with World::addStiffWire(), World::addCompliantWire() or World::addCustomWire(); the world owns them. Internally each wire is backed by a two-site spatial Tendon.

Public types ​

WireType ​

cpp
enum class WireType : int

Concrete wire model.

EnumeratorValueDescription
STIFF0StiffLengthConstraint: hard length limit.
COMPLIANTCompliantLengthConstraint: spring with stiffness.
CUSTOMCustomLengthConstraint: user-specified tension.

StretchType ​

cpp
enum class StretchType : int

Which length deviation the wire resists.

EnumeratorValueDescription
STRETCH_RESISTANT_ONLY0Resists only distances longer than the length (like a rope). Default for stiff and compliant wires created by World.
COMPRESSION_RESISTANT_ONLYResists only distances shorter than the length.
BOTHResists both.

Constructors & destructor ​

LengthConstraint ​

cpp
LengthConstraint(
    Object *obj1,
    size_t localIdx1,
    Vec<3> pos1_b,
    Object *obj2,
    size_t localIdx2,
    Vec<3> pos2_b,
    double length)

Use the World::add*Wire() functions instead of constructing wires directly.

Parameters

ParameterDescription
obj1 (in)first object (non-null)
localIdx1 (in)local body index on obj1
pos1_b (in)mount position in obj1's body frame
obj2 (in)second object (non-null)
localIdx2 (in)local body index on obj2
pos2_b (in)mount position in obj2's body frame
length (in)rest length in meters (finite, nonnegative). Throws std::invalid_argument otherwise

~LengthConstraint ​

cpp
virtual ~LengthConstraint()

Public member functions ​

getTendon ​

cpp
Tendon *getTendon() const

Compatibility view of a World-owned tendon; null before registration.

Returns the backing tendon (owned by World) or nullptr

update ​

cpp
void update(contact::ContactProblems &contact_problems)

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

Parameters

ParameterDescription
contact_problems (in, out)contact problems of the world

getLength ​

cpp
double getLength() const

Returns the configured nominal (rest) length of the wire in meters, not the current separation (see getDistance())

getVisualizationWidth ​

cpp
double getVisualizationWidth()

get wire width for visualization

Returns width in meters

setVisualizationWidth ​

cpp
void setVisualizationWidth(double width)

set visualization width. A width of zero hides the wire.

Parameters

ParameterDescription
width (in)width in meters. Must be finite and nonnegative (throws std::invalid_argument otherwise)

getDistance ​

cpp
double getDistance() const

Returns the distance between the two mounting points (m) at the last update

getP1 ​

cpp
const Vec<3> &getP1() const

Returns the first attachment point in the World frame

getP2 ​

cpp
const Vec<3> &getP2() const

Returns the second attachment point in the World frame

getBody1 ​

cpp
Object *getBody1() const

Returns the first object to which the wire is attached

getBody2 ​

cpp
Object *getBody2() const

Returns the second object to which the wire is attached

getNorm ​

cpp
const Vec<3> &getNorm() const

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

getLocalIdx1 ​

cpp
size_t getLocalIdx1() const

Returns the local index of object1

getLocalIdx2 ​

cpp
size_t getLocalIdx2() const

Returns the local index of object2

getStretch ​

cpp
double getStretch() const

Returns the stretch length, getDistance() - getLength() (m), at the last update

setName ​

cpp
void setName(const std::string &name)

set name of the wire

Parameters

ParameterDescription
name (in)the constraint's name

getName ​

cpp
const std::string &getName() const

get name of the wire

Returns the wire name

setStretchType ​

cpp
void setStretchType(StretchType type)

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

Parameters

ParameterDescription
type (in)the wire stretch type. Available types: STRETCH_RESISTANT_ONLY, COMPRESSION_RESISTANT_ONLY, BOTH

getStretchType ​

cpp
StretchType getStretchType() const

get the constraint's stretch type

Returns the wire stretch type

getWireType ​

cpp
WireType getWireType() const

get wire type

Returns wire type

getOb1MountPos ​

cpp
const Vec<3> &getOb1MountPos() const

get pos on ob1 where the wire is attached

Returns mount position 1 in body1's frame

getOb2MountPos ​

cpp
const Vec<3> &getOb2MountPos() const

get pos on ob2 where the wire is attached

Returns mount position 2 in body2's frame

Public attributes ​

isActive ​

cpp
bool isActive

True when the constraint is active in the solver.

Inherited members ​

From raisim::Constraints: getColor, lock, lockMutex, setColor, try_lock, unlock, unlockMutex

RaiSim — physics for robotics and AI.