[modules] broadcast airspeed over ABI

This commit is contained in:
Christophe De Wagter
2016-07-18 13:35:56 +02:00
parent 469d09258d
commit 3006238bea
3 changed files with 25 additions and 2 deletions
+5 -1
View File
@@ -73,13 +73,17 @@
<field name="z" type="float" unit="m/s"/>
<field name="noise" type="float"/>
</message>
<message name="RSSI" id="13">
<field name="ac_id" type="uint8_t"/>
<field name="source_strength" type="int8_t" unit="dB"/>
<field name="rssi" type="int8_t" unit="dB"/>
</message>
<message name="AIRSPEED" id="14">
<field name="eas" type="float" unit="m/s"/>
</message>
</msg_class>
</protocol>
+19
View File
@@ -59,6 +59,13 @@ static abi_event pressure_diff_ev;
#endif
static abi_event temperature_ev;
/** ABI binding for airspeed
*/
#ifndef AIR_DATA_AIRSPEED_ID
#define AIR_DATA_AIRSPEED_ID ABI_BROADCAST
#endif
static abi_event airspeed_ev;
/** Default factor to convert estimated airspeed (EAS) to true airspeed (TAS) */
#ifndef AIR_DATA_TAS_FACTOR
#define AIR_DATA_TAS_FACTOR 1.0
@@ -144,6 +151,17 @@ static void temperature_cb(uint8_t __attribute__((unused)) sender_id, float temp
}
}
static void airspeed_cb(uint8_t __attribute__((unused)) sender_id, float eas)
{
air_data.airspeed = eas;
if (air_data.calc_airspeed) {
air_data.tas = tas_from_eas(air_data.airspeed);
#if USE_AIRSPEED_AIR_DATA
stateSetAirspeed_f(air_data.airspeed);
#endif
}
}
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
@@ -205,6 +223,7 @@ void air_data_init(void)
AbiBindMsgBARO_ABS(AIR_DATA_BARO_ABS_ID, &pressure_abs_ev, pressure_abs_cb);
AbiBindMsgBARO_DIFF(AIR_DATA_BARO_DIFF_ID, &pressure_diff_ev, pressure_diff_cb);
AbiBindMsgTEMPERATURE(AIR_DATA_TEMPERATURE_ID, &temperature_ev, temperature_cb);
AbiBindMsgAIRSPEED(AIR_DATA_AIRSPEED_ID, &airspeed_ev, airspeed_cb);
#if PERIODIC_TELEMETRY
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_BARO_RAW, send_baro_raw);
+1 -1
View File
@@ -108,7 +108,7 @@ static inline void mag_pitot_parse_msg(void)
case DL_IMCU_REMOTE_AIRSPEED: {
// Should be updated to differential pressure
float pitot_ias = DL_IMCU_REMOTE_AIRSPEED_pitot_IAS(mp_msg_buf);
stateSetAirspeed_f(pitot_ias);
AbiSendMsgAIRSPEED(IMU_MAG_PITOT_ID, pitot_ias);
break;
}