Modeling a train using joints & a number of raycast vehicles

Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by Flix »

dumbo2007 wrote:So I was wondering if as a offshoot , a new trajectory constraint would be useful in Bullet.
For sure I'll find it very useful :) ! ...and I was thinking that by adding some kind of (global,per node or per segment?) "track width" parameter together with an overridable method to manually set the force/torque needed to keep the body on track, it could be used to ease the development of the AI in car racing games... furthermode in your program you make the train cars go alone along the path (with speed limits at some points): that would probably be useful too.

Anyway if you want to do it, I suggest you stick to its basic form, before trying to include too many things together.. :wink: .
horvatha4
Posts: 14
Joined: Sun Jun 16, 2013 3:52 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by horvatha4 »

Hi!
I start develop a train simulator. My goal is to get to reality as close as possible.
First time I build the complet loco from rigid bodies and joints. All working fine and real - up to 15km/h. Above the 50 km/h the loco is jump from the rails because the axles get a so high hit on every poligon's edge.
So I turn to raycast wehicles. This loco is builded 3 rigid body. One for the chasis, and one-one for the bogeys(red).
Every bogey have 12 wheel. 6 down with normal wheel diamater (blue) and 3 - 3 look to side (pink).
Image
Image
Image
Image
Every railsection is a btBvhTriangleMeshShape.
Now the loco can run over 80km/h smooth, nice and well.
The weights is important. I start about 80t but the rays go thru the btBvhTriangleMeshShape. Now the chasis is 400kg and one bogey is 300kg.
I just start playing with the raycast, but I think this can be a good way.

Arpi
Last edited by horvatha4 on Fri May 01, 2015 10:30 am, edited 1 time in total.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by Flix »

Adding orthogonal ray tests to trap the train onto the track is an interesting approach indeed :D. Thanks for sharing the details :P !
horvatha4
Posts: 14
Joined: Sun Jun 16, 2013 3:52 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by horvatha4 »

Hello Everyone!
I have a few question:
-When I add a wheel to the Vehicle, why is important it is a frontwheel or not? This is not so obvious by trains.

In the coordinate sytem the right-, up-, forwardaxis index is not 100% clean for me.
By the loco, the forward direction is X, Right -Z, Up Y - but when I call setCoordinateSystem( 2,1,0 ) the program is crashing. Just the (0,1,2) set working.
The wheelDirection and the wheelAxleCS vector must always perpendicular to each other?

And one more problem, the wheels don't turning, when the loco moving.

Code: Select all

		//this->pRaycastVehicle->updateWheelTransform( i, true ); <--- called or not is equal
		btTrans = this->pRaycastVehicle->getWheelInfo(i).m_worldTransform;
Have anybody an idea?

Arpi

P.S.
One video may help to understand the problem: http://youtu.be/CDFNq1eZgAE

P.S.2

What a fun :lol: call setCoordinateSystem( 0,1,0 ) and the wheels turning perfectly: https://www.youtube.com/watch?v=LMAgg_8y1FQ
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by Flix »

horvatha4 wrote:When I add a wheel to the Vehicle, why is important it is a frontwheel or not? This is not so obvious by trains.
Well, I've not been using btRaycastVehicles for some time, but as far as I can remember the wheels marked as 'front' are the ones that can be used for steering the vehicle.

I don't know if you're using the btRaycastVehicle class directly (or you've made a custom class for your train), but I suppose you aren't using the default steering methods to make the train follow the tracks, are you ? If you don't use them, probably you shouldn't worry about which wheel is marked 'front' or 'rear'.

As far as the coordinate system problem is concerned, I've always used the default one (the one used in appVehicleDemo): the x-axis is the lateral axis and the z-axis the front-back axis AFAIR. I suggest you rotate your model if you experience problems.
horvatha4 wrote:call setCoordinateSystem( 0,1,0 ) and the wheels turning perfectly
Well, I still suggest you use the default settings: from the video it seems that the train slows down too much on curved tracks.

P.S. I still haven't completely understood how you make your train steer using additional lateral raycast results to keep it on the track (I'm not sure if it's possible to simply add 'ray-wheels' with a different direction to the same vehicle or not: should that work, you shouldn't use any steering method at all).
horvatha4
Posts: 14
Joined: Sun Jun 16, 2013 3:52 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by horvatha4 »

Hi Flix!
Thanks the reply!
So, I don't use steering. The Loco haven't steered wheel. All wheel just drived and braked (with the original btRaycastVehicle class).

You suggest a 90 grad turn around the Y axle. Well, currently all think working as I would. Furthermore I must then turn everythink: bodies, joints. Every vehicle generated/builded/welded from an xml file. Then I must check/correct all function. May be next time ;-)
Well, I still suggest you use the default settings: from the video it seems that the train slows down too much on curved tracks.
I purpose stopped the Loco, because at higher speed you can't see the wheels how good turning. ;-)

A few days later you can test personally, if you would.

Here is a fun jump: http://youtu.be/_1a3MrmA9pU
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by Flix »

horvatha4 wrote:I purpose stopped the Loco, because at higher speed you can't see the wheels how good turning. ;-)
Good to know, so everything seems to work as expected :) . Furthermore, if you're using the default btRaycastVechicle, that means that 'ray-wheels' with different directions are working nice, and this technique can be applied to other kind of vehicles too :D .

