Privacy
An open-source, flexible 3D physical simulation framework
mars::sim::JointPhysics Class Reference

#include <JointPhysics.h>

Public Member Functions

 JointPhysics (interfaces::PhysicsInterface *world)
 the constructor More...
 
virtual ~JointPhysics (void)
 the destructor More...
 
virtual bool createJoint (interfaces::JointData *joint, const interfaces::NodeInterface *node1, const interfaces::NodeInterface *node2)
 create Joint getting as argument the JointData which give the joint informations. More...
 
virtual void getAnchor (utils::Vector *anchor) const
 get the anchor of the joint More...
 
virtual void setAnchor (const utils::Vector &anchor)
 set the anchor i.e. the position where the joint is created of the joint More...
 
virtual void setAxis (const utils::Vector &axis)
 set the world informations More...
 
virtual void setAxis2 (const utils::Vector &axis)
 Set the Axis2 of the Joint. More...
 
virtual void getAxis (utils::Vector *axis) const
 Gets the actual axis of a joint. More...
 
virtual void getAxis2 (utils::Vector *axis) const
 Gets the actual second axis of a joint. More...
 
virtual void setWorldObject (interfaces::PhysicsInterface *world)
 set the world informations More...
 
virtual void setForceLimit (interfaces::sReal max_force)
 
virtual void setForceLimit2 (interfaces::sReal max_force)
 
virtual void setVelocity (interfaces::sReal velocity)
 
virtual void setVelocity2 (interfaces::sReal velocity)
 
virtual interfaces::sReal getVelocity (void) const
 
virtual interfaces::sReal getVelocity2 (void) const
 
virtual void setJointAsMotor (int axis)
 
virtual void unsetJointAsMotor (int axis)
 
virtual interfaces::sReal getPosition (void) const
 
virtual interfaces::sReal getPosition2 (void) const
 
virtual void getForce1 (utils::Vector *f) const
 Gets the force the joint applies to the first body. More...
 
virtual void getForce2 (utils::Vector *f) const
 Gets the force the joint applies to the second body. More...
 
virtual void getTorque1 (utils::Vector *t) const
 Gets the torque the joint applies to the first body. More...
 
virtual void getTorque2 (utils::Vector *t) const
 Gets the torque the joint applies to the second body. More...
 
virtual void setTorque (interfaces::sReal torque)
 
virtual void setTorque2 (interfaces::sReal torque)
 
virtual void reattacheJoint (void)
 reset the achor to the actual position. More...
 
virtual void update (void)
 we need to calculate the axis torques and joint load before we can return it. More...
 
virtual void getJointLoad (utils::Vector *t) const
 
virtual void getAxisTorque (utils::Vector *t) const
 Return the torque vector for the first axis of the joint. More...
 
virtual void getAxis2Torque (utils::Vector *t) const
 
virtual void changeStepSize (const interfaces::JointData &jointS)
 
virtual interfaces::sReal getMotorTorque (void) const
 
virtual interfaces::sReal getLowStop () const
 
virtual interfaces::sReal getHighStop () const
 
virtual interfaces::sReal getLowStop2 () const
 
virtual interfaces::sReal getHighStop2 () const
 
virtual void setLowStop (interfaces::sReal lowStop)
 
virtual void setHighStop (interfaces::sReal highStop)
 
virtual void setLowStop2 (interfaces::sReal lowStop2)
 
virtual void setHighStop2 (interfaces::sReal highStop2)
 
- Public Member Functions inherited from mars::interfaces::JointInterface
virtual ~JointInterface ()
 

Private Member Functions

void calculateCfmErp (const interfaces::JointData *jointS)
 
void createHinge (interfaces::JointData *jointS, dBodyID body1, dBodyID body2)
 create a joint from type Hing More...
 
void createHinge2 (interfaces::JointData *jointS, dBodyID body1, dBodyID body2)
 Creates a hinge2 joint in the physical environment. More...
 
void createSlider (interfaces::JointData *jointS, dBodyID body1, dBodyID body2)
 
void createBall (interfaces::JointData *jointS, dBodyID body1, dBodyID body2)
 
