Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / Joint and control issues

Author
Message
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 2nd Sep 2009 16:40 Edited at: 2nd Sep 2009 17:39
Hi, I've been trying for a while now to build my own vehicle without using the vehicle commands. I have it working to a point. My basic vehicle has 4 wheels that are connected using revolute joints. I can add some throttle to which ever wheels I want, and it works quite well. It even does a wheelie given the correct amount of power and rear wheel drive.

The problem is the wheels seem to be attached using rubber axles Is there a way of making the axles more secure? I like the way it seems to act like it has a little bit of suspension so would like to keep that bit of the bendiness if possible.

Another thing is how would I apply power to individual wheels and have good throttle control? The motor commands work ok, but it doesn't seem very good at having realtime control over the throttle. The local Torque commands seem to work, but the vehicle doesn't go very fast even with very high torque values.

This is just the first stage in making this thing work. Its annoyingly close to working too!

This is the join I'm using:

Thanks
Nick


EDIT - Cured the the throttle control issue...Just as I got back to DarkBASIC I decided to look if there are torque limits and there are so I can now do donuts with the car when rear wheel drive. Now just to cure the rubbery axles. Any help would be helpful Thanks
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 2nd Sep 2009 17:12 Edited at: 2nd Sep 2009 17:21
this might help you, it a demo like the physx demo in the SDK, some of it values have words instead of values to show how to lock something.
I think you have work out most of this, but it might give you a clue as to what to do next.


[edit]
I realies this not what you are asking however it might have the answer.
[/edit]

Dark Physics makes any hot drink go cold.
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 2nd Sep 2009 17:41 Edited at: 2nd Sep 2009 18:43
Thanks HowDo. I'll have a look through that to see if theres any clues

EDIT does the PHY SET REVOLUTE JOINT SPRING command have something to do with this? I seem to be able to make a slight difference to the springiness but can't get it anywhere near to cured.
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 2nd Sep 2009 19:42 Edited at: 2nd Sep 2009 19:44
Look in to "PHY SET REVOLUTE JOINT PROJECTIOn ID, mode, distance#, angle#"

More info on it in the Information help;
"Joint projection is a method for correcting large joint errors. Joint errors occur when a joints constraint is violated, imagine the ball being pulled out of the socket in a spherical joint. Under normal circumstances these joint errors are small (but unavoidable due to the imprecise nature of floating point math and numerical integrators). Dark Physics will apply small correcting forces to the simulation to try and reduce joint errors over time."

"However if a joint error becomes very large more drastic measures can be necessary, this is when joint projection comes into play."

Regards
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 2nd Sep 2009 20:13 Edited at: 2nd Sep 2009 20:13
YES!....I mean thanks Duke E. I've made quite a lot of progress now with this. My car just needs steering n brakes and a few other tweaks and it'll be useful. WAHOO!

Thanks
Nick
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 2nd Sep 2009 20:18 Edited at: 2nd Sep 2009 20:19
here's another one I did it newtons cradle, which uses
PHY SET SPHERE JOINT SWING LIMIT
and I think theres the same sort of command for revolute, if so then it use something called Twist and Swing Decomposition in Quaternion Components

this is how I stopped the balls going all over the place and staying in the swing range.





[edit]
well done, you posted while I was doing this.
[/edit]

Dark Physics makes any hot drink go cold.
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 3rd Sep 2009 01:13
Thankyou both of you for all your help. Ive had DarkPhysics for a couple of weeks, but over the past couple of days I think I've started to crack it

Thanks
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 3rd Sep 2009 01:21
well done took me alot longer, plus it broke and took some time to work out how to fix it.

check this thread out saves you having to look in the chm files, unless you like them.
http://forum.thegamecreators.com/?m=forum_view&t=131511&b=30

Dark Physics makes any hot drink go cold.
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 3rd Sep 2009 19:16
Thanks HowDo

Hehe the keyword in that sentence was "starting".

My car now works in a straight line (unless it wheel spins and veers off course) forwards or backwards, but steering really is annoying. I've tried a sphere joint for the steerable wheels which sort of worked, but I don't know how to control the joint enough. I didn't try the actual control of the steering direction, but only because I couldn't keep the joint from moving in all directions. Is there a good way of making it so I can control twist and turn, but only on the correct axis...if that makes any sense? Should I use a different joint? I've had a look at the quite daunting 6DOF joint but not sure if that'd do it. Any ideas?

I hope this makes sense

Thanks
Nick
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 3rd Sep 2009 19:22
check out this lot.

PHY SET RIGID BODY KINEMATIC POSITION
PHY SET RIGID BODY KINEMATIC ROTATION
PHY SET RIGID BODY KINEMATIC

Dark Physics makes any hot drink go cold.
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 4th Sep 2009 17:01 Edited at: 4th Sep 2009 17:32
Hi and thanks HowDo for your help,

I've tried a few things. I tried a couple of my own ideas this morning then just tried your last suggestion. The kinematic commands seem to disable most of the physics from any body using them. So when my vehicle starts a bit above the ground only the rear drops to the ground. Have I done this right? I enabled it then tried to rotate it. I tried to enable the gravity for each body that it applies to with no success. I have managed to get some very simple steering working by simply applying torque to the joints, but I can't get the steering limits to work and the wheels still flop around on all axis (being a sphere joint) The steering is effective when going very slowly forwards but useless at speed due to the floppiness

I've included a screenshot that has 2 shots in 1 image. You can see it works when stood still or going slow but if I steer too much and go fast the other shot shows what happens.

EDIT - Ignore the crap car model in the screenshot it was a 5 minute simple car for testing only!

Attachments

Login to view attachments
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 4th Sep 2009 18:16 Edited at: 4th Sep 2009 18:22
NickH I don't know if you picked this up yet but when using physX you have to do everything like it would be in the real world.

so each of your wheels would need a sphere which the wheel is connected too and then this sphere is connected to a cylinder which you move.

you are basically going to end up with a simple rack and pinion system.

so with KINEMATIC object connected as an offset object

eg

Wheel-sphere|connecting bar offset|sphere-Wheel.

so that when you move the connecting bar left or right the sphere rotate a few degrees and that make the wheels turn.

there's something like this in the chm files with a small bit on which physx bits to use.

[edit]
distance joint would one I'd used for the connecting bar.
and cylindrical joint to connect the wheels to the support struc.

Dark Physics makes any hot drink go cold.
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 7th Sep 2009 19:28 Edited at: 7th Sep 2009 19:30
Thanks HowDo

I'm doing what I'd call stage 2 of my car development. Just rewriting it to include steering. This reminds me of Technics Lego

I've loaded a simple chassis object to be the start of all this. I'm not sure if I've found a bug or what. As I'm using my v1 code as a rough guide I've added the command:

phy set rigid body mass 1,3

Now this seems to make my object pass straight through the simple box I've placed as the ground. Its only a box generated by DB. It's ok without the command and bounces as normal. Have you encountered this before? It worked in my first version of this.

Thanks
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 7th Sep 2009 19:56
I think it depends on how big your model is, seem anything bigger than 2 or 3 can have a wried effect on how PhysX works but that a guess.

you could try 'PHY SET GROUND PLANE Integer Value' will save you having to make base to put something on.

