What's the best version for a vehicle simulation?

ozmic66

11-07-2007 21:43:22

Hey there,

This is my first post to the NxOgre Forum. I started using it yesterday, and I find it really great. Thank you betajaen for all your hard work.

At first I was very impressed with the tutorials collection on the site (nxogre.org) but I've downloaded 0.9 and there don't seem to be any tutorials.

My reason for using NxOgre is to create an accurate 3-wheeled robot simulation. I've noticed through some forum posts that 0.6 has vehicle code implemented but 0.9 doesn't.

Would be great if someone could let me know which you think would be better for me to use at the moment? I'm willing to look through code and implement some things myself if needed if 0.9 is more stable, and would help me avoid re-learning everything when 1.0 comes out

For now, here's a technical question:

I've tried to use the WheelShape unsuccessfully (the program crashes after a second):

Actor* cab = mScene->createBody("cube.1m.mesh",new CubeShape(1,1,1),Vector3(0,0,2));
WheelParams wp;
WheelShape* wheel1 = new WheelShape(1,"",wp);
cab->addShape(wheel1);



Any light anyone could shed on this will be greatly appreciated

betajaen

11-07-2007 21:55:11

Thankyou. 0.6 and 0.9 both have wheels and "vehicles". I consider 0.9 to be the most stable and best NxOgre there is.

In 0.9, I've approached vehicles a little differently, rather than defining what a vehicle actually is. I've provided a framework; think of the wheels, axles and motor in car, rather than the chassis, doors, headlights and seats. It is called the WheelSet.

mRobot = mScene->createBody("cube.1m.mesh", new CubeShape(1,1,1), Vector3(0,0.5f,0), "mass: 1");

WheelSet ws;

ws.createFourWheelSet(mRobot, Vector3(1,0,1), Vector3(-1,0,1));

ws.attachDriveShaft(new Motor("RobotMotor", mScene, ws.mWheels));
ws.setMotorTorque(10);
ws.turn(Degree(30));



As you can see I've provided a FourWheelSet there, but there is a function four a three, and six WheelSet as well. I don't believe that code is completed, but I'm sure you can fill in the blanks for me. If in doubt work from the FourWheel code, and take away a wheel!

ozmic66

11-07-2007 22:33:53

Thank you for that quick answer :)

I copied your code exactly and it looks much better now, but there seems to be a problem with the motor.

The line:
ws.attachDriveShaft(new Motor("RobotMotor", mScene, ws.mWheels));

Gave the error:
error C2664: 'NxOgre::Motor::Motor(const NxOgre::NxString &,NxOgre::Scene *,NxOgre::Wheels *)' : cannot convert parameter 3 from 'NxOgre::Wheels' to 'NxOgre::Wheels *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called


So I changed it to:
ws.attachDriveShaft(new Motor("RobotMotor", mScene, &ws.mWheels));

Now it compiles, but when I run it the program mysteriously crashes.

The NxOgre log (which looks very slick btw) doesn't have any info about the crash.

The last few lines in the ogre log are:

17:33:01: Mesh: Loading cube.1m.mesh.
17:33:01: WARNING: cube.1m.mesh is an older format ([MeshSerializer_v1.30]); you should upgrade it as soon as possible using the OgreMeshUpgrade tool.
17:33:01: *** Initializing OIS ***
17:33:01: Texture: spot_shadow_fade.png: Loading 1 faces(PF_R8G8B8,128x128x1) with 5 hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.


Thanks again for all the help

betajaen

11-07-2007 23:01:37

I'll have a look a bit later. But I'm hoping Luis may pop in. He pretty much wrote the Wheel System for us.

luis

12-07-2007 12:06:00

Well, i'm not using the wheelset class, i'm using my own class and loading all parameters from a config file and storing the wheels in a std::vector more or less what the wheelset do but using config files.

Drakon

13-07-2007 00:37:52

I traced problem to the Motor class, to the simulate function :

void Motor::simulate(float deltaTime) {

NxReal torque;
/*
NxReal b, d;
if ( mEngineTorque <= 1000.0 ) {
b = 0.0;
d = 220.0;
}
else if ( mEngineTorque < 4600.0 ) {
b = 0.025;
d = 195.0;
}
else {
b = -0.032;
d = 457.2;
}
*/



torque = ((mAcceleration * 7200.0f) * mGear[mCurrentGear] * mFinalGear) / (0.5f * 2000.0f);


//error is here when it is trying to iterate all the wheels
------------>
for(Wheels::Iterator i = Drive->items.begin();i != Drive->items.end();++i)
{
<-----------
(*i)->setMotorTorque(torque);

}


}


from debuger I got this:
+ _Myhead 0xcccccccc {_Next=??? _Prev=??? _Myval=??? } std::_List_nod<NxOgre::Wheel *,std::allocator<NxOgre::Wheel *> >::_Node *


I can only have a hope that this will help fix the problem...

betajaen

13-07-2007 00:57:04

I'll have a look at it.

But the original poster won't need a motor, it would be better to control the wheel torque separately through the wheelSet.

ozmic66

13-07-2007 01:33:08

How would I do that? :)

betajaen

13-07-2007 09:35:20

mRobot = mScene->createBody("cube.1m.mesh", new CubeShape(1,1,1), Vector3(0,0.5f,0), "mass: 1");

WheelSet ws;

ws.createFourWheelSet(mRobot, Vector3(1,0,1), Vector3(-1,0,1));

ws.setMotorTorque(10);
ws.turn(Degree(30));