void createUniversal (interfaces::JointData *jointS, dBodyID body1, dBodyID body2)
 Creates a universal joint in the physical environment. More...
 
void createFixed (interfaces::JointData *jointS, dBodyID body1, dBodyID body2)
 Creates a fixed joint in the physical environment. More...
 

Private Attributes

WorldPhysicstheWorld
 
dJointID jointId
 
dJointID ball_motor
 
dJointFeedback feedback
 
dBodyID body1
 
dBodyID body2
 
int joint_type
 
dReal cfm
 
dReal cfm1
 
dReal cfm2
 
dReal erp1
 
dReal erp2
 
dReal lo1
 
dReal lo2
 
dReal hi1
 
dReal hi2
 
dReal damping
 
dReal spring
 
dReal jointCFM
 
utils::Vector axis1_torque
 
utils::Vector axis2_torque
 
utils::Vector joint_load
 
dReal motor_torque
 

Detailed Description

Definition at line 36 of file JointPhysics.h.

Constructor & Destructor Documentation

◆ JointPhysics()

mars::sim::JointPhysics::JointPhysics ( interfaces::PhysicsInterface world)

the constructor

the constructor of the Joint physics initialize the attributes of the object

Definition at line 48 of file JointPhysics.cpp.

◆ ~JointPhysics()

mars::sim::JointPhysics::~JointPhysics ( void  )
virtual

the destructor

Destroys the joint in the physics world.

pre:

  • theWorld is the correct world object

post:

  • all physical representation of the joint should be cleared

Definition at line 69 of file JointPhysics.cpp.

Member Function Documentation

◆ calculateCfmErp()

void mars::sim::JointPhysics::calculateCfmErp ( const interfaces::JointData jointS)
private

Definition at line 77 of file JointPhysics.cpp.

◆ changeStepSize()

void mars::sim::JointPhysics::changeStepSize ( const interfaces::JointData jointS)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1189 of file JointPhysics.cpp.

◆ createBall()

void mars::sim::JointPhysics::createBall ( interfaces::JointData jointS,
dBodyID  body1,
dBodyID  body2 
)
private

Definition at line 427 of file JointPhysics.cpp.

◆ createFixed()

void mars::sim::JointPhysics::createFixed ( interfaces::JointData jointS,
dBodyID  body1,
dBodyID  body2 
)
private

Creates a fixed joint in the physical environment.

For static fixed objects a same group id is prefered, the fixed joint should only be used to dynamically connect and unconnect nodes.

pre:

  • body1 and/or body2 should be aviable

post:

  • a fixed joint should be created and connected to the bodies

Definition at line 1085 of file JointPhysics.cpp.

◆ createHinge()

void mars::sim::JointPhysics::createHinge ( interfaces::JointData jointS,
dBodyID  body1,
dBodyID  body2 
)
private

create a joint from type Hing

Creates a hinge joint in the physical environment.

We get a problem here. There two different way how a hinge joint can be used. First is can be used only as joint. So we should set the low and height stop to zero and use the stopcfm and stoperp values to simulate the spring-damping properties of the joint. The second case is, to use the hinge to simulate a motor. I don't know how the ode behavior will look like, if we set the same parameter and use the force and velocity params to simulate a motor.

Definition at line 322 of file JointPhysics.cpp.

◆ createHinge2()

void mars::sim::JointPhysics::createHinge2 ( interfaces::JointData jointS,
dBodyID  body1,
dBodyID  body2 
)
private

Creates a hinge2 joint in the physical environment.

pre:

  • body1 and body2 should be aviable

post:

  • a hinge2 joint should be created and connected to the bodies

Definition at line 366 of file JointPhysics.cpp.

◆ createJoint()

bool mars::sim::JointPhysics::createJoint ( interfaces::JointData joint,
const interfaces::NodeInterface node1,
const interfaces::NodeInterface node2 
)
virtual

create Joint getting as argument the JointData which give the joint informations.

create the joint with the informations giving from jointS

Implements mars::interfaces::JointInterface.

Definition at line 110 of file JointPhysics.cpp.

◆ createSlider()