Dark Physics makes any hot drink go cold.
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 7th Sep 2009 23:04
Try "Phy Update Rigid Body Mass ID, Value#, Value#" instead (Value# is the same for both parameters).

I have had pretty inconsistent results with the "phy set rigid body mass" command, it seems to make dynamics dampened so they wont react correctly.

Regards
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 8th Sep 2009 01:59
Joint and control issues is a serious problem, see a doctor immediately

NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 8th Sep 2009 13:54 Edited at: 8th Sep 2009 13:55
Thankyou Duke E

I had got the mass thing to work by scaling up my car a bit, but I've replaced that with what you've suggested and kept my car its original size. Not that its a full car yet

AlexI

I've tried pouring cod liver oil on my hard drive but its not worked
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 8th Sep 2009 14:38
Sizes of primitives usually scale ok, can be problematic with convexes, those needing mass updates.
Masses of jointed objects should not be too different i have read somewhere. I can recall some objects i have had jointed that was like small struts connecting (for show) between leg pylons. The struts being thin and getting very low mass and falling off too easily when using breakable joints.

Regards
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 9th Sep 2009 15:24 Edited at: 9th Sep 2009 15:28
Thanks Duke, I cured the mass thing by doing what you said.

I've made a simple steering and suspension system Technics lego style. Mainly just a load of boxes I modeled in Lightwave and rigged up so i could steal the co-ordinates

The first version of my code is a little messy, but I can't see any reason why it shouldn't work. When I run it, it goes crazy though. It was fine before I put a wheel on it. it just flies around even though theres no torque being applied to it yet. Is this a common problem with complicated systems? Its only, chassis, wishbone x2, hub, steering arm and a servo type arm, along with a wheel.

I've included a screenshot of it in Lightwave to help explain what it should look like. Is this even possible? its not that complex really!

Thanks

Attachments

Login to view attachments
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 10th Sep 2009 11:14
Hard to say what goes wrong. With such a complicated system it is easy to get some joint(s) connected wrong in the code. Objects being too close is also a problem as they will repel each other then be pulled back, making the jointed object bounce around.

However, it is not needed to simulate the wishbone and pullers initially. You could just use a hub and have that on a Y axis revolute joint to the chassis (steering) and a X axis from the hub to the wheel first. Separate the hub a bit from the wheel and chassis. Could add a hidden dummy object in the model to use as a hub.

The hub will not need to be connected "physically" (by objects touching) to the chassis. The spacing between physx objects when they are created then joined with a joint are kept at the distance they where on creation (unless you move them with phy set location or the solver breaks the joint).

You could add the wishbones and linkage as physx or normal objects (just for show) later when you get the setup to work.

Regards
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 25th Sep 2009 20:16 Edited at: 25th Sep 2009 21:59
Thanks Duke E

I've changed my plans quite a bit. I've made a 6x6 skid steer vehicle this morning. It's a mesh attached to 6 capsules running around on a mesh terrain.Its working fine being able to drive around brilliantly. The problem is if I flip it over the chassis won't collide with the ground. Is there a problem with a mesh colliding with another mesh? The vehicle doesn't fall completely through the ground as the wheels stop it, so it basically drives upside down with the top half of the vehicle underground. I put another object (a box) in which does collide with the chassis if treated as a box, but won't collide as a mesh.

I tried the update mass command (mentioned in a previous post)

EDIT - I've changed my game completely not just compromised my design.

Thanks
Nick
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 26th Sep 2009 03:22 Edited at: 26th Sep 2009 03:24
Dynamic Mesh is not recommended to use as they are somewhat bugged, not colliding with other Meshes (dynamic or static), they collide o.k with generic boxes, spheres and stuff though. The documentation even states Dynamic Meshes are maybe not supported in future versions.
Static mesh is o.k though for static objects. Even for terrain, as static terrain runs really slow.

Dynamic Convex is probably the way to go for you, however a convex shape will cut any shapes from a model that are curving in.
Imagine a Coca Cola bottle model with a waist. If you make a Dynamic Convex out of a model like that and insert it in the simulation Physx will take away the Coca cola bottle waist and make a vertically homogeneous bottle without the waist.
Anyways Dynamic Convexes work great in the simulation, just have to take the convex shape limitation in to consideration.

Regards
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 26th Sep 2009 14:09 Edited at: 26th Sep 2009 20:01
Wahoo! all bugs fixed so far, thanks. My brother will be happy...we was sat up till gone 3am lastnight/ this morning "beta testing" it

Thankyou for your continued advice Duke E! I hadn't realised there was a way of making semi-accurate collision detection.
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 26th Sep 2009 19:53 Edited at: 26th Sep 2009 20:00
Just a small question. Does anyone know of a way of limiting the angle of a joint relative to the object it's joined too? I'm adding weaponry to the vehicle now. The turret was easy to fit and it has the gyro effect that a modern tank has so it always faces the direction it is aimed at no matter what you do with the vehicle. I was after the same effect vertically for any weapons fitted to the turret. I can do it easily, except I need to be able to limit the angles so you don't shoot yourself, but also allow for the gyro effect when within limits.

I hope that makes sense. I've tried various things with only a little success. Any ideas? Sorry for asking so many questions...I've learnt a lot in the past few weeks!

EDIT - I've been simply setting the angular velocity for each weapons object to achieve more accurate control over the turret.

Thanks
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 27th Sep 2009 04:32
You are welcome =)

