Anatomy of a rocket landing

Ian Tsybulkin
6 min readMar 15, 2018

--

Recent developments in robotics and AI allow us to solve the problems that for a long time were considered as difficult or unsolvable. Planetary soft landing problem is one of those problems in optimal control theory that recently gained an interest again.

This article describes a generic approach to developing a control systems, which can be applied to a wide range of robotic applications, not necessarily rockets. We are going to move through all major steps of analysis and design of a robot control system using as an example a rocket similar to Falcon9 of SpaceX.

The Model Assumptions

Let us build a simple model of a rocket and explore its landing behavior. First of all let us assume that there is no air friction. Of course, we can take it into account, however, we are going to ignore it just to have the model as simple as possible without sacrificing on accuracy.

Additionally, let us ignore that the rocket mass is not constant. Falcon9 spends about 200 kg of fuel in landing. We will simulate the last few seconds of landing trajectory, so we may consider the mass is constant.

And at last, let us consider the dynamics only in 2D space, which means that we can assume that the third coordinate does not need to be controlled or in other words the error along that axis is zero. We may add the third coordinate later. It makes no big difference, however, in 2D, it is easier to observe the behavior of the object.

Rocket Dynamics

Let us assume that just three out of 9 engines of the rocket first stage are used to control the rocket on a plane XZ. Thus, our thrust force will be split into two vectors having a little different angles a and (a + u)

We added to the equations a little noise defined by a random variable γ, where D is a distance between opposite engines.

Thus, starting from initial conditions q = (x, ẋ, z, ż, a, ȧ) and defined functions Fth(q, t) and u(q, t) we may simulate how our rocket will behave. Let us start with finding rocket thrust function.

Rocket Thrust

Imagine that we consider the opposite problem. The rocket is taking off with a constant thrust Fth. Its height and vertical velocity can be found from the following equations:

So, solving backward, we may easily find a required thrust Fth for a given initial condition z and ż:

Let us simulate and check how it works for initial conditions:
x = 1.5m, ẋ = 0.5 m/s
z = 231m, ż =-50m/s ,
a = 0, ȧ = 0

Landing failed because of the final horizontal velocity is not small enough. However, the vertical velocity of the rocket is close to zero which is great.

The Controller of the Engine Angle

Now let us develop a controller that will make the rest of variables that define the rocket motion go close to zero. In other words, we need to find a function u = u(x, ẋ, z, ż, a, ȧ), which will make all trajectories started from a given initial conditions go to the point close to (0, 0, 0, 0, 0, 0).

Fortunately, the equations that describe the rocket motion are almost linear as rocket angle a is small enough. We may re-write them after linearization as shown below:

Now let us look at so-called LQR controller, which is a powerful method for finding an optimal control for systems that can be described by a linear differential equations of the first order. (https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic_regulator)

LQR

As we found already a controller for z, all we need is to solve it for two other variables x and a. Introducing v=and w=ȧ as a new variable we can decrease the order of differential equations as shown below:

So, the equation will look like:

or

LQR allows us to find in the form of u = -K p, where K is a matrix, which minimizes a quadratic cost function defined as:

Q and R should be positive-definite matrices. Usually, for Q and R we may choose diagonal matrices. Let us choose for Q a matrix with diagonal elements [0.5, 10, 1, 1] and for R identity matrix of rank 1. We choose a small number for x and 20 times bigger number for because the deviation from zero for x is not so sensitive in terms of successful landing as for the horizontal velocity. In the picture below, we may see that 5m error for x-coordinate is not a problem at all.

If you use python, for example, you may find LQR solver in scipy.linalg library.

You may notice that real parts of any eigenvalue of the matrix (A-BK) is negative which means that the found control u = -Kq is stable.

Now let us simulate the rocket behavior with the found LQR controller:

And the side view of the rocket trajectory and corresponding engine angle u function:

Conclusions

To summarize, I want to say a few words about the general approach in developing a control system for your robot. The first step is always building a model. When you have a model you may play with it, changing initial conditions, robot parameters etc. This analysis helps you to understand what are the challenges or where problems lay in.

Then, you may start designing controllers knowing what type of problems you want to address. You may come up with a different robot design at the end.

And finally, I want to draw your attention to LQR as powerful and fast method of finding an optimal control for systems that are linear or almost linear.

The details of the project can be found in my github:
https://github.com/tsybulkin/rocket_landing

--

--