void mars::sim::JointPhysics::createSlider ( interfaces::JointData jointS,
dBodyID  body1,
dBodyID  body2 
)
private

Definition at line 400 of file JointPhysics.cpp.

◆ createUniversal()

void mars::sim::JointPhysics::createUniversal ( interfaces::JointData jointS,
dBodyID  body1,
dBodyID  body2 
)
private

Creates a universal joint in the physical environment.

pre:

  • body1 and body2 should be aviable

post:

  • a universal joint should be created and connected to the bodies

Definition at line 477 of file JointPhysics.cpp.

◆ getAnchor()

void mars::sim::JointPhysics::getAnchor ( utils::Vector anchor) const
virtual

get the anchor of the joint

Implements mars::interfaces::JointInterface.

Definition at line 175 of file JointPhysics.cpp.

◆ getAxis()

void mars::sim::JointPhysics::getAxis ( utils::Vector axis) const
virtual

Gets the actual axis of a joint.

pre:

  • the joint should be created and should have a axis vector

post:

  • the given axis struct should be filled with correct values

Implements mars::interfaces::JointInterface.

Definition at line 618 of file JointPhysics.cpp.

◆ getAxis2()

void mars::sim::JointPhysics::getAxis2 ( utils::Vector axis) const
virtual

Gets the actual second axis of a joint.

pre:

  • the joint should be created and should have second axis vector

post:

  • the given axis struct should be filled with correct values

Implements mars::interfaces::JointInterface.

Definition at line 656 of file JointPhysics.cpp.

◆ getAxis2Torque()

void mars::sim::JointPhysics::getAxis2Torque ( utils::Vector t) const
virtual

Implements mars::interfaces::JointInterface.

Definition at line 902 of file JointPhysics.cpp.

◆ getAxisTorque()

void mars::sim::JointPhysics::getAxisTorque ( utils::Vector t) const
virtual

Return the torque vector for the first axis of the joint.

v1[0] = b1_pos[0] - anchor[0]; v1[1] = b1_pos[1] - anchor[1]; v1[2] = b1_pos[2] - anchor[2]; radius = dSqrt(v1[0]*v1[0]+ v1[1]*v1[1]+ v1[2]*v1[2]); normal[0] = axis[1]*v1[2] - axis[2]*v1[1]; normal[1] = -axis[0]*v1[2] + axis[2]*v1[0]; normal[2] = axis[0]*v1[1] - axis[1]*v1[0]; dot = (normal[0]*feedback.f1[0]+ normal[1]*feedback.f1[1]+ normal[2]*feedback.f1[2]); normal[0] *= dot*radius; normal[1] *= dot*radius; normal[2] *= dot*radius;

Implements mars::interfaces::JointInterface.

Definition at line 896 of file JointPhysics.cpp.

◆ getForce1()

void mars::sim::JointPhysics::getForce1 ( utils::Vector f) const
virtual

Gets the force the joint applies to the first body.

pre:

  • the joint should be created

post:

Implements mars::interfaces::JointInterface.

Definition at line 776 of file JointPhysics.cpp.

◆ getForce2()

void mars::sim::JointPhysics::getForce2 ( utils::Vector f) const
virtual

Gets the force the joint applies to the second body.

pre:

  • the joint should be created

post:

Implements mars::interfaces::JointInterface.

Definition at line 791 of file JointPhysics.cpp.

◆ getHighStop()

interfaces::sReal mars::sim::JointPhysics::getHighStop ( ) const
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1317 of file JointPhysics.cpp.

◆ getHighStop2()

interfaces::sReal mars::sim::JointPhysics::getHighStop2 ( ) const
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1343 of file JointPhysics.cpp.

◆ getJointLoad()

void mars::sim::JointPhysics::getJointLoad ( utils::Vector t) const
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1067 of file JointPhysics.cpp.

◆ getLowStop()

interfaces::sReal mars::sim::JointPhysics::getLowStop ( ) const
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1302 of file JointPhysics.cpp.

◆ getLowStop2()

interfaces::sReal mars::sim::JointPhysics::getLowStop2 ( ) const
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1332 of file JointPhysics.cpp.

