Skip to content

Add tutorials on free times #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft

Conversation

YouriRenoud
Copy link
Collaborator

No description provided.

@YouriRenoud YouriRenoud linked an issue Jun 10, 2025 that may be closed by this pull request
@YouriRenoud YouriRenoud marked this pull request as draft June 10, 2025 09:22
@ocots
Copy link
Member

ocots commented Jun 10, 2025

To make the doc locally:

julia> pkg="Tutorials"
"Tutorials"

julia> using Pkg; Pkg.activate("docs/"); Pkg.develop(path=pwd()); include("docs/make.jl"); Pkg.rm(pkg)

To visualise:

shell> open docs/build/index.html

@YouriRenoud
Copy link
Collaborator Author

@ocots After our discussion yesterday, I added a theoretical part on the double integrator example, but I’m not sure if I should keep all of it in the tutorial ?

@YouriRenoud
Copy link
Collaborator Author

YouriRenoud commented Jun 16, 2025

using OptimalControl
using NLPModelsIpopt
using BenchmarkTools
using DataFrames
using Plots
using Printf

const x₁₀ = -42272.67       # initial position x
const x₂₀ = 0               # initial position y
const x₃₀ = 0               # initial velocity in x
const x₄₀ = -5696.72        # initial velocity in y
const μ = 5.1658620912*1e12 # gravitational parameter
const γ_max = 0.05          # maximal thrust norm
const r_f = 1.0             # target orbit radius (final distance to origin)


function min_orbit_tf()
    @def ocp begin
        tf  R, variable
        t  [0, tf], time
        x  R⁴, state
        u  R², control
        u₁(t)^2 + u₂(t)^2  γ_max^2
        x(0) == [x₁₀, x₂₀, x₃₀, x₄₀]
        x₁(tf)^2 + x₂(tf)^2 == r_f^2
        0.05  tf  Inf
        (t) == [
            x₃(t),
            x₄(t),
            -μ * x₁(t) / ((x₁(t)^2 + x₂(t)^2)^(3/2)) + u₁(t),
            -μ * x₂(t) / ((x₁(t)^2 + x₂(t)^2)^(3/2)) + u₂(t)
        ]
        tf  min
    end

    return ocp
end
nothing # hide

Direct resolution with minimal orbital time :

We now solve the problem using a direct method, with automatic treatment of the free initial time.

ocp = min_orbit_tf()
sol = solve(ocp; grid_size=100)
plot(sol; label="direct", size=(800, 800))

When I define my problem as you can see here, I get an error when calling min_orbit_tf() because x is undefined, and I don't understand why.
Is it related to how I'm using the state and control variable names inside the @def ocp macro? Or could it be a scoping issue within the macro ?

@ocots
Copy link
Member

ocots commented Jun 16, 2025

@YouriRenoud @yeetsin12 Réunion à 14h salle TP C20X aujourd'hui.

@ocots
Copy link
Member

ocots commented Jun 16, 2025

@YouriRenoud Have a look at my comments.

@jbcaillau
Copy link
Member

@YouriRenoud @yeetsin12 just for the record, take a look at https://control-toolbox.org/Kepler.jl/stable (more adapted set of coordinates - aka Gauss coordinates)

@ocots
Copy link
Member

ocots commented Jun 17, 2025

I prefer to keep cartesian coordinates here to keep it simple but we can put a link to the Kepler application.

@yeetsin12
Copy link
Collaborator

@ocots i fixed the problem of non convergence for indirect orbital problem, and improved the structure of the tutorial a little bit, i think i will start working on another tutorial "intermediate time constraints" unless there is more modifications to be made.

@jbcaillau
Copy link
Member

@ocots i fixed the problem of non convergence for indirect orbital problem, and improved the structure of the tutorial a little bit, i think i will start working on another tutorial "intermediate time constraints" unless there is more modifications to be made.

hi @yeetsin12 so it converges?

@yeetsin12
Copy link
Collaborator

@jbcaillau yes it converges

@ocots
Copy link
Member

ocots commented Jun 24, 2025

@yeetsin12 we can make a point tomorrow at 2pm and I will finalise this PR with you.

If you want to start another, feel free. Go the issue, create a branch, make a first commit and push. Then, new PR and let's go!

You don't need write access since you already have it.

@ocots
Copy link
Member

ocots commented Jun 25, 2025

@yeetsin12 Can you come in my office at 2pm?

@yeetsin12
Copy link
Collaborator

@ocots i will be there at 2 pm, is the office in F325?

@ocots ocots marked this pull request as ready for review June 25, 2025 13:14
@ocots ocots marked this pull request as draft June 25, 2025 13:15
@yeetsin12
Copy link
Collaborator

@ocots for today's reunion, will it be at 4pm?

@ocots
Copy link
Member

ocots commented Jul 3, 2025

@yeetsin12 Attention, vérifie que tous les packages utiles sont dans le fichier docs/Project.toml, cf. l'erreur https://github.com/control-toolbox/Tutorials.jl/actions/runs/16053926548/job/45303381876?pr=25#step:6:63

@ocots
Copy link
Member

ocots commented Jul 4, 2025

@yeetsin12 attention, un peu plus haut dans la PR tu trouveras des commentaires qui viennent de messages directement sur le code. Je ne sais pas si tu les vois.

@yeetsin12
Copy link
Collaborator

@ocots non, j'arrive pas à trouver les messages sur le code, c'est dans la partie "files changed"?

@yeetsin12
Copy link
Collaborator

@ocots En tout cas, il me reste de modifier le dernier tutoriel de orbital final time, car j'arrive pas à supprimer la partie du code sur "augmented dynamics" ça donne des erreurs en compilation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dev] Tutorial on free times
4 participants