velocity_optimization.opt_postproc.src package

Submodules

velocity_optimization.opt_postproc.src.CalcObjective module

class velocity_optimization.opt_postproc.src.CalcObjective.CalcObjective(csv_name: str, log_lines: int, sid: str, params_path: str)[source]

Bases: object

Python version: 3.5 Created by: Thomas Herrmann (thomas.herrmann@tum.de) Created on: 01.11.2019

Documentation: Class to read available velocity-optimization-logs and re-calculate the objective function J for the entirely logged session

Inputs: csv_name: Path and file name to log-file log_lines: Number of lines in log file that build one data-block sid: ID ‘PerfSQP’ or ‘EmergSQP’ of SQP optimization object params_path: absolute path to folder containing config file .ini

J_eps_tre_lin
J_eps_tre_quad
J_jerk
J_vvmax
calc_objective()[source]

Python version: 3.5 Created by: Thomas Herrmann Created on: 01.11.2019

Documentation: Re-calculates the objective function J from logged data as well as it stores the status, iteration number and QP runtime of the last QP within the SQP

csv_name
dt_sqp_arr
log_lines
params
params_path
qp_iter_last_arr
qp_status_last_arr
read_params(sid: str) dict[source]

Python version: 3.5 Created by: Thomas Herrmann Created on: 01.11.2019

Documentation: Read parameters of SQP velocity optimizer

Inputs: sid: ID ‘PerfSQP’ or ‘EmergSQP’ of SQP optimization object

Outputs: params: QP solver parameters

velocity_optimization.opt_postproc.src.VOptIPOPT module

class velocity_optimization.opt_postproc.src.VOptIPOPT.VOptIPOPT(m: int, sid: str, params_path: str, vis_options: dict, sol_dict: dict, key: str, b_warm: bool = False)[source]

Bases: object

Class to construct the Interior-Point QP-optimizer IPOPT by defining the objective function f(x)

and constraints g(x) to optimize a velocity profile for a given path.

\[ \begin{align}\begin{aligned}\mathrm{min} f(x) \\\mathrm{s.t.} \quad g(x) \leq 0\end{aligned}\end{align} \]

More information to the IPOPT Solver can be found at https://coin-or.github.io/Ipopt/

Parameters
  • m – number of velocity points

  • sid – optimized ID ‘PerfSQP’ or ‘EmergSQP’

  • slack_every_v – slack variable for every n velocity points

  • params_path – absolute path to folder containing config file .ini

  • vis_options – user specified visualization options of the debugging tool

  • sol_options – user specified solver options of the debugging tool

  • key – key of the used solver

  • b_warm – allow or disallow the use of a warm start

Authors

Thomas Herrmann <thomas.herrmann@tum.de>

Tobias Klotz <tobias.klotz@tum.de>

Created on

01.01.2020

J
b_warm
calc_v_ipopt(v_ini: numpy.ndarray, kappa: numpy.ndarray, delta_s: numpy.ndarray, v_max: numpy.ndarray, F_ini: float, v_end: float, P_max: numpy.array, x0_v: numpy.ndarray, x0_s_t: numpy.ndarray, ax_max: numpy.ndarray, ay_max: numpy.ndarray) tuple[source]

Function to update the paramter vector and initial guess for the solution.

Parameters
  • v_ini – initial hard constrained velocity [m/s]

  • kappa – curvature profile of given path [rad/m]

  • delta_s – discretization step length of given path [m]

  • v_max – max. allowed velocity (in objective function) [m/s]

  • F_ini – hard constrained initial force [kN]

  • v_end – hard constrained max. allowed value of end velocity in optimization horizon [m/s]

  • P_max – max. allowed power [kW]

  • x0_v – initial guess velocity [m/s]

  • x0_s_t – initial guess slack variables tire [-]

  • ax_max – max. allowed longitudinal acceleration [m/s^2]

  • ay_max – max. allowed lateral accelereation [m/s]

Returns

sol: solution of the QP

param_vec: parameter vector

dt_ipopt: runtime of the solver IPOPT [ms]

sol_status: status of the solution (solved, infeasible, etc.)

Authors

Thomas Herrmann <thomas.herrmann@tum.de>

Tobias Klotz <tobias.klotz@tum.de>

Created on

01.01.2020

g
key
lam_g0
lam_x0
lbg
lbx
m
n
params_path
sid
slack_every_v
sol_dict
sol_init()[source]

Function to initialize the IPOPT solver by defining the objective function

and constraints with the CasADi modeling language.

Authors

Thomas Herrmann <thomas.herrmann@tum.de>

Tobias Klotz <tobias.klotz@tum.de>

Created on

01.01.2020

solve(x0: numpy.ndarray, param_vec: numpy.ndarray) tuple[source]

Function to solve the constructed QP.

Parameters
  • x0 – initial guess of the solution

  • param_vec – paramter vector

Returns

sol: solution of the QP

dt_ipopt: runtime of the Solver IPOPT [ms]

sol_status: status of the solution (solved, infeasible, etc.)

Authors

Thomas Herrmann <thomas.herrmann@tum.de>

Tobias Klotz <tobias.klotz@tum.de>

Created on

01.01.2020

