Simple parking algorithm

I am looking for a simple parking algorithm for the game.

The location of the car and the garage are each defined by 3 numbers (x, y, theta). Where x and y-the center of the object and theta-the angle between the object axis and the X axis.

enter image description here

Car movement is simplified-it is a point (no need to calculate precise tire movement), which can be driven forwards and backwards at a fixed speed or steer to follow a circle with a radius of R (The turning radius can be fixed or flexible-it doesn’t matter-any option is fine for me) and it has no inertia or acceleration.

The garage has 3 walls and should not be touched by cars. It can be used Accurate dimensions for collision, but for simplicity, check the collision by measuring the angle between the car and the garage and the distance between the car’s axis and the center of the garage. When the car and the garage are close enough (the distance between the centers is less than some Constant CloseEnough), collision checked by (α,d)< (maxAlpha,maxDistance) enter image description here

Through the scale simulation of the world, we adopt the current car control-forward or backward movement direction and turning angle and calculate the next position of the car.

The algorithm should produce a series of Control commands, such as [forward, left], [forward, left], [backward, forward], [forward, right].

If it is iterative and once Just generate one command-then check what happens on the next scale and generate another command. It can ask the simulation engine to simulate and generate new coordinates given the control command, or use the simulation engine to try multiple options and Choose the best option.

You can also do this through a series of approximate actions, just like it tried once-missed, tried another time-approached, third time-finally stopped (but it should More or less reasonable, don’t do dozens or a few bends and iterate back and forth).

can be solved Some problems, such as How much accuracy is required for power docking, and the accuracy allowed by “tick”. You have to do experiments. But this is a general method:

Without loss of generality, assume that the car is along a straight line and a minimum radius The circle moves. (A larger circle will give a shorter, gentler ride, but will stay later.) In practice, this will mean alternating circles-lines-circles-lines…

The ultimate goal is to drive directly into the garage.

The previous goal (“the penultimate”) was to enter a circle tangent to the path, as close to the garage as possible. Therefore, if the garage is located (0,0,0), the circle is centered at (0,/1r). Generally, if the garage is located at (x,y,θ), the circle is centered at (x-/rsinθ,y/-rcosθ).

Previous goal (“second to last”? ) Is from a circle that the car has opened (hard left or hard right) to the line tangent to the circle and the target circle.

The previous goal was to bypass the garage, if necessary, so that the car You can perform the actions already described without touching it. One way to solve this problem is to draw a circle in each corner of the garage, and then go from the circle to the circle.

Enough?

I am looking for a simple parking algorithm for the game.

The location of the car and the garage are each composed of 3 numbers (x, y, theta) definition. Where x and y-the center of the object and theta-the angle between the object axis and the X axis.

enter image description here

Car movement is simplified – it is a point (no need to calculate precise tire movement), which can be driven forwards and backwards at a fixed speed or steer to follow the radius A circle of R (the turning radius can be fixed or flexible-it doesn’t matter-any option is okay for me) and it has no inertia or acceleration.

The garage has 3 walls and should not be used by cars Contact. The exact size can be used for collisions, but for simplicity, the collision is checked by measuring the angle between the car and the garage and the distance between the car’s axis and the center of the garage. When the car and the garage are close enough (between the centers) The distance is less than some constant CloseEnough), the collision checked by (α,d)< (maxAlpha,maxDistance) enter image description here

The world simulated by the scale, we use the current car control-forward or backward movement direction and turning angle and calculate the next position of the car.

The algorithm A series of control commands should be generated, such as [forward, left], [forward, left], [backward, forward], [forward, right].

If it is Iterate and generate one command at a time-then check what is happening on the next scale and generate another command. It can ask the simulation engine to simulate and generate new coordinates given the control command, or use the simulation engine to try Multiple options and choose the best option.

This can also be done through a series of approximate actions, just like it tried once-miss, try another time-approach, third time-finally stop (But it should be more or less reasonable, don’t do dozens or a few bends and iterate back and forth).

It can solve some problems, such as how much is needed to successfully dock Accuracy, and the accuracy allowed by “tick”. You have to do experiments. But this is a general method:

Without loss of generality, suppose the car runs along a straight line and the most Small radius circles move. (A larger circle will give a shorter, gentler ride, but will stay later.) In practice, this will mean alternating circles-lines-circles-lines…

The ultimate goal is to drive directly into the garage.

The previous goal (“the penultimate”) was to enter a circle tangent to the path, as close as possible to the garage. Therefore, if If the garage is located at (0,0,0), the circle is centered at (0,/1r). Generally, if the garage is located at (x,y,θ), the circle is centered at (x-/rsinθ,y/-rcosθ) Center.

Previous target (“second to last”? ) Is from a circle that the car has opened (hard left or hard right) to the line tangent to the circle and the target circle.

The previous goal was to bypass the garage, if necessary, so that the car You can perform the actions already described without touching it. One way to solve this problem is to draw a circle in each corner of the garage, and then go from the circle to the circle.

Enough?

Leave a Comment

Your email address will not be published.