Well i cant figure the turret stuff you describe. I suppose you mean the horizontal aiming is o.k, but the vertical up/down is the problem as the bullet object hits the tanks body?

An easy fix is to use Collision Groups (it's in the documentation), However i don't use that method...

I do not use bullets (impact triggered bullets that is) as a true physics object, instead I turn off the collision for bullets with "Phy Set Collision State ObjectID, 0"

"Phy Set Collision State ObjectID, 0" will make the ObjectID pass trough any other static or dynamic and it will exclude the object from the Physx collision stack. However the object will respond to gravity.

Instead of checking collisions I use raycast. Track the coordinates of a bullet object with its it's x.y.z position, storing every frame to oldx.oldy.oldz. Casting a ray from the old value to the current value every frame and see if the ray hits something.

Using this method and if the raycast hits the object number of the tank that shot the bullet you can opt to make that shot non valid.

Regards
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 28th Sep 2009 14:12 Edited at: 28th Sep 2009 20:46
Hehe sorry, my previous question both didn't make sense and I'm starting to wonder if it is indeed a small question!

Its mainly limiting the angles of an object that's being controlled by setting the angular velocity. So an angle can be set and no matter what happens the object will try it's best to stay at that angle. I mean if I set the velocity of the turret to 0 it'll stay facing that way, but hitting stuff etc moves it. I need it to move back. This is only part of the thing I need to sort. The main part is the weapons mounted on the turret. I've included a diagram to show what I mean. Basically I want to set an angle, but if the turret pitches beyond this range I want the gun to lock. I'm still trying to solve this.

Attachments

Login to view attachments
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 28th Sep 2009 14:30 Edited at: 28th Sep 2009 17:33
Heres a rough screenshot of the experimental version of this game so far. Once I've sorted out a few more of the basics, I'll rewrite it all and make some proper landscapes etc.

EDIT - I've been trying to combine EZ Rotate and Darkphysics, using EZ Rotate for returning angles only, but I don't know either like an expert!

EDIT 2 - I've almost done it (The turret heading angle)...sort of, its not 100% accurate and doesn't always stick to the angle I want:



The axis angle is (in theory) the angle of the turret and TA is the turret angle required. I think once I've sorted this I'll be able to get the weapons to pitch up and down successfully.

Attachments

Login to view attachments
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 29th Sep 2009 05:53
Looks promising

Ok i see what you mean now...

I use the standard DBP command "Curveangle" to turn missiles. It takes three parameters; the destination angle, current angle and a speed value if i remember correctly and returns the portion of the angle that is traversed depending on the speed value. You could probably get really smooth turret movement by changing the speed value the closer the current angle is to the destination angle making it slow down to stop realistically.

The angles you can get with "Atanfull".

Do you really need the turret to be a physx object by the way? You could have a hidden physics turret that approximates the shape of the visible one you rotate and pitch, this invisible turret handles collision if something hits the tank on top. Then have a normal object or limb attached to the same position that is nonphysics, easy to rotate with standard commands. That way you don't need to bother with the Phy set Rigid Angular Velocity.

Regards
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 30th Sep 2009 21:22 Edited at: 30th Sep 2009 21:35
Thank you Duke E

I had a little explore of my 1.5km x 1.5km test terrain n found a better view which I've included. Also theres a bit more debugging stuff on it (FPS is limited to 30 at the moment...if you think it's going slow)

Yeah I had thought of sort of faking it a bit like that, but I'm so damn close to getting this to work using a PhysX object. I've managed to get this to work in almost all situations, but it doesn't like to for example:

