Complex model

And

04-07-2008 15:35:14

Hi All

I wonder if some one can help me or point me in the right direction. I want to develop a robot simulator using OgreODE. I want to have a mobile robot that can move around its surroundings and interact with them. The robot will have a body with 4 - 6 wheels, some cameras and a robotic arm, can some one suggest the best way to model this environment/setup.

I started using blender to build the parts of the arm first and build them in individual components say hand, fore arm, upper arm and shoulder. then I try and connect them into ogreode using something similar to the chain demo moving the components to their correct places etc, i've noticed several problems, when i move the component the collision wire frame is then seperate from the visual object.

Is there an easier way of building my model? can the mesh be generated in one go? and the joints put in after?

Does any one have a model similar that i can look at in blender?

Hope this makes sense :)
Andy

And

07-07-2008 09:35:36

Bump

Has no-one got any information on how to generate the complex .ogreode model files or any opinions on how to generate a complex model?

Cheers
Andy

electronics45

07-07-2008 14:07:42

...when i move the component the collision wire frame is then seperate from the visual object

So, when the OgreOde body moves, the rendered object is left behind (or visa versa)? A silly question, but have you got the OgreOde body and Ogre mesh attached to the same scene node?

And

07-07-2008 14:56:25

Hi
both the mesh and the colliion mesh move relative to each other but not together, I've attached a pic to show what i mean, this is the code I use also

Entity* entity;
if (i == 0){ //is the base joint
entity = _mgr->createEntity(name,"ArmBase.mesh");
} else if (i == 1){
entity = _mgr->createEntity(name,"ArmShoulder.mesh");
} else if (i == 2){
entity = _mgr->createEntity(name,"ArmUpper.mesh");
} else if (i == 3){
entity = _mgr->createEntity(name,"ArmLower.mesh");
} else if (i == 4){
entity = _mgr->createEntity(name,"ArmWrist.mesh");
} else if (i == 5){
entity = _mgr->createEntity(name,"ArmPaw.mesh");
}
entity->setNormaliseNormals(true);
entity->setCastShadows(true);

SceneNode* meshNode = _mgr->getRootSceneNode()->createChildSceneNode(entity->getName());
name = String("ArmModel_") + StringConverter::toString(i);
//SceneNode* modelNode = meshNode->createChildSceneNode(name);
meshNode->attachObject(entity);
meshNode->setScale(0.01,0.01,0.01);

if (i == 0){
meshNode->setPosition(Vector3(0.0, 0.0,0));
} else if (i == 1){
meshNode->setPosition(Vector3(0.0, 10.0,0));
} else if (i == 2){
meshNode->setPosition(Vector3(0.0, 10.0,0));
} else if (i == 3){
meshNode->setPosition(Vector3(0.0, 0.0,0));
} else if (i == 4){
meshNode->setPosition(Vector3(0.0, 0.0,0));
} else if (i == 5){
meshNode->setPosition(Vector3(0.0, 0.0,0));
}
//node->rotate(Vector3(0,1,0),Degree(90));

// Physicals
OgreOde::EntityInformer ei(entity,meshNode->_getFullTransform());
OgreOde::Body* body = new OgreOde::Body(_world);
OgreOde::Geometry *geom = ei.createStaticTriangleMesh( _world, _space);
meshNode->attachObject(body);

OgreOde::BoxMass mass(1.0, ei.getSize());
mass.setDensity(5.0, ei.getSize());

body->setMass(mass);

// Tie the collision geometry to the physical body
geom->setBody(body);
entity->setUserObject(geom);

_bodies.push_back(body);
_geoms.push_back(body->getGeometry(0));

// Join the current body to the last one (if there was a last one)
if (!_first_body)
{
_last_node = meshNode;
_first_body = body;
}

if (last_body)
{
OgreOde::BallJoint* joint = new OgreOde::BallJoint(_world);
joint->attach(body,last_body);
Real ja = ((Real)i + 0.5) * (link_size[i] + adjust);
joint->setAnchor(Vector3(ja,ja + 0.4,ja));

_joints.push_back(joint);
}




And

07-07-2008 15:25:58

this is ruffly what i'm after, I have a 3D model of a robotic arm that I would like to model in OgreODE and be able to control the movement of, doing the calculations of where to move the arm joints to.

This image shows the layout of the arm.


The red lines show the rotational axis of the joints, currently 5 and each of the joints are a seperate component. My question real is whats the best way to build this arm so that i can control the joints seperately?

Cheers
Andy

rewb0rn

07-07-2008 16:14:50

Well you can actually model a ragdoll in your modelling software and load it in OgreOde. For this refer to the simplescenes ragdolls demo (f7)

I also faced the problem with the displaced body once, the solution can be found here.

And

07-07-2008 16:24:01

I thought about this method but wasn't sure if i needed a new skeleton file like the zombie example plus how is the zombie.ogreode file generated? by hand?

