Jump to content

  • Log In with Google      Sign In   
  • Create Account


Calculating arrival with soft turn (help!)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
13 replies to this topic

#1 NEXUSKill   Members   -  Reputation: 456

Like
0Likes
Like

Posted 12 November 2013 - 12:35 PM

So, we have a mobile that behaves very much like a car, with some rules simplified.

 

The mobile has a maximum turning speed and a turning acceleration, this goes to both directions of the car relative to its forward vector.

It also has a top forward speed, which is limited to a linear interpolation between the maximum in straight line and the maximum while using top turning speed.

In order to reach this top speed and to stop it has an acceleration as well, considered to be constant.

Unlike a car, we are not meant to move backwards.

 

For the purposes of this task we are in a wide open empty parking lot, so room to move and manouver is plenty, we start in a given position facing a given angle and we are given the goal of arriving at another specific spot at another specific orientation.

This goal may very well be to end up standing in the same spot but facing the opposite direction.

Acceleration and speeds for both translation and rotation will make the beggining of our movement process look very nice, but arrival is more complicated, we need to arrive from a specific direction in order to end up looking in the angle we were given.

 

My first instinct is to try to extrapolate the arrival turn from the goal backwards, but I have no idea how to do this mathematically. Formulas? hints? alternative solutions? it needs to look soft and obey the rules stated above.

Acceleration and deceleration may have different magnitudes.


Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272



Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 12921

Like
3Likes
Like

Posted 12 November 2013 - 01:43 PM

This is a difficult problem that I have thought about in the past. The paradigm I would use to solve it is that of optimal control using dynamic programming.

 

In coordinates in which the goal is the origin and the target orientation is 0 (the positive x axis, if you use standard trigonometric conventions), your mobile is at (x,y) with a speed s and an orientation o (between -pi and pi). So your state is described by 4 numbers. Now discretize those 4 numbers, discretize time and discretize the possible actions you can take in one time step.

 

Write down an instantaneous utility function, which tells you how close to achieving the goal you are (something like exp(-(s^2+x^2+y^2+o^2)) would do, perhaps with weights in front of each quantity squared). Now define the total utility as the sum of future values of the instantaneous utility function, with some exponential decay to discount the distant future (so you get there earlier if possible).

 

In a 4-D array, store the current estimate of the total utility assuming optimal actions are taken in the future (this is known as the "value function"). Whenever you query this 4-D array you'll use some sort of interpolation, because you will be querying at situations that aren't necessarily in the grid. This estimate can initially be very bad (say, the instantaneous utility). You can then iterate over the entries in this 4-D array and refine your estimate of the total utility by finding the action that would lead to the best next situation from each hypothetical situation. Repeat until it converges.

 

You can do all of this optimization offline, and then online you simply look up for each of your actions what leads to the best value in one step, and take it. You could also just store the optimal action from each state and simply take that.

 

I believe this procedure is called "value iteration", although Bellman equation seems to refer to the same thing, or something very similar.

 

If you end up implementing something like this, I would love to see a demo.


Edited by Álvaro, 12 November 2013 - 01:45 PM.


#3 Álvaro   Crossbones+   -  Reputation: 12921

Like
0Likes
Like

Posted 13 November 2013 - 09:00 AM

Oh, I forgot to post a link to this lecture on the subject. It's hard to get through the notation at the beginning (perhaps watching the previous lectures would help with that). But then there are some neat examples where the state is 2D and the actions are 1D (so you can make neat images to represent both the optimal policy and the value function).



#4 NEXUSKill   Members   -  Reputation: 456

Like
0Likes
Like

Posted 15 November 2013 - 08:25 AM

I just came up with an idea that has potential, Given a starting linear velocity, angular velocity and their respective accelerations, if the mobile were to turn and decelerate (regardles of a target) it would descrive an inward spiral, which has a center (that must be aligned with our target) and an entry radius, if I can calculate that radius based on the mobile's current kinematic parameters and steer it towards the center offseted by the radius in a perpendicular direction to the mobile's heading, it would enter by the tangent of the spiral.

Once the mobile reaches the entry tangent, it changes its behavior from seek to arrive, steering and decelerating towards the target, it should reach it with a very small margin of error that can be compensated easily.

Any idea what would be the formula of the radius? I know that for linear movement with a final speed of 0 the traveled distance is d = (So * So) / (2 * a)
d being distance, So being initial speed at the moment of evaluation and a being constant acceleration, I'm looking up angular movement to see if I can figure out a similar formula that gives me the entry tangent radius.


Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272



#5 NEXUSKill   Members   -  Reputation: 456

Like
0Likes
Like

