# Optimal control - minimum time manouvering

**URL:** https://discourse.julialang.org/t/optimal-control-minimum-time-manouvering/75967
**Category:** Modelling & Simulations
**Tags:** question
**Created:** [February 7, 2022, 7:06pm UTC](https://discourse.julialang.org/t/optimal-control-minimum-time-manouvering/75967 "2022-02-07T19:06:41Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![FedeClaudi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedeclaudi/32/33490_2.png) [@FedeClaudi](https://discourse.julialang.org/u/FedeClaudi)
#### Post date: [February 7, 2022, 7:06pm UTC](https://discourse.julialang.org/t/optimal-control-minimum-time-manouvering/75967/1 "2022-02-07T19:06:41Z")

</div>

Hey everyone,

I’m trying to use Julia to solve a non-linear optimal control problem, the “minimum time manouvering” problem for (simulated) race cars ([Casanova 2000](https://dspace.lib.cranfield.ac.uk/handle/1826/1091), [Van Koutrik 2015](https://www.semanticscholar.org/paper/Optimal-Control-for-Race-Car-Minimum-Time-Koutrik/611d8c2c02ea4a74fadf36d97626632226612d98)).

Briefly, you have a set of differential equations that describe the dynamics and kinematics of the car under the effects of control inputs (acceleration, steering). The goal is to find the controls history yielding the fastest trajectory around the track, under the constraint imposed by the track boundary (the car can’t get out of the track). There’s many [papers](https://cecas.clemson.edu/ayalew/Papers/Vehicle%20Systems%20Dynamics%20and%20Control/Papers/Modeling%20Professional%20Drivers_VSD2017/modeling%20professional%20drivers%20with%20MPC.pdf) (and [this](https://www.tandfonline.com/doi/full/10.1080/00423114.2021.1910718)) proposing solutions to this kind of problem, but I haven’t seen a code implementation yet.

I thought I’d try to solve a simplified version of this in Julia, but I haven’t been able to find a package that could help me in that. I know there’s [NLOptControl](https://github.com/JuliaMPC/NLOptControl.jl), JuMP, Optim… but I’m not sure how I would use them for this kind of trajectory optimization problem. I’ve seen some people using [DiffEqFlux](https://diffeqflux.sciml.ai/dev/examples/optimal_control/)’s Neural ODEs to solve optimal control problems, but again I’m not sure how I’d use it here.  
I’ve tried to use the set of packages from [RoboticExplorationLab](https://bjack205.github.io/code/) which include trajectory optimization and non-linear solvers and seemed ideal for my needs, but I got stuck with some issues and haven’t (yet 🤞) [heard back](https://github.com/RoboticExplorationLab/Altro.jl/issues/32) from the developers

Is there any well documented, full of examples, trajectory optimization optimal control library out there that you’d recommend?

Thank you 🙏

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [February 7, 2022, 7:53pm UTC](https://discourse.julialang.org/t/optimal-control-minimum-time-manouvering/75967/2 "2022-02-07T19:53:10Z")

</div>

[https://github.com/RoboticExplorationLab/TrajectoryOptimization.jl](https://github.com/RoboticExplorationLab/TrajectoryOptimization.jl)  
has quite a few examples [https://github.com/RoboticExplorationLab/ALTRO.jl/tree/master/problems](https://github.com/RoboticExplorationLab/ALTRO.jl/tree/master/problems)

---

<div class="post-metadata">

### Author: ![FedeClaudi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedeclaudi/32/33490_2.png) [@FedeClaudi](https://discourse.julialang.org/u/FedeClaudi)
#### Post date: [February 7, 2022, 8:00pm UTC](https://discourse.julialang.org/t/optimal-control-minimum-time-manouvering/75967/3 "2022-02-07T20:00:11Z")

</div>

Thank you. It is indeed great and I thought It’d be ideal for my problem, but as discussed in [this issue](https://github.com/RoboticExplorationLab/Altro.jl/issues/32) I got stuck getting it to work. Perhaps there’s someone with more experience with this package that can point out what I’m doing wrong?

---

<div class="post-metadata">

### Author: ![IlyaOrson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ilyaorson/32/1681_2.png) [@IlyaOrson](https://discourse.julialang.org/u/IlyaOrson)
#### Post date: [February 8, 2022, 9:50am UTC](https://discourse.julialang.org/t/optimal-control-minimum-time-manouvering/75967/4 "2022-02-08T09:50:19Z")

</div>

You can also do this with collocation, see [here](https://github.com/pulsipher/InfiniteOpt.jl/discussions/188) for an example using InfiniteOpt.jl, which does it under the hood for you and then uses JuMP to handle the constrained optimization problem.

---

<div class="post-metadata">

### Author: ![A\_C](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@A\_C](https://discourse.julialang.org/u/A_C)
#### Post date: [March 6, 2022, 11:21pm UTC](https://discourse.julialang.org/t/optimal-control-minimum-time-manouvering/75967/5 "2022-03-06T23:21:34Z")

</div>

I have used JuMP for time optimal control of Dubins vehicle. These examples show how to solve optimal control problems:

1. [Optimal control for a Space Shuttle reentry trajectory · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/nonlinear/space_shuttle_reentry_trajectory/)
2. [Rocket Control · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/nonlinear/rocket_control/)

Do you need something like this:  
 ![dubins_obstacle](https://global.discourse-cdn.com/julialang/original/3X/3/1/31eac7ac531ceb8dd3685ff87bdef821a235ef90.png)

---

<div class="post-metadata">

### Author: ![FedeClaudi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedeclaudi/32/33490_2.png) [@FedeClaudi](https://discourse.julialang.org/u/FedeClaudi)
#### Post date: [March 11, 2022, 5:02pm UTC](https://discourse.julialang.org/t/optimal-control-minimum-time-manouvering/75967/6 "2022-03-11T17:02:39Z")

</div>

Just for reference, I’ve ended up using [InfiniteOpt](https://github.com/pulsipher/InfiniteOpt.jl/discussions/219), see also [here](https://github.com/pulsipher/InfiniteOpt.jl/discussions/219)
