4
* Created on: Nov 18, 2008
12
#include <srCore/actuator/actuatorBase.h>
13
#include <srCore/simulationUtils.h>
16
#include <dtAudio/sound.h>
19
//TODO: remodel the Screw Drive according to the test results of the real one (which needs to be done as well)
20
//TODO: provide current screw drive information such as velocity and acceleration. Currently only the values which have been set are returned
26
class ScrewDrive2: public ActuatorBase {
29
ScrewDrive2(const std::string name);
31
virtual ~ScrewDrive2();
33
void registerActuator();
35
void init(dtCore::RefPtr<BodyBase> attachedBody, dtCore::RefPtr<ScrewDrive2> second, bool isOnRightHandSide) {
37
isOnRightHandSide = isOnRightHandSide;
38
secondScrewDrive = second;
39
this->attachedBody = attachedBody;
46
for(unsigned int i = 0; i < this->GetNumChildren(); ++i)
47
if((screwSound = dynamic_cast<dtAudio::Sound*>(this->GetChild(i))) != NULL)
52
inline dtCore::RefPtr<BodyBase> getAttachedBody() {return attachedBody;};
56
* \brief Writes the parameter value in parameter
58
* The available parameters can be retrieved by calling getParameterList()
59
* See also: ObjectBase::getParameter()
63
inline virtual void getParameter(const std::string &name, ParameterReturnValue parameter) {
65
//frontActuator->getParameter(name, parameter);
70
* \brief Sets a parameter
72
* See also ObjectBase::getParameter()
75
inline virtual void setParameter(const std::string &name, ParameterReturnValue parameter) {
77
//frontActuator->setParameter(name, parameter);
81
//returns the jointID of the hinge.
82
inline dJointID getHinge() {printf("Warning: This screw drive has actually no ode hinge \n"); return 0;}
83
//inline dJointID getHinge(int index) {return ((index==0) ? frontActuator->getHinge() : backActuator->getHinge());}
87
// Maximum torque that can be applied by the motor.
88
//virtual void setMaxTorque(float torque) = 0;
90
// Maximum torque that the motor can stand(then switched off) to hold its position
91
//virtual void setHoldingTorque(float torque) = 0;
93
// Torque, that applies against the velocity vector, to slow down the joint.
94
//virtual void setBrakeTorque(float torque) = 0;
96
// Maximum speed the joint can reach.
97
//virtual void setMaxSpeed(float v_max) = 0;
99
//! Setting a torque directly to a joint, can't be greater than maxTorque.
100
inline void setTorque(float torque, float deltaTime) {};
102
//! Setting a velocity.
103
/*! Motor tries to reach this velocity as fast as possible, but is constrained
106
void setVel(float v, float deltaTime);
108
//! Returns the current velocity of the joint.
109
inline float getVel(float deltaTime) { return velocity; };
111
//! Returns the current position of the joint.
112
inline float getPos() {return 0;};
114
//! Sets ode parameters for the joint. For more Information, see www.ode.org/ode-latest-user-guide.org.
115
inline void setODEParameter(int parameter, float value) {};
116
inline float getODEParameter(int parameter) { return 0.0; }; //Anne
118
//! activate/deactivate the actuator
119
inline void setActive(bool activate) {active = activate;}
121
//! will be called in the TickLocal function of the robotActorBase class
122
inline void update(float deltaSimTime) {setVel(getVel(deltaSimTime), deltaSimTime);}
124
dtCore::RefPtr<ScrewDrive2> secondScrewDrive;
127
dtAudio::Sound* screwSound;
131
dtCore::RefPtr<BodyBase> attachedBody;
132
bool isOnRightHandSide;
136
float d_m, my_Screw, l, F_div_M;
142
#endif /* SCREWDRIVE2_H_ */