Posted 15 November 2013 - 08:30 AM

Hmmm, though this will make the mobile arrive at the target from a spiral, it doesn't solve heading arrival (arriving to the target position from a specific heading as well), but if we can calculate the entry spiral, we can force it to be oriented in such a way that the final heading is as desired, and then force the entry tangent and radius to satisfy that condition as well, question is how.


Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272



#6 NEXUSKill   Members   -  Reputation: 456

Like
0Likes
Like

Posted 15 November 2013 - 09:31 AM

Another way to do this my coleagues and I thought of, that aproximates the previous idea well enough and might even take other things into consideration (obstacle evation and other movement rules) is to simulate an anti-mobile, that starts at the target and tries to get to our mobile, with the same parameters our mobile should use on arrival, deceleration speed, turning angle and so on, each frame our mobile moves towards the anti-mobile instead of the final target, and the anti-mobile moves toward the mobile.

 

Once the path of the mobile towards the anti-mobile requires no steering (both mobiles are moving in a colinear fashion), we stop moving the anti-movile, and once the mobile catches up with the anti-mobile, our mobile tries to move to the target, but from a state that favors a good arrival trayectory.

 

Does this make sense?


Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272



#7 Kryzon   Prime Members   -  Reputation: 2930

Like
0Likes
Like

Posted 17 November 2013 - 10:29 PM

A couple of ideas, if it helps:

 

- How would you steer the vehicle yourself to reach the goal? If you analyze the steps you would take when steering the vehicle, your reasoning behind it, it could be a guide to modelling this behaviour.

 

- Resort to AI: http://www.red3d.com/cwr/steer/

Look for the "arrival" sample. It doesn't take as many parameters as you want, but it's a start.

It's part of the OpenSteer library, and the logic behind the "arrival" sample is described here.



#8 NEXUSKill   Members   -  Reputation: 456

Like
0Likes
Like

Posted 19 November 2013 - 10:33 AM

I already have arrive implemented, and the mobiles do arrive and slow down at target, the problem is when you want them to end up looking with a specific direction and you don't want them to reorientate after arriving, but rather come softly from behind the desired heading.

 

I'm already using steering behaviors for this.

 

The target ghost boid as I've come to call it seems a promising approach, though it still needs tweaking.


Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272



#9 CombatWombat   Members   -  Reputation: 456

Like
0Likes
Like

Posted 19 November 2013 - 03:02 PM

I think this is similar to the "Piano Movers Problem".  It is motion planning / pathfinding with lot's of degrees of freedom. 

 

This article touches on some of the methods (See configuration space part).

http://www.gamasutra.com/blogs/MattKlingensmith/20130907/199787/Overview_of_Motion_Planning.php?print=1

 

Beyond giving you some search terms and links, I can't be much more help as this is kind of over my head, though...

 

Good luck.



#10 NEXUSKill   Members   -  Reputation: 456

Like
0Likes
Like

Posted 20 November 2013 - 11:42 AM

The target ghost worked quite well, its not perfect and its subject to a fine tuning of the kinematic parameters of the mobiles, but gives out a nice effect for what I wanted,
A more precise method would probably exist but I don't need to dig deeper at this moment.

For reference, the idea is to create a ghost mobile starting on the target position and orientation and having it move backwards based on the same logic used to move forwad with some reversed signs and considerations, the positive and negative boids are aligned you can move on to follow the target directly and arrival should do the rest quite nicely.


Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272



#11 ferrous   Members   -  Reputation: 1919

Like
0Likes
Like

Posted 21 November 2013 - 08:13 PM

Interesting stuff, I started digging into a similar issue, and it really is quite complicated.  If you get a sample working, I'd love to see a video.



#12 NEXUSKill   Members   -  Reputation: 456

Like
1Likes
Like

Posted 22 November 2013 - 10:00 AM

I'm thinking of putting together an article for flocking and steering behaviors, the working code I have now I cannot share due to contractual obligations but I can make something on the outside and get a working demo of the technique.


Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272



#13 Waterlimon   Crossbones+   -  Reputation: 2464

Like
0Likes
Like

Posted 22 November 2013 - 12:16 PM

Would it be possible to spawn more of the ghosts and have them follow different paths? This might let you find an optimal path in less time but will of course be slow.


o3o


#14 ferrous   Members   -  Reputation: 1919

Like
0Likes
Like

Posted 22 November 2013 - 02:35 PM

Would it be possible to spawn more of the ghosts and have them follow different paths? This might let you find an optimal path in less time but will of course be slow.

 

I believe that's how several research papers do it for motion planning.  (the gama article links to them)






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS