View Full Version : [expresso]Car control
handige_harrie 04-21-2003, 06:44 PM I started a few days ago, partly due to Squidincs dustbuggy topic.
His buggy will be controlled by using expresso. I wanted to do the same for some time with a four-wheel vehicle. I had not tried expresso before so it's still mostly a learning process.
I got pretty far (I think :wip: ):
-wheels spin according to speed.
-frontwheels turn realistic (inner wheel turns in more than outer wheel).
-car rotates according to frontwheel rotation.
-independant steeringwheel controls car/wheels rotation
-independant throttle controls car position.
I am having problems with the cars position while making a corner. The problem most likely is in the "position of car" part. I tried a lot using the cars previous position, but didn't work so far.
Because I don't really know a lot about expresso options I only used math and trigonometric nodes. Vectors might be a more efficient way to tackle this problem?
Anyway I would like to know how to solve the problem my way (IE: going from what I've got).
Of course other suggestions are welcome too.
Download the file (http://members.home.nl/hcgl.hermans/expresso_car.c4d)
Sorry for typo in link :D
|
|
That Adrian Guy
04-21-2003, 07:12 PM
Oh god please tell me this is XL7 compatible
:drool:
handige_harrie
04-21-2003, 07:16 PM
Sorry it's 8.0 :shrug:
ThirdEye
04-21-2003, 07:16 PM
Well, if he used Xpresso it's not R7 compatible :hmm:
Zoogie
04-21-2003, 07:21 PM
handige,
wanted to check it out, clicked the link, but got a "..is niet beschikbaar".
handige_harrie
04-21-2003, 07:23 PM
Typo in link, sorry, check again, should work now.
Zoogie
04-21-2003, 07:29 PM
Pretty cool, Handige.
I gotta digest that later.
Thanks for sharing.
That Adrian Guy
04-21-2003, 07:31 PM
Ohh yeah.. forgot I'm limited to Coffee.
Well... it's pretty impressive, thanks for sharing the code anyway!
XL7 users... we must stick together to hold our own against the evil that is R8 :p
ThirdEye
04-21-2003, 07:35 PM
Originally posted by That Adrian Guy
Ohh yeah.. forgot I'm limited to Coffee.
Well... it's pretty impressive, thanks for sharing the code anyway!
XL7 users... we must stick together to hold our own against the evil that is R8 :p
Or maybe you should stick together and buy him a R8 update :D
manlio
04-21-2003, 10:24 PM
Thanks for sharing! It is very useful xpresso code.
astrofish
04-22-2003, 12:15 AM
Hi all,
I've put together something that shows how to get the rotation and position for a car working properly.
It's a combination of XPresso and Coffee - mainly coffee.
It doesn't do wheel rotation or accurate wheel pointing, but it does do correct rotation and positioning of the car itself.
This version also assumes that rear wheels steer - the maths is a bit simpler that way...
Anyway, hopefully between this and handige_harrie's original post, this should be most of what's needed to get driveable cars that look plausible.
Open the attached C4D file, and the car should start driving by itself.
The circle that's leaping around all over the place is the instantaneous turning circle (i.e. the circle it would follow if the steering was held still).
If you want to drive it yourself, select the 'Control' NULL, click the attribute manager, then right click on steering and steed and remove the animation tracks. If you now start animation playback you can actually drive the car in 'sort of real time' (you'll see what I mean...). You might want to increase the animation length because the car is reset to its start position every time the animation hits frame zero.
For V7 users I've also attached the text of the Coffee script (which is almost all of the work).
You'll need to connect inputs and outputs to use this with R7 - In R8 they
are connected to XPresso nodes.
Anyway, the connections (variables) you need are:-
Inputs:
steerCtrl steering angle (radians)
speedCtrl 0.05*speed ft/s (I.e. 1 = 20ft/sec)
heading Car direction in XZ plane (radians)
position World coords of car
deltaT Duration of a frame (s)
wheelBase Distance between front and rear axles (ft)
frame Frame number - used to reset at frame 0.
startPos Position to reset to.
Outputs:
headingNew As it says
positionNew As it says
circlePos Global coords of centre of turning circle (or car position if driving straight)
circleRad Radius of turning circle (or 0 is car driving straight)
Anyway, here's the files - have fun!
C4D Project File (http://www.astrofish.com/bitsandbobs/carDemo1.c4d)
Coffee program text (http://www.astrofish.com/bitsandbobs/carcode.txt)
Cheers - Steve
dude just use the demo you can open it up.
handige_harrie
04-23-2003, 06:04 PM
Astrofish, your file doesn't work here, I get an error about a missing plugin and I can't find a COFFEE tag. The car doesn't move, although the wheels do.
Besides that, I can't code in COFFEE, so it is not going to help me a whole lot right now (I checked the txt-file). I might learn one day, but expresso is already causing sleepless nights :D, so I'll stick to that for now.
It's nice that people thank me for sharing the code, but I would really like to see some suggestions on how to get it working right. I am sure there are enough brilliant minds here to crack this nut :wip:.
astrofish
04-23-2003, 06:19 PM
Hi,
It sounds like you haven't upgraded to C4D 8.1... It works fine in 8.1, but I've just tried it on an old copy of 8.0 and I get the same errors you describe.
The Coffee code is actually embedded in an XPresso node, so you can just use the node as-is within the rest of your XPresso set up if you want - and ignore the fact that it's internally written in Coffee..
If you want to convert the whole thing to XPresso only then you should be able to use the coffee code as a reference - I tried to put a lot of commenting in there to explain what I was doing.
Cheers - Steve
CGTalk Moderation
01-14-2006, 10:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.