◆ getMotorTorque()

sReal mars::sim::JointPhysics::getMotorTorque ( void  ) const
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1298 of file JointPhysics.cpp.

◆ getPosition()

sReal mars::sim::JointPhysics::getPosition ( void  ) const
virtual

Implements mars::interfaces::JointInterface.

Definition at line 277 of file JointPhysics.cpp.

◆ getPosition2()

sReal mars::sim::JointPhysics::getPosition2 ( void  ) const
virtual

Implements mars::interfaces::JointInterface.

Definition at line 297 of file JointPhysics.cpp.

◆ getTorque1()

void mars::sim::JointPhysics::getTorque1 ( utils::Vector t) const
virtual

Gets the torque the joint applies to the first body.

pre:

  • the joint should be created

post:

Implements mars::interfaces::JointInterface.

Definition at line 806 of file JointPhysics.cpp.

◆ getTorque2()

void mars::sim::JointPhysics::getTorque2 ( utils::Vector t) const
virtual

Gets the torque the joint applies to the second body.

pre:

  • the joint should be created

post:

Implements mars::interfaces::JointInterface.

Definition at line 821 of file JointPhysics.cpp.

◆ getVelocity()

sReal mars::sim::JointPhysics::getVelocity ( void  ) const
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1098 of file JointPhysics.cpp.

◆ getVelocity2()

sReal mars::sim::JointPhysics::getVelocity2 ( void  ) const
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1123 of file JointPhysics.cpp.

◆ reattacheJoint()

void mars::sim::JointPhysics::reattacheJoint ( void  )
virtual

reset the achor to the actual position.

If a Node is moved or rotated by the editor, this function resets the constrains the joint applies to the Nodes that are connected.

pre:

  • the joint should be created

post:

Implements mars::interfaces::JointInterface.

Definition at line 838 of file JointPhysics.cpp.

◆ setAnchor()

void mars::sim::JointPhysics::setAnchor ( const utils::Vector anchor)
virtual

set the anchor i.e. the position where the joint is created of the joint

Implements mars::interfaces::JointInterface.

Definition at line 520 of file JointPhysics.cpp.

◆ setAxis()

void mars::sim::JointPhysics::setAxis ( const utils::Vector axis)
virtual

set the world informations

Set the Axis of the Joint to a new position.

pre:

post:

Implements mars::interfaces::JointInterface.

Definition at line 553 of file JointPhysics.cpp.

◆ setAxis2()

void mars::sim::JointPhysics::setAxis2 ( const utils::Vector axis)
virtual

Set the Axis2 of the Joint.

pre:

post:

Implements mars::interfaces::JointInterface.

Definition at line 585 of file JointPhysics.cpp.

◆ setForceLimit()

void mars::sim::JointPhysics::setForceLimit ( interfaces::sReal  max_force)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 205 of file JointPhysics.cpp.

◆ setForceLimit2()

void mars::sim::JointPhysics::setForceLimit2 ( interfaces::sReal  max_force)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 224 of file JointPhysics.cpp.

◆ setHighStop()

void mars::sim::JointPhysics::setHighStop ( interfaces::sReal  highStop)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1372 of file JointPhysics.cpp.

◆ setHighStop2()

void mars::sim::JointPhysics::setHighStop2 ( interfaces::sReal  highStop2)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1402 of file JointPhysics.cpp.

◆ setJointAsMotor()

void mars::sim::JointPhysics::setJointAsMotor ( int  axis)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 690 of file JointPhysics.cpp.

◆ setLowStop()

void mars::sim::JointPhysics::setLowStop ( interfaces::sReal  lowStop)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1354 of file JointPhysics.cpp.

◆ setLowStop2()

void mars::sim::JointPhysics::setLowStop2 ( interfaces::sReal  lowStop2)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1390 of file JointPhysics.cpp.

◆ setTorque()

void mars::sim::JointPhysics::setTorque ( interfaces::sReal  torque)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1146 of file JointPhysics.cpp.

◆ setTorque2()

