0
$\begingroup$

I'm working on AI vehicle movement for a game. This is an open terrain game so the vehicles are not using a predefined track. The AI is given a list of waypoints that they must follow believably. Right now they kinda are but they need to adjust their speed for corners, so I need some help trying to figure out the correct speed they should be going during turns.

The variables I am currently working with are: the angle for the next turn (if several turns are close together I add them to the current turn angle), the current speed, the braking distance, gravity, and friction between the ground and the vehicle.

I saw this post but I wasn't sure how Ri and Ro played into my way-point list: Car racing: How to calculate the radius of the racing line through a turn of varying length

Any help would be really appreciated!

$\endgroup$
  • $\begingroup$ You’re not always going to be able to use that solution as is, but it’s a reasonable starting point: as the angle gets shallower and the road wider, the turn starts and ends farther and farther from the apex. If your waypoints are spaced close together relative to the vehicles performances, there might not be enough room for it to reach max cornering speed for the next turn. As well, it might not have room to slow down enough to take the next corner at all. Have a look at Beckman’s old The Physics of Racing. $\endgroup$ – amd Sep 15 '18 at 0:13
1
$\begingroup$

A reasonable model is that you can accelerate up to some limit in any direction-forward, backward (braking), or sideways (turning). If $v$ is the speed you are running and $a$ is the acceleration limit, the acceleration due to turning is $\frac {v^2}r=\omega^2r$ where $\omega$ is the angular velocity, $\omega=\frac vr$. I did the problem once and convinced myself that if you want to make a U turn it is worth decelerating to zero speed, making a sharp corner, and accelerating back to speed. There is some smaller angle where you should just make the turn at speed because the decelerate/accelerate is a fixed cost while the time saved turning is proportional to the turn angle. A reasonable acceleration limit for cars is $0.8-1$g.

$\endgroup$
  • $\begingroup$ It really depends on what you’re trying to optimize. If it’s time spent in the turn in isolation, then the shortest path usually wins. On the other hand, if you’re trying to minimize the total time to traverse some path that includes that turn, it can be better to trade time spent in the corner for increased exit speed. $\endgroup$ – amd Sep 15 '18 at 4:49
  • $\begingroup$ @amd: That is what I remember doing for a U turn. It was better to decelerate to save the time in the turn. Clearly for a small turn you should not. I have not calculated the transition point in angle. I suspect it is a sharp jump. It was long ago and the memory is hazy. $\endgroup$ – Ross Millikan Sep 15 '18 at 4:52
  • $\begingroup$ That’s a great edge case that illustrates why the simplified “racing line” of a constant-speed circular arc isn’t the real racing line: You spend too much time changing direction and can’t start to increase your speed until after you’ve gotten a long way out of the corner. The transition angle is going to (obviously) depend on the car’s characteristics, though. Generally speaking, I’d expect that the better the longitudinal acceleration, the greater range of turn angles benefit from a “point and shoot” approach, but what comes next will have an influence, too. Real-time brachistochrones :) $\endgroup$ – amd Sep 15 '18 at 5:41
  • $\begingroup$ I’ll note that for a realistic-feeling model, longitudinal acceleration (throttle) should be less than deceleration (braking). $\endgroup$ – amd Sep 15 '18 at 5:43
  • $\begingroup$ @RossMillikan so is ω the speed I want to have in the corner? I understand that its the angular velocity, but I don't really have control over that, I can only modify forward velocity and steering. Also is r calculated the same as the answer above? And how does a acceleration limit play into this equation? Thanks for the responses. $\endgroup$ – LDOG Sep 17 '18 at 16:40
0
$\begingroup$

$R_i$ and $R_o$ are the inner and outer radii of the road which determines the actual radius of your turn. The larger the radius the better which is always larger than $R_o$ enabling you to go through the corner faster. This is a geometry problem as a vehicle will go from outside to inside and back to outside in making the turn radius as large as possible.

$\endgroup$
  • $\begingroup$ Thanks for the response! So are R_i and R_o arbitrary, can they be whatever I want or do I have to calculate them? $\endgroup$ – LDOG Sep 14 '18 at 23:53
  • $\begingroup$ @LDOG For your application, they are parameters that you get to adjust—they constrain how far off the “connect the dots” path you allow the vehicle to go. $\endgroup$ – amd Sep 15 '18 at 0:08
  • $\begingroup$ @amd Not really, I am using physically based vehicle model and a custom path-following implementation. So I'm trying to figure out what the best target speed is for my vehicle so that it doesn't skid or veer to far off the track. $\endgroup$ – LDOG Sep 15 '18 at 0:14
  • $\begingroup$ @LDOG In your question, you wrote that there is no track. “Too far” is entirely up to you to define, which in turn constrains the inner and outer radii—effectively the width—of the imaginary road that you’re trying to keep the vehicle on. $\endgroup$ – amd Sep 15 '18 at 0:17
  • $\begingroup$ @LDOG Yes, you can make them whatever you want If you want to constrain the path of the vehicle. $\endgroup$ – Phil H Sep 15 '18 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.