Tuesday, May 1, 2012

Capital AI


After the students had such a hard time with the docking, I decided to work on the AI a little bit for myself as a fun little challenge.  What I ended up constructing was a basic planning AI which can dock with the station given any set of waypoints.

First, it waits until the station's air traffic controller contacts it and asks for intent.  It then asks for docking permission, and when it's been cleared (and given a set of waypoints to the docking point) it generates its plan.

It loops through each waypoint and determines its distance.  If it's more than 20km away, it will burn the main engine to get there.  Otherwise, it travels there on maneuvering thrusters.  Once it's at the second to last waypoint, it aligns for docking and slowly travels towards the docking point.  When it's in range, it calls the docking solver which returns and error or success code.  Based on this code, it determines what to do next.

If the dock succeeded, it does nothing else.

If it failed, it checks the error to see what went wrong.  If it was out of range, it attempts to re-approach.  If the angle was too steep, it attempts to re-align and then approach.

No comments:

Post a Comment