The only thing that could probably be modified is the big number of rays (mainly to maximize performance), but, as far as I can understand, you need all the vertical rays to position all the train wheels correctly, and you've used an equal number of lateral rays to improve the simulation (you said: "My goal is to get to reality as close as possible"), and maybe that allows the train to reach a higher speed without getting out of the track too.

And beside that, I'm not sure that trains made with wheel rigid bodies and joints perform better, due to the amount of contact points that are generated every frame between the wheels and the rails, that in your implementation are missing :wink: .
horvatha4
Posts: 14
Joined: Sun Jun 16, 2013 3:52 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by horvatha4 »

Flix wrote:I'm not sure that trains made with wheel rigid bodies and joints perform better,
You have right! As I wrote, I start with rigid bodies. This mean, the axis was build from one rigidbody too. But that implement run only about 35 FPS.
Flix wrote:...but, as far as I can understand, you need all the vertical rays to position all the train wheels correctly, and you've used an equal number of lateral rays to improve the simulation (you said: "My goal is to get to reality as close as possible"), and maybe that allows the train to reach a higher speed without getting out of the track too.
Yes, correct.
And not maybe, this is certain :mrgreen:

Thank you
Arpi
dumbo2007
Posts: 66
Joined: Sun Jan 30, 2011 8:46 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by dumbo2007 »

Looks really good Horvath. I havent read all your posts yet, but are you turning the front wheels ? Or thats not required, as the lateral raycasts keeps the loco on the track ?

-----------
I guess the number of lateral casts can be reduced to one per bogie rather than 1 per wheel ? Where do the lateral ray casts start currently ? At the wheel connection points ?
horvatha4
Posts: 14
Joined: Sun Jun 16, 2013 3:52 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by horvatha4 »

Hi dumbo!
None of wheels turned, all have a fix direction.
The lateral raycasts start at the wheel connection points.
I use 4 raycast-wheel per axle. You can see at the picture above.
The blue lines are the vertical wheels what hold the loco's weight.
The pink lines are the lateral wheels what hold the loco on the track.

Arpi
dumbo2007
Posts: 66
Joined: Sun Jan 30, 2011 8:46 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by dumbo2007 »

horvatha4
Posts: 14
Joined: Sun Jun 16, 2013 3:52 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by horvatha4 »

Nice pics dumbo!
The #2 is the winner.

When you use #1, the wheels climbing over the rails and the train goes as it want.

Arpi
Garfield83
Posts: 4
Joined: Tue Oct 31, 2017 12:40 am
Contact:

Re: Modeling a train using joints & a number of raycast vehi

Post by Garfield83 »

Hello,
i have a little question.

@horvatha4 has posted that he using btRaycastVehicle class for his trainobject.
But multibody vehicle is unsupported in Bullet-physics or it is true?

In his post has he written that he makes three bodies, one for the chassis and one each for the bogies.
But the btRaycastVehicle class supported one rigidbody what can attach to it.
e.g.: if the chassis the main rigidbody and the wheels are attached over the btRaycastVehicle.
As attachs the wheels to the train bogie and the bogie to the chassis?

Can i Attach the bogies with chassis over the btHingeConstraint ?
And one each bogies is a separate btRaycastVehicle instance where both are synchronized with each other every frame?

Gives an example code for the train with btRaycastVehicle?

Best regards
Daniel S.
horvatha4
Posts: 14
Joined: Sun Jun 16, 2013 3:52 pm

Re: Modeling a train using joints & a number of raycast vehi

Post by horvatha4 »

Hi Daniel,
I try answer your questions!

So, you wrote and asked:
"... multibody vehicle is unsupported in Bullet-physics or it is true?"
I don´t know that. A Long time I did´t read Bullet Phisics documentations.

"... attachs the wheels to the train bogie and the bogie to the chassis?" - Yes exactly!

"Can i Attach the bogies with chassis over the btHingeConstraint ?" - Yes I made that too.

"And one each bogies is a separate btRaycastVehicle instance... " - Yes

" ... where both are synchronized with each other every frame?" - How/what you means "synchronized" ?

"Gives an example code for the train with btRaycastVehicle?" - No, sorry.
And here is the reason why: I didn´t made any special. There are tonns of sample code, source code, documentation etc...
You know what you will, grab the code and turn into your project. If I give you 100 line code, you will not understand why and what called.

My recommendation is: in these days there are a lot of Game Engines what implemented Bullet or other phisics engines. You don´t care about syncing/build/destroy/show/hide object and other problems. These engines made that for you easy and well, can run in any network etc.

If you write here what you want make or why you interesting this btRaycastVehicle -hopely- I can recomned to you a solve or what else.
Another option is, you can try my builded project what you can see in the youtube videos. For testing purposes is enough.

Best Regards

Árpi
Garfield83
Posts: 4
Joined: Tue Oct 31, 2017 12:40 am
Contact:

Re: Modeling a train using joints & a number of raycast vehi

Post by Garfield83 »

horvatha4 wrote:" ... where both are synchronized with each other every frame?" - How/what you means "synchronized" ?
These are actually two separate vehicles or not? which are connected only by the chassis by means of hinge constraint.
Or is that wrong?
Do I not then have to update the two vehicle instances with each other?
Post Reply