diff --git a/02_telemetry_bridge/src/mode_mavlink.cpp b/02_telemetry_bridge/src/mode_mavlink.cpp index 62dcda8..aef73f5 100644 --- a/02_telemetry_bridge/src/mode_mavlink.cpp +++ b/02_telemetry_bridge/src/mode_mavlink.cpp @@ -93,8 +93,12 @@ static void mav_tick() { if (now - tATT >= 100) { // ATTITUDE 10 Hz tATT = now; const float D2R = (float)M_PI / 180.0f; + // Pitch e roll invertiti: con naso giu' / ala abbassata mwp mostrava + // l'indicatore di assetto nel verso opposto (segno opposto alla + // convenzione attesa dal GCS). Nego pitch e roll per allineare + // l'orizzonte artificiale a mwp. Yaw ok. mavlink_msg_attitude_pack(SYSID, COMPID, &mmsg, - now, c_roll * D2R, c_pitch * D2R, c_yaw * D2R, 0, 0, 0); + now, -c_roll * D2R, -c_pitch * D2R, c_yaw * D2R, 0, 0, 0); sendMsg(); } if (now - tGPS >= 200) { // GPS_RAW_INT 5 Hz @@ -122,7 +126,11 @@ static void mav_tick() { if (now - tSYS >= 500) { // SYS_STATUS 2 Hz (corrente!) tSYS = now; uint16_t vbat_mv = (uint16_t)(c_vbat * 1000.0f); - int16_t curr_ca = (int16_t)(c_curr * 100.0f); // A -> cA (spec MAVLink) + // NB: NON spec-compliant di proposito. Lo spec MAVLink vuole cA (A*100), + // ma mwp interpreta current_battery come mA e divide per 1000, mostrando + // quindi A/10 (1.2A -> 0.12A). Mandiamo A*1000 per compensare il bug di + // mwp: 1.2A -> 1200 -> mwp mostra 1.2A. Limite: overflow int16 oltre ~32A. + int16_t curr_ca = (int16_t)(c_curr * 1000.0f); // A*1000 (workaround mwp) mavlink_msg_sys_status_pack(SYSID, COMPID, &mmsg, 0, 0, 0, // sensors present/enabled/health 0, // load @@ -141,7 +149,7 @@ static void mav_tick() { 0, MAV_BATTERY_FUNCTION_ALL, MAV_BATTERY_TYPE_LIPO, INT16_MAX, // temperatura non nota volts, - (int16_t)(c_curr * 100.0f), // corrente in cA + (int16_t)(c_curr * 1000.0f), // A*1000 (workaround mwp, vedi SYS_STATUS) (int32_t)c_mah, // consumo in mAh -1, // energia consumata non nota (int8_t)c_rem, // % rimanente