~robot3d-team/robot3d/trunk

« back to all changes in this revision

Viewing changes to inc/srActuator/screwDrive2.h

  • Committer: Anne van Rossum
  • Date: 2010-08-10 15:58:55 UTC
  • Revision ID: anne@gamix-20100810155855-kve7x2vwouagdij9
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ScrewDrive.h
 
3
 *
 
4
 *  Created on: Nov 18, 2008
 
5
 *      Author: winkler
 
6
 */
 
7
 
 
8
#ifndef SCREWDRIVE2_H_
 
9
#define SCREWDRIVE2_H_
 
10
 
 
11
// Robot3D files
 
12
#include <srCore/actuator/actuatorBase.h>
 
13
#include <srCore/simulationUtils.h>
 
14
 
 
15
#ifdef AUDIO_ON
 
16
        #include <dtAudio/sound.h>
 
17
#endif
 
18
 
 
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
 
21
 
 
22
 
 
23
namespace srCore {
 
24
 
 
25
 
 
26
class ScrewDrive2: public ActuatorBase {
 
27
 
 
28
public:
 
29
        ScrewDrive2(const std::string name);
 
30
 
 
31
        virtual ~ScrewDrive2();
 
32
 
 
33
        void registerActuator();
 
34
 
 
35
        void init(dtCore::RefPtr<BodyBase> attachedBody, dtCore::RefPtr<ScrewDrive2> second, bool isOnRightHandSide) {
 
36
 
 
37
                isOnRightHandSide = isOnRightHandSide;
 
38
                secondScrewDrive = second;
 
39
                this->attachedBody = attachedBody;
 
40
 
 
41
                velocity = 0;
 
42
                
 
43
#ifdef  AUDIO_ON
 
44
                screwSound = NULL;
 
45
 
 
46
                for(unsigned int i = 0; i < this->GetNumChildren(); ++i)
 
47
                        if((screwSound = dynamic_cast<dtAudio::Sound*>(this->GetChild(i))) != NULL)
 
48
                                break;
 
49
#endif
 
50
        };
 
51
 
 
52
        inline dtCore::RefPtr<BodyBase> getAttachedBody() {return attachedBody;};
 
53
 
 
54
 
 
55
        /**
 
56
         * \brief  Writes the parameter value in parameter
 
57
         *
 
58
         *              The available parameters can be retrieved by calling getParameterList()
 
59
         *              See also: ObjectBase::getParameter()
 
60
         *
 
61
         *
 
62
         */
 
63
        inline virtual void getParameter(const std::string &name, ParameterReturnValue  parameter) {
 
64
 
 
65
                //frontActuator->getParameter(name, parameter);
 
66
 
 
67
        }
 
68
 
 
69
        /**
 
70
         * \brief  Sets a parameter
 
71
         *
 
72
         *              See also ObjectBase::getParameter()
 
73
         *
 
74
         */
 
75
        inline virtual void setParameter(const std::string &name, ParameterReturnValue  parameter) {
 
76
 
 
77
                //frontActuator->setParameter(name, parameter);
 
78
 
 
79
        }
 
80
 
 
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());}
 
84
 
 
85
        //NULL;};
 
86
 
 
87
        // Maximum torque that can be applied by the motor.
 
88
        //virtual void setMaxTorque(float torque) = 0;
 
89
 
 
90
        // Maximum torque that the motor can stand(then switched off) to hold its position
 
91
        //virtual void setHoldingTorque(float torque) = 0;
 
92
 
 
93
        // Torque, that applies against the velocity vector, to slow down the joint.
 
94
        //virtual void setBrakeTorque(float torque) = 0;
 
95
 
 
96
        // Maximum speed the joint can reach.
 
97
        //virtual void setMaxSpeed(float v_max) = 0;
 
98
 
 
99
        //! Setting a torque directly to a joint, can't be greater than maxTorque.
 
100
        inline void setTorque(float torque, float deltaTime) {};
 
101
 
 
102
        //! Setting a velocity.
 
103
        /*! Motor tries to reach this velocity as fast as possible, but is constrained
 
104
         * by maxTorque
 
105
         */
 
106
        void setVel(float v, float deltaTime);
 
107
 
 
108
        //! Returns the current velocity of the joint.
 
109
        inline float getVel(float deltaTime) { return velocity; };
 
110
 
 
111
        //! Returns the current position of the joint.
 
112
        inline float getPos() {return 0;};
 
113
 
 
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
 
117
 
 
118
        //! activate/deactivate the actuator
 
119
        inline void setActive(bool activate) {active = activate;}
 
120
 
 
121
        //! will be called in the TickLocal function of the robotActorBase class
 
122
        inline void update(float deltaSimTime) {setVel(getVel(deltaSimTime), deltaSimTime);}
 
123
 
 
124
        dtCore::RefPtr<ScrewDrive2> secondScrewDrive;
 
125
        
 
126
#ifdef  AUDIO_ON
 
127
        dtAudio::Sound* screwSound;
 
128
#endif
 
129
private:
 
130
 
 
131
        dtCore::RefPtr<BodyBase> attachedBody;
 
132
        bool isOnRightHandSide;
 
133
 
 
134
private:
 
135
  
 
136
        float d_m, my_Screw, l, F_div_M;
 
137
 
 
138
 
 
139
};
 
140
}
 
141
 
 
142
#endif /* SCREWDRIVE2_H_ */