long mpc: add acados solver type stub so it type checks without a build (#39502)

This commit is contained in:
Adeeb Shihadeh
2026-11-28 12:18:58 -06:00
committed by firestar5683
parent c04969a0ae
commit c0b3f8ea35
2 changed files with 30 additions and 0 deletions
@@ -0,0 +1,27 @@
# acados_template's Cython solver, compiled against c_generated_code by the SConscript
from typing import Any
import numpy as np
class AcadosOcpSolverCython:
def __init__(self, model_name: str, nlp_solver_type: str, N: int) -> None: ...
def solve_for_x0(self, x0_bar: np.ndarray) -> np.ndarray: ...
def solve(self) -> int: ...
def reset(self, reset_qp_solver_mem: int = 1) -> int: ...
def custom_update(self, data_: np.ndarray) -> int: ...
def set_new_time_steps(self, new_time_steps: np.ndarray) -> None: ...
def update_qp_solver_cond_N(self, qp_solver_cond_N: int) -> None: ...
def eval_param_sens(self, index: int, stage: int = 0, field: str = "ex") -> None: ...
def get(self, stage: int, field_: str) -> np.ndarray: ...
def print_statistics(self) -> None: ...
def store_iterate(self, filename: str = '', overwrite: bool = False) -> None: ...
def load_iterate(self, filename: str) -> None: ...
def get_stats(self, field_: str) -> Any: ...
def get_cost(self) -> float: ...
def get_residuals(self, recompute: bool = False) -> np.ndarray: ...
def set(self, stage: int, field_: str, value_: Any) -> None: ...
def cost_set(self, stage: int, field_: str, value_: Any) -> None: ...
def constraints_set(self, stage: int, field_: str, value_: Any) -> None: ...
def get_from_qp_in(self, stage: int, field_: str) -> np.ndarray: ...
def options_set(self, field_: str, value_: Any) -> None: ...
def set_params_sparse(self, stage: int, idx_values_: np.ndarray, param_values_: np.ndarray) -> None: ...
@@ -3,6 +3,7 @@ import os
import time
import math
from dataclasses import dataclass
from typing import TYPE_CHECKING
import numpy as np
from openpilot.cereal import log
from opendbc.car.interfaces import ACCEL_MIN, ACCEL_MAX
@@ -15,6 +16,8 @@ from openpilot.selfdrive.controls.radard import _LEAD_ACCEL_TAU, RADAR_TO_CAMERA
if __name__ == '__main__': # generating code
from acados.acados_template import AcadosModel, AcadosOcp, AcadosOcpSolver
elif TYPE_CHECKING:
from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.acados_ocp_solver_pyx import AcadosOcpSolverCython
else:
from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.c_generated_code.acados_ocp_solver_pyx import AcadosOcpSolverCython