Files
dragonpilot/selfdrive/controls/lib/lateral_mpc/libmpc_py.py
HaraldSchafer 0e49919ab9 Cleanup pathplanner (#19827)
* no divide by 0

* misc cleanup

* final fixes

* remove last polys

* new ref

* fix test

* update again
2021-01-19 00:02:53 -08:00

33 lines
822 B
Python

import os
from cffi import FFI
from common.ffi_wrapper import suffix
mpc_dir = os.path.dirname(os.path.abspath(__file__))
libmpc_fn = os.path.join(mpc_dir, "libmpc"+suffix())
ffi = FFI()
ffi.cdef("""
typedef struct {
double x, y, psi, tire_angle, tire_angle_rate;
} state_t;
int N = 16;
typedef struct {
double x[N+1];
double y[N+1];
double psi[N+1];
double tire_angle[N+1];
double tire_angle_rate[N];
double cost;
} log_t;
void init(double pathCost, double headingCost, double steerRateCost);
void init_weights(double pathCost, double headingCost, double steerRateCost);
int run_mpc(state_t * x0, log_t * solution,
double v_ego, double curvature_factor, double rotation_radius,
double target_y[N+1], double target_psi[N+1]);
""")
libmpc = ffi.dlopen(libmpc_fn)