1
//! Specialized body class.
4
* Predefined body class. Ready to use in a RobotActor.
5
* This body represents the wheels of the robot.
11
#include <srBody/wheel.h>
15
// units need to be around one to make the ode most stable. Hereby 1 length union is equal to 5cm.
16
#define SCALE_3DS 0.2 //0.2
17
#define WHEEL_SIZE SCALE_3DS
18
#define WHEEL_MASS 0.01
19
#define WHEEL_RADIUS 0.5 * SCALE_3DS //4.5
20
#define WHEEL_LENGTH 1 * SCALE_3DS //2
22
using namespace srCore;
25
/*! @param id a 16bit id, used to set the colliding bit parameter.
26
* @param x, y, z the position of the hinge in the world coordinate system.
27
* @param heading, pitch, roll the orientation of the axis of the hinge in the world coordinate system.
28
* @param Scene the scene in which the body should be placed.
31
Wheel::Wheel( RobotActorBase* robot,
32
float x, float y, float z,
33
float heading, float pitch, float roll)
40
// initializing. parameters: name, id (of the robot), position, orientation and the scene
41
// needs to be done first
42
this->init("wheel", robot, x, y, z, heading, pitch, roll);
47
sprintf(file, "%s/StaticMeshes/wheel.3ds", SimulationUtils::getStageProjectPath().c_str());
48
//sprintf(file, "%s/StaticMeshes/barrel.ive", SimulationUtils::getStageProjectPath().c_str());
50
LoadFile(file, false);
53
SetScale(osg::Vec3(WHEEL_SIZE, WHEEL_SIZE, WHEEL_SIZE));
56
// our Object just needs a mass now ...
57
this->setMass(WHEEL_MASS, WHEEL_RADIUS, WHEEL_LENGTH);
59
// defining the collision box
60
this->setCollisionCylinder(WHEEL_RADIUS, WHEEL_LENGTH);
62
// ... and then, it is ready to place it in the scene
65
// to check if the collision geometry fits to the model:
66
this->renderCollisionGeometry(true);
67
this->colorCollisionShape(osg::Vec4(255,0,0,0));
68
// this->colorBody(osg::Vec4(1,0,0,0));
70
// need to be set to let the wheels rotate
71
dBodySetFiniteRotationMode(GetBodyID(), 1);