1
//! Actuator base class.
5
* This is a basic actuator class. Actuators are joints, created by the Open Dynamics Engine (ODE) which connects two bodies
11
//TODO: Include an AMotor joint to simulate friction of the actuator
13
/* TODO: What are the basic properties each actuator has in common --> adopt the interface accordingly
14
* Torque the motor can apply to the joint,
15
* Max Velocity the joint can rotate/move
16
* (Friction of the motor)
17
* Holding Torque of the motor
18
* Position / Velocity / Acceleration
21
/* TODO: providing internal functions, such as joint distance to body 1 and 2, (kinematic) energy of the system,
22
* oscillating movements of the bodies to provide a measurement of the stability of the simulation. These
23
* functions should be private and a friend class which is determing the stability of the simulation is its
27
// TODO: Sound should be handled by the actuator classes and therefore an interface needs to be defined here.
32
#include <srCore/robot/objectBase.h>
34
#include <dtCore/dt.h>
35
#include <dtCore/object.h>
36
#include <dtCore/globals.h>
37
#include <dtCore/transform.h>
38
#include <dtGame/gameactor.h>
39
#include <dtCore/refptr.h>
43
#include <osgDB/ReadFile>
54
class ActuatorBase : public ObjectBase
59
static std::map< dJointID, ActuatorBase*> jointActuatorMap;
62
// static inline void registerActuator(ActuatorBase* actuator) {
64
// jointActuatorMap.insert(std::pair<ActuatorBase*, dJointID>(actuator, actuator->getHinge()));
70
ActuatorBase(const std::string name, const std::string type) :
78
* \brief Initializes the actuator
81
* \param bodyI First Body
82
* \param bodyII Second Body
83
* \param anchorX, anchorY, anchorZ position of the joint
84
* \param axisX, axisY, axisZ orientation of the joint
88
virtual void init(dtCore::RefPtr<BodyBase> myBody1, dtCore::RefPtr<BodyBase> myBody2,
89
float anchorX, float anchorY, float anchorZ,
90
float axisX, float axisY, float axisZ) {};
94
virtual void registerActuator() = 0;
96
//returns the jointID of the hinge.
97
virtual dJointID getHinge() = 0;
99
// Maximum torque that can be applied by the motor.
100
//virtual void setMaxTorque(float torque) = 0;
102
// Maximum torque that the motor can stand(then switched off) to hold its position
103
//virtual void setHoldingTorque(float torque) = 0;
105
// Torque, that applies against the velocity vector, to slow down the joint.
106
//virtual void setBrakeTorque(float torque) = 0;
108
// Maximum speed the joint can reach.
109
//virtual void setMaxSpeed(float v_max) = 0;
111
//! Setting a torque directly to a joint, can't be greater than maxTorque.
112
virtual void setTorque(float torque, float deltaTime) = 0;
114
//! Setting a velocity.
115
/*! Motor tries to reach this velocity as fast as possible, but is constrained
118
virtual void setVel(float v, float deltaTime) = 0;
120
//! Returns the current velocity of the joint.
121
virtual float getVel(float deltaTime) {return velocity;};
123
//! Returns the current position of the joint.
124
virtual float getPos() = 0;
126
//! Sets ode parameters for the joint. For more Information, see www.ode.org/ode-latest-user-guide.org.
127
virtual void setODEParameter(int parameter, float value) = 0;
128
virtual float getODEParameter(int parameter) = 0;
130
//! activate/deactivate the actuator
131
virtual void setActive(bool activate) {}
133
//! will be called in the TickLocal function of the robotActorBase class
134
virtual void update(float deltaSimTme) {}
136
//! returns the name of the actuator
137
inline std::string getName() const {return name;}
139
//!returns the type of the class
140
inline std::string getType() const {return type;}
143
virtual ~ActuatorBase() {};
149
const std::string name;
150
const std::string type;
154
void setVel(float v,float deltatime);
155
void setParam(int parameter, float value);
160
typedef std::map< dJointID, ActuatorBase*> map_type;
161
typedef map_type::value_type pair_type;
167
#endif /*ACTUATOR_H_*/