mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 08:53:54 +08:00
* refactor * needs casting * tests pass * fix that test * refactor in controls * lets not go crazy * change of names * use constants * better naming * renamed * soft constraints * compile slack variables * rm git conflict * add slack variables * unused * new edition * fcw * fix tests * dividing causes problems * was way too slow * take a step back * byeeee * for another time * bad idxs * little more cpu for cruise mpc * update refs * these limits seem fine * rename * test model timings fails sometimes * add default * save some cpu * Revert "little more cpu for cruise mpc" This reverts commit f0a8163ec90e8dc1eabb3c4a4268ad330d23374d. * Revert "test model timings fails sometimes" This reverts commit d259d845710ed2cbeb28b383e2600476527d4838. * update refs * less cpu * Revert "Revert "test model timings fails sometimes"" This reverts commit e0263050d9929bfc7ee70c9788234541a4a8461c. * Revert "less cpu" This reverts commit 679007472bc2013e7fafb7b17de7a43d6f82359a. * cleanup * not too much until we clean up mpc * more cost on jerk * change ref * add todo * new ref * indentation
35 lines
753 B
Python
35 lines
753 B
Python
import os
|
|
|
|
from cffi import FFI
|
|
from common.ffi_wrapper import suffix
|
|
|
|
mpc_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)))
|
|
libmpc_fn = os.path.join(mpc_dir, "libmpc"+suffix())
|
|
|
|
ffi = FFI()
|
|
ffi.cdef("""
|
|
const int MPC_N = 32;
|
|
|
|
typedef struct {
|
|
double x_ego, v_ego, a_ego;
|
|
} state_t;
|
|
|
|
|
|
typedef struct {
|
|
double x_ego[MPC_N+1];
|
|
double v_ego[MPC_N+1];
|
|
double a_ego[MPC_N+1];
|
|
double t[MPC_N+1];
|
|
double j_ego[MPC_N];
|
|
double cost;
|
|
} log_t;
|
|
|
|
|
|
void init(double xCost, double vCost, double aCost, double jerkCost, double constraintCost);
|
|
int run_mpc(state_t * x0, log_t * solution,
|
|
double target_x[MPC_N+1], double target_v[MPC_N+1], double target_a[MPC_N+1],
|
|
double min_a, double max_a);
|
|
""")
|
|
|
|
libmpc = ffi.dlopen(libmpc_fn)
|