Monday, October 22, 2007

Trajectory Feedback

This week I've been working on feedback in my lunar lander program.

The screenshot is not terribly clear. The ugly disc on the bottom is the moon. The tilted green arrow in the center marks the lander's position and orientation; when the camera zooms in you can see the lander itself. The curve passing through the lander that leads to the the little arrow on the ground is the ballistic trajectory (the arrow marks its impact site), while the second curve which intersects the ground is the maximum deceleration trajectory.

The ballistic trajectory is handy for some things. It shows you the “default” behavior of the spacecraft if you don't do anything. You can make a pinpoint landing reasonably well by aiming the ballistic impact site at your target and then throttling and steering to keep it there as the rocket decelerates.

I've been experimenting with some other displays. One I'd like to have is an indication, when you're in orbit, of the nearest point on the planet that you can safely land on. My first attempt toward that is the maximum deceleration trajectory. This simply integrates the spacecraft's position while choosing to decelerate in the direction opposite the velocity vector at each step.

When the rocket is flying high enough, it can reach zero velocity above the ground, in which case this trajectory is good. When you're orbiting lower, though, the trajectory may not reach zero velocity until under the ground somewhere, which isn't as useful.

What I really need is a trajectory that diverts power as necessary away from maximum deceleration and toward maintaining positive elevation. I haven't figured out quite how to do this yet, though. There are a variety of papers about how to compute optimal soft-landing trajectories, but they are almost all for sale at $25 each from IEEE and AIAA. I don't want to buy papers sight-unseen so I'm still trying to figure out a way to see them.

Another display I'd like is an indication, on the ballistic trajectory, of the point beyond which there is nothing you can do to prevent a crash. My first attempt toward that assumes only vertical motion, constant gravity acceleration, and constant rocket acceleration. It computes the altitude at which you must begin decelerating (at your current rocket thrust level) in order to bring the rocket to a soft landing.



Initial equations:

The position and velocity need to match up at the boundary between the unpowered and powered flight segments. Equating these yields two equations in two unknowns: s and t, the durations of the unpowered and powered segments, respectively:

Via a lot of tedious algebra, these can be solved for t, which can then be plugged into one of the initial equations to yield the altitude at which the powered braking segment begins:

I was surprised at first to see that the direction of initial velocity doesn't matter. You can be going up, or down, and the elevation is the same. On thinking about it, this makes sense, because if you are going up, you are on a parabolic arc that will come back down to the same elevation with exactly opposite velocity.

This equation assumes that gravity is constant. Near the surface this is a reasonable approximation but as you get higher, gravity drops off and it becomes less accurate. Initially I chose to use surface gravity as the approximation. This is conservative because it makes the equation think the rocket will fall faster than it actually does. Choosing gravity at the spacecraft's initial elevation would sometimes cause the equation to underestimate the height at which to start braking. I've experimented with using the average of the gravity at ground and at the spacecraft's initial altitude; this works pretty well. If we were to make gravity dependent on altitude the equations would become differential equations. I might take a look at solving that, eventually.

Even as it is, this display is pretty useful. I can tune the throttle up and down and the indicated altitude rises and falls; if I set it to the bottom of the spacecraft then it will make a perfect soft landing.

No comments: