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
enum class WireType : intConcrete wire model.
| Enumerator | Value | Description |
|---|---|---|
STIFF | 0 | StiffLengthConstraint: hard length limit. |
COMPLIANT | CompliantLengthConstraint: spring with stiffness. | |
CUSTOM | CustomLengthConstraint: user-specified tension. |
StretchType
enum class StretchType : intWhich length deviation the wire resists.
| Enumerator | Value | Description |
|---|---|---|
STRETCH_RESISTANT_ONLY | 0 | Resists only distances longer than the length (like a rope). Default for stiff and compliant wires created by World. |
COMPRESSION_RESISTANT_ONLY | Resists only distances shorter than the length. | |
BOTH | Resists both. |
Constructors & destructor
LengthConstraint
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
| Parameter | Description |
|---|---|
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
virtual ~LengthConstraint()Public member functions
getTendon
Tendon *getTendon() constCompatibility view of a World-owned tendon; null before registration.
Returns the backing tendon (owned by World) or nullptr
update
void update(contact::ContactProblems &contact_problems)update internal variables (called by World::integrate1())
Parameters
| Parameter | Description |
|---|---|
contact_problems (in, out) | contact problems of the world |
getLength
double getLength() constReturns the configured nominal (rest) length of the wire in meters, not the current separation (see getDistance())
getVisualizationWidth
double getVisualizationWidth()get wire width for visualization
Returns width in meters
setVisualizationWidth
void setVisualizationWidth(double width)set visualization width. A width of zero hides the wire.
Parameters
| Parameter | Description |
|---|---|
width (in) | width in meters. Must be finite and nonnegative (throws std::invalid_argument otherwise) |
getDistance
double getDistance() constReturns the distance between the two mounting points (m) at the last update
getP1
const Vec<3> &getP1() constReturns the first attachment point in the World frame
getP2
const Vec<3> &getP2() constReturns the second attachment point in the World frame
getBody1
Object *getBody1() constReturns the first object to which the wire is attached
getBody2
Object *getBody2() constReturns the second object to which the wire is attached
getNorm
const Vec<3> &getNorm() constReturns the direction of the normal (i.e., p2-p1 normalized)
getLocalIdx1
size_t getLocalIdx1() constReturns the local index of object1
getLocalIdx2
size_t getLocalIdx2() constReturns the local index of object2
getStretch
double getStretch() constReturns the stretch length, getDistance() - getLength() (m), at the last update
setName
void setName(const std::string &name)set name of the wire
Parameters
| Parameter | Description |
|---|---|
name (in) | the constraint's name |
getName
const std::string &getName() constget name of the wire
Returns the wire name
setStretchType
void setStretchType(StretchType type)set stretch type of the wire Check http://raisim.com/sections/StiffLengthConstraint.html
Parameters
| Parameter | Description |
|---|---|
type (in) | the wire stretch type. Available types: STRETCH_RESISTANT_ONLY, COMPRESSION_RESISTANT_ONLY, BOTH |
getStretchType
StretchType getStretchType() constget the constraint's stretch type
Returns the wire stretch type
getWireType
WireType getWireType() constget wire type
Returns wire type
getOb1MountPos
const Vec<3> &getOb1MountPos() constget pos on ob1 where the wire is attached
Returns mount position 1 in body1's frame
getOb2MountPos
const Vec<3> &getOb2MountPos() constget pos on ob2 where the wire is attached
Returns mount position 2 in body2's frame
Public attributes
isActive
bool isActiveTrue when the constraint is active in the solver.
Inherited members
From raisim::Constraints: getColor, lock, lockMutex, setColor, try_lock, unlock, unlockMutex