You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.5 KiB
78 lines
2.5 KiB
Import('env', 'envCython', 'arch', 'common')
|
|
|
|
gen = "c_generated_code"
|
|
|
|
casadi_model = [
|
|
f'{gen}/lat_model/lat_expl_ode_fun.c',
|
|
f'{gen}/lat_model/lat_expl_vde_forw.c',
|
|
]
|
|
|
|
casadi_cost_y = [
|
|
f'{gen}/lat_cost/lat_cost_y_fun.c',
|
|
f'{gen}/lat_cost/lat_cost_y_fun_jac_ut_xt.c',
|
|
f'{gen}/lat_cost/lat_cost_y_hess.c',
|
|
]
|
|
|
|
casadi_cost_e = [
|
|
f'{gen}/lat_cost/lat_cost_y_e_fun.c',
|
|
f'{gen}/lat_cost/lat_cost_y_e_fun_jac_ut_xt.c',
|
|
f'{gen}/lat_cost/lat_cost_y_e_hess.c',
|
|
]
|
|
|
|
casadi_cost_0 = [
|
|
f'{gen}/lat_cost/lat_cost_y_0_fun.c',
|
|
f'{gen}/lat_cost/lat_cost_y_0_fun_jac_ut_xt.c',
|
|
f'{gen}/lat_cost/lat_cost_y_0_hess.c',
|
|
]
|
|
|
|
build_files = [f'{gen}/acados_solver_lat.c'] + casadi_model + casadi_cost_y + casadi_cost_e + casadi_cost_0
|
|
|
|
# extra generated files used to trigger a rebuild
|
|
generated_files = [
|
|
f'{gen}/Makefile',
|
|
|
|
f'{gen}/main_lat.c',
|
|
f'{gen}/acados_solver_lat.h',
|
|
f'{gen}/acados_solver.pxd',
|
|
|
|
f'{gen}/lat_model/lat_expl_vde_adj.c',
|
|
|
|
f'{gen}/lat_model/lat_model.h',
|
|
f'{gen}/lat_cost/lat_cost_y_fun.h',
|
|
f'{gen}/lat_cost/lat_cost_y_e_fun.h',
|
|
f'{gen}/lat_cost/lat_cost_y_0_fun.h',
|
|
] + build_files
|
|
|
|
lenv = env.Clone()
|
|
lenv.Clean(generated_files, Dir(gen))
|
|
|
|
lenv.Command(generated_files,
|
|
["lat_mpc.py"],
|
|
f"cd {Dir('.').abspath} && python3 lat_mpc.py")
|
|
|
|
lenv["CFLAGS"].append("-DACADOS_WITH_QPOASES")
|
|
lenv["CXXFLAGS"].append("-DACADOS_WITH_QPOASES")
|
|
lenv["CCFLAGS"].append("-Wno-unused")
|
|
if arch != "Darwin":
|
|
lenv["LINKFLAGS"].append("-Wl,--disable-new-dtags")
|
|
lib_solver = lenv.SharedLibrary(f"{gen}/acados_ocp_solver_lat",
|
|
build_files,
|
|
LIBS=['m', 'acados', 'hpipm', 'blasfeo', 'qpOASES_e'])
|
|
|
|
# generate cython stuff
|
|
acados_ocp_solver_pyx = File("#pyextra/acados_template/acados_ocp_solver_pyx.pyx")
|
|
acados_ocp_solver_common = File("#pyextra/acados_template/acados_solver_common.pxd")
|
|
libacados_ocp_solver_pxd = File(f'{gen}/acados_solver.pxd')
|
|
libacados_ocp_solver_c = File(f'{gen}/acados_ocp_solver_pyx.c')
|
|
|
|
lenv2 = envCython.Clone()
|
|
lenv2["LINKFLAGS"] += [lib_solver[0].get_labspath()]
|
|
lenv2.Command(libacados_ocp_solver_c,
|
|
[acados_ocp_solver_pyx, acados_ocp_solver_common, libacados_ocp_solver_pxd],
|
|
f'cython' + \
|
|
f' -o {libacados_ocp_solver_c.get_labspath()}' + \
|
|
f' -I {libacados_ocp_solver_pxd.get_dir().get_labspath()}' + \
|
|
f' -I {acados_ocp_solver_common.get_dir().get_labspath()}' + \
|
|
f' {acados_ocp_solver_pyx.get_labspath()}')
|
|
lib_cython = lenv2.Program(f'{gen}/acados_ocp_solver_pyx.so', [libacados_ocp_solver_c])
|
|
lenv2.Depends(lib_cython, lib_solver)
|
|
|