Trajectory optimization, lunar lander [2]: optimization code detail (CasADi+IPOpt)

Antonio Sala, UPV

Difficulty: **** ,       Relevance: PIC,      Duration: 29:39

Materials:    [Python/landercasadiPythonVideos123.zip]

Summary:

This video continues the lunar spacecraft case study whose generic problem statement and vehicle dynamics were discussed in video [lander1EN].

In this second installment, we discuss the core optimization code, in Python, using CasADi and IPOpt. We discuss cost index formulation, waypoints, and the integrator that stitches them (assuming constant thrust and pitch in the inter-waypoint segment). We also discuss the needed constraints (integrator-related ones, plus actuator bounds, avoidance of collisions with terrain, and an optional smooth descent velocity constraint as a function of the current spacecraft elevation above the terrain).Once all decision variables and constraints are specified, the solver is called, and an animation of the solution, along with various plots, is executed. Nevertheless, the cosmetic animation code is not discussed in the video for brevity.

Several simulations changing initial conditions, constraints and cost index will be deferred to video [lander3EN], which will conclude the open-loop trajectory optimization case study. In real applications, we will have modelling errors and disturbances which will force us to include some closed-loop control strategies, out of the scope of the case study at this moment.

*Link to my [whole collection] of videos in English. Link to larger [Colección completa] in Spanish.

© 2026, A. Sala. All rights reserved for materials from authors affiliated to Universitat Politecnica de Valencia.
Please consult original source/authors for info regarding rights of materials from third parties.