Skip to content

Instantly share code, notes, and snippets.

@hi-mel
hi-mel / cartpole_trajopt.jl
Last active December 20, 2020 22:39
Non-linear trajectory optimization of a cart-pole system written in Julia
#=
Example Source: http://www.matthewpeterkelly.com/tutorials/trajectoryOptimization/cartPoleCollocation.svg
Learning trajectory optimization with a simple cartpole system
=#
using JuMP, Ipopt
using Plots
# Number of time steps, increase to reduce error at computation expense
N = 39
@hi-mel
hi-mel / levenberg_marquardt.jl
Last active April 8, 2024 20:12
Simple Julia implementation of Levenberg-Marquardt with a simple single chain 2D robot inverse kinematics example
using ForwardDiff
using LinearAlgebra
using StaticArrays
using BenchmarkTools
function levenberg_marquardt(func, desired::SVector, θ_init::SVector, debug=false)
"""
Finds the optimal input values θ to a function to approximate desired output values
using the Levenberg-Marquardt Algorithm
# Arguments