I wondered if it was possible to draw the arm in blender and place armatures/bonds on the links and then export the file, but not sure of the whole process, as I've not come across any documentation.

I've started putting the links in blender, is this the right way of doing it?

Cheers
Andy

rewb0rn

07-07-2008 16:29:57

I am not an artist but yes, you can model the skeleton in Blender. Also you don't need an ogreode file, you only need it to specify how the joints are allowed to turn and stuff, so if you want to set constraints on the movement. And yes, its generated by hand. If you have a look you will see how its done.

And

09-07-2008 09:09:50

i'm no made mu arm with armatures in blender and saved it (it generates a skeleton file), and I can no import the mesh into OgreODE using the ragdoll demo. I made a .ogreode file for it also describing the joints, is there an easy way to access the joints and move them individually using the keyboard say?

dermont

09-07-2008 10:15:15

There's a robotic arm demo in the old gangsta project which may help. It shouldn't be too difficult to convert to OgreOde.

http://sourceforge.net/projects/gangsta
http://gangsta.cvs.sourceforge.net/gang ... iew=markup

And

10-07-2008 14:39:04

Ok I've started converting the gangsta model to OgreOde but although I can set the joints I don't seem to have any control over them and they just fold with gravity see below.




and I set up the joints as follows, this is pretty much the same for each joint. This example if from the base rotation should be straight up.


jg = new OgreOde::JointGroup(_world);
_Hinge[0] = new OgreOde::HingeJoint(_world, jg);
_Hinge[0]->attach(body,last_body);
_Hinge[0]->setAnchor(origin);
_Hinge[0]->setAxis(Vector3::UNIT_Y);



_joints[0] = new OgreOde::AngularMotorJoint(_world, jg);
_joints[0]->attach(body,last_body);
_joints[0]->setAnchor(origin);
_joints[0]->setMode(OgreOde::AngularMotorJoint::Mode_UserAngularMotor);
_joints[0]->setAxisCount(1);
_joints[0]->setAxis(2,OgreOde::AngularMotorJoint::RelativeOrientation_GlobalFrame,Vector3::UNIT_Y);
_joints[0]->setAngle(1, 45.0);
_positions[0] = 45;
_joints[0]->setParameter(OgreOde::Joint::Parameter_MaximumForce, 150, 1);
_joints[0]->setParameter(OgreOde::Joint::Parameter_MotorVelocity, 150, 1);
_lo_limits[0] = -180;
_hi_limits[0] = 180;
_joints[0]->setParameter(OgreOde::Joint::Parameter_HighStop, _hi_limits[0],1);
_joints[0]->setParameter(OgreOde::Joint::Parameter_LowStop, _lo_limits[0],1);




then I have some code to change the poisiton on a key press which does change the joint angle but there's no movement.


Real d = _positions[0] - Ogre::Math::RadiansToDegrees(_joints[0]->getAngle(1));
if(d > 180.0f) d -= 360.0f;
else if(d < -180.0f) d += 360.0f;

// _joints[0]->applyTorque((d * t_adj) - (_joints[0]->getAngularVelocity() * t_adj * t_fac));
_joints[0]->setParameter(OgreOde::AngularMotorJoint::Parameter_MotorVelocity,d);
_joints[0]->setParameter(OgreOde::AngularMotorJoint::Parameter_MaximumForce,m_trq);
_joints[0]->setAngle(1,Ogre::Math::DegreesToRadians(_positions[0]));
_joints[0]->addTorque(0,100,0);



Any ideas??

Thanks
Andy

dermont

14-07-2008 07:22:33


Ok I've started converting the gangsta model to OgreOde but although I can set the joints I don't seem to have any control over them and they just fold with gravity see below.

Never tried connecting staticTriangleMesh geometries with joints. Have you tried Transform/Box geometries?

Then I have some code to change the poisiton on a key press which does change the joint angle but there's no movement.


Not too sure but I think the problem may be with your axis setup in your AngularMotorJoint. You should check the ode manual for clarification - http://www.ode.org/ode-latest-userguide.html

dJointAddAMotorTorques(dJointID joint, dReal torque0, dReal torque1,
dReal torque2)

Applies torque0 about the AMotor's axis 0, torque1 about the AMotor's axis 1, and torque2 about the AMotor's axis 2. If the motor has fewer than three axes, the higher torques are ignored.


Here's some example code:

OgreOde::TransformGeometry* trans;
OgreOde::BoxGeometry* geom;
OgreOde::HingeJoint* joint;
OgreOde::AngularMotorJoint* motorJoint;

// Create a space for the robot to live in
_robot_space = new OgreOde::SimpleSpace(_world, _world->getDefaultSpace());
_robot_space->setInternalCollisions(false);
_robot_space->setAutoCleanup(false);

// Create joint group
jointGroup = new OgreOde::JointGroup(_world);