void mars::sim::JointPhysics::setTorque2 ( interfaces::sReal  torque)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 1169 of file JointPhysics.cpp.

◆ setVelocity()

void mars::sim::JointPhysics::setVelocity ( interfaces::sReal  velocity)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 241 of file JointPhysics.cpp.

◆ setVelocity2()

void mars::sim::JointPhysics::setVelocity2 ( interfaces::sReal  velocity)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 260 of file JointPhysics.cpp.

◆ setWorldObject()

void mars::sim::JointPhysics::setWorldObject ( interfaces::PhysicsInterface world)
virtual

set the world informations

Implements mars::interfaces::JointInterface.

Definition at line 686 of file JointPhysics.cpp.

◆ unsetJointAsMotor()

void mars::sim::JointPhysics::unsetJointAsMotor ( int  axis)
virtual

Implements mars::interfaces::JointInterface.

Definition at line 733 of file JointPhysics.cpp.

◆ update()

void mars::sim::JointPhysics::update ( void  )
virtual

we need to calculate the axis torques and joint load before we can return it.

Implements mars::interfaces::JointInterface.

Definition at line 913 of file JointPhysics.cpp.

Member Data Documentation

◆ axis1_torque

utils::Vector mars::sim::JointPhysics::axis1_torque
private

Definition at line 99 of file JointPhysics.h.

◆ axis2_torque

utils::Vector mars::sim::JointPhysics::axis2_torque
private

Definition at line 99 of file JointPhysics.h.

◆ ball_motor

dJointID mars::sim::JointPhysics::ball_motor
private

Definition at line 92 of file JointPhysics.h.

◆ body1

dBodyID mars::sim::JointPhysics::body1
private

Definition at line 94 of file JointPhysics.h.

◆ body2

dBodyID mars::sim::JointPhysics::body2
private

Definition at line 94 of file JointPhysics.h.

◆ cfm

dReal mars::sim::JointPhysics::cfm
private

Definition at line 96 of file JointPhysics.h.

◆ cfm1

dReal mars::sim::JointPhysics::cfm1
private

Definition at line 96 of file JointPhysics.h.

◆ cfm2

dReal mars::sim::JointPhysics::cfm2
private

Definition at line 96 of file JointPhysics.h.

◆ damping

dReal mars::sim::JointPhysics::damping
private

Definition at line 98 of file JointPhysics.h.

◆ erp1

dReal mars::sim::JointPhysics::erp1
private

Definition at line 96 of file JointPhysics.h.

◆ erp2

dReal mars::sim::JointPhysics::erp2
private

Definition at line 96 of file JointPhysics.h.

◆ feedback

dJointFeedback mars::sim::JointPhysics::feedback
private

Definition at line 93 of file JointPhysics.h.

◆ hi1

dReal mars::sim::JointPhysics::hi1
private

Definition at line 97 of file JointPhysics.h.

◆ hi2

dReal mars::sim::JointPhysics::hi2
private

Definition at line 97 of file JointPhysics.h.

◆ joint_load

utils::Vector mars::sim::JointPhysics::joint_load
private

Definition at line 99 of file JointPhysics.h.

◆ joint_type

int mars::sim::JointPhysics::joint_type
private

Definition at line 95 of file JointPhysics.h.

◆ jointCFM

dReal mars::sim::JointPhysics::jointCFM
private

Definition at line 98 of file JointPhysics.h.

◆ jointId

dJointID mars::sim::JointPhysics::jointId
private

Definition at line 92 of file JointPhysics.h.

◆ lo1

dReal mars::sim::JointPhysics::lo1
private

Definition at line 97 of file JointPhysics.h.

◆ lo2

dReal mars::sim::JointPhysics::lo2
private

Definition at line 97 of file JointPhysics.h.

◆ motor_torque

dReal mars::sim::JointPhysics::motor_torque
private

Definition at line 100 of file JointPhysics.h.

◆ spring

dReal mars::sim::JointPhysics::spring
private

Definition at line 98 of file JointPhysics.h.

◆ theWorld

WorldPhysics* mars::sim::JointPhysics::theWorld
private

Definition at line 91 of file JointPhysics.h.


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