alpaqa 0.0.1
Nonconvex constrained optimization
Functions | Variables
bicycle-obstacle-avoidance-mpc Namespace Reference

Functions

def solve_ocp (state, y_sol, x_sol)
 

Variables

float Ts = 0.05
 
int N_hor = 18
 
int N_sim = 80
 
bool multipleshooting = False
 
int R_obstacle = 2
 
 f
 
 nlp
 
 bounds
 
 n_states
 
 n_inputs
 
 first_input_idx
 
string name = "mpcproblem"
 
 f_prob = cs.Function("f", [nlp["x"], nlp["p"]], [nlp["f"]])
 
 g_prob = cs.Function("g", [nlp["x"], nlp["p"]], [nlp["g"]])
 
 prob = pa.generate_and_compile_casadi_problem(f_prob, g_prob, name=name)
 
 lowerbound
 
 upperbound
 
int lbfgsmem = N_hor
 
int tol = 1e-5
 
bool verbose = False
 
dictionary panocparams
 
 innersolver
 
 almparams
 
 solver = pa.ALMSolver(almparams, innersolver)
 
 state = np.array([-5, 0, 0, 0])
 
 dest = np.array([5, 0.1, 0, 0])
 
 x_sol = np.concatenate((np.tile(state, N_hor), np.zeros((n_inputs * N_hor,))))
 
 y_sol = np.zeros((prob.m,))
 
 xs = np.zeros((N_sim, n_states))
 
 times = np.zeros((N_sim,))
 
 t
 
 stats
 
 input = x_sol[first_input_idx : first_input_idx + n_inputs]
 
 fig_trajectory
 
 ax
 
 c = plt.Circle((0, 0), R_obstacle)
 
 fig_time
 

Function Documentation

◆ solve_ocp()

def bicycle-obstacle-avoidance-mpc.solve_ocp (   state,
  y_sol,
  x_sol 
)

Definition at line 91 of file bicycle-obstacle-avoidance-mpc.py.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ Ts

float Ts = 0.05

Definition at line 19 of file bicycle-obstacle-avoidance-mpc.py.

◆ N_hor

int N_hor = 18

Definition at line 20 of file bicycle-obstacle-avoidance-mpc.py.

◆ N_sim

int N_sim = 80

Definition at line 21 of file bicycle-obstacle-avoidance-mpc.py.

◆ multipleshooting

bool multipleshooting = False

Definition at line 23 of file bicycle-obstacle-avoidance-mpc.py.

◆ R_obstacle

int R_obstacle = 2

Definition at line 24 of file bicycle-obstacle-avoidance-mpc.py.

◆ f

f

Definition at line 26 of file bicycle-obstacle-avoidance-mpc.py.

◆ nlp

nlp

Definition at line 26 of file bicycle-obstacle-avoidance-mpc.py.

◆ bounds

bounds

Definition at line 26 of file bicycle-obstacle-avoidance-mpc.py.

◆ n_states

n_states

Definition at line 26 of file bicycle-obstacle-avoidance-mpc.py.

◆ n_inputs

n_inputs

Definition at line 26 of file bicycle-obstacle-avoidance-mpc.py.

◆ first_input_idx

first_input_idx

Definition at line 26 of file bicycle-obstacle-avoidance-mpc.py.

◆ name

string name = "mpcproblem"

Definition at line 35 of file bicycle-obstacle-avoidance-mpc.py.

◆ f_prob

f_prob = cs.Function("f", [nlp["x"], nlp["p"]], [nlp["f"]])

Definition at line 36 of file bicycle-obstacle-avoidance-mpc.py.

◆ g_prob

g_prob = cs.Function("g", [nlp["x"], nlp["p"]], [nlp["g"]])

Definition at line 37 of file bicycle-obstacle-avoidance-mpc.py.

◆ prob

prob = pa.generate_and_compile_casadi_problem(f_prob, g_prob, name=name)

Definition at line 38 of file bicycle-obstacle-avoidance-mpc.py.

◆ lowerbound

lowerbound

Definition at line 40 of file bicycle-obstacle-avoidance-mpc.py.

◆ upperbound

upperbound

Definition at line 41 of file bicycle-obstacle-avoidance-mpc.py.

◆ lbfgsmem

int lbfgsmem = N_hor

Definition at line 47 of file bicycle-obstacle-avoidance-mpc.py.

◆ tol

int tol = 1e-5

Definition at line 48 of file bicycle-obstacle-avoidance-mpc.py.

◆ verbose

bool verbose = False

Definition at line 49 of file bicycle-obstacle-avoidance-mpc.py.

◆ panocparams

dictionary panocparams
Initial value:
1= {
2 "max_iter": 1000,
3 "max_time": timedelta(seconds=0.5),
4 "print_interval": 10 if verbose else 0,
5 "stop_crit": pa.PANOCStopCrit.ProjGradUnitNorm,
6 "update_lipschitz_in_linesearch": True,
7}

Definition at line 51 of file bicycle-obstacle-avoidance-mpc.py.

◆ innersolver

innersolver
Initial value:
1= pa.PANOCSolver(
2 pa.PANOCParams(**panocparams),
3 pa.LBFGSParams(memory=lbfgsmem),
4)

Definition at line 59 of file bicycle-obstacle-avoidance-mpc.py.

◆ almparams

almparams
Initial value:
1= pa.ALMParams(
2 max_iter=20,
3 max_time=timedelta(seconds=1),
4 print_interval=1 if verbose else 0,
5 preconditioning=False,
6 ε=tol,
7 δ=tol,
8 Δ=5,
9 Σ_0=4e5,
10 Σ_max=1e12,
11)

Definition at line 64 of file bicycle-obstacle-avoidance-mpc.py.

◆ solver

solver = pa.ALMSolver(almparams, innersolver)

◆ state

state = np.array([-5, 0, 0, 0])

Definition at line 80 of file bicycle-obstacle-avoidance-mpc.py.

◆ dest

dest = np.array([5, 0.1, 0, 0])

Definition at line 81 of file bicycle-obstacle-avoidance-mpc.py.

◆ x_sol

x_sol = np.concatenate((np.tile(state, N_hor), np.zeros((n_inputs * N_hor,))))

Definition at line 84 of file bicycle-obstacle-avoidance-mpc.py.

◆ y_sol

y_sol = np.zeros((prob.m,))

Definition at line 88 of file bicycle-obstacle-avoidance-mpc.py.

◆ xs

xs = np.zeros((N_sim, n_states))

Definition at line 100 of file bicycle-obstacle-avoidance-mpc.py.

◆ times

times = np.zeros((N_sim,))

Definition at line 101 of file bicycle-obstacle-avoidance-mpc.py.

◆ t

t

Definition at line 103 of file bicycle-obstacle-avoidance-mpc.py.

◆ stats

stats

◆ input

Definition at line 112 of file bicycle-obstacle-avoidance-mpc.py.

◆ fig_trajectory

fig_trajectory

Definition at line 117 of file bicycle-obstacle-avoidance-mpc.py.

◆ ax

ax

Definition at line 117 of file bicycle-obstacle-avoidance-mpc.py.

◆ c

c = plt.Circle((0, 0), R_obstacle)

Definition at line 118 of file bicycle-obstacle-avoidance-mpc.py.

◆ fig_time

fig_time

Definition at line 124 of file bicycle-obstacle-avoidance-mpc.py.