~robot3d-team/robot3d/trunk

« back to all changes in this revision

Viewing changes to src/srCore/actuator/wheelActuator.cpp

  • 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
 * Robot3D Physical realistic 3D simulator for robots
 
3
 *
 
4
 * @license GNU Lesser General Public License
 
5
 *
 
6
 * @author Lutz Winkler
 
7
 * @author Anne C. van Rossum
 
8
 */
 
9
 
 
10
#include <srCore/actuator/wheelActuator.h>
 
11
 
 
12
namespace srCore {
 
13
 
 
14
 
 
15
WheelActuator::WheelActuator(const std::string name,  const std::string type) :
 
16
        ActuatorBase(name, type)
 
17
{
 
18
}
 
19
 
 
20
WheelActuator::~WheelActuator()
 
21
{
 
22
 
 
23
        dJointDestroy(this->joint);
 
24
}
 
25
 
 
26
 
 
27
//! initializes the connector. Needs to be called before using the wheel.
 
28
void WheelActuator::init(dtCore::RefPtr<BodyBase> myBody1, dtCore::RefPtr<BodyBase> myBody2,
 
29
                                                float anchorX, float anchorY, float anchorZ,
 
30
                                                float axis1_X, float axis1_Y, float axis1_Z,
 
31
                                                float axis2_X, float axis2_Y, float axis2_Z)
 
32
 
 
33
{
 
34
        dWorldID worldID = myBody1->GetSceneParent()->GetWorldID();
 
35
 
 
36
        //create Wheel using the Hinge2 joint
 
37
        this->joint = dJointCreateHinge2(worldID, 0);
 
38
        dJointAttach(this->joint, myBody1->GetBodyID(), myBody2->GetBodyID());
 
39
        myBody = myBody1;
 
40
 
 
41
        //set relation of the parts of the replicator
 
42
        dJointSetHinge2Anchor(this->joint, anchorX, anchorY, anchorZ);
 
43
 
 
44
        //set joint axis
 
45
        dJointSetHinge2Axis1(this->joint, axis1_X, axis1_Y, axis1_Z);
 
46
        dJointSetHinge2Axis2(this->joint, axis2_X, axis2_Y, axis2_Z);
 
47
}
 
48
 
 
49
void WheelActuator::registerActuator()
 
50
{
 
51
 
 
52
                ActuatorBase::jointActuatorMap.insert(std::pair<dJointID, ActuatorBase*>(this->getHinge(), this));
 
53
 
 
54
};
 
55
 
 
56
dJointID WheelActuator::getWheel() {
 
57
 
 
58
        return this->joint;
 
59
 
 
60
}
 
61
 
 
62
//!  Sets ode parameters for the joint. For more Information, see www.ode.org/ode-latest-user-guide.org.
 
63
void WheelActuator::setODEParameter(int parameter, float value) {
 
64
 
 
65
        dJointSetHinge2Param(this->joint, parameter, value);
 
66
 
 
67
}
 
68
 
 
69
}