solver
tire_model
transform_sol(sol: dict, param_vec_: numpy.ndarray, vis_options: dict) tuple[source]

Function to recalculat the optimization variables of the QP.

Parameters
  • sol – solution of the QP

  • param_vec – paramter vector

  • vis_options – user specified visualization options of the debugging tool

Returns

v: optimized velocity [m/s]

eps_tre: optimized tire slacks [-]

F_p: optimize powertrain force [kN]

P_p: optimized power force [kW]

a_x: acceleration in x-direction of CoG [m/s²]

a_y: acceleration in y-direction of CoG [m/s²]

Authors

Thomas Herrmann <thomas.herrmann@tum.de>

Tobias Klotz <tobias.klotz@tum.de>

Created on

01.01.2020

trj
ubg
ubx
unit_eps_tre
vis_options
x
x0

velocity_optimization.opt_postproc.src.VOptQPOASES module

class velocity_optimization.opt_postproc.src.VOptQPOASES.VOpt_qpOASES(Hm: numpy.ndarray, Am: numpy.ndarray)[source]

Bases: object

Class to optimize a velocity profile for a given path using the solver qpOASES.

\[ \begin{align}\begin{aligned}\min_x \qquad 1/2~x^T H_m x + q^T_v x \\\mathrm{s.t} \qquad lba \leq A_m x \leq uba\end{aligned}\end{align} \]
Parameters
  • Hm – Hessian problem matrix

  • Am – Linearized constraints matrix (Jacobian)

Authors

Thomas Herrmann <thomas.herrmann@tum.de>

Created on

01.01.2020

sol_init(Hm: numpy.ndarray, Am: numpy.ndarray)[source]

Function to initialize the qpOASES solver.

Parameters
  • Hm – Hessian problem matrix

  • Am – Linearized constraints matrix (Jacobian)

Authors

Thomas Herrmann <thomas.herrmann@tum.de>

Created on

01.01.2020

solve(x0: numpy.ndarray, Hm: numpy.ndarray, gv: numpy.ndarray, Am: numpy.ndarray, lba: numpy.ndarray, uba: numpy.ndarray) list[source]

Function to solve qpOASES optimization problem.

Parameters
  • x0 – initial guess of optimization variables,

  • Hm – Hessian problem matrix

  • gv – Jacobian of problem’s objective function,

  • Am – Linearized constraints matrix

  • lba – lower boundary vector constraints

  • uba – upper boundary vector constraints

Returns

x_opt: optimized qpOASES solution vector

Authors

Thomas Herrmann <thomas.herrmann@tum.de>

Created on

01.01.2020

solver

velocity_optimization.opt_postproc.src.online_qp_postproc module

velocity_optimization.opt_postproc.src.online_qp_postproc.online_qp_postproc(velqp: velocity_optimization.src.VelQP.VelQP, vp_qpOASES: velocity_optimization.opt_postproc.src.VOptQPOASES.VOpt_qpOASES, v_ini: float, kappa: numpy.ndarray, delta_s: numpy.ndarray, P_max: Optional[numpy.array] = None, ax_max: Optional[numpy.array] = None, ay_max: Optional[numpy.array] = None, x0_v: Optional[numpy.ndarray] = None, x0_s_t: Optional[numpy.ndarray] = None, v_max: Optional[numpy.ndarray] = None, v_end: Optional[float] = None, F_ini: Optional[float] = None, s_glo: Optional[float] = None) tuple[source]

Python version: 3.5 Created by: Thomas Herrmann (thomas.herrmann@tum.de) Created on: 01.02.2020

Documentation: Function to create an SQP that optimizes a velocity profile for a given path. For postprocessing and solver comparison purpose only!

Inputs: velqp: Velocity optimization object using the OSQP solver vp_qpOASES: Velocity optimization object using the qpOASES solver v_ini: initial velocity [m/s] kappa: curvature profile [1/m] delta_s: spatial discretization between discretization points [m] P_max: max. allowed power [kW] ax_max: max. longitudinal acceleration limits [m/s^2] ay_max: max. lateral acceleration limits [m/s^2] x0_v: initial velocity guess [m/s] x0_s_t: initial slack value guess [m/s] v_max: max. velocity allowed [m/s] v_end: end velocity within optimization horizon [m/s] F_ini: initial force constraint from first to second velocity point to be optimized [kN] s_glo: global s coordinate on race track [m]

Outputs: v_op: optimized velocity [m/s] s_t_op: optimized slack variables [-] F_op: optimized force profile [kN]

velocity_optimization.opt_postproc.src.read_ltpl_raw module

velocity_optimization.opt_postproc.src.read_ltpl_raw.read_ltpl_raw(csv_name: str) tuple[source]

Python version: 3.5 Created by: Thomas Herrmann (thomas.herrmann@tum.de) Created on: 01.02.2020

Documentation: Read log data from TUM trajectory planner module

Inputs: csv_name: Path and file name to log file

Outputs: s_glob_arr: array filled with global s coordinate values [m] v_arr: array containing the driven velocity [m/s] ax_arr: array containing the driven longitudinal acceleration [m/s^2] ay_arr: array containing the driven lateral acceleration [m/s^2]

Module contents