Entity* entity = mSceneMgr->createEntity("base","robot_base.mesh");
entity->setCastShadows(true);
SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode("base");
node->attachObject(entity);

// base body
OgreOde::Body* body = new OgreOde::Body(_world);
node->attachObject(body);
body->setMass(OgreOde::BoxMass(1.0,Ogre::Vector3(2.32,0.93,2.29)));
body->setPosition(origin);
body->setOrientation(orient);
body->setLinearDamping(l_damp);
body->setAngularDamping(a_damp);
_bodies.push_back(body);

// base geometry 1
trans = new OgreOde::TransformGeometry(_world, _robot_space);
geom = new OgreOde::BoxGeometry(Ogre::Vector3(2.32,0.93,2.29), _world, 0);
trans->setBody(body);
trans->setEncapsulatedGeometry(geom);
geom->setPosition(Ogre::Vector3(0,-0.611,0));
_geoms.push_back(geom);
_geoms.push_back(trans);

// base geometry 2
trans = new OgreOde::TransformGeometry(_world, _robot_space);
geom = new OgreOde::BoxGeometry(Ogre::Vector3(0.69,1.21,0.71), _world, 0);
trans->setBody(body);
trans->setEncapsulatedGeometry(geom);
geom->setPosition(Ogre::Vector3(0,0.470,0));
_geoms.push_back(geom);
_geoms.push_back(trans);

// joint
joint = new OgreOde::HingeJoint(_world, jointGroup);
joint->attach(body);
joint->setAnchor(origin);
joint->setAxis(Ogre::Vector3::UNIT_Y);
joint->setParameter(OgreOde::Joint::Parameter_HighStop,
Ogre::Degree(30.0).valueRadians(), 1);
joint->setParameter(OgreOde::Joint::Parameter_LowStop,
Ogre::Degree(-30.0).valueRadians(), 1);
_joints.push_back(joint);

motorJoint = new OgreOde::AngularMotorJoint(_world, jointGroup);
motorJoint->attach(body);
motorJoint->setAnchor(origin);
motorJoint->setMode(OgreOde::AngularMotorJoint::Mode_UserAngularMotor);
motorJoint->setAxisCount(1);
motorJoint->setAxis( 0, OgreOde::AngularMotorJoint::RelativeOrientation_GlobalFrame,
Vector3::UNIT_Y);
motorJoint->setAngle(0, Ogre::Degree(-30.0).valueRadians());
motorJoint->setParameter(OgreOde::Joint::Parameter_MotorVelocity, 100, 1);
motorJoint->setParameter(OgreOde::Joint::Parameter_MaximumForce, 200.0, 1);
_motorjoints.push_back(motorJoint);

// for next joint
last_body = body;
body->setAutoSleep(false);


and ..

if (mKeyboard->isKeyDown(OIS::KC_1)){
_motorjoints[0]->setParameter(OgreOde::Joint::Parameter_MotorVelocity, 0, 1);
_motorjoints[0]->addTorque( -75.0, 0.0, 0.0);
}
if (mKeyboard->isKeyDown(OIS::KC_2)){
_motorjoints[0]->setParameter(OgreOde::Joint::Parameter_MotorVelocity, 0, 1);
_motorjoints[0]->addTorque( 75.0, 0.0, 0.0);
}

And

14-07-2008 15:39:26

I think i'm getting there but I still have a few problems, the joints don't seem to lock into place, they still just fall with gravity? I can move them but I have to set the is like this (the MotorVelocity) otherwise the joints don't move? any ideas?


Rval = _Motjoints[0]->getParameter(OgreOde::AngularMotorJoint::Parameter_MotorVelocity,1);
if(input->isKeyDown(KC_1)) {
Rval -= a_step;
_Motjoints[0]->setParameter(OgreOde::AngularMotorJoint::Parameter_MotorVelocity, Rval, 1);
_Motjoints[0]->addTorque(-Rval,0,0);
}
if(input->isKeyDown(KC_2)) {
Rval += a_step;
_Motjoints[0]->setParameter(OgreOde::AngularMotorJoint::Parameter_MotorVelocity, Rval, 1);
_Motjoints[0]->addTorque(Rval,0,0);
}

dermont

14-07-2008 17:20:35

Sorry haven't tried the demo with AngularMotorJoints. If you look at the original demo I think that to keep the robotic arm in equilibrium the following code is used on the hinge joints:


float d = _positions[0] - Ogre::Math::RadiansToDegrees(_joints[0]->getAngle() );
if(d > 180.0f) d -= 360.0f;
else if(d < -180.0f) d += 360.0f;
_joints[0]->setParameter(OgreOde::Joint::Parameter_MotorVelocity, d, 1);
_joints[0]->setParameter(OgreOde::Joint::Parameter_MaximumForce, m_trq, 1);


Maybe try incorporating something similar with your code.