mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-08 00:53:48 +08:00
Chestnut Diagnostics
This commit is contained in:
Binary file not shown.
@@ -774,6 +774,7 @@ struct ChestnutState {
|
||||
pcieLtssm @7 :UInt8;
|
||||
supplyVoltage @8 :UInt16; # mV
|
||||
supplyCurrent @9 :Int16; # mA
|
||||
supplyFault @10 :Bool;
|
||||
}
|
||||
|
||||
struct RadarState @0x9a185389d6fdd05f {
|
||||
|
||||
Binary file not shown.
@@ -113,6 +113,12 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"ObdMultiplexingChanged", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, BOOL}},
|
||||
{"ObdMultiplexingEnabled", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, BOOL}},
|
||||
{"Offroad_CarUnrecognized", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, JSON}},
|
||||
{"Offroad_ChestnutNotDetected", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, JSON}},
|
||||
{"Offroad_ChestnutOverheated", {CLEAR_ON_MANAGER_START, JSON}},
|
||||
{"Offroad_ChestnutPcieUnavailable", {CLEAR_ON_MANAGER_START, JSON}},
|
||||
{"Offroad_ChestnutUncompiled", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, JSON}},
|
||||
{"Offroad_ChestnutUpdateFailed", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, JSON}},
|
||||
{"Offroad_ChestnutUsbSlow", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, JSON}},
|
||||
{"Offroad_ConnectivityNeeded", {CLEAR_ON_MANAGER_START, JSON}},
|
||||
{"Offroad_ConnectivityNeededPrompt", {CLEAR_ON_MANAGER_START, JSON}},
|
||||
{"Offroad_ExcessiveActuation", {PERSISTENT, JSON}},
|
||||
|
||||
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
extern const uint8_t gitversion[19];
|
||||
const uint8_t gitversion[19] = "DEV-a5d7db3b-DEBUG";
|
||||
const uint8_t gitversion[19] = "DEV-c03d06b4-DEBUG";
|
||||
|
||||
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.
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.
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.
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.
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.
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
DEV-a5d7db3b-DEBUG
|
||||
DEV-c03d06b4-DEBUG
|
||||
@@ -45,326 +45,326 @@ const static double MAHA_THRESH_31 = 3.8414588206941227;
|
||||
* *
|
||||
* This file is part of 'ekf' *
|
||||
******************************************************************************/
|
||||
void err_fun(double *nom_x, double *delta_x, double *out_7751375231448978305) {
|
||||
out_7751375231448978305[0] = delta_x[0] + nom_x[0];
|
||||
out_7751375231448978305[1] = delta_x[1] + nom_x[1];
|
||||
out_7751375231448978305[2] = delta_x[2] + nom_x[2];
|
||||
out_7751375231448978305[3] = delta_x[3] + nom_x[3];
|
||||
out_7751375231448978305[4] = delta_x[4] + nom_x[4];
|
||||
out_7751375231448978305[5] = delta_x[5] + nom_x[5];
|
||||
out_7751375231448978305[6] = delta_x[6] + nom_x[6];
|
||||
out_7751375231448978305[7] = delta_x[7] + nom_x[7];
|
||||
out_7751375231448978305[8] = delta_x[8] + nom_x[8];
|
||||
void err_fun(double *nom_x, double *delta_x, double *out_789804740016769707) {
|
||||
out_789804740016769707[0] = delta_x[0] + nom_x[0];
|
||||
out_789804740016769707[1] = delta_x[1] + nom_x[1];
|
||||
out_789804740016769707[2] = delta_x[2] + nom_x[2];
|
||||
out_789804740016769707[3] = delta_x[3] + nom_x[3];
|
||||
out_789804740016769707[4] = delta_x[4] + nom_x[4];
|
||||
out_789804740016769707[5] = delta_x[5] + nom_x[5];
|
||||
out_789804740016769707[6] = delta_x[6] + nom_x[6];
|
||||
out_789804740016769707[7] = delta_x[7] + nom_x[7];
|
||||
out_789804740016769707[8] = delta_x[8] + nom_x[8];
|
||||
}
|
||||
void inv_err_fun(double *nom_x, double *true_x, double *out_1186045100449225538) {
|
||||
out_1186045100449225538[0] = -nom_x[0] + true_x[0];
|
||||
out_1186045100449225538[1] = -nom_x[1] + true_x[1];
|
||||
out_1186045100449225538[2] = -nom_x[2] + true_x[2];
|
||||
out_1186045100449225538[3] = -nom_x[3] + true_x[3];
|
||||
out_1186045100449225538[4] = -nom_x[4] + true_x[4];
|
||||
out_1186045100449225538[5] = -nom_x[5] + true_x[5];
|
||||
out_1186045100449225538[6] = -nom_x[6] + true_x[6];
|
||||
out_1186045100449225538[7] = -nom_x[7] + true_x[7];
|
||||
out_1186045100449225538[8] = -nom_x[8] + true_x[8];
|
||||
void inv_err_fun(double *nom_x, double *true_x, double *out_385986033898548509) {
|
||||
out_385986033898548509[0] = -nom_x[0] + true_x[0];
|
||||
out_385986033898548509[1] = -nom_x[1] + true_x[1];
|
||||
out_385986033898548509[2] = -nom_x[2] + true_x[2];
|
||||
out_385986033898548509[3] = -nom_x[3] + true_x[3];
|
||||
out_385986033898548509[4] = -nom_x[4] + true_x[4];
|
||||
out_385986033898548509[5] = -nom_x[5] + true_x[5];
|
||||
out_385986033898548509[6] = -nom_x[6] + true_x[6];
|
||||
out_385986033898548509[7] = -nom_x[7] + true_x[7];
|
||||
out_385986033898548509[8] = -nom_x[8] + true_x[8];
|
||||
}
|
||||
void H_mod_fun(double *state, double *out_5403210608595880924) {
|
||||
out_5403210608595880924[0] = 1.0;
|
||||
out_5403210608595880924[1] = 0.0;
|
||||
out_5403210608595880924[2] = 0.0;
|
||||
out_5403210608595880924[3] = 0.0;
|
||||
out_5403210608595880924[4] = 0.0;
|
||||
out_5403210608595880924[5] = 0.0;
|
||||
out_5403210608595880924[6] = 0.0;
|
||||
out_5403210608595880924[7] = 0.0;
|
||||
out_5403210608595880924[8] = 0.0;
|
||||
out_5403210608595880924[9] = 0.0;
|
||||
out_5403210608595880924[10] = 1.0;
|
||||
out_5403210608595880924[11] = 0.0;
|
||||
out_5403210608595880924[12] = 0.0;
|
||||
out_5403210608595880924[13] = 0.0;
|
||||
out_5403210608595880924[14] = 0.0;
|
||||
out_5403210608595880924[15] = 0.0;
|
||||
out_5403210608595880924[16] = 0.0;
|
||||
out_5403210608595880924[17] = 0.0;
|
||||
out_5403210608595880924[18] = 0.0;
|
||||
out_5403210608595880924[19] = 0.0;
|
||||
out_5403210608595880924[20] = 1.0;
|
||||
out_5403210608595880924[21] = 0.0;
|
||||
out_5403210608595880924[22] = 0.0;
|
||||
out_5403210608595880924[23] = 0.0;
|
||||
out_5403210608595880924[24] = 0.0;
|
||||
out_5403210608595880924[25] = 0.0;
|
||||
out_5403210608595880924[26] = 0.0;
|
||||
out_5403210608595880924[27] = 0.0;
|
||||
out_5403210608595880924[28] = 0.0;
|
||||
out_5403210608595880924[29] = 0.0;
|
||||
out_5403210608595880924[30] = 1.0;
|
||||
out_5403210608595880924[31] = 0.0;
|
||||
out_5403210608595880924[32] = 0.0;
|
||||
out_5403210608595880924[33] = 0.0;
|
||||
out_5403210608595880924[34] = 0.0;
|
||||
out_5403210608595880924[35] = 0.0;
|
||||
out_5403210608595880924[36] = 0.0;
|
||||
out_5403210608595880924[37] = 0.0;
|
||||
out_5403210608595880924[38] = 0.0;
|
||||
out_5403210608595880924[39] = 0.0;
|
||||
out_5403210608595880924[40] = 1.0;
|
||||
out_5403210608595880924[41] = 0.0;
|
||||
out_5403210608595880924[42] = 0.0;
|
||||
out_5403210608595880924[43] = 0.0;
|
||||
out_5403210608595880924[44] = 0.0;
|
||||
out_5403210608595880924[45] = 0.0;
|
||||
out_5403210608595880924[46] = 0.0;
|
||||
out_5403210608595880924[47] = 0.0;
|
||||
out_5403210608595880924[48] = 0.0;
|
||||
out_5403210608595880924[49] = 0.0;
|
||||
out_5403210608595880924[50] = 1.0;
|
||||
out_5403210608595880924[51] = 0.0;
|
||||
out_5403210608595880924[52] = 0.0;
|
||||
out_5403210608595880924[53] = 0.0;
|
||||
out_5403210608595880924[54] = 0.0;
|
||||
out_5403210608595880924[55] = 0.0;
|
||||
out_5403210608595880924[56] = 0.0;
|
||||
out_5403210608595880924[57] = 0.0;
|
||||
out_5403210608595880924[58] = 0.0;
|
||||
out_5403210608595880924[59] = 0.0;
|
||||
out_5403210608595880924[60] = 1.0;
|
||||
out_5403210608595880924[61] = 0.0;
|
||||
out_5403210608595880924[62] = 0.0;
|
||||
out_5403210608595880924[63] = 0.0;
|
||||
out_5403210608595880924[64] = 0.0;
|
||||
out_5403210608595880924[65] = 0.0;
|
||||
out_5403210608595880924[66] = 0.0;
|
||||
out_5403210608595880924[67] = 0.0;
|
||||
out_5403210608595880924[68] = 0.0;
|
||||
out_5403210608595880924[69] = 0.0;
|
||||
out_5403210608595880924[70] = 1.0;
|
||||
out_5403210608595880924[71] = 0.0;
|
||||
out_5403210608595880924[72] = 0.0;
|
||||
out_5403210608595880924[73] = 0.0;
|
||||
out_5403210608595880924[74] = 0.0;
|
||||
out_5403210608595880924[75] = 0.0;
|
||||
out_5403210608595880924[76] = 0.0;
|
||||
out_5403210608595880924[77] = 0.0;
|
||||
out_5403210608595880924[78] = 0.0;
|
||||
out_5403210608595880924[79] = 0.0;
|
||||
out_5403210608595880924[80] = 1.0;
|
||||
void H_mod_fun(double *state, double *out_4046004184415297016) {
|
||||
out_4046004184415297016[0] = 1.0;
|
||||
out_4046004184415297016[1] = 0.0;
|
||||
out_4046004184415297016[2] = 0.0;
|
||||
out_4046004184415297016[3] = 0.0;
|
||||
out_4046004184415297016[4] = 0.0;
|
||||
out_4046004184415297016[5] = 0.0;
|
||||
out_4046004184415297016[6] = 0.0;
|
||||
out_4046004184415297016[7] = 0.0;
|
||||
out_4046004184415297016[8] = 0.0;
|
||||
out_4046004184415297016[9] = 0.0;
|
||||
out_4046004184415297016[10] = 1.0;
|
||||
out_4046004184415297016[11] = 0.0;
|
||||
out_4046004184415297016[12] = 0.0;
|
||||
out_4046004184415297016[13] = 0.0;
|
||||
out_4046004184415297016[14] = 0.0;
|
||||
out_4046004184415297016[15] = 0.0;
|
||||
out_4046004184415297016[16] = 0.0;
|
||||
out_4046004184415297016[17] = 0.0;
|
||||
out_4046004184415297016[18] = 0.0;
|
||||
out_4046004184415297016[19] = 0.0;
|
||||
out_4046004184415297016[20] = 1.0;
|
||||
out_4046004184415297016[21] = 0.0;
|
||||
out_4046004184415297016[22] = 0.0;
|
||||
out_4046004184415297016[23] = 0.0;
|
||||
out_4046004184415297016[24] = 0.0;
|
||||
out_4046004184415297016[25] = 0.0;
|
||||
out_4046004184415297016[26] = 0.0;
|
||||
out_4046004184415297016[27] = 0.0;
|
||||
out_4046004184415297016[28] = 0.0;
|
||||
out_4046004184415297016[29] = 0.0;
|
||||
out_4046004184415297016[30] = 1.0;
|
||||
out_4046004184415297016[31] = 0.0;
|
||||
out_4046004184415297016[32] = 0.0;
|
||||
out_4046004184415297016[33] = 0.0;
|
||||
out_4046004184415297016[34] = 0.0;
|
||||
out_4046004184415297016[35] = 0.0;
|
||||
out_4046004184415297016[36] = 0.0;
|
||||
out_4046004184415297016[37] = 0.0;
|
||||
out_4046004184415297016[38] = 0.0;
|
||||
out_4046004184415297016[39] = 0.0;
|
||||
out_4046004184415297016[40] = 1.0;
|
||||
out_4046004184415297016[41] = 0.0;
|
||||
out_4046004184415297016[42] = 0.0;
|
||||
out_4046004184415297016[43] = 0.0;
|
||||
out_4046004184415297016[44] = 0.0;
|
||||
out_4046004184415297016[45] = 0.0;
|
||||
out_4046004184415297016[46] = 0.0;
|
||||
out_4046004184415297016[47] = 0.0;
|
||||
out_4046004184415297016[48] = 0.0;
|
||||
out_4046004184415297016[49] = 0.0;
|
||||
out_4046004184415297016[50] = 1.0;
|
||||
out_4046004184415297016[51] = 0.0;
|
||||
out_4046004184415297016[52] = 0.0;
|
||||
out_4046004184415297016[53] = 0.0;
|
||||
out_4046004184415297016[54] = 0.0;
|
||||
out_4046004184415297016[55] = 0.0;
|
||||
out_4046004184415297016[56] = 0.0;
|
||||
out_4046004184415297016[57] = 0.0;
|
||||
out_4046004184415297016[58] = 0.0;
|
||||
out_4046004184415297016[59] = 0.0;
|
||||
out_4046004184415297016[60] = 1.0;
|
||||
out_4046004184415297016[61] = 0.0;
|
||||
out_4046004184415297016[62] = 0.0;
|
||||
out_4046004184415297016[63] = 0.0;
|
||||
out_4046004184415297016[64] = 0.0;
|
||||
out_4046004184415297016[65] = 0.0;
|
||||
out_4046004184415297016[66] = 0.0;
|
||||
out_4046004184415297016[67] = 0.0;
|
||||
out_4046004184415297016[68] = 0.0;
|
||||
out_4046004184415297016[69] = 0.0;
|
||||
out_4046004184415297016[70] = 1.0;
|
||||
out_4046004184415297016[71] = 0.0;
|
||||
out_4046004184415297016[72] = 0.0;
|
||||
out_4046004184415297016[73] = 0.0;
|
||||
out_4046004184415297016[74] = 0.0;
|
||||
out_4046004184415297016[75] = 0.0;
|
||||
out_4046004184415297016[76] = 0.0;
|
||||
out_4046004184415297016[77] = 0.0;
|
||||
out_4046004184415297016[78] = 0.0;
|
||||
out_4046004184415297016[79] = 0.0;
|
||||
out_4046004184415297016[80] = 1.0;
|
||||
}
|
||||
void f_fun(double *state, double dt, double *out_3846473641327680019) {
|
||||
out_3846473641327680019[0] = state[0];
|
||||
out_3846473641327680019[1] = state[1];
|
||||
out_3846473641327680019[2] = state[2];
|
||||
out_3846473641327680019[3] = state[3];
|
||||
out_3846473641327680019[4] = state[4];
|
||||
out_3846473641327680019[5] = dt*((-state[4] + (-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])/(mass*state[4]))*state[6] - 9.8100000000000005*state[8] + stiffness_front*(-state[2] - state[3] + state[7])*state[0]/(mass*state[1]) + (-stiffness_front*state[0] - stiffness_rear*state[0])*state[5]/(mass*state[4])) + state[5];
|
||||
out_3846473641327680019[6] = dt*(center_to_front*stiffness_front*(-state[2] - state[3] + state[7])*state[0]/(rotational_inertia*state[1]) + (-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])*state[5]/(rotational_inertia*state[4]) + (-pow(center_to_front, 2)*stiffness_front*state[0] - pow(center_to_rear, 2)*stiffness_rear*state[0])*state[6]/(rotational_inertia*state[4])) + state[6];
|
||||
out_3846473641327680019[7] = state[7];
|
||||
out_3846473641327680019[8] = state[8];
|
||||
void f_fun(double *state, double dt, double *out_467921565295650481) {
|
||||
out_467921565295650481[0] = state[0];
|
||||
out_467921565295650481[1] = state[1];
|
||||
out_467921565295650481[2] = state[2];
|
||||
out_467921565295650481[3] = state[3];
|
||||
out_467921565295650481[4] = state[4];
|
||||
out_467921565295650481[5] = dt*((-state[4] + (-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])/(mass*state[4]))*state[6] - 9.8100000000000005*state[8] + stiffness_front*(-state[2] - state[3] + state[7])*state[0]/(mass*state[1]) + (-stiffness_front*state[0] - stiffness_rear*state[0])*state[5]/(mass*state[4])) + state[5];
|
||||
out_467921565295650481[6] = dt*(center_to_front*stiffness_front*(-state[2] - state[3] + state[7])*state[0]/(rotational_inertia*state[1]) + (-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])*state[5]/(rotational_inertia*state[4]) + (-pow(center_to_front, 2)*stiffness_front*state[0] - pow(center_to_rear, 2)*stiffness_rear*state[0])*state[6]/(rotational_inertia*state[4])) + state[6];
|
||||
out_467921565295650481[7] = state[7];
|
||||
out_467921565295650481[8] = state[8];
|
||||
}
|
||||
void F_fun(double *state, double dt, double *out_6505574540477860652) {
|
||||
out_6505574540477860652[0] = 1;
|
||||
out_6505574540477860652[1] = 0;
|
||||
out_6505574540477860652[2] = 0;
|
||||
out_6505574540477860652[3] = 0;
|
||||
out_6505574540477860652[4] = 0;
|
||||
out_6505574540477860652[5] = 0;
|
||||
out_6505574540477860652[6] = 0;
|
||||
out_6505574540477860652[7] = 0;
|
||||
out_6505574540477860652[8] = 0;
|
||||
out_6505574540477860652[9] = 0;
|
||||
out_6505574540477860652[10] = 1;
|
||||
out_6505574540477860652[11] = 0;
|
||||
out_6505574540477860652[12] = 0;
|
||||
out_6505574540477860652[13] = 0;
|
||||
out_6505574540477860652[14] = 0;
|
||||
out_6505574540477860652[15] = 0;
|
||||
out_6505574540477860652[16] = 0;
|
||||
out_6505574540477860652[17] = 0;
|
||||
out_6505574540477860652[18] = 0;
|
||||
out_6505574540477860652[19] = 0;
|
||||
out_6505574540477860652[20] = 1;
|
||||
out_6505574540477860652[21] = 0;
|
||||
out_6505574540477860652[22] = 0;
|
||||
out_6505574540477860652[23] = 0;
|
||||
out_6505574540477860652[24] = 0;
|
||||
out_6505574540477860652[25] = 0;
|
||||
out_6505574540477860652[26] = 0;
|
||||
out_6505574540477860652[27] = 0;
|
||||
out_6505574540477860652[28] = 0;
|
||||
out_6505574540477860652[29] = 0;
|
||||
out_6505574540477860652[30] = 1;
|
||||
out_6505574540477860652[31] = 0;
|
||||
out_6505574540477860652[32] = 0;
|
||||
out_6505574540477860652[33] = 0;
|
||||
out_6505574540477860652[34] = 0;
|
||||
out_6505574540477860652[35] = 0;
|
||||
out_6505574540477860652[36] = 0;
|
||||
out_6505574540477860652[37] = 0;
|
||||
out_6505574540477860652[38] = 0;
|
||||
out_6505574540477860652[39] = 0;
|
||||
out_6505574540477860652[40] = 1;
|
||||
out_6505574540477860652[41] = 0;
|
||||
out_6505574540477860652[42] = 0;
|
||||
out_6505574540477860652[43] = 0;
|
||||
out_6505574540477860652[44] = 0;
|
||||
out_6505574540477860652[45] = dt*(stiffness_front*(-state[2] - state[3] + state[7])/(mass*state[1]) + (-stiffness_front - stiffness_rear)*state[5]/(mass*state[4]) + (-center_to_front*stiffness_front + center_to_rear*stiffness_rear)*state[6]/(mass*state[4]));
|
||||
out_6505574540477860652[46] = -dt*stiffness_front*(-state[2] - state[3] + state[7])*state[0]/(mass*pow(state[1], 2));
|
||||
out_6505574540477860652[47] = -dt*stiffness_front*state[0]/(mass*state[1]);
|
||||
out_6505574540477860652[48] = -dt*stiffness_front*state[0]/(mass*state[1]);
|
||||
out_6505574540477860652[49] = dt*((-1 - (-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])/(mass*pow(state[4], 2)))*state[6] - (-stiffness_front*state[0] - stiffness_rear*state[0])*state[5]/(mass*pow(state[4], 2)));
|
||||
out_6505574540477860652[50] = dt*(-stiffness_front*state[0] - stiffness_rear*state[0])/(mass*state[4]) + 1;
|
||||
out_6505574540477860652[51] = dt*(-state[4] + (-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])/(mass*state[4]));
|
||||
out_6505574540477860652[52] = dt*stiffness_front*state[0]/(mass*state[1]);
|
||||
out_6505574540477860652[53] = -9.8100000000000005*dt;
|
||||
out_6505574540477860652[54] = dt*(center_to_front*stiffness_front*(-state[2] - state[3] + state[7])/(rotational_inertia*state[1]) + (-center_to_front*stiffness_front + center_to_rear*stiffness_rear)*state[5]/(rotational_inertia*state[4]) + (-pow(center_to_front, 2)*stiffness_front - pow(center_to_rear, 2)*stiffness_rear)*state[6]/(rotational_inertia*state[4]));
|
||||
out_6505574540477860652[55] = -center_to_front*dt*stiffness_front*(-state[2] - state[3] + state[7])*state[0]/(rotational_inertia*pow(state[1], 2));
|
||||
out_6505574540477860652[56] = -center_to_front*dt*stiffness_front*state[0]/(rotational_inertia*state[1]);
|
||||
out_6505574540477860652[57] = -center_to_front*dt*stiffness_front*state[0]/(rotational_inertia*state[1]);
|
||||
out_6505574540477860652[58] = dt*(-(-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])*state[5]/(rotational_inertia*pow(state[4], 2)) - (-pow(center_to_front, 2)*stiffness_front*state[0] - pow(center_to_rear, 2)*stiffness_rear*state[0])*state[6]/(rotational_inertia*pow(state[4], 2)));
|
||||
out_6505574540477860652[59] = dt*(-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])/(rotational_inertia*state[4]);
|
||||
out_6505574540477860652[60] = dt*(-pow(center_to_front, 2)*stiffness_front*state[0] - pow(center_to_rear, 2)*stiffness_rear*state[0])/(rotational_inertia*state[4]) + 1;
|
||||
out_6505574540477860652[61] = center_to_front*dt*stiffness_front*state[0]/(rotational_inertia*state[1]);
|
||||
out_6505574540477860652[62] = 0;
|
||||
out_6505574540477860652[63] = 0;
|
||||
out_6505574540477860652[64] = 0;
|
||||
out_6505574540477860652[65] = 0;
|
||||
out_6505574540477860652[66] = 0;
|
||||
out_6505574540477860652[67] = 0;
|
||||
out_6505574540477860652[68] = 0;
|
||||
out_6505574540477860652[69] = 0;
|
||||
out_6505574540477860652[70] = 1;
|
||||
out_6505574540477860652[71] = 0;
|
||||
out_6505574540477860652[72] = 0;
|
||||
out_6505574540477860652[73] = 0;
|
||||
out_6505574540477860652[74] = 0;
|
||||
out_6505574540477860652[75] = 0;
|
||||
out_6505574540477860652[76] = 0;
|
||||
out_6505574540477860652[77] = 0;
|
||||
out_6505574540477860652[78] = 0;
|
||||
out_6505574540477860652[79] = 0;
|
||||
out_6505574540477860652[80] = 1;
|
||||
void F_fun(double *state, double dt, double *out_2429260194375294140) {
|
||||
out_2429260194375294140[0] = 1;
|
||||
out_2429260194375294140[1] = 0;
|
||||
out_2429260194375294140[2] = 0;
|
||||
out_2429260194375294140[3] = 0;
|
||||
out_2429260194375294140[4] = 0;
|
||||
out_2429260194375294140[5] = 0;
|
||||
out_2429260194375294140[6] = 0;
|
||||
out_2429260194375294140[7] = 0;
|
||||
out_2429260194375294140[8] = 0;
|
||||
out_2429260194375294140[9] = 0;
|
||||
out_2429260194375294140[10] = 1;
|
||||
out_2429260194375294140[11] = 0;
|
||||
out_2429260194375294140[12] = 0;
|
||||
out_2429260194375294140[13] = 0;
|
||||
out_2429260194375294140[14] = 0;
|
||||
out_2429260194375294140[15] = 0;
|
||||
out_2429260194375294140[16] = 0;
|
||||
out_2429260194375294140[17] = 0;
|
||||
out_2429260194375294140[18] = 0;
|
||||
out_2429260194375294140[19] = 0;
|
||||
out_2429260194375294140[20] = 1;
|
||||
out_2429260194375294140[21] = 0;
|
||||
out_2429260194375294140[22] = 0;
|
||||
out_2429260194375294140[23] = 0;
|
||||
out_2429260194375294140[24] = 0;
|
||||
out_2429260194375294140[25] = 0;
|
||||
out_2429260194375294140[26] = 0;
|
||||
out_2429260194375294140[27] = 0;
|
||||
out_2429260194375294140[28] = 0;
|
||||
out_2429260194375294140[29] = 0;
|
||||
out_2429260194375294140[30] = 1;
|
||||
out_2429260194375294140[31] = 0;
|
||||
out_2429260194375294140[32] = 0;
|
||||
out_2429260194375294140[33] = 0;
|
||||
out_2429260194375294140[34] = 0;
|
||||
out_2429260194375294140[35] = 0;
|
||||
out_2429260194375294140[36] = 0;
|
||||
out_2429260194375294140[37] = 0;
|
||||
out_2429260194375294140[38] = 0;
|
||||
out_2429260194375294140[39] = 0;
|
||||
out_2429260194375294140[40] = 1;
|
||||
out_2429260194375294140[41] = 0;
|
||||
out_2429260194375294140[42] = 0;
|
||||
out_2429260194375294140[43] = 0;
|
||||
out_2429260194375294140[44] = 0;
|
||||
out_2429260194375294140[45] = dt*(stiffness_front*(-state[2] - state[3] + state[7])/(mass*state[1]) + (-stiffness_front - stiffness_rear)*state[5]/(mass*state[4]) + (-center_to_front*stiffness_front + center_to_rear*stiffness_rear)*state[6]/(mass*state[4]));
|
||||
out_2429260194375294140[46] = -dt*stiffness_front*(-state[2] - state[3] + state[7])*state[0]/(mass*pow(state[1], 2));
|
||||
out_2429260194375294140[47] = -dt*stiffness_front*state[0]/(mass*state[1]);
|
||||
out_2429260194375294140[48] = -dt*stiffness_front*state[0]/(mass*state[1]);
|
||||
out_2429260194375294140[49] = dt*((-1 - (-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])/(mass*pow(state[4], 2)))*state[6] - (-stiffness_front*state[0] - stiffness_rear*state[0])*state[5]/(mass*pow(state[4], 2)));
|
||||
out_2429260194375294140[50] = dt*(-stiffness_front*state[0] - stiffness_rear*state[0])/(mass*state[4]) + 1;
|
||||
out_2429260194375294140[51] = dt*(-state[4] + (-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])/(mass*state[4]));
|
||||
out_2429260194375294140[52] = dt*stiffness_front*state[0]/(mass*state[1]);
|
||||
out_2429260194375294140[53] = -9.8100000000000005*dt;
|
||||
out_2429260194375294140[54] = dt*(center_to_front*stiffness_front*(-state[2] - state[3] + state[7])/(rotational_inertia*state[1]) + (-center_to_front*stiffness_front + center_to_rear*stiffness_rear)*state[5]/(rotational_inertia*state[4]) + (-pow(center_to_front, 2)*stiffness_front - pow(center_to_rear, 2)*stiffness_rear)*state[6]/(rotational_inertia*state[4]));
|
||||
out_2429260194375294140[55] = -center_to_front*dt*stiffness_front*(-state[2] - state[3] + state[7])*state[0]/(rotational_inertia*pow(state[1], 2));
|
||||
out_2429260194375294140[56] = -center_to_front*dt*stiffness_front*state[0]/(rotational_inertia*state[1]);
|
||||
out_2429260194375294140[57] = -center_to_front*dt*stiffness_front*state[0]/(rotational_inertia*state[1]);
|
||||
out_2429260194375294140[58] = dt*(-(-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])*state[5]/(rotational_inertia*pow(state[4], 2)) - (-pow(center_to_front, 2)*stiffness_front*state[0] - pow(center_to_rear, 2)*stiffness_rear*state[0])*state[6]/(rotational_inertia*pow(state[4], 2)));
|
||||
out_2429260194375294140[59] = dt*(-center_to_front*stiffness_front*state[0] + center_to_rear*stiffness_rear*state[0])/(rotational_inertia*state[4]);
|
||||
out_2429260194375294140[60] = dt*(-pow(center_to_front, 2)*stiffness_front*state[0] - pow(center_to_rear, 2)*stiffness_rear*state[0])/(rotational_inertia*state[4]) + 1;
|
||||
out_2429260194375294140[61] = center_to_front*dt*stiffness_front*state[0]/(rotational_inertia*state[1]);
|
||||
out_2429260194375294140[62] = 0;
|
||||
out_2429260194375294140[63] = 0;
|
||||
out_2429260194375294140[64] = 0;
|
||||
out_2429260194375294140[65] = 0;
|
||||
out_2429260194375294140[66] = 0;
|
||||
out_2429260194375294140[67] = 0;
|
||||
out_2429260194375294140[68] = 0;
|
||||
out_2429260194375294140[69] = 0;
|
||||
out_2429260194375294140[70] = 1;
|
||||
out_2429260194375294140[71] = 0;
|
||||
out_2429260194375294140[72] = 0;
|
||||
out_2429260194375294140[73] = 0;
|
||||
out_2429260194375294140[74] = 0;
|
||||
out_2429260194375294140[75] = 0;
|
||||
out_2429260194375294140[76] = 0;
|
||||
out_2429260194375294140[77] = 0;
|
||||
out_2429260194375294140[78] = 0;
|
||||
out_2429260194375294140[79] = 0;
|
||||
out_2429260194375294140[80] = 1;
|
||||
}
|
||||
void h_25(double *state, double *unused, double *out_1325906349074366668) {
|
||||
out_1325906349074366668[0] = state[6];
|
||||
void h_25(double *state, double *unused, double *out_4530459753918271082) {
|
||||
out_4530459753918271082[0] = state[6];
|
||||
}
|
||||
void H_25(double *state, double *unused, double *out_693697758010493692) {
|
||||
out_693697758010493692[0] = 0;
|
||||
out_693697758010493692[1] = 0;
|
||||
out_693697758010493692[2] = 0;
|
||||
out_693697758010493692[3] = 0;
|
||||
out_693697758010493692[4] = 0;
|
||||
out_693697758010493692[5] = 0;
|
||||
out_693697758010493692[6] = 1;
|
||||
out_693697758010493692[7] = 0;
|
||||
out_693697758010493692[8] = 0;
|
||||
void H_25(double *state, double *unused, double *out_4551338626615593728) {
|
||||
out_4551338626615593728[0] = 0;
|
||||
out_4551338626615593728[1] = 0;
|
||||
out_4551338626615593728[2] = 0;
|
||||
out_4551338626615593728[3] = 0;
|
||||
out_4551338626615593728[4] = 0;
|
||||
out_4551338626615593728[5] = 0;
|
||||
out_4551338626615593728[6] = 1;
|
||||
out_4551338626615593728[7] = 0;
|
||||
out_4551338626615593728[8] = 0;
|
||||
}
|
||||
void h_24(double *state, double *unused, double *out_7507130987037302702) {
|
||||
out_7507130987037302702[0] = state[4];
|
||||
out_7507130987037302702[1] = state[5];
|
||||
void h_24(double *state, double *unused, double *out_211848015086222289) {
|
||||
out_211848015086222289[0] = state[4];
|
||||
out_211848015086222289[1] = state[5];
|
||||
}
|
||||
void H_24(double *state, double *unused, double *out_2864227840791829444) {
|
||||
out_2864227840791829444[0] = 0;
|
||||
out_2864227840791829444[1] = 0;
|
||||
out_2864227840791829444[2] = 0;
|
||||
out_2864227840791829444[3] = 0;
|
||||
out_2864227840791829444[4] = 1;
|
||||
out_2864227840791829444[5] = 0;
|
||||
out_2864227840791829444[6] = 0;
|
||||
out_2864227840791829444[7] = 0;
|
||||
out_2864227840791829444[8] = 0;
|
||||
out_2864227840791829444[9] = 0;
|
||||
out_2864227840791829444[10] = 0;
|
||||
out_2864227840791829444[11] = 0;
|
||||
out_2864227840791829444[12] = 0;
|
||||
out_2864227840791829444[13] = 0;
|
||||
out_2864227840791829444[14] = 1;
|
||||
out_2864227840791829444[15] = 0;
|
||||
out_2864227840791829444[16] = 0;
|
||||
out_2864227840791829444[17] = 0;
|
||||
void H_24(double *state, double *unused, double *out_7319833640502439787) {
|
||||
out_7319833640502439787[0] = 0;
|
||||
out_7319833640502439787[1] = 0;
|
||||
out_7319833640502439787[2] = 0;
|
||||
out_7319833640502439787[3] = 0;
|
||||
out_7319833640502439787[4] = 1;
|
||||
out_7319833640502439787[5] = 0;
|
||||
out_7319833640502439787[6] = 0;
|
||||
out_7319833640502439787[7] = 0;
|
||||
out_7319833640502439787[8] = 0;
|
||||
out_7319833640502439787[9] = 0;
|
||||
out_7319833640502439787[10] = 0;
|
||||
out_7319833640502439787[11] = 0;
|
||||
out_7319833640502439787[12] = 0;
|
||||
out_7319833640502439787[13] = 0;
|
||||
out_7319833640502439787[14] = 1;
|
||||
out_7319833640502439787[15] = 0;
|
||||
out_7319833640502439787[16] = 0;
|
||||
out_7319833640502439787[17] = 0;
|
||||
}
|
||||
void h_30(double *state, double *unused, double *out_6134652415174521657) {
|
||||
out_6134652415174521657[0] = state[4];
|
||||
void h_30(double *state, double *unused, double *out_4687646422269400227) {
|
||||
out_4687646422269400227[0] = state[4];
|
||||
}
|
||||
void H_30(double *state, double *unused, double *out_1824635200496754935) {
|
||||
out_1824635200496754935[0] = 0;
|
||||
out_1824635200496754935[1] = 0;
|
||||
out_1824635200496754935[2] = 0;
|
||||
out_1824635200496754935[3] = 0;
|
||||
out_1824635200496754935[4] = 1;
|
||||
out_1824635200496754935[5] = 0;
|
||||
out_1824635200496754935[6] = 0;
|
||||
out_1824635200496754935[7] = 0;
|
||||
out_1824635200496754935[8] = 0;
|
||||
void H_30(double *state, double *unused, double *out_4421999679472353658) {
|
||||
out_4421999679472353658[0] = 0;
|
||||
out_4421999679472353658[1] = 0;
|
||||
out_4421999679472353658[2] = 0;
|
||||
out_4421999679472353658[3] = 0;
|
||||
out_4421999679472353658[4] = 1;
|
||||
out_4421999679472353658[5] = 0;
|
||||
out_4421999679472353658[6] = 0;
|
||||
out_4421999679472353658[7] = 0;
|
||||
out_4421999679472353658[8] = 0;
|
||||
}
|
||||
void h_26(double *state, double *unused, double *out_3515782194269032819) {
|
||||
out_3515782194269032819[0] = state[7];
|
||||
void h_26(double *state, double *unused, double *out_1875094318999546844) {
|
||||
out_1875094318999546844[0] = state[7];
|
||||
}
|
||||
void H_26(double *state, double *unused, double *out_4435201076884549916) {
|
||||
out_4435201076884549916[0] = 0;
|
||||
out_4435201076884549916[1] = 0;
|
||||
out_4435201076884549916[2] = 0;
|
||||
out_4435201076884549916[3] = 0;
|
||||
out_4435201076884549916[4] = 0;
|
||||
out_4435201076884549916[5] = 0;
|
||||
out_4435201076884549916[6] = 0;
|
||||
out_4435201076884549916[7] = 1;
|
||||
out_4435201076884549916[8] = 0;
|
||||
void H_26(double *state, double *unused, double *out_809835307741537504) {
|
||||
out_809835307741537504[0] = 0;
|
||||
out_809835307741537504[1] = 0;
|
||||
out_809835307741537504[2] = 0;
|
||||
out_809835307741537504[3] = 0;
|
||||
out_809835307741537504[4] = 0;
|
||||
out_809835307741537504[5] = 0;
|
||||
out_809835307741537504[6] = 0;
|
||||
out_809835307741537504[7] = 1;
|
||||
out_809835307741537504[8] = 0;
|
||||
}
|
||||
void h_27(double *state, double *unused, double *out_5073135168339482478) {
|
||||
out_5073135168339482478[0] = state[3];
|
||||
void h_27(double *state, double *unused, double *out_8953904322109987302) {
|
||||
out_8953904322109987302[0] = state[3];
|
||||
}
|
||||
void H_27(double *state, double *unused, double *out_4048229271680698152) {
|
||||
out_4048229271680698152[0] = 0;
|
||||
out_4048229271680698152[1] = 0;
|
||||
out_4048229271680698152[2] = 0;
|
||||
out_4048229271680698152[3] = 1;
|
||||
out_4048229271680698152[4] = 0;
|
||||
out_4048229271680698152[5] = 0;
|
||||
out_4048229271680698152[6] = 0;
|
||||
out_4048229271680698152[7] = 0;
|
||||
out_4048229271680698152[8] = 0;
|
||||
void H_27(double *state, double *unused, double *out_2247236367671928747) {
|
||||
out_2247236367671928747[0] = 0;
|
||||
out_2247236367671928747[1] = 0;
|
||||
out_2247236367671928747[2] = 0;
|
||||
out_2247236367671928747[3] = 1;
|
||||
out_2247236367671928747[4] = 0;
|
||||
out_2247236367671928747[5] = 0;
|
||||
out_2247236367671928747[6] = 0;
|
||||
out_2247236367671928747[7] = 0;
|
||||
out_2247236367671928747[8] = 0;
|
||||
}
|
||||
void h_29(double *state, double *unused, double *out_9171438466618854342) {
|
||||
out_9171438466618854342[0] = state[1];
|
||||
void h_29(double *state, double *unused, double *out_5855390223345541964) {
|
||||
out_5855390223345541964[0] = state[1];
|
||||
}
|
||||
void H_29(double *state, double *unused, double *out_2334866544811147119) {
|
||||
out_2334866544811147119[0] = 0;
|
||||
out_2334866544811147119[1] = 1;
|
||||
out_2334866544811147119[2] = 0;
|
||||
out_2334866544811147119[3] = 0;
|
||||
out_2334866544811147119[4] = 0;
|
||||
out_2334866544811147119[5] = 0;
|
||||
out_2334866544811147119[6] = 0;
|
||||
out_2334866544811147119[7] = 0;
|
||||
out_2334866544811147119[8] = 0;
|
||||
void H_29(double *state, double *unused, double *out_4932231023786745842) {
|
||||
out_4932231023786745842[0] = 0;
|
||||
out_4932231023786745842[1] = 1;
|
||||
out_4932231023786745842[2] = 0;
|
||||
out_4932231023786745842[3] = 0;
|
||||
out_4932231023786745842[4] = 0;
|
||||
out_4932231023786745842[5] = 0;
|
||||
out_4932231023786745842[6] = 0;
|
||||
out_4932231023786745842[7] = 0;
|
||||
out_4932231023786745842[8] = 0;
|
||||
}
|
||||
void h_28(double *state, double *unused, double *out_6016645021241144913) {
|
||||
out_6016645021241144913[0] = state[0];
|
||||
void h_28(double *state, double *unused, double *out_8510755658264266202) {
|
||||
out_8510755658264266202[0] = state[0];
|
||||
}
|
||||
void H_28(double *state, double *unused, double *out_2747532472258383455) {
|
||||
out_2747532472258383455[0] = 1;
|
||||
out_2747532472258383455[1] = 0;
|
||||
out_2747532472258383455[2] = 0;
|
||||
out_2747532472258383455[3] = 0;
|
||||
out_2747532472258383455[4] = 0;
|
||||
out_2747532472258383455[5] = 0;
|
||||
out_2747532472258383455[6] = 0;
|
||||
out_2747532472258383455[7] = 0;
|
||||
out_2747532472258383455[8] = 0;
|
||||
void H_28(double *state, double *unused, double *out_6895861295352072093) {
|
||||
out_6895861295352072093[0] = 1;
|
||||
out_6895861295352072093[1] = 0;
|
||||
out_6895861295352072093[2] = 0;
|
||||
out_6895861295352072093[3] = 0;
|
||||
out_6895861295352072093[4] = 0;
|
||||
out_6895861295352072093[5] = 0;
|
||||
out_6895861295352072093[6] = 0;
|
||||
out_6895861295352072093[7] = 0;
|
||||
out_6895861295352072093[8] = 0;
|
||||
}
|
||||
void h_31(double *state, double *unused, double *out_2311543179179655682) {
|
||||
out_2311543179179655682[0] = state[8];
|
||||
void h_31(double *state, double *unused, double *out_3677036992164635768) {
|
||||
out_3677036992164635768[0] = state[8];
|
||||
}
|
||||
void H_31(double *state, double *unused, double *out_5061409179117901392) {
|
||||
out_5061409179117901392[0] = 0;
|
||||
out_5061409179117901392[1] = 0;
|
||||
out_5061409179117901392[2] = 0;
|
||||
out_5061409179117901392[3] = 0;
|
||||
out_5061409179117901392[4] = 0;
|
||||
out_5061409179117901392[5] = 0;
|
||||
out_5061409179117901392[6] = 0;
|
||||
out_5061409179117901392[7] = 0;
|
||||
out_5061409179117901392[8] = 1;
|
||||
void H_31(double *state, double *unused, double *out_4581984588492554156) {
|
||||
out_4581984588492554156[0] = 0;
|
||||
out_4581984588492554156[1] = 0;
|
||||
out_4581984588492554156[2] = 0;
|
||||
out_4581984588492554156[3] = 0;
|
||||
out_4581984588492554156[4] = 0;
|
||||
out_4581984588492554156[5] = 0;
|
||||
out_4581984588492554156[6] = 0;
|
||||
out_4581984588492554156[7] = 0;
|
||||
out_4581984588492554156[8] = 1;
|
||||
}
|
||||
#include <eigen3/Eigen/Dense>
|
||||
#include <iostream>
|
||||
@@ -518,68 +518,68 @@ void car_update_28(double *in_x, double *in_P, double *in_z, double *in_R, doubl
|
||||
void car_update_31(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
|
||||
update<1, 3, 0>(in_x, in_P, h_31, H_31, NULL, in_z, in_R, in_ea, MAHA_THRESH_31);
|
||||
}
|
||||
void car_err_fun(double *nom_x, double *delta_x, double *out_7751375231448978305) {
|
||||
err_fun(nom_x, delta_x, out_7751375231448978305);
|
||||
void car_err_fun(double *nom_x, double *delta_x, double *out_789804740016769707) {
|
||||
err_fun(nom_x, delta_x, out_789804740016769707);
|
||||
}
|
||||
void car_inv_err_fun(double *nom_x, double *true_x, double *out_1186045100449225538) {
|
||||
inv_err_fun(nom_x, true_x, out_1186045100449225538);
|
||||
void car_inv_err_fun(double *nom_x, double *true_x, double *out_385986033898548509) {
|
||||
inv_err_fun(nom_x, true_x, out_385986033898548509);
|
||||
}
|
||||
void car_H_mod_fun(double *state, double *out_5403210608595880924) {
|
||||
H_mod_fun(state, out_5403210608595880924);
|
||||
void car_H_mod_fun(double *state, double *out_4046004184415297016) {
|
||||
H_mod_fun(state, out_4046004184415297016);
|
||||
}
|
||||
void car_f_fun(double *state, double dt, double *out_3846473641327680019) {
|
||||
f_fun(state, dt, out_3846473641327680019);
|
||||
void car_f_fun(double *state, double dt, double *out_467921565295650481) {
|
||||
f_fun(state, dt, out_467921565295650481);
|
||||
}
|
||||
void car_F_fun(double *state, double dt, double *out_6505574540477860652) {
|
||||
F_fun(state, dt, out_6505574540477860652);
|
||||
void car_F_fun(double *state, double dt, double *out_2429260194375294140) {
|
||||
F_fun(state, dt, out_2429260194375294140);
|
||||
}
|
||||
void car_h_25(double *state, double *unused, double *out_1325906349074366668) {
|
||||
h_25(state, unused, out_1325906349074366668);
|
||||
void car_h_25(double *state, double *unused, double *out_4530459753918271082) {
|
||||
h_25(state, unused, out_4530459753918271082);
|
||||
}
|
||||
void car_H_25(double *state, double *unused, double *out_693697758010493692) {
|
||||
H_25(state, unused, out_693697758010493692);
|
||||
void car_H_25(double *state, double *unused, double *out_4551338626615593728) {
|
||||
H_25(state, unused, out_4551338626615593728);
|
||||
}
|
||||
void car_h_24(double *state, double *unused, double *out_7507130987037302702) {
|
||||
h_24(state, unused, out_7507130987037302702);
|
||||
void car_h_24(double *state, double *unused, double *out_211848015086222289) {
|
||||
h_24(state, unused, out_211848015086222289);
|
||||
}
|
||||
void car_H_24(double *state, double *unused, double *out_2864227840791829444) {
|
||||
H_24(state, unused, out_2864227840791829444);
|
||||
void car_H_24(double *state, double *unused, double *out_7319833640502439787) {
|
||||
H_24(state, unused, out_7319833640502439787);
|
||||
}
|
||||
void car_h_30(double *state, double *unused, double *out_6134652415174521657) {
|
||||
h_30(state, unused, out_6134652415174521657);
|
||||
void car_h_30(double *state, double *unused, double *out_4687646422269400227) {
|
||||
h_30(state, unused, out_4687646422269400227);
|
||||
}
|
||||
void car_H_30(double *state, double *unused, double *out_1824635200496754935) {
|
||||
H_30(state, unused, out_1824635200496754935);
|
||||
void car_H_30(double *state, double *unused, double *out_4421999679472353658) {
|
||||
H_30(state, unused, out_4421999679472353658);
|
||||
}
|
||||
void car_h_26(double *state, double *unused, double *out_3515782194269032819) {
|
||||
h_26(state, unused, out_3515782194269032819);
|
||||
void car_h_26(double *state, double *unused, double *out_1875094318999546844) {
|
||||
h_26(state, unused, out_1875094318999546844);
|
||||
}
|
||||
void car_H_26(double *state, double *unused, double *out_4435201076884549916) {
|
||||
H_26(state, unused, out_4435201076884549916);
|
||||
void car_H_26(double *state, double *unused, double *out_809835307741537504) {
|
||||
H_26(state, unused, out_809835307741537504);
|
||||
}
|
||||
void car_h_27(double *state, double *unused, double *out_5073135168339482478) {
|
||||
h_27(state, unused, out_5073135168339482478);
|
||||
void car_h_27(double *state, double *unused, double *out_8953904322109987302) {
|
||||
h_27(state, unused, out_8953904322109987302);
|
||||
}
|
||||
void car_H_27(double *state, double *unused, double *out_4048229271680698152) {
|
||||
H_27(state, unused, out_4048229271680698152);
|
||||
void car_H_27(double *state, double *unused, double *out_2247236367671928747) {
|
||||
H_27(state, unused, out_2247236367671928747);
|
||||
}
|
||||
void car_h_29(double *state, double *unused, double *out_9171438466618854342) {
|
||||
h_29(state, unused, out_9171438466618854342);
|
||||
void car_h_29(double *state, double *unused, double *out_5855390223345541964) {
|
||||
h_29(state, unused, out_5855390223345541964);
|
||||
}
|
||||
void car_H_29(double *state, double *unused, double *out_2334866544811147119) {
|
||||
H_29(state, unused, out_2334866544811147119);
|
||||
void car_H_29(double *state, double *unused, double *out_4932231023786745842) {
|
||||
H_29(state, unused, out_4932231023786745842);
|
||||
}
|
||||
void car_h_28(double *state, double *unused, double *out_6016645021241144913) {
|
||||
h_28(state, unused, out_6016645021241144913);
|
||||
void car_h_28(double *state, double *unused, double *out_8510755658264266202) {
|
||||
h_28(state, unused, out_8510755658264266202);
|
||||
}
|
||||
void car_H_28(double *state, double *unused, double *out_2747532472258383455) {
|
||||
H_28(state, unused, out_2747532472258383455);
|
||||
void car_H_28(double *state, double *unused, double *out_6895861295352072093) {
|
||||
H_28(state, unused, out_6895861295352072093);
|
||||
}
|
||||
void car_h_31(double *state, double *unused, double *out_2311543179179655682) {
|
||||
h_31(state, unused, out_2311543179179655682);
|
||||
void car_h_31(double *state, double *unused, double *out_3677036992164635768) {
|
||||
h_31(state, unused, out_3677036992164635768);
|
||||
}
|
||||
void car_H_31(double *state, double *unused, double *out_5061409179117901392) {
|
||||
H_31(state, unused, out_5061409179117901392);
|
||||
void car_H_31(double *state, double *unused, double *out_4581984588492554156) {
|
||||
H_31(state, unused, out_4581984588492554156);
|
||||
}
|
||||
void car_predict(double *in_x, double *in_P, double *in_Q, double dt) {
|
||||
predict(in_x, in_P, in_Q, dt);
|
||||
|
||||
@@ -9,27 +9,27 @@ void car_update_27(double *in_x, double *in_P, double *in_z, double *in_R, doubl
|
||||
void car_update_29(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea);
|
||||
void car_update_28(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea);
|
||||
void car_update_31(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea);
|
||||
void car_err_fun(double *nom_x, double *delta_x, double *out_7751375231448978305);
|
||||
void car_inv_err_fun(double *nom_x, double *true_x, double *out_1186045100449225538);
|
||||
void car_H_mod_fun(double *state, double *out_5403210608595880924);
|
||||
void car_f_fun(double *state, double dt, double *out_3846473641327680019);
|
||||
void car_F_fun(double *state, double dt, double *out_6505574540477860652);
|
||||
void car_h_25(double *state, double *unused, double *out_1325906349074366668);
|
||||
void car_H_25(double *state, double *unused, double *out_693697758010493692);
|
||||
void car_h_24(double *state, double *unused, double *out_7507130987037302702);
|
||||
void car_H_24(double *state, double *unused, double *out_2864227840791829444);
|
||||
void car_h_30(double *state, double *unused, double *out_6134652415174521657);
|
||||
void car_H_30(double *state, double *unused, double *out_1824635200496754935);
|
||||
void car_h_26(double *state, double *unused, double *out_3515782194269032819);
|
||||
void car_H_26(double *state, double *unused, double *out_4435201076884549916);
|
||||
void car_h_27(double *state, double *unused, double *out_5073135168339482478);
|
||||
void car_H_27(double *state, double *unused, double *out_4048229271680698152);
|
||||
void car_h_29(double *state, double *unused, double *out_9171438466618854342);
|
||||
void car_H_29(double *state, double *unused, double *out_2334866544811147119);
|
||||
void car_h_28(double *state, double *unused, double *out_6016645021241144913);
|
||||
void car_H_28(double *state, double *unused, double *out_2747532472258383455);
|
||||
void car_h_31(double *state, double *unused, double *out_2311543179179655682);
|
||||
void car_H_31(double *state, double *unused, double *out_5061409179117901392);
|
||||
void car_err_fun(double *nom_x, double *delta_x, double *out_789804740016769707);
|
||||
void car_inv_err_fun(double *nom_x, double *true_x, double *out_385986033898548509);
|
||||
void car_H_mod_fun(double *state, double *out_4046004184415297016);
|
||||
void car_f_fun(double *state, double dt, double *out_467921565295650481);
|
||||
void car_F_fun(double *state, double dt, double *out_2429260194375294140);
|
||||
void car_h_25(double *state, double *unused, double *out_4530459753918271082);
|
||||
void car_H_25(double *state, double *unused, double *out_4551338626615593728);
|
||||
void car_h_24(double *state, double *unused, double *out_211848015086222289);
|
||||
void car_H_24(double *state, double *unused, double *out_7319833640502439787);
|
||||
void car_h_30(double *state, double *unused, double *out_4687646422269400227);
|
||||
void car_H_30(double *state, double *unused, double *out_4421999679472353658);
|
||||
void car_h_26(double *state, double *unused, double *out_1875094318999546844);
|
||||
void car_H_26(double *state, double *unused, double *out_809835307741537504);
|
||||
void car_h_27(double *state, double *unused, double *out_8953904322109987302);
|
||||
void car_H_27(double *state, double *unused, double *out_2247236367671928747);
|
||||
void car_h_29(double *state, double *unused, double *out_5855390223345541964);
|
||||
void car_H_29(double *state, double *unused, double *out_4932231023786745842);
|
||||
void car_h_28(double *state, double *unused, double *out_8510755658264266202);
|
||||
void car_H_28(double *state, double *unused, double *out_6895861295352072093);
|
||||
void car_h_31(double *state, double *unused, double *out_3677036992164635768);
|
||||
void car_H_31(double *state, double *unused, double *out_4581984588492554156);
|
||||
void car_predict(double *in_x, double *in_P, double *in_Q, double dt);
|
||||
void car_set_mass(double x);
|
||||
void car_set_rotational_inertia(double x);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,18 +5,18 @@ void pose_update_4(double *in_x, double *in_P, double *in_z, double *in_R, doubl
|
||||
void pose_update_10(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea);
|
||||
void pose_update_13(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea);
|
||||
void pose_update_14(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea);
|
||||
void pose_err_fun(double *nom_x, double *delta_x, double *out_5867685499485526905);
|
||||
void pose_inv_err_fun(double *nom_x, double *true_x, double *out_7496427572072330735);
|
||||
void pose_H_mod_fun(double *state, double *out_4599731282943687674);
|
||||
void pose_f_fun(double *state, double dt, double *out_8448766243959956852);
|
||||
void pose_F_fun(double *state, double dt, double *out_3524034210859456461);
|
||||
void pose_h_4(double *state, double *unused, double *out_1468084297579901706);
|
||||
void pose_H_4(double *state, double *unused, double *out_552787102095393061);
|
||||
void pose_h_10(double *state, double *unused, double *out_1051779536617211070);
|
||||
void pose_H_10(double *state, double *unused, double *out_7440841037325716699);
|
||||
void pose_h_13(double *state, double *unused, double *out_4266757043601180240);
|
||||
void pose_H_13(double *state, double *unused, double *out_3765060927427725862);
|
||||
void pose_h_14(double *state, double *unused, double *out_1847032621455587499);
|
||||
void pose_H_14(double *state, double *unused, double *out_117670575450509462);
|
||||
void pose_err_fun(double *nom_x, double *delta_x, double *out_7754318151462489406);
|
||||
void pose_inv_err_fun(double *nom_x, double *true_x, double *out_5172808168415891616);
|
||||
void pose_H_mod_fun(double *state, double *out_2254475305049299983);
|
||||
void pose_f_fun(double *state, double dt, double *out_9187930556967356165);
|
||||
void pose_F_fun(double *state, double dt, double *out_1250378920670806697);
|
||||
void pose_h_4(double *state, double *unused, double *out_3431796064752050994);
|
||||
void pose_H_4(double *state, double *unused, double *out_1019746773741649270);
|
||||
void pose_h_10(double *state, double *unused, double *out_4742817048768310237);
|
||||
void pose_H_10(double *state, double *unused, double *out_7482829619336622044);
|
||||
void pose_h_13(double *state, double *unused, double *out_3124060736866225144);
|
||||
void pose_H_13(double *state, double *unused, double *out_2192527051590683531);
|
||||
void pose_h_14(double *state, double *unused, double *out_3873502266244196496);
|
||||
void pose_H_14(double *state, double *unused, double *out_2943494082597835259);
|
||||
void pose_predict(double *in_x, double *in_P, double *in_Q, double dt);
|
||||
}
|
||||
@@ -5,6 +5,7 @@ from functools import cached_property
|
||||
import json
|
||||
import os
|
||||
import struct
|
||||
import usb1
|
||||
from openpilot.system.hardware import HARDWARE, TICI
|
||||
os.environ['GMMU'] = '0'
|
||||
os.environ['DEV'] = 'QCOM' if TICI else 'LLVM'
|
||||
@@ -50,6 +51,7 @@ from openpilot.selfdrive.modeld.compile_modeld import (
|
||||
)
|
||||
from openpilot.selfdrive.modeld.helpers import get_tg_input_devices, load_oob, tinygrad_dev_config, usbgpu_present
|
||||
from openpilot.selfdrive.modeld.usbgpu_link import wait_usbgpu_link
|
||||
from openpilot.system.hardware.usb import CHESTNUT_USB_IDS
|
||||
from openpilot.starpilot.assets.model_manager import (
|
||||
ModelManager,
|
||||
get_model_profile,
|
||||
@@ -212,6 +214,38 @@ class ChestnutState:
|
||||
self.valid = True
|
||||
self.sends = 0
|
||||
self.metrics = {}
|
||||
self._asm_usb = None
|
||||
|
||||
def _close_asm_usb(self) -> None:
|
||||
if self._asm_usb is not None:
|
||||
self._asm_usb.close()
|
||||
self._asm_usb = None
|
||||
|
||||
def _open_asm_usb(self):
|
||||
context = usb1.USBContext()
|
||||
for vendor_id, product_id in CHESTNUT_USB_IDS:
|
||||
handle = context.openByVendorIDAndProductID(vendor_id, product_id, skip_on_error=True)
|
||||
if handle is not None:
|
||||
return handle
|
||||
context.close()
|
||||
|
||||
def _read_ina(self) -> tuple[int, int, bool]:
|
||||
if "AMD" in Device._opened_devices and self._asm_usb is None:
|
||||
try:
|
||||
raw = Device["AMD"].iface.pci_dev.usb.usb.control_read(0xC0, 5)
|
||||
return struct.unpack("<Hh?", bytes(raw))
|
||||
except Exception:
|
||||
pass
|
||||
if self._asm_usb is None:
|
||||
self._asm_usb = self._open_asm_usb()
|
||||
if self._asm_usb is None:
|
||||
raise usb1.USBErrorNoDevice
|
||||
try:
|
||||
raw = self._asm_usb.controlRead(0xC0, 0xC0, 0, 0, 5, timeout=100)
|
||||
except usb1.USBError:
|
||||
self._close_asm_usb()
|
||||
raise
|
||||
return struct.unpack("<Hh?", bytes(raw))
|
||||
|
||||
@cached_property
|
||||
def power_limit(self) -> int:
|
||||
@@ -253,12 +287,14 @@ class ChestnutState:
|
||||
setattr(state, key, value)
|
||||
|
||||
asm_valid = False
|
||||
try:
|
||||
state.supplyVoltage, state.supplyCurrent, state.supplyFault = self._read_ina()
|
||||
asm_valid = True
|
||||
except Exception:
|
||||
pass
|
||||
if "AMD" in Device._opened_devices:
|
||||
try:
|
||||
asm = Device["AMD"].iface.pci_dev.usb
|
||||
state.pcieLtssm = asm.read(0xB450, 1)[0]
|
||||
state.supplyVoltage, state.supplyCurrent = struct.unpack("<Hh", bytes(asm.usb.control_read(0xC0, 5))[:4])
|
||||
asm_valid = True
|
||||
state.pcieLtssm = Device["AMD"].iface.pci_dev.usb.read(0xB450, 1)[0]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import io
|
||||
import struct
|
||||
from types import MethodType
|
||||
from types import SimpleNamespace
|
||||
|
||||
@@ -152,6 +153,42 @@ def test_chestnut_telemetry_is_bounded_when_amd_is_unavailable(monkeypatch):
|
||||
assert not message.valid
|
||||
|
||||
|
||||
def test_chestnut_power_telemetry_works_before_amd_initializes(monkeypatch):
|
||||
class FakePubMaster:
|
||||
def __init__(self):
|
||||
self.sent = []
|
||||
|
||||
def send(self, service, message):
|
||||
self.sent.append((service, message))
|
||||
|
||||
class FakeHandle:
|
||||
def controlRead(self, *_args, **_kwargs):
|
||||
return struct.pack("<Hh?", 12100, 850, True)
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
class FakeContext:
|
||||
def openByVendorIDAndProductID(self, *_args, **_kwargs):
|
||||
return FakeHandle()
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
publisher = FakePubMaster()
|
||||
monkeypatch.setattr(modeld, "Device", SimpleNamespace(_opened_devices=set()))
|
||||
monkeypatch.setattr(modeld.usb1, "USBContext", FakeContext)
|
||||
|
||||
telemetry = modeld.ChestnutState(publisher, big=False)
|
||||
telemetry.send()
|
||||
|
||||
_, message = publisher.sent[0]
|
||||
assert message.valid
|
||||
assert message.chestnutState.supplyVoltage == 12100
|
||||
assert message.chestnutState.supplyCurrent == 850
|
||||
assert message.chestnutState.supplyFault
|
||||
|
||||
|
||||
def test_tinygrad_disk_cache_connection_is_closed_between_models(monkeypatch):
|
||||
import tinygrad.helpers as tinygrad_helpers
|
||||
|
||||
|
||||
Binary file not shown.
@@ -17,6 +17,30 @@
|
||||
"severity": 1,
|
||||
"_comment": "Set extra field to the failed reason."
|
||||
},
|
||||
"Offroad_ChestnutNotDetected": {
|
||||
"text": "Chestnut not detected. Check USB and 12V connections.",
|
||||
"severity": 0
|
||||
},
|
||||
"Offroad_ChestnutOverheated": {
|
||||
"text": "Chestnut overheated. Ensure good airflow. Current GPU temperature is %1.",
|
||||
"severity": 0
|
||||
},
|
||||
"Offroad_ChestnutPcieUnavailable": {
|
||||
"text": "%1",
|
||||
"severity": 0
|
||||
},
|
||||
"Offroad_ChestnutUncompiled": {
|
||||
"text": "The active Chestnut model is not installed. Download it in Model Manager.",
|
||||
"severity": 0
|
||||
},
|
||||
"Offroad_ChestnutUpdateFailed": {
|
||||
"text": "Chestnut update failed. Check the USB cable.",
|
||||
"severity": 0
|
||||
},
|
||||
"Offroad_ChestnutUsbSlow": {
|
||||
"text": "Chestnut USB link is slow. Check the USB cable. The current speed is %1.",
|
||||
"severity": 0
|
||||
},
|
||||
"Offroad_IsTakingSnapshot": {
|
||||
"text": "Taking camera snapshots. System won't start until finished.",
|
||||
"severity": 0
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,93 @@
|
||||
import time
|
||||
|
||||
from openpilot.system.hardware.usb import CHESTNUT_USB_PRODUCT, is_chestnut_usb_id
|
||||
|
||||
|
||||
CHESTNUT_POWERED_VOLTAGE = 5000
|
||||
GPU_TEMP_LIMIT = 100.0
|
||||
MEMORY_TEMP_LIMIT = 95.0
|
||||
TEMP_HYSTERESIS = 5.0
|
||||
|
||||
|
||||
class ChestnutStatus:
|
||||
def __init__(self):
|
||||
self.started = time.monotonic()
|
||||
self.offroad = True
|
||||
self.pcie_failed = False
|
||||
self.power_seen = False
|
||||
self.power_unavailable = False
|
||||
self.power_lost = False
|
||||
self.power_restored = False
|
||||
self.link_failures = 0
|
||||
self.model_loading_seen = False
|
||||
self.model_attempted = False
|
||||
self.overheated = False
|
||||
self.usb_seen = False
|
||||
self.usb_failed = False
|
||||
|
||||
def update(self, offroad: bool, expected: bool, usb_state: list[dict], firmware_failed: bool,
|
||||
model_loading: bool, model_active: bool | None, compiled: bool, state, set_alert) -> None:
|
||||
detected = [d for d in usb_state if is_chestnut_usb_id(d["vendorId"], d["productId"], include_bootloader=True)]
|
||||
devices = [d for d in detected if is_chestnut_usb_id(d["vendorId"], d["productId"])]
|
||||
firmware_ok = len(devices) == 1 and devices[0]["product"] == CHESTNUT_USB_PRODUCT
|
||||
|
||||
if self.offroad and not offroad:
|
||||
self.pcie_failed = False
|
||||
self.power_seen = False
|
||||
self.power_unavailable = False
|
||||
self.power_lost = False
|
||||
self.power_restored = False
|
||||
self.link_failures = 0
|
||||
self.model_loading_seen = False
|
||||
self.model_attempted = False
|
||||
self.usb_seen = firmware_ok
|
||||
self.usb_failed = False
|
||||
|
||||
self.model_loading_seen |= model_loading
|
||||
self.model_attempted |= self.model_loading_seen and not model_loading and model_active is not None
|
||||
|
||||
if expected and not offroad and self.usb_seen and not firmware_ok:
|
||||
self.usb_failed = True
|
||||
|
||||
power_lost = False
|
||||
if expected and not offroad and state is not None:
|
||||
powered = state.supplyVoltage >= CHESTNUT_POWERED_VOLTAGE
|
||||
power_lost = state.supplyFault or not powered
|
||||
if self.model_attempted and power_lost and not self.power_lost:
|
||||
self.power_unavailable = not self.power_seen
|
||||
self.power_seen |= powered
|
||||
|
||||
if expected and not offroad and self.model_attempted and state is not None:
|
||||
self.link_failures = self.link_failures + 1 if state.pcieLtssm != 0x78 else 0
|
||||
self.pcie_failed |= self.link_failures >= 2 or power_lost
|
||||
self.power_lost |= power_lost
|
||||
|
||||
if self.pcie_failed and self.power_lost and state is not None:
|
||||
self.power_restored |= not state.supplyFault and state.supplyVoltage >= CHESTNUT_POWERED_VOLTAGE
|
||||
if self.usb_failed:
|
||||
self.pcie_failed = False
|
||||
self.power_seen = False
|
||||
self.power_unavailable = False
|
||||
self.power_lost = False
|
||||
self.power_restored = False
|
||||
|
||||
if state is not None:
|
||||
gpu_limit = GPU_TEMP_LIMIT - (TEMP_HYSTERESIS if self.overheated else 0.0)
|
||||
memory_limit = MEMORY_TEMP_LIMIT - (TEMP_HYSTERESIS if self.overheated else 0.0)
|
||||
self.overheated = state.tempC >= gpu_limit or state.memoryTempC >= memory_limit
|
||||
|
||||
missing = expected and (self.usb_failed or (offroad and time.monotonic() - self.started > 10.0 and len(detected) != 1))
|
||||
slow_usb = offroad and len(devices) == 1 and devices[0]["speedMbps"] < 5000
|
||||
set_alert("Offroad_ChestnutNotDetected", missing)
|
||||
set_alert("Offroad_ChestnutOverheated", self.overheated, f"{state.tempC:.0f} °C" if state is not None else None)
|
||||
set_alert("Offroad_ChestnutUsbSlow", slow_usb, f"{devices[0]['speedMbps']} Mbps" if slow_usb else None)
|
||||
if self.power_lost:
|
||||
pcie_alert = ("Chestnut power restored. 12V is stable again, cycle ignition." if self.power_restored else
|
||||
"Chestnut power disconnected. Check 12V connection, then cycle ignition." if self.power_unavailable else
|
||||
"Chestnut power lost. Possibly caused by an engine-crank voltage drop. Check 12V connection, then cycle ignition.")
|
||||
else:
|
||||
pcie_alert = "Chestnut GPU unavailable. PCIe link is not up. Check the GPU is securely seated."
|
||||
set_alert("Offroad_ChestnutPcieUnavailable", expected and self.pcie_failed, pcie_alert)
|
||||
set_alert("Offroad_ChestnutUncompiled", offroad and expected and firmware_ok and not compiled)
|
||||
set_alert("Offroad_ChestnutUpdateFailed", offroad and firmware_failed)
|
||||
self.offroad = offroad
|
||||
@@ -29,12 +29,13 @@ from openpilot.system.hardware.power_monitoring import PowerMonitoring
|
||||
from openpilot.system.hardware.fan_controller import TiciFanController
|
||||
from openpilot.system.hardware.usb import (
|
||||
CHESTNUT_FW_VERSION,
|
||||
CHESTNUT_ROM_USB_IDS,
|
||||
CHESTNUT_USB_IDS,
|
||||
CHESTNUT_USB_PRODUCT,
|
||||
get_usb_state,
|
||||
get_usb_topology,
|
||||
is_chestnut_usb_id,
|
||||
set_usb_state,
|
||||
)
|
||||
from openpilot.system.hardware.chestnut.status import ChestnutStatus
|
||||
from openpilot.system.version import terms_version, training_version
|
||||
from openpilot.system.athena.registration import UNREGISTERED_DONGLE_ID
|
||||
|
||||
@@ -118,11 +119,15 @@ class Chestnut:
|
||||
self.attempts = 0
|
||||
self.last_attempt = 0.0
|
||||
self.flashed = False
|
||||
self.mismatch = False
|
||||
|
||||
@property
|
||||
def failed(self) -> bool:
|
||||
return self.mismatch and self.attempts >= self.MAX_ATTEMPTS and self.thread is not None and not self.thread.is_alive() and not self.flashed
|
||||
|
||||
def _firmware_mismatch(self, usb_state: list[dict]) -> bool:
|
||||
expected = f"custom {CHESTNUT_FW_VERSION}-CLEAN"
|
||||
ids = CHESTNUT_USB_IDS + CHESTNUT_ROM_USB_IDS
|
||||
return any((device["vendorId"], device["productId"]) in ids and device["product"] != expected for device in usb_state)
|
||||
return any(is_chestnut_usb_id(device["vendorId"], device["productId"], include_bootloader=True) and
|
||||
device["product"] != CHESTNUT_USB_PRODUCT for device in usb_state)
|
||||
|
||||
def _flash(self) -> None:
|
||||
script = os.path.join(os.path.dirname(__file__), "chestnut", "flash.py")
|
||||
@@ -137,7 +142,8 @@ class Chestnut:
|
||||
self.flashed = result.returncode == 0
|
||||
|
||||
def update(self, offroad: bool, usb_state: list[dict]) -> None:
|
||||
if not self._firmware_mismatch(usb_state):
|
||||
self.mismatch = self._firmware_mismatch(usb_state)
|
||||
if not self.mismatch:
|
||||
self.flashed = False
|
||||
return
|
||||
if not offroad or self.flashed or self.attempts >= self.MAX_ATTEMPTS:
|
||||
@@ -295,7 +301,7 @@ def hw_state_thread(end_event, hw_queue):
|
||||
|
||||
def hardware_thread(end_event, hw_queue) -> None:
|
||||
pm = messaging.PubMaster(['deviceState'])
|
||||
sm = messaging.SubMaster(["peripheralState", "gpsLocationExternal", "selfdriveState", "pandaStates"], poll="pandaStates")
|
||||
sm = messaging.SubMaster(["peripheralState", "gpsLocationExternal", "selfdriveState", "pandaStates", "chestnutState"], poll="pandaStates")
|
||||
|
||||
count = 0
|
||||
|
||||
@@ -337,6 +343,7 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
params = Params()
|
||||
power_monitor = PowerMonitoring()
|
||||
chestnut = Chestnut() if AGNOS else None
|
||||
chestnut_status = ChestnutStatus() if AGNOS else None
|
||||
|
||||
uptime_offroad: float = params.get("UptimeOffroad", return_default=True)
|
||||
uptime_onroad: float = params.get("UptimeOnroad", return_default=True)
|
||||
@@ -420,6 +427,23 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
set_usb_state(msg.deviceState, last_hw_state.usb_state)
|
||||
if chestnut is not None:
|
||||
chestnut.update(started_ts is None, last_hw_state.usb_state)
|
||||
model_lab_config = params.get("ModelLabConfig")
|
||||
chestnut_expected = bool(params.get("ActiveBigModel")) or (
|
||||
isinstance(model_lab_config, dict) and bool(model_lab_config.get("enabled"))
|
||||
)
|
||||
chestnut_state = sm["chestnutState"]
|
||||
chestnut_valid = sm.alive["chestnutState"] and sm.valid["chestnutState"]
|
||||
chestnut_status.update(
|
||||
started_ts is None,
|
||||
chestnut_expected,
|
||||
last_hw_state.usb_state,
|
||||
chestnut.failed,
|
||||
params.get_bool("UsbGpuLoading"),
|
||||
params.get("UsbGpuActive"),
|
||||
params.get_bool("UsbGpuCompiled"),
|
||||
chestnut_state if chestnut_valid else None,
|
||||
set_offroad_alert_if_changed,
|
||||
)
|
||||
|
||||
# this subset is only used for offroad
|
||||
temp_sources = [
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
from openpilot.system.hardware.chestnut import status as chestnut_status
|
||||
from openpilot.system.hardware.chestnut.status import ChestnutStatus
|
||||
from openpilot.system.hardware.usb import CHESTNUT_USB_PRODUCT
|
||||
|
||||
|
||||
DEVICE = {
|
||||
"vendorId": 0x3801,
|
||||
"productId": 0x0001,
|
||||
"product": CHESTNUT_USB_PRODUCT,
|
||||
"speedMbps": 5000,
|
||||
}
|
||||
STATE = SimpleNamespace(
|
||||
supplyVoltage=12000,
|
||||
supplyFault=False,
|
||||
pcieLtssm=0x78,
|
||||
tempC=50.0,
|
||||
memoryTempC=60.0,
|
||||
)
|
||||
|
||||
|
||||
class Alerts:
|
||||
def __init__(self):
|
||||
self.values = {}
|
||||
|
||||
def set(self, name, enabled, extra=None):
|
||||
self.values[name] = (enabled, extra)
|
||||
|
||||
@property
|
||||
def active(self):
|
||||
return {name for name, (enabled, _) in self.values.items() if enabled}
|
||||
|
||||
|
||||
def update(status, alerts=None, *, offroad=True, expected=True, devices=None, firmware_failed=False,
|
||||
loading=False, active=False, compiled=True, state=STATE):
|
||||
alerts = alerts or Alerts()
|
||||
status.update(
|
||||
offroad,
|
||||
expected,
|
||||
[DEVICE] if devices is None else devices,
|
||||
firmware_failed,
|
||||
loading,
|
||||
active,
|
||||
compiled,
|
||||
state,
|
||||
alerts.set,
|
||||
)
|
||||
return alerts
|
||||
|
||||
|
||||
def test_missing_chestnut_only_alerts_when_expected(monkeypatch):
|
||||
status = ChestnutStatus()
|
||||
monkeypatch.setattr(chestnut_status.time, "monotonic", lambda: status.started + 11.0)
|
||||
assert not update(status, expected=False, devices=[]).active
|
||||
alerts = update(status, expected=True, devices=[])
|
||||
assert alerts.active == {"Offroad_ChestnutNotDetected"}
|
||||
|
||||
|
||||
def test_slow_usb_and_uncompiled_alerts():
|
||||
status = ChestnutStatus()
|
||||
alerts = update(status, devices=[DEVICE | {"speedMbps": 480}])
|
||||
assert alerts.active == {"Offroad_ChestnutUsbSlow"}
|
||||
assert alerts.values["Offroad_ChestnutUsbSlow"][1] == "480 Mbps"
|
||||
|
||||
alerts = update(status, compiled=False)
|
||||
assert alerts.active == {"Offroad_ChestnutUncompiled"}
|
||||
|
||||
|
||||
def test_firmware_failure_alert():
|
||||
alerts = update(ChestnutStatus(), firmware_failed=True)
|
||||
assert alerts.active == {"Offroad_ChestnutUpdateFailed"}
|
||||
|
||||
|
||||
def test_overheat_hysteresis():
|
||||
status = ChestnutStatus()
|
||||
hot = SimpleNamespace(**(vars(STATE) | {"tempC": 101.0}))
|
||||
alerts = update(status, state=hot)
|
||||
assert alerts.active == {"Offroad_ChestnutOverheated"}
|
||||
assert alerts.values["Offroad_ChestnutOverheated"][1] == "101 °C"
|
||||
|
||||
warm = SimpleNamespace(**(vars(STATE) | {"tempC": 97.0}))
|
||||
assert "Offroad_ChestnutOverheated" in update(status, state=warm).active
|
||||
assert "Offroad_ChestnutOverheated" not in update(status).active
|
||||
|
||||
|
||||
def test_pcie_failure_after_model_load():
|
||||
status, alerts = ChestnutStatus(), Alerts()
|
||||
update(status, alerts, offroad=False, loading=True)
|
||||
update(status, alerts, offroad=False, loading=False, active=False)
|
||||
link_down = SimpleNamespace(**(vars(STATE) | {"pcieLtssm": 0x00}))
|
||||
update(status, alerts, offroad=False, state=link_down)
|
||||
assert "Offroad_ChestnutPcieUnavailable" not in alerts.active
|
||||
update(status, alerts, offroad=False, state=link_down)
|
||||
assert alerts.active == {"Offroad_ChestnutPcieUnavailable"}
|
||||
assert "PCIe link is not up" in alerts.values["Offroad_ChestnutPcieUnavailable"][1]
|
||||
|
||||
|
||||
def test_power_loss_reports_cause_and_recovery():
|
||||
status, alerts = ChestnutStatus(), Alerts()
|
||||
update(status, alerts, offroad=False, loading=True)
|
||||
update(status, alerts, offroad=False, loading=False, active=True)
|
||||
low = SimpleNamespace(**(vars(STATE) | {"supplyVoltage": 3000, "supplyFault": True, "pcieLtssm": 0x00}))
|
||||
update(status, alerts, offroad=False, state=low)
|
||||
assert alerts.active == {"Offroad_ChestnutPcieUnavailable"}
|
||||
assert "power lost" in alerts.values["Offroad_ChestnutPcieUnavailable"][1]
|
||||
|
||||
update(status, alerts, offroad=False, state=STATE)
|
||||
assert "power restored" in alerts.values["Offroad_ChestnutPcieUnavailable"][1]
|
||||
|
||||
|
||||
def test_onroad_usb_disconnect_is_latched():
|
||||
status, alerts = ChestnutStatus(), Alerts()
|
||||
update(status, alerts, offroad=False)
|
||||
update(status, alerts, offroad=False, devices=[], state=None)
|
||||
assert alerts.active == {"Offroad_ChestnutNotDetected"}
|
||||
update(status, alerts, offroad=False)
|
||||
assert "Offroad_ChestnutNotDetected" in alerts.active
|
||||
@@ -24,6 +24,13 @@ def test_chestnut_present_with_comma_vendor_id(tmp_path, monkeypatch):
|
||||
assert usb.chestnut_present()
|
||||
|
||||
|
||||
def test_chestnut_usb_ids_include_runtime_and_bootloader():
|
||||
assert usb.is_chestnut_usb_id(0x3801, 0x0001)
|
||||
assert usb.is_chestnut_usb_id(0xADD1, 0x0001)
|
||||
assert not usb.is_chestnut_usb_id(0x174C, 0x2464)
|
||||
assert usb.is_chestnut_usb_id(0x174C, 0x2464, include_bootloader=True)
|
||||
|
||||
|
||||
def test_chestnut_absent_for_other_usb_device(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(usb, "USB_DEVICES_PATH", tmp_path)
|
||||
device = tmp_path / "1-1"
|
||||
|
||||
+10
-5
@@ -7,11 +7,17 @@ CHESTNUT_PRODUCT_ID = 0x0001
|
||||
CHESTNUT_USB_IDS = tuple((vendor_id, CHESTNUT_PRODUCT_ID) for vendor_id in CHESTNUT_VENDOR_IDS)
|
||||
CHESTNUT_FW_VERSION = "ed4e39b7"
|
||||
CHESTNUT_ROM_USB_IDS = ((0x174C, 0x2464), (0x174C, 0x2463))
|
||||
CHESTNUT_USB_PRODUCT = f"custom {CHESTNUT_FW_VERSION}-CLEAN"
|
||||
USB_DEVICES_PATH = Path("/sys/bus/usb/devices")
|
||||
TYPEC_CC_ORIENTATION_PATH = Path("/sys/class/power_supply/usb/typec_cc_orientation")
|
||||
PRIMARY_USB_CONTROLLER = "a600000.ssusb"
|
||||
|
||||
|
||||
def is_chestnut_usb_id(vendor_id: int, product_id: int, include_bootloader: bool = False) -> bool:
|
||||
ids = CHESTNUT_USB_IDS + CHESTNUT_ROM_USB_IDS if include_bootloader else CHESTNUT_USB_IDS
|
||||
return (vendor_id, product_id) in ids
|
||||
|
||||
|
||||
def get_usb_topology() -> set[str]:
|
||||
try:
|
||||
return set(os.listdir(USB_DEVICES_PATH))
|
||||
@@ -47,16 +53,15 @@ def usb_devices() -> list[Path]:
|
||||
|
||||
def chestnut_present() -> bool:
|
||||
return any(
|
||||
(read_int(device / "idVendor", 16), read_int(device / "idProduct", 16)) in CHESTNUT_USB_IDS
|
||||
is_chestnut_usb_id(read_int(device / "idVendor", 16), read_int(device / "idProduct", 16))
|
||||
for device in usb_devices()
|
||||
)
|
||||
|
||||
|
||||
def chestnut_firmware_ready() -> bool:
|
||||
expected = f"custom {CHESTNUT_FW_VERSION}-CLEAN"
|
||||
return any(
|
||||
(read_int(device / "idVendor", 16), read_int(device / "idProduct", 16)) in CHESTNUT_USB_IDS and
|
||||
read_text(device / "product") == expected
|
||||
is_chestnut_usb_id(read_int(device / "idVendor", 16), read_int(device / "idProduct", 16)) and
|
||||
read_text(device / "product") == CHESTNUT_USB_PRODUCT
|
||||
for device in usb_devices()
|
||||
)
|
||||
|
||||
@@ -103,7 +108,7 @@ def set_usb_state(device_state, devices: list[dict]) -> None:
|
||||
entry.linkErrorCount = device["linkErrorCount"]
|
||||
entry.usb3Lane = device.get("usb3Lane", "unknown")
|
||||
|
||||
if (entry.vendorId, entry.productId) in CHESTNUT_USB_IDS:
|
||||
if is_chestnut_usb_id(entry.vendorId, entry.productId):
|
||||
chestnut_found = True
|
||||
|
||||
device_state.chestnutPresent = chestnut_found
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user