MAVLINK: inverti pitch e roll, corrente x10 per mwp
- ATTITUDE: nego pitch e roll (mwp mostrava l'assetto al contrario su entrambi gli assi con telemetria reale). Yaw invariato. - SYS_STATUS/BATTERY_STATUS: corrente ora A*1000 invece di cA (A*100). Workaround del bug mwp (mostra current_battery /10): cosi' 1.2A -> 1.2A in mwp. Non spec-compliant di proposito; overflow int16 oltre ~32A. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -93,8 +93,12 @@ static void mav_tick() {
|
|||||||
if (now - tATT >= 100) { // ATTITUDE 10 Hz
|
if (now - tATT >= 100) { // ATTITUDE 10 Hz
|
||||||
tATT = now;
|
tATT = now;
|
||||||
const float D2R = (float)M_PI / 180.0f;
|
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,
|
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();
|
sendMsg();
|
||||||
}
|
}
|
||||||
if (now - tGPS >= 200) { // GPS_RAW_INT 5 Hz
|
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!)
|
if (now - tSYS >= 500) { // SYS_STATUS 2 Hz (corrente!)
|
||||||
tSYS = now;
|
tSYS = now;
|
||||||
uint16_t vbat_mv = (uint16_t)(c_vbat * 1000.0f);
|
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,
|
mavlink_msg_sys_status_pack(SYSID, COMPID, &mmsg,
|
||||||
0, 0, 0, // sensors present/enabled/health
|
0, 0, 0, // sensors present/enabled/health
|
||||||
0, // load
|
0, // load
|
||||||
@@ -141,7 +149,7 @@ static void mav_tick() {
|
|||||||
0, MAV_BATTERY_FUNCTION_ALL, MAV_BATTERY_TYPE_LIPO,
|
0, MAV_BATTERY_FUNCTION_ALL, MAV_BATTERY_TYPE_LIPO,
|
||||||
INT16_MAX, // temperatura non nota
|
INT16_MAX, // temperatura non nota
|
||||||
volts,
|
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
|
(int32_t)c_mah, // consumo in mAh
|
||||||
-1, // energia consumata non nota
|
-1, // energia consumata non nota
|
||||||
(int8_t)c_rem, // % rimanente
|
(int8_t)c_rem, // % rimanente
|
||||||
|
|||||||
Reference in New Issue
Block a user