longitudinal MPC: use reset() function instead of recreating the solver in (#24091)
* scons: add acados_template as dependency for lat and long mpc * long MPC: use acados reset instead of recreating the solver * long MPC: print timings and reset commented * update acados x86_64 * update acados include folder * update acados Python interface * update acados reference commit to latest acados/master * update x86 libs * update comma two * update acados again with commit 8ea8827fafb1b23b4c7da1c4cf650de1cbd73584 * update comma two * update comma three * update x86 Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Comma Device <device@comma.ai>pull/24106/head
parent
b51deb97d1
commit
a9bac5acf8
59 changed files with 1532 additions and 233 deletions
@ -0,0 +1,116 @@ |
||||
# -*- coding: future_fstrings -*- |
||||
# |
||||
# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, |
||||
# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, |
||||
# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, |
||||
# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl |
||||
# |
||||
# This file is part of acados. |
||||
# |
||||
# The 2-Clause BSD License |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are met: |
||||
# |
||||
# 1. Redistributions of source code must retain the above copyright notice, |
||||
# this list of conditions and the following disclaimer. |
||||
# |
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
# this list of conditions and the following disclaimer in the documentation |
||||
# and/or other materials provided with the distribution. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||||
# POSSIBILITY OF SUCH DAMAGE.; |
||||
# |
||||
|
||||
import os |
||||
import sys |
||||
from subprocess import call |
||||
|
||||
|
||||
class CMakeBuilder: |
||||
""" |
||||
Class to work with the `CMake` build system. |
||||
""" |
||||
def __init__(self): |
||||
self._source_dir = None # private source directory, this is set to code_export_dir |
||||
self.build_dir = 'build' |
||||
self._build_dir = None # private build directory, usually rendered to abspath(build_dir) |
||||
self.generator = None |
||||
"""Defines the generator, options can be found via `cmake --help` under 'Generator'. Type: string. Linux default 'Unix Makefiles', Windows 'Visual Studio 15 2017 Win64'; default value: `None`.""" |
||||
# set something for Windows |
||||
if os.name == 'nt': |
||||
self.generator = 'Visual Studio 15 2017 Win64' |
||||
self.build_targets = None |
||||
"""A comma-separated list of the build targets, if `None` then all targets will be build; type: List of strings; default: `None`.""" |
||||
self.options_on = None |
||||
"""List of strings as CMake options which are translated to '-D Opt[0]=ON -D Opt[1]=ON ...'; default: `None`.""" |
||||
|
||||
# Generate the command string for handling the cmake command. |
||||
def get_cmd1_cmake(self): |
||||
defines_str = '' |
||||
if self.options_on is not None: |
||||
defines_arr = [f' -D{opt}=ON' for opt in self.options_on] |
||||
defines_str = ' '.join(defines_arr) |
||||
generator_str = '' |
||||
if self.generator is not None: |
||||
generator_str = f' -G"{self.generator}"' |
||||
return f'cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="{self._source_dir}"{defines_str}{generator_str} -Wdev -S"{self._source_dir}" -B"{self._build_dir}"' |
||||
|
||||
# Generate the command string for handling the build. |
||||
def get_cmd2_build(self): |
||||
import multiprocessing |
||||
cmd = f'cmake --build "{self._build_dir}" --config Release -j{multiprocessing.cpu_count()}' |
||||
if self.build_targets is not None: |
||||
cmd += f' -t {self.build_targets}' |
||||
return cmd |
||||
|
||||
# Generate the command string for handling the install command. |
||||
def get_cmd3_install(self): |
||||
return f'cmake --install "{self._build_dir}"' |
||||
|
||||
def exec(self, code_export_directory): |
||||
""" |
||||
Execute the compilation using `CMake` with the given settings. |
||||
:param code_export_directory: must be the absolute path to the directory where the code was exported to |
||||
""" |
||||
if(os.path.isabs(code_export_directory) is False): |
||||
print(f'(W) the code export directory "{code_export_directory}" is not an absolute path!') |
||||
self._source_dir = code_export_directory |
||||
self._build_dir = os.path.abspath(self.build_dir) |
||||
try: |
||||
os.mkdir(self._build_dir) |
||||
except FileExistsError as e: |
||||
pass |
||||
|
||||
try: |
||||
os.chdir(self._build_dir) |
||||
cmd_str = self.get_cmd1_cmake() |
||||
print(f'call("{cmd_str})"') |
||||
retcode = call(cmd_str, shell=True) |
||||
if retcode != 0: |
||||
raise RuntimeError(f'CMake command "{cmd_str}" was terminated by signal {retcode}') |
||||
cmd_str = self.get_cmd2_build() |
||||
print(f'call("{cmd_str}")') |
||||
retcode = call(cmd_str, shell=True) |
||||
if retcode != 0: |
||||
raise RuntimeError(f'Build command "{cmd_str}" was terminated by signal {retcode}') |
||||
cmd_str = self.get_cmd3_install() |
||||
print(f'call("{cmd_str}")') |
||||
retcode = call(cmd_str, shell=True) |
||||
if retcode != 0: |
||||
raise RuntimeError(f'Install command "{cmd_str}" was terminated by signal {retcode}') |
||||
except OSError as e: |
||||
print("Execution failed:", e, file=sys.stderr) |
||||
except Exception as e: |
||||
print("Execution failed:", e, file=sys.stderr) |
||||
exit(1) |
@ -0,0 +1,374 @@ |
||||
# |
||||
# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren, |
||||
# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor, |
||||
# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan, |
||||
# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl |
||||
# |
||||
# This file is part of acados. |
||||
# |
||||
# The 2-Clause BSD License |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are met: |
||||
# |
||||
# 1. Redistributions of source code must retain the above copyright notice, |
||||
# this list of conditions and the following disclaimer. |
||||
# |
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
# this list of conditions and the following disclaimer in the documentation |
||||
# and/or other materials provided with the distribution. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||||
# POSSIBILITY OF SUCH DAMAGE.; |
||||
# |
||||
|
||||
{%- if solver_options.qp_solver %} |
||||
{%- set qp_solver = solver_options.qp_solver %} |
||||
{%- else %} |
||||
{%- set qp_solver = "FULL_CONDENSING_HPIPM" %} |
||||
{%- endif %} |
||||
|
||||
{%- if solver_options.hessian_approx %} |
||||
{%- set hessian_approx = solver_options.hessian_approx %} |
||||
{%- elif solver_options.sens_hess %} |
||||
{%- set hessian_approx = "EXACT" %} |
||||
{%- else %} |
||||
{%- set hessian_approx = "GAUSS_NEWTON" %} |
||||
{%- endif %} |
||||
|
||||
{%- if constraints.constr_type %} |
||||
{%- set constr_type = constraints.constr_type %} |
||||
{%- else %} |
||||
{%- set constr_type = "NONE" %} |
||||
{%- endif %} |
||||
|
||||
{%- if constraints.constr_type_e %} |
||||
{%- set constr_type_e = constraints.constr_type_e %} |
||||
{%- else %} |
||||
{%- set constr_type_e = "NONE" %} |
||||
{%- endif %} |
||||
|
||||
{%- if cost.cost_type %} |
||||
{%- set cost_type = cost.cost_type %} |
||||
{%- else %} |
||||
{%- set cost_type = "NONE" %} |
||||
{%- endif %} |
||||
|
||||
{%- if cost.cost_type_e %} |
||||
{%- set cost_type_e = cost.cost_type_e %} |
||||
{%- else %} |
||||
{%- set cost_type_e = "NONE" %} |
||||
{%- endif %} |
||||
|
||||
{%- if cost.cost_type_0 %} |
||||
{%- set cost_type_0 = cost.cost_type_0 %} |
||||
{%- else %} |
||||
{%- set cost_type_0 = "NONE" %} |
||||
{%- endif %} |
||||
|
||||
{%- if dims.nh %} |
||||
{%- set dims_nh = dims.nh %} |
||||
{%- else %} |
||||
{%- set dims_nh = 0 %} |
||||
{%- endif %} |
||||
|
||||
{%- if dims.nphi %} |
||||
{%- set dims_nphi = dims.nphi %} |
||||
{%- else %} |
||||
{%- set dims_nphi = 0 %} |
||||
{%- endif %} |
||||
|
||||
{%- if dims.nh_e %} |
||||
{%- set dims_nh_e = dims.nh_e %} |
||||
{%- else %} |
||||
{%- set dims_nh_e = 0 %} |
||||
{%- endif %} |
||||
|
||||
{%- if dims.nphi_e %} |
||||
{%- set dims_nphi_e = dims.nphi_e %} |
||||
{%- else %} |
||||
{%- set dims_nphi_e = 0 %} |
||||
{%- endif %} |
||||
|
||||
{%- if solver_options.model_external_shared_lib_dir %} |
||||
{%- set model_external_shared_lib_dir = solver_options.model_external_shared_lib_dir %} |
||||
{%- endif %} |
||||
|
||||
{%- if solver_options.model_external_shared_lib_name %} |
||||
{%- set model_external_shared_lib_name = solver_options.model_external_shared_lib_name %} |
||||
{%- endif %} |
||||
|
||||
{#- control operator #} |
||||
{%- if os and os == "pc" %} |
||||
{%- set control = "&" %} |
||||
{%- else %} |
||||
{%- set control = ";" %} |
||||
{%- endif %} |
||||
|
||||
{%- if acados_link_libs and os and os == "pc" %}{# acados linking libraries and flags #} |
||||
{%- set link_libs = acados_link_libs.qpoases ~ " " ~ acados_link_libs.hpmpc ~ " " ~ acados_link_libs.osqp -%} |
||||
{%- set openmp_flag = acados_link_libs.openmp %} |
||||
{%- else %} |
||||
{%- set openmp_flag = " " %} |
||||
{%- if qp_solver == "FULL_CONDENSING_QPOASES" %} |
||||
{%- set link_libs = "-lqpOASES_e" %} |
||||
{%- else %} |
||||
{%- set link_libs = "" %} |
||||
{%- endif %} |
||||
{%- endif %} |
||||
|
||||
cmake_minimum_required(VERSION 3.10) |
||||
|
||||
project({{ model.name }}) |
||||
|
||||
# build options. |
||||
option(BUILD_ACADOS_SOLVER_LIB "Should the solver library acados_solver_{{ model.name }} be build?" OFF) |
||||
option(BUILD_ACADOS_OCP_SOLVER_LIB "Should the OCP solver library acados_ocp_solver_{{ model.name }} be build?" OFF) |
||||
option(BUILD_EXAMPLE "Should the example main_{{ model.name }} be build?" OFF) |
||||
{%- if solver_options.integrator_type != "DISCRETE" %} |
||||
option(BUILD_SIM_EXAMPLE "Should the simulation example main_sim_{{ model.name }} be build?" OFF) |
||||
option(BUILD_ACADOS_SIM_SOLVER_LIB "Should the simulation solver library acados_sim_solver_{{ model.name }} be build?" OFF) |
||||
{%- endif %} |
||||
|
||||
# object target names |
||||
set(MODEL_OBJ model_{{ model.name }}) |
||||
set(OCP_OBJ ocp_{{ model.name }}) |
||||
set(SIM_OBJ sim_{{ model.name }}) |
||||
|
||||
# model |
||||
set(MODEL_SRC |
||||
{%- if solver_options.integrator_type == "ERK" %} |
||||
{{ model.name }}_model/{{ model.name }}_expl_ode_fun.c |
||||
{{ model.name }}_model/{{ model.name }}_expl_vde_forw.c |
||||
{%- if hessian_approx == "EXACT" %} |
||||
{{ model.name }}_model/{{ model.name }}_expl_ode_hess.c |
||||
{%- endif %} |
||||
{%- elif solver_options.integrator_type == "IRK" %} |
||||
{{ model.name }}_model/{{ model.name }}_impl_dae_fun.c |
||||
{{ model.name }}_model/{{ model.name }}_impl_dae_fun_jac_x_xdot_z.c |
||||
{{ model.name }}_model/{{ model.name }}_impl_dae_jac_x_xdot_u_z.c |
||||
{%- if hessian_approx == "EXACT" %} |
||||
{{ model.name }}_model/{{ model.name }}_impl_dae_hess.c |
||||
{%- endif %} |
||||
{%- elif solver_options.integrator_type == "LIFTED_IRK" %} |
||||
{{ model.name }}_model/{{ model.name }}_impl_dae_fun.c |
||||
{{ model.name }}_model/{{ model.name }}_impl_dae_fun_jac_x_xdot_u.c |
||||
{%- if hessian_approx == "EXACT" %} |
||||
{{ model.name }}_model/{{ model.name }}_impl_dae_hess.c |
||||
{%- endif %} |
||||
{%- elif solver_options.integrator_type == "GNSF" %} |
||||
{% if model.gnsf.purely_linear != 1 %} |
||||
{{ model.name }}_model/{{ model.name }}_gnsf_phi_fun.c |
||||
{{ model.name }}_model/{{ model.name }}_gnsf_phi_fun_jac_y.c |
||||
{{ model.name }}_model/{{ model.name }}_gnsf_phi_jac_y_uhat.c |
||||
{% if model.gnsf.nontrivial_f_LO == 1 %} |
||||
{{ model.name }}_model/{{ model.name }}_gnsf_f_lo_fun_jac_x1k1uz.c |
||||
{%- endif %} |
||||
{%- endif %} |
||||
{{ model.name }}_model/{{ model.name }}_gnsf_get_matrices_fun.c |
||||
{%- elif solver_options.integrator_type == "DISCRETE" %} |
||||
{%- if model.dyn_ext_fun_type == "casadi" %} |
||||
{{ model.name }}_model/{{ model.name }}_dyn_disc_phi_fun.c |
||||
{{ model.name }}_model/{{ model.name }}_dyn_disc_phi_fun_jac.c |
||||
{%- if hessian_approx == "EXACT" %} |
||||
{{ model.name }}_model/{{ model.name }}_dyn_disc_phi_fun_jac_hess.c |
||||
{%- endif %} |
||||
{%- else %} |
||||
{{ model.name }}_model/{{ model.dyn_source_discrete }} |
||||
{%- endif %} |
||||
{%- endif -%} |
||||
) |
||||
add_library(${MODEL_OBJ} OBJECT ${MODEL_SRC} ) |
||||
|
||||
# optimal control problem - mostly CasADi exports |
||||
if(${BUILD_ACADOS_SOLVER_LIB} OR ${BUILD_ACADOS_OCP_SOLVER_LIB} OR ${BUILD_EXAMPLE}) |
||||
set(OCP_SRC |
||||
{%- if constr_type == "BGP" and dims_nphi > 0 %} |
||||
{{ model.name }}_constraints/{{ model.name }}_phi_constraint.c |
||||
{%- endif %} |
||||
{%- if constr_type_e == "BGP" and dims_nphi_e > 0 %} |
||||
{{ model.name }}_constraints/{{ model.name }}_phi_e_constraint.c |
||||
{%- endif %} |
||||
|
||||
{%- if constr_type == "BGH" and dims_nh > 0 %} |
||||
{{ model.name }}_constraints/{{ model.name }}_constr_h_fun_jac_uxt_zt.c |
||||
{{ model.name }}_constraints/{{ model.name }}_constr_h_fun.c |
||||
{%- if hessian_approx == "EXACT" %} |
||||
{{ model.name }}_constraints/{{ model.name }}_constr_h_fun_jac_uxt_zt_hess.c |
||||
{%- endif %} |
||||
{%- endif %} |
||||
|
||||
{%- if constr_type_e == "BGH" and dims_nh_e > 0 %} |
||||
{{ model.name }}_constraints/{{ model.name }}_constr_h_e_fun_jac_uxt_zt.c |
||||
{{ model.name }}_constraints/{{ model.name }}_constr_h_e_fun.c |
||||
{%- if hessian_approx == "EXACT" %} |
||||
{{ model.name }}_constraints/{{ model.name }}_constr_h_e_fun_jac_uxt_zt_hess.c |
||||
{%- endif %} |
||||
{%- endif %} |
||||
|
||||
{%- if cost_type_0 == "NONLINEAR_LS" %} |
||||
{{ model.name }}_cost/{{ model.name }}_cost_y_0_fun.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_y_0_fun_jac_ut_xt.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_y_0_hess.c |
||||
{%- elif cost_type_0 == "EXTERNAL" %} |
||||
{%- if cost.cost_ext_fun_type_0 == "casadi" %} |
||||
{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_0_fun.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_0_fun_jac.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_0_fun_jac_hess.c |
||||
{%- else %} |
||||
{{ model.name }}_cost/{{ cost.cost_source_ext_cost_0 }} |
||||
{%- endif %} |
||||
{%- endif %} |
||||
{%- if cost_type == "NONLINEAR_LS" %} |
||||
{{ model.name }}_cost/{{ model.name }}_cost_y_fun.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_y_fun_jac_ut_xt.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_y_hess.c |
||||
{%- elif cost_type == "EXTERNAL" %} |
||||
{%- if cost.cost_ext_fun_type == "casadi" %} |
||||
{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_fun.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_fun_jac.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_fun_jac_hess.c |
||||
{%- elif cost.cost_source_ext_cost != cost.cost_source_ext_cost_0 %} |
||||
{{ model.name }}_cost/{{ cost.cost_source_ext_cost }} |
||||
{%- endif %} |
||||
{%- endif %} |
||||
{%- if cost_type_e == "NONLINEAR_LS" %} |
||||
{{ model.name }}_cost/{{ model.name }}_cost_y_e_fun.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_y_e_fun_jac_ut_xt.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_y_e_hess.c |
||||
{%- elif cost_type_e == "EXTERNAL" %} |
||||
{%- if cost.cost_ext_fun_type_e == "casadi" %} |
||||
{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_e_fun.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_e_fun_jac.c |
||||
{{ model.name }}_cost/{{ model.name }}_cost_ext_cost_e_fun_jac_hess.c |
||||
{%- elif cost.cost_source_ext_cost_e != cost.cost_source_ext_cost_0 %} |
||||
{{ model.name }}_cost/{{ cost.cost_source_ext_cost_e }} |
||||
{%- endif %} |
||||
{%- endif %} |
||||
acados_solver_{{ model.name }}.c) |
||||
add_library(${OCP_OBJ} OBJECT ${OCP_SRC}) |
||||
endif() |
||||
|
||||
{%- if solver_options.integrator_type != "DISCRETE" %} |
||||
# for sim solver |
||||
if(${BUILD_ACADOS_SOLVER_LIB} OR ${BUILD_EXAMPLE} |
||||
{%- if solver_options.integrator_type != "DISCRETE" %} |
||||
OR ${BUILD_SIM_EXAMPLE} OR ${BUILD_ACADOS_SIM_SOLVER_LIB} |
||||
{%- endif -%} |
||||
) |
||||
set(SIM_SRC acados_sim_solver_{{ model.name }}.c) |
||||
add_library(${SIM_OBJ} OBJECT ${SIM_SRC}) |
||||
endif() |
||||
{%- endif %} |
||||
|
||||
# for target example |
||||
set(EX_SRC main_{{ model.name }}.c) |
||||
set(EX_EXE main_{{ model.name }}) |
||||
|
||||
{%- if model_external_shared_lib_dir and model_external_shared_lib_name %} |
||||
set(EXTERNAL_DIR {{ model_external_shared_lib_dir }}) |
||||
set(EXTERNAL_LIB {{ model_external_shared_lib_name }}) |
||||
{%- else %} |
||||
set(EXTERNAL_DIR) |
||||
set(EXTERNAL_LIB) |
||||
{%- endif %} |
||||
|
||||
# set some search paths for preprocessor and linker |
||||
set(ACADOS_INCLUDE_PATH {{ acados_include_path }} CACHE PATH "Define the path which contains the include directory for acados.") |
||||
set(ACADOS_LIB_PATH {{ acados_lib_path }} CACHE PATH "Define the path which contains the lib directory for acados.") |
||||
|
||||
# c-compiler flags for debugging |
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb") |
||||
|
||||
set(CMAKE_C_FLAGS " |
||||
{%- if qp_solver == "FULL_CONDENSING_QPOASES" -%} |
||||
-DACADOS_WITH_QPOASES |
||||
{%- endif -%} |
||||
{%- if qp_solver == "PARTIAL_CONDENSING_OSQP" -%} |
||||
-DACADOS_WITH_OSQP |
||||
{%- endif -%} |
||||
{%- if qp_solver == "PARTIAL_CONDENSING_QPDUNES" -%} |
||||
-DACADOS_WITH_QPDUNES |
||||
{%- endif -%} |
||||
-fPIC -std=c99 {{ openmp_flag }}") |
||||
#-fno-diagnostics-show-line-numbers -g |
||||
|
||||
include_directories( |
||||
${ACADOS_INCLUDE_PATH} |
||||
${ACADOS_INCLUDE_PATH}/acados |
||||
${ACADOS_INCLUDE_PATH}/blasfeo/include |
||||
${ACADOS_INCLUDE_PATH}/hpipm/include |
||||
{%- if qp_solver == "FULL_CONDENSING_QPOASES" %} |
||||
${ACADOS_INCLUDE_PATH}/qpOASES_e/ |
||||
{%- endif %} |
||||
) |
||||
|
||||
# linker flags |
||||
link_directories(${ACADOS_LIB_PATH}) |
||||
|
||||
# link to libraries |
||||
if(UNIX) |
||||
link_libraries(acados hpipm blasfeo m {{ link_libs }}) |
||||
else() |
||||
link_libraries(acados hpipm blasfeo {{ link_libs }}) |
||||
endif() |
||||
|
||||
# the targets |
||||
|
||||
# bundled_shared_lib |
||||
if(${BUILD_ACADOS_SOLVER_LIB}) |
||||
set(LIB_ACADOS_SOLVER acados_solver_{{ model.name }}) |
||||
add_library(${LIB_ACADOS_SOLVER} SHARED $<TARGET_OBJECTS:${MODEL_OBJ}> $<TARGET_OBJECTS:${OCP_OBJ}> |
||||
{%- if solver_options.integrator_type != "DISCRETE" %} |
||||
$<TARGET_OBJECTS:${SIM_OBJ}> |
||||
{%- endif -%} |
||||
) |
||||
install(TARGETS ${LIB_ACADOS_SOLVER} DESTINATION ${CMAKE_INSTALL_PREFIX}) |
||||
endif(${BUILD_ACADOS_SOLVER_LIB}) |
||||
|
||||
# ocp_shared_lib |
||||
if(${BUILD_ACADOS_OCP_SOLVER_LIB}) |
||||
set(LIB_ACADOS_OCP_SOLVER acados_ocp_solver_{{ model.name }}) |
||||
add_library(${LIB_ACADOS_OCP_SOLVER} SHARED $<TARGET_OBJECTS:${MODEL_OBJ}> $<TARGET_OBJECTS:${OCP_OBJ}>) |
||||
# Specify libraries or flags to use when linking a given target and/or its dependents. |
||||
target_link_libraries(${LIB_ACADOS_OCP_SOLVER} PRIVATE ${EXTERNAL_LIB}) |
||||
target_link_directories(${LIB_ACADOS_OCP_SOLVER} PRIVATE ${EXTERNAL_DIR}) |
||||
install(TARGETS ${LIB_ACADOS_OCP_SOLVER} DESTINATION ${CMAKE_INSTALL_PREFIX}) |
||||
endif(${BUILD_ACADOS_OCP_SOLVER_LIB}) |
||||
|
||||
# example |
||||
if(${BUILD_EXAMPLE}) |
||||
add_executable(${EX_EXE} ${EX_SRC} $<TARGET_OBJECTS:${MODEL_OBJ}> $<TARGET_OBJECTS:${OCP_OBJ}> |
||||
{%- if solver_options.integrator_type != "DISCRETE" %} |
||||
$<TARGET_OBJECTS:${SIM_OBJ}> |
||||
{%- endif -%} |
||||
) |
||||
install(TARGETS ${EX_EXE} DESTINATION ${CMAKE_INSTALL_PREFIX}) |
||||
endif(${BUILD_EXAMPLE}) |
||||
|
||||
{% if solver_options.integrator_type != "DISCRETE" -%} |
||||
# example_sim |
||||
if(${BUILD_SIM_EXAMPLE}) |
||||
set(EX_SIM_SRC main_sim_{{ model.name }}.c) |
||||
set(EX_SIM_EXE main_sim_{{ model.name }}) |
||||
add_executable(${EX_SIM_EXE} ${EX_SIM_SRC} $<TARGET_OBJECTS:${MODEL_OBJ}> $<TARGET_OBJECTS:${SIM_OBJ}>) |
||||
install(TARGETS ${EX_SIM_EXE} DESTINATION ${CMAKE_INSTALL_PREFIX}) |
||||
endif(${BUILD_SIM_EXAMPLE}) |
||||
|
||||
# sim_shared_lib |
||||
if(${BUILD_ACADOS_SIM_SOLVER_LIB}) |
||||
set(LIB_ACADOS_SIM_SOLVER acados_sim_solver_{{ model.name }}) |
||||
add_library(${LIB_ACADOS_SIM_SOLVER} SHARED $<TARGET_OBJECTS:${MODEL_OBJ}> $<TARGET_OBJECTS:${SIM_OBJ}>) |
||||
install(TARGETS ${LIB_ACADOS_SIM_SOLVER} DESTINATION ${CMAKE_INSTALL_PREFIX}) |
||||
endif(${BUILD_ACADOS_SIM_SOLVER_LIB}) |
||||
{%- endif %} |
||||
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,84 @@ |
||||
/**************************************************************************************************
|
||||
* * |
||||
* This file is part of BLASFEO. * |
||||
* * |
||||
* BLASFEO -- BLAS For Embedded Optimization. * |
||||
* Copyright (C) 2019 by Gianluca Frison. * |
||||
* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * |
||||
* All rights reserved. * |
||||
* * |
||||
* The 2-Clause BSD License * |
||||
* * |
||||
* Redistribution and use in source and binary forms, with or without * |
||||
* modification, are permitted provided that the following conditions are met: * |
||||
* * |
||||
* 1. Redistributions of source code must retain the above copyright notice, this * |
||||
* list of conditions and the following disclaimer. * |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, * |
||||
* this list of conditions and the following disclaimer in the documentation * |
||||
* and/or other materials provided with the distribution. * |
||||
* * |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * |
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * |
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * |
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * |
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * |
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * |
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * |
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
||||
* * |
||||
* Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * |
||||
* * |
||||
**************************************************************************************************/ |
||||
|
||||
#ifndef BLASFEO_D_BLASFEO_HP_API_H_ |
||||
#define BLASFEO_D_BLASFEO_HP_API_H_ |
||||
|
||||
|
||||
|
||||
#include "blasfeo_common.h" |
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
|
||||
|
||||
//
|
||||
// level 3 BLAS
|
||||
//
|
||||
|
||||
// dense
|
||||
|
||||
|
||||
// D <= beta * C + alpha * A^T * B
|
||||
void blasfeo_hp_dgemm_tn(int m, int n, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); |
||||
// D <= beta * C + alpha * A * B^T; C, D lower triangular
|
||||
void blasfeo_hp_dsyrk_ln(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); |
||||
// D <= beta * C + alpha * A * A^T ; C, D lower triangular
|
||||
void blasfeo_hp_dsyrk3_ln(int m, int k, double alpha, struct blasfeo_dmat *sA, int ai, int aj, double beta, struct blasfeo_dmat *sC, int ci, int cj, struct blasfeo_dmat *sD, int di, int dj); |
||||
// D <= alpha * B * A^{-T} , with A lower triangular
|
||||
void blasfeo_hp_dtrsm_rltn(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dmat *sB, int bi, int bj, struct blasfeo_dmat *sD, int di, int dj); |
||||
|
||||
|
||||
//
|
||||
// level 2 BLAS
|
||||
//
|
||||
|
||||
// dense
|
||||
|
||||
// z <= beta * y + alpha * A * x
|
||||
void blasfeo_hp_dgemv_n(int m, int n, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi); |
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif // BLASFEO_D_BLASFEO_HP_API_H_
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue