To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 23920
23919  |  23921
Subject: 
Re: Robotic simulators
Newsgroups: 
lugnet.robotics
Date: 
Mon, 25 Apr 2005 20:39:06 GMT
Original-From: 
PeterBalch <PeterBalch@compuserve+stopspammers+.com>
Viewed: 
1009 times
  
Dan and Steve

I worked on this a couple of years ago. Not for Lego but for a Robot Wars
game. (We failed to get the contract from the BBC.)

I have a 2D simulator for the "gameplay" - the computer controlled robots
attack, defend, run away and avoid the pit; the electric motors have
inertia and back-emf; the wheels have friction and stiction; the bots have
momentum; they take damage and limp round in circles; the bots can be
customised with wheels and weapons, etc, etc. But the bots are stuck to the
2D ground.

And I have a separate 3D simulator for dynamics and kinetics. I had
intended to integrate the two but I lost interest when the contract went
elsewhere.

All the 3D simulator does is drop two dice above a table (rendered in
Direct3D). The dice hit each other and the table, bounce around and
eventually come to rest. They have all the proper physics: inertia, angular
momentum, friction, partially-elastic collisions, etc. When I started, I
thought "I understand the physics - how hard can it be?". Hah! How wrong I
was.

I chose dice because cubes are pretty simple, convex hulls. Doing Newtonian
mechanics is easy. The big problem is collisions.

It's not neccessary to model the physics exactly. Just so long as the
result is within 10%. After a few decades living on Earth, it's glaringly
obvious if objects don't behave properly but 10% is good enough.

You can tell that the dice have collided because they inter-penetrate. But
then what? Forces are generated but how big and in what direction?

I assume that the force is proportional to the degree of inter-penetration.
Does "degree" mean volume or distance? I assume distance. Find the most
deply penetrated part. Find the vector from there to the nearest surface.
The force is proportional to the length of the vector and operates along
the vector. You've got to do that twice of course - once for each of the
two objects - I think I chose the biggest or maybe I summed them. The final
force operates on both objects in opposite directions

What is the constant of proportionality? That depends on how hard the
objects are and how big your simulation timesteps are. Too too big and the
objects gain energy from the collision; too small and they pass through
each other. And you have to make sure the objects lose some energy because
the collisions are not perfectly elastic.

That will work 99% of the time but in the remaining 1% of collisions, the
system goes haywire. It seems to happen when a corner hits an edge or
another corner. I think it's to do with the corner penetrating one face but
then approaching another face. The cubes seem to get energy from nowhere
and whizz off away from each other. You can sometimes see it with other
people's simulations so it's clearly not a bug specific to my s/w.

My solution was a "sanity check". If the total kinetic energy after the
collision is greater than the total kinetic energy before then decrease the
energy of both objects.

That gave a completely convincing simulation of two cubes but I was
exhausted. What I thought would take me a couple of days had taken a
fortnight. and I'd lost my appetite for applying it to simulated robots.

Beware, it's a deceptive problem.

If you go ahead with the project, I'll happily give advice and maybe even
dig out some old (Delphi) code but a Rich Client would have to pay me A Lot
Of Money to head back into that jungle. (I'm happy to send the EXEs today
to anyone who asks.)

Good luck

Peter



Message has 1 Reply:
  Re: Robotic simulators
 
(...) As hard as this was - it would only have to have been 'good enough' to fool the naked eye - and the robots themselves would (presumably) have been designed by you with only a handful of design variations. Trying to make a simulation that (...) (20 years ago, 26-Apr-05, to lugnet.robotics)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
7 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR