Realistic steering wheel angle when car follows points along a path

In summary, the problem with my algorithm is that on certain portions, the car tends to zigzag. Any idea please to remove this zigzag effect?
  • #1
Guitz
22
8
TL;DR Summary
I'm developping a traffic simulation on Unreal Engine
Good morning ,

I managed to simplify the physics of my car with only the centrifugal and traction forces. If I'm in control of it, the realism is acceptable for a city builder. On the other hand, I encounter a problem when the car follows an array of points.

2.jpg


The path of the car on my graph consists of an array of position vectors A[],
I'd like the steering wheel to rotate realistically based on the car's position and rotation relative to each A .
The unit vector u is always in the same direction as the front of the car, P is located between the 2 front wheels.

The problem with my algorithm is that on certain portions, the car tends to zigzag.

Any idea please to remove this zigzag effect?
 
Physics news on Phys.org
  • #2
Guitz said:
Any idea please to remove this zigzag effect?
Start by finding out what is causing it.

Do you want the car to follow the path and the steering is for the realistic look only? Then you should control the motion by the path, not by forces. Derive the steering for visuals from the motion of the wheel locations relative to the ground.
 
Last edited:
  • #3
Guitz said:
Any idea please to remove this zigzag effect?
The steering wheel angular position will track the radius of curvature of the track on the ground. You show the points approximated by a smooth curve. Compute the RofC of that line, then move the steering wheel to track that, as the vehicle moves along that line.
 
  • #4
Sorry i forgot to show you the algorithm :

Code:
Every frame if CarIsMoving = true :
If DegreesAngle(A[i] – P, u) >= 90
we go to next A[i], so
      i = i+1
 Else,
 
DeltaSteeringAngle = DegreesAngle(RotateVectorAroundZAxis(u, SteeringAngle), A[i] – P)/15
SteeringAngle = SteeringAngle + DeltaSteeringAngle
 
  • #5
Does DegreesAngle(A – P, u) range from -180° to +180°, or from 0° to 360° ?

I would expect; ABSolute ( DegreesAngle(A – P, u) ) >= 90
or; DegreesAngle(A – P, u) >= 180

I think you will need a Bézier curve approximation to the sparse waypoints to determine the steering wheel angle.
 
  • #6
Baluncore said:
Does DegreesAngle(A – P, u) range from -180° to +180°, or from 0° to 360° ?

I would expect; ABSolute ( DegreesAngle(A – P, u) ) >= 90
or; DegreesAngle(A – P, u) >= 180

I think you will need a Bézier curve approximation to the sparse waypoints to determine the steering wheel angle.
Yes i used Abs() but i wanted to simplify the algorithm to make it easier to read on forums
 
  • #7
Guitz said:
Yes i used Abs() but i wanted to simplify the algorithm to make it easier to read on forums
We can only look for problems in the code you post.
How does the car navigate between the waypoints ?
How could a car do a three-point-turn ?
 
  • #8
Baluncore said:
How does the car navigate between the waypoints ?
I update the Thottle property everyframe, but car speed is bounded by every A[].SpeedLimit. In fact
A[] is a PathData struct array storing Location, Tangent, SpeedLimit properties
 
Last edited:
  • #9
You show a curved path, but only use waypoints on that curve.
Do you know what you mean by tangent? I don't.
 
  • #10
Baluncore said:
You show a curved path, but only use waypoints on that curve.
Do you know what you mean by tangent? I don't.
these tangents are simply tangents on every waypoint. I use them to correctly orientate the car in the correct direction when i spawn it at a specific A[0]
 
  • #11
If you have two points with tangents, then they define a circular arc. The vehicle orientation can change as it moves in single frame steps along that arc, and the steering wheel position can be determined by the radius of curvature of the arc.
 
  • #12
Baluncore said:
If you have two points with tangents, then they define a circular arc. The vehicle orientation can change as it moves in single frame steps along that arc, and the steering wheel position can be determined by the radius of curvature of the arc.
Thank you so much, ill try this approach
 
  • #13
If you use a circular arc, the steering will jump when you reach a waypoint on a curve, because the radius changes instantly. If you use a parabolic curve between the two tangents, it will not have a step change, but the steering wheel will oscillate a little either side.
The next refinement beyond a parabolic curve is a spline, or a Bézier curve. Then, while travelling a segment, you always consider four points, the two points behind and the two points ahead.
 
  • #15
A.T. said:
Start by finding out what is causing it.

Do you want the car to follow the path and the steering is for the realistic look only? Then you should control the motion by the path, not by forces. Derive the steering for visuals from the motion of the wheel locations relative to the ground.
Hi A.T.,

if the car follows a path without taking into account the forces, it is the most optimized (i need to spawn 5000 vehicles in my city builder) but is there a way to make it realistic enough?

As I said, I take into account the centrifugal force and the traction force only,
but i am open to your suggestion.
 
  • #16
please guys, have a look at 2:25



The developer has the same zigzag problem as me.
This is a very complicated issue to solve also considering i must also optimize/simplify a lot because i will allow the user to spawn max 5000 vehicules at runtime.

Thanks for your help
 
  • #17
Guitz said:
if the car follows a path without taking into account the forces, it is the most optimized (i need to spawn 5000 vehicles in my city builder)
Then do it without forces:
- Place the center of the back axle on the path at some point P and rotate the car such that the back axle is perpendicular to the path at P.
- Orient the front wheel axles, so they point to the center of curvature of the path at P. Note that for a straight path the center of curvature is at infinity, so you might need a threshold to deal with that numerically.
330px-Ackermann_turning.svg.png


https://en.wikipedia.org/wiki/Ackermann_steering_geometry
330px-Osculating_circle.svg.png

https://en.wikipedia.org/wiki/Osculating_circle

Guitz said:
but is there a way to make it realistic enough?
What is "realistic enough"? Use the most efficient approach, then check how it looks, and improve only if needed.

Guitz said:
The developer has the same zigzag problem as me.
If you try to follow an exact path using steering inputs, forces and Newton's Laws, you have a control problem, which might not be worth the trouble, if it is only for visuals:
https://en.wikipedia.org/wiki/PID_controller
 
Last edited:
  • #18
You know the direction of the track at the front of the car. Point the front wheels in that direction. The rear wheels will follow in a pursuit curve, so always aim the back wheels at the front wheels. The car body will be oriented the same way as the rear wheels.
 
  • #19
Thanks again, i'll try to implement this
 
  • #20
Hello everyone,

As suggested i will have to use osculating circles:



What do you think is the best optimization/realism compromise?

Should the car's OsculatingCircle be updated every frame from its trajectory spline? Or is it realistic enough to bake 1 OsculatingCircle per checkpoint, and interpolate car position / front wheels rotation / car rotation between them?
 
  • #21
Guitz said:
What do you think is the best optimization/realism compromise?
Try it and compare. Computing the circle approximation from 3 points on the path should not be that computationally expensive. Or there might be an analytical formula for the type of spline you are using.
 
  • #22
Hi all, finally i computed osculating circle every frame.
Thank you very much for giving me this solution. Not only this method offers a clean car behavior, but also it is more optimized than using Newton's 2nd Law by following a array of points.
 
  • Like
Likes Juanda and A.T.

FAQ: Realistic steering wheel angle when car follows points along a path

What factors determine the realistic steering wheel angle when a car follows a path?

The realistic steering wheel angle is determined by several factors, including the vehicle's speed, the curvature of the path, the vehicle's wheelbase (distance between the front and rear axles), and the steering ratio (the ratio of the steering wheel angle to the angle of the wheels). Additionally, the dynamics of the car, such as tire grip and suspension settings, also play a role.

How do you calculate the steering wheel angle for a given path?

To calculate the steering wheel angle, you can use the Ackermann steering geometry principles, which relate the turning radius to the wheel angles. The steering wheel angle θ can be approximated using the formula: θ = atan(L / R) * (steering ratio), where L is the wheelbase of the car, R is the turning radius, and the steering ratio is the ratio of the steering wheel rotation to the front wheel rotation.

How does vehicle speed affect the required steering wheel angle?

Vehicle speed affects the required steering wheel angle because higher speeds generally require smaller steering angles to navigate a curve safely. This is due to the increased lateral forces at higher speeds. Additionally, at higher speeds, the response of the vehicle to steering inputs becomes more sensitive, necessitating more precise control to maintain stability and trajectory.

What role does the steering ratio play in determining the steering wheel angle?

The steering ratio is crucial as it determines how much the steering wheel needs to be turned to achieve a certain wheel angle. A higher steering ratio means that the steering wheel needs to be turned more for the same wheel angle, which can provide finer control at high speeds. Conversely, a lower steering ratio means less steering wheel movement is needed, which can be beneficial for quick maneuvers.

How do you account for dynamic factors like tire grip and suspension in determining the steering wheel angle?

Dynamic factors such as tire grip and suspension settings are accounted for through vehicle dynamics models that simulate how these factors affect the car's behavior. These models can be complex and typically involve simulations or empirical data to predict how the car will respond to steering inputs under different conditions. Adjustments can then be made to the steering inputs to ensure the car follows the intended path accurately.

Similar threads

Replies
8
Views
2K
Replies
5
Views
5K
Replies
20
Views
3K
Replies
13
Views
4K
Replies
2
Views
2K
Back
Top