5
* This class simulates a hinge joint. Can be used for all rotatorial joints with just one axis.
6
* For example, for hinges or wheels, what are fixed.
15
#include <dtCore/dt.h>
16
#include <dtCore/object.h>
17
#include <dtCore/globals.h>
18
#include <dtCore/transform.h>
19
#include <dtGame/gameactor.h>
20
#include <dtCore/refptr.h>
24
#include <osgDB/ReadFile>
28
#include <srCore/actuator/actuatorBase.h>
32
class HingeActuator : public ActuatorBase
36
HingeActuator(const std::string name, const std::string type);
37
virtual ~HingeActuator();
39
void registerActuator();
42
* \brief Initializes the Hinge
44
* Needs to be called before using the hinge.
46
* \param bodyI First Body
47
* \param bodyII Second Body
48
* \param anchorX, anchorY, anchorZ position of the joint
49
* \param axisX, axisY, axisZ orientation of the joint
53
void init(dtCore::RefPtr<BodyBase> myBody1, dtCore::RefPtr<BodyBase> myBody2,
54
float anchorX, float anchorY, float anchorZ,
55
float axisX, float axisY, float axisZ);
58
* \brief Writes the parameter value in parameter
60
* The available parameters can be retrieved by calling getParameterList()
61
* See also: ObjectBase::getParameter()
65
virtual void getParameter(const std::string &name, ParameterReturnValue parameter);
68
* \brief Sets a parameter
70
* See also getParameter()
73
virtual void setParameter(const std::string &name, ParameterReturnValue parameter);
75
//todo: one time there should not be the need anymore to access the joint directly:
76
//! returns the jointID of the hinge. Will become obsolete.
79
void gotoAngle(float angle);
81
//! Maximum torque that can be applied by the motor.
82
void setMaxTorque(float torque);
84
//! Maximum torque that the motor can stand(then switched off) to hold its position
85
void setHoldingTorque(float torque);
87
//! Torque, that applies against the velocity vector, to slow down the joint.
88
void setBrakeTorque(float torque);
90
//! Maximum speed the joint can reach.
91
void setMaxVelocity(float v_max);
93
//! Setting a torque directly to a joint, can't be greater than maxTorque.
94
void setTorque(float torque, float deltaTime);
96
//! Setting a velocity.
97
/*! Motor tries to reach this velocity as fast as possible, but is constrained
100
void setVel(float v, float deltaTime);
102
//! Returns the current velocity of the joint.
103
float getVel(float deltaTime);
105
//! Returns the current position of the joint.
108
//! Returns the time derivate of the hinge position
109
float getAngleRate();
111
//! Sets ode parameters for the joint. For more Information, see www.ode.org/ode-latest-user-guide.org.
112
void setODEParameter(int parameter, float value);
114
float getODEParameter(int parameter);
116
//! when the joint will be created in such a way that the actuator already has a position different when zero.
117
void setZeroAngle(float angle);
119
//! will be called in the TickLocal function of the robotActorBase class
120
virtual void update(float deltaSimTme);
124
double calculateTorqueToStop(float deltaTime);
125
dJointID joint, motor;
130
float maxTorque; // maximum torque the motor can apply
132
float maxHoldingTorque; // holding torque, when actor isn't moving
133
float maxBrakeTorque; // torque that will apply then actor is moving, but motor is off
134
float maxVelocity; // maximum angular velocity the joint can reach
135
bool isAtConstraint; // joint reached a constraint.
137
float paramAngle, paramVelocity, paramFMax, paramDesiredVelocity, paramLoStop, paramHiStop, paramDesiredAngle;
139
float zeroAngle; // when joint will be created in such a way that the actuator already has a position different when zero.
145
#endif /*HINGEACTOR_H_*/