The turret is actually at an angle of 300, but you set it to move to 45 degrees. It goes the long way round. Also if you set it to go to 0 degrees it will get there, but the slightest knock to the vehicle n it will often do a full rotation just because it can't find it's way back using the shortest route. Its fine finding the shortest route so long as it isn't beyond 0 degrees, and will turn in the correct direction.

I'm using the following line of code to move the turret.

If (TA-EZro_GetAxisAngleY()) <> 0 Then Phy Set Rigid Body Angular Velocity 20,0,(TA-EZro_GetAxisAngleY())/30,0

TA is the goal angle and the Ezro command gets the actual heading angle.

I've tried various ways of doing this and the above works very well, but for this one problem. Any ideas on how best to calculate the velocity required? I know this isn't strictly a PhysX question Its starting to get quite frustrating as once I have the turret and weapons moving correctly I'll plan and write the proper version of this!

Thanks
Nick

Attachments

Login to view attachments
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 1st Oct 2009 12:17
You take negative angles in to consideration when the target angle is say; 340 and the actual angle is 5?
Otherwise the turret will go the "long" way around. Would "EZro_GetAxisAngleY()|" return a negative in the case above?

When i think about it more it could be the local angles get thrown off as your model get rolled,pitched in X and Z when you traverse the terrain, i would try this with the vehicle body horizontal first then on the terrain. Depends on the model, is the turret a separate object or does it take its angle origins from the vehicle body? You can't think global rotations in this case.

Regards
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 1st Oct 2009 13:24 Edited at: 1st Oct 2009 20:07
EZ Rotate is returning positive values and they are local angles. It is a true Y axis angle no matter what the chassis is doing. The turret is a separate model attached to the body using a revolute joint. I'll have another go at this in a bit I think.

EDIT - It works fine over even the heaviest of landings/ crashes or steepest terrain so long as it's not set to 0 and will turn in the correct direction so long as 0 isn't in between the set and actual angles. Me and my brother have beta tested it so far and this is the only problem.

Thanks
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 8th Oct 2009 14:36
I've come up with the following code



This doesn't work either. I've been through the code line by line and can't see why its not working. Any ideas?

T.SetTorque is the torque value to be used as the angular velocity
T.SetAngle is the set angle
The Ezro command returns a true local turret heading
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Oct 2009 15:39
T.SetTorque is the torque value to be used as the angular velocity
T.SetAngle is the set angle
are these float values? if so try using 180.0

Dark Physics makes any hot drink go cold.
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 8th Oct 2009 18:41 Edited at: 8th Oct 2009 18:46
Hi, HowDo,

They're all floats. Isn't 180 treated the same as 180.0 though?

I've tried a different way now which sort of works but still doesn't function entirely to plan:

HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Oct 2009 19:42
Quote: "Isn't 180 treated the same as 180.0 though?

"


No, in DBPro its not.

When doing something like this I change everything to floats then work them back until I see which bit does work.

Dark Physics makes any hot drink go cold.
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 9th Oct 2009 00:23
Quote: "No, in DBPro its not."


I didn't know that. How does it differ?

I've been trying to remark parts etc, in the usual way, but I think I'll go back to the drawing board again tomorrow. I'm getting through paper like theres no tomorrow on this one
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 9th Oct 2009 14:21
NickH now you've ask me to prove it, I have to say I must be wrong as I cannot get it to do what I thought it did.

if it did do it, Lee must have fixed it.

Dark Physics makes any hot drink go cold.
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 9th Oct 2009 15:55
Hehe ok, I did try changing it, to no effect. Thanks anyway.
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 10th Oct 2009 03:08 Edited at: 10th Oct 2009 03:12
Well i think i solved it, you have to adapt it for your own code though, but you where close so you only need the conditionals in the main loop i suppose. This is standalone code, paste it in to the editor and experiment with it.



Regards
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 10th Oct 2009 12:50
Oooo thank Guy Fawlks for that...oh and Duke E Thanks it works perfectly. That had halted things for quite a while now.

Login to post a reply

Server time is: 2024-05-06 00:20:43
Your offset time is: 2024-05-06 00:20:43