# Flying to a Waypoint

This topic is 4251 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I'm making a 2D Airport simulator in Java and I'm having some problems getting the plane go to a particular waypoint. A waypoint in my program is defined as an X and Y coordinate, with a vector attached that indicates the heading with which the plane should be at when it reaches the X and Y coordinate. The plane itself has two vectors and an X and Y coordinate. The first vector represents the currentVelocity which is where the plane is facing in this particular frame and a targetVelocity which is set by the navigator. Each frame the angle of the currentVelocity is incremented by a proportion of a constant called ANGLE_CHANGE_RATE depending on how many seconds have past. I really am not sure where to start... my first thought was to calculate how long it would take for the plane to turn to the correct heading:
double timeToAdjustAngle = Math.abs((currentVelocity.getAngDeg() - targetWaypoint.getAngDeg())) / ANGLE_CHANGE_RATE;
and then work out the distance between the Plane and the line formed by the vector somehow then at the right distance begin turning... I couldn't find the distance, also I wasn't sure if that was a good way of doing it anyway. I feel there must be a better way... if I somehow implemented that way, it means the plane would always be flying on a straight course and then keep doing sharp angles at the last second. Surely, I thought to myself, I could just make the Plane calculate the required angle each frame from anywhere to increment by and then the next frame that would be the same angle so I'd get a nice smooth banking motion. Not really sure, it can't be too hard but I just feel bogged down =/ I can't look at it properly... I never did physics damnit heh. If you've got any help, it'd be much appreciated.

##### Share on other sites
Most simulation of this type of system will use one of:

1/ Dubin's curves - the optimal path for a vehicle flying at constant altitude with constant speed is made up of a maximum of three segments which may be arcs or lines. These paths can be annoying to construct but they give nice results if obstacle avoidance is important.

2/ Flying between line segments using cross track error (distance of the vehicle from line you are trying to track) as a feedback signal to the input rate of your aircraft. This has the side effect that you can no longer control angle reliably.

3/ Kappa paths which are an extension on just tracking lines which can be used to convert waypoint lists to lines with bridging curves. The implementation is tricky, but there are at least three available from the original authors website from memory.

2. is the easiest to implement
1. gives the best results
3. is a nice compromise.

Be aware that you will probably need some type of feedback controller to track whatever trajectories you generate ... but that's another problem.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633678
• Total Posts
3013290
×