Skip to content

Commit

Permalink
[abi] update ABI bindings to pass single types by value
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Feb 7, 2015
1 parent 12e256d commit 9f0240d
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 136 deletions.
14 changes: 7 additions & 7 deletions conf/abi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@

<message name="IMU_GYRO_INT32" id="4">
<field name="stamp" type="uint32_t" unit="us"/>
<field name="gyro" type="struct Int32Rates"/>
<field name="gyro" type="struct Int32Rates *"/>
</message>

<message name="IMU_ACCEL_INT32" id="5">
<field name="stamp" type="uint32_t" unit="us"/>
<field name="accel" type="struct Int32Vect3"/>
<field name="accel" type="struct Int32Vect3 *"/>
</message>

<message name="IMU_MAG_INT32" id="6">
<field name="stamp" type="uint32_t" unit="us"/>
<field name="mag" type="struct Int32Vect3"/>
<field name="mag" type="struct Int32Vect3 *"/>
</message>

<message name="IMU_LOWPASSED" id="7">
<field name="stamp" type="uint32_t" unit="us"/>
<field name="gyro" type="struct Int32Rates"/>
<field name="accel" type="struct Int32Vect3"/>
<field name="mag" type="struct Int32Vect3"/>
<field name="gyro" type="struct Int32Rates *"/>
<field name="accel" type="struct Int32Vect3 *"/>
<field name="mag" type="struct Int32Vect3 *"/>
</message>

<message name="BODY_TO_IMU_QUAT" id="8">
<field name="q_b2i_f" type="struct FloatQuat"/>
<field name="q_b2i_f" type="struct FloatQuat *"/>
</message>

</msg_class>
Expand Down
6 changes: 3 additions & 3 deletions sw/airborne/firmwares/fixedwing/main_ap.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ static inline void on_accel_event(void)

imu_scale_accel(&imu);

AbiSendMsgIMU_ACCEL_INT32(1, &now_ts, &imu.accel);
AbiSendMsgIMU_ACCEL_INT32(1, now_ts, &imu.accel);
}

static inline void on_gyro_event(void)
Expand All @@ -778,7 +778,7 @@ static inline void on_gyro_event(void)

imu_scale_gyro(&imu);

AbiSendMsgIMU_GYRO_INT32(1, &now_ts, &imu.gyro_prev);
AbiSendMsgIMU_GYRO_INT32(1, now_ts, &imu.gyro_prev);

#if USE_AHRS_ALIGNER
if (ahrs_aligner.status != AHRS_ALIGNER_LOCKED) {
Expand Down Expand Up @@ -818,7 +818,7 @@ static inline void on_mag_event(void)
uint32_t now_ts = get_sys_time_usec();

imu_scale_mag(&imu);
AbiSendMsgIMU_MAG_INT32(1, &now_ts, &imu.mag);
AbiSendMsgIMU_MAG_INT32(1, now_ts, &imu.mag);
#endif
}

Expand Down
6 changes: 3 additions & 3 deletions sw/airborne/firmwares/rotorcraft/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ static inline void on_accel_event( void ) {

imu_scale_accel(&imu);

AbiSendMsgIMU_ACCEL_INT32(1, &now_ts, &imu.accel);
AbiSendMsgIMU_ACCEL_INT32(1, now_ts, &imu.accel);
}

static inline void on_gyro_event( void ) {
Expand All @@ -371,7 +371,7 @@ static inline void on_gyro_event( void ) {

imu_scale_gyro(&imu);

AbiSendMsgIMU_GYRO_INT32(1, &now_ts, &imu.gyro_prev);
AbiSendMsgIMU_GYRO_INT32(1, now_ts, &imu.gyro_prev);

#if USE_AHRS_ALIGNER
if (ahrs_aligner.status != AHRS_ALIGNER_LOCKED) {
Expand Down Expand Up @@ -420,7 +420,7 @@ static inline void on_mag_event(void)
// current timestamp
uint32_t now_ts = get_sys_time_usec();

AbiSendMsgIMU_MAG_INT32(1, &now_ts, &imu.mag);
AbiSendMsgIMU_MAG_INT32(1, now_ts, &imu.mag);

#ifdef USE_VEHICLE_INTERFACE
vi_notify_mag_available();
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/modules/sensors/mag_hmc58xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void mag_hmc58xx_module_event(void)
// scale vector
imu_scale_mag(&imu);

AbiSendMsgIMU_MAG_INT32(MAG_HMC58XX_SENDER_ID, &now_ts, &imu.mag);
AbiSendMsgIMU_MAG_INT32(MAG_HMC58XX_SENDER_ID, now_ts, &imu.mag);
#endif
#if MODULE_HMC58XX_SYNC_SEND
mag_hmc58xx_report();
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/subsystems/ahrs/ahrs_aligner.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void ahrs_aligner_run(void)
LED_ON(AHRS_ALIGNER_LED);
#endif
uint32_t now_ts = get_sys_time_usec();
AbiSendMsgIMU_LOWPASSED(ABI_BROADCAST, &now_ts, &ahrs_aligner.lp_gyro,
AbiSendMsgIMU_LOWPASSED(ABI_BROADCAST, now_ts, &ahrs_aligner.lp_gyro,
&ahrs_aligner.lp_accel, &ahrs_aligner.lp_mag);
}
}
Expand Down
45 changes: 22 additions & 23 deletions sw/airborne/subsystems/ahrs/ahrs_float_cmpl_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,40 +69,40 @@ static abi_event aligner_ev;
static abi_event body_to_imu_ev;


static void gyro_cb(uint8_t __attribute__((unused)) sender_id, const uint32_t *stamp,
const struct Int32Rates *gyro)
static void gyro_cb(uint8_t __attribute__((unused)) sender_id, uint32_t stamp,
struct Int32Rates *gyro)
{
#if USE_AUTO_AHRS_FREQ || !defined(AHRS_PROPAGATE_FREQUENCY)
PRINT_CONFIG_MSG("Calculating dt for AHRS_FC propagation.")
/* timestamp in usec when last callback was received */
static uint32_t last_stamp = 0;

if (last_stamp > 0 && ahrs_fc.is_aligned) {
float dt = (float)(*stamp - last_stamp) * 1e-6;
ahrs_fc_propagate((struct Int32Rates *)gyro, dt);
float dt = (float)(stamp - last_stamp) * 1e-6;
ahrs_fc_propagate(gyro, dt);
}
last_stamp = *stamp;
last_stamp = stamp;
#else
PRINT_CONFIG_MSG("Using fixed AHRS_PROPAGATE_FREQUENCY for AHRS_FC propagation.")
PRINT_CONFIG_VAR(AHRS_PROPAGATE_FREQUENCY)
if (ahrs_fc.status == AHRS_FC_RUNNING) {
const float dt = 1. / (AHRS_PROPAGATE_FREQUENCY);
ahrs_fc_propagate((struct Int32Rates *)gyro, dt);
ahrs_fc_propagate(gyro, dt);
}
#endif
}

static void accel_cb(uint8_t __attribute__((unused)) sender_id, const uint32_t *stamp,
const struct Int32Vect3 *accel)
static void accel_cb(uint8_t __attribute__((unused)) sender_id, uint32_t stamp,
struct Int32Vect3 *accel)
{
#if USE_AUTO_AHRS_FREQ || !defined(AHRS_CORRECT_FREQUENCY)
PRINT_CONFIG_MSG("Calculating dt for AHRS float_cmpl accel update.")
static uint32_t last_stamp = 0;
if (last_stamp > 0 && ahrs_fc.is_aligned) {
float dt = (float)(*stamp - last_stamp) * 1e-6;
float dt = (float)(stamp - last_stamp) * 1e-6;
ahrs_fc_update_accel((struct Int32Vect3 *)accel, dt);
}
last_stamp = *stamp;
last_stamp = stamp;
#else
PRINT_CONFIG_MSG("Using fixed AHRS_CORRECT_FREQUENCY for AHRS float_cmpl accel update.")
PRINT_CONFIG_VAR(AHRS_CORRECT_FREQUENCY)
Expand All @@ -113,42 +113,41 @@ static void accel_cb(uint8_t __attribute__((unused)) sender_id, const uint32_t *
#endif
}

static void mag_cb(uint8_t __attribute__((unused)) sender_id, const uint32_t *stamp,
const struct Int32Vect3 *mag)
static void mag_cb(uint8_t __attribute__((unused)) sender_id, uint32_t stamp,
struct Int32Vect3 *mag)
{
#if USE_AUTO_AHRS_FREQ || !defined(AHRS_MAG_CORRECT_FREQUENCY)
PRINT_CONFIG_MSG("Calculating dt for AHRS float_cmpl mag update.")
static uint32_t last_stamp = 0;
if (last_stamp > 0 && ahrs_fc.is_aligned) {
float dt = (float)(*stamp - last_stamp) * 1e-6;
ahrs_fc_update_mag((struct Int32Vect3 *)mag, dt);
float dt = (float)(stamp - last_stamp) * 1e-6;
ahrs_fc_update_mag(mag, dt);
}
last_stamp = *stamp;
last_stamp = stamp;
#else
PRINT_CONFIG_MSG("Using fixed AHRS_MAG_CORRECT_FREQUENCY for AHRS float_cmpl mag update.")
PRINT_CONFIG_VAR(AHRS_MAG_CORRECT_FREQUENCY)
if (ahrs_fc.is_aligned) {
const float dt = 1. / (AHRS_MAG_CORRECT_FREQUENCY);
ahrs_fc_update_mag((struct Int32Vect3 *)mag, dt);
ahrs_fc_update_mag(mag, dt);
}
#endif
}

static void aligner_cb(uint8_t __attribute__((unused)) sender_id,
const uint32_t *stamp __attribute__((unused)),
const struct Int32Rates *lp_gyro, const struct Int32Vect3 *lp_accel,
const struct Int32Vect3 *lp_mag)
uint32_t stamp __attribute__((unused)),
struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel,
struct Int32Vect3 *lp_mag)
{
if (!ahrs_fc.is_aligned) {
ahrs_fc_align((struct Int32Rates *)lp_gyro, (struct Int32Vect3 *)lp_accel,
(struct Int32Vect3 *)lp_mag);
ahrs_fc_align(lp_gyro, lp_accel, lp_mag);
}
}

static void body_to_imu_cb(uint8_t sender_id __attribute__((unused)),
const struct FloatQuat *q_b2i_f)
struct FloatQuat *q_b2i_f)
{
ahrs_fc_set_body_to_imu_quat((struct FloatQuat *)q_b2i_f);
ahrs_fc_set_body_to_imu_quat(q_b2i_f);
}

void ahrs_fc_register(void)
Expand Down
37 changes: 18 additions & 19 deletions sw/airborne/subsystems/ahrs/ahrs_float_dcm_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,61 +42,60 @@ static abi_event aligner_ev;
static abi_event body_to_imu_ev;


static void gyro_cb(uint8_t __attribute__((unused)) sender_id, const uint32_t *stamp,
const struct Int32Rates *gyro)
static void gyro_cb(uint8_t __attribute__((unused)) sender_id, uint32_t stamp,
struct Int32Rates *gyro)
{
#if USE_AUTO_AHRS_FREQ || !defined(AHRS_PROPAGATE_FREQUENCY)
PRINT_CONFIG_MSG("Calculating dt for AHRS dcm propagation.")
/* timestamp in usec when last callback was received */
static uint32_t last_stamp = 0;
if (last_stamp > 0 && ahrs_dcm.is_aligned) {
float dt = (float)(*stamp - last_stamp) * 1e-6;
ahrs_dcm_propagate((struct Int32Rates *)gyro, dt);
float dt = (float)(stamp - last_stamp) * 1e-6;
ahrs_dcm_propagate(gyro, dt);
}
last_stamp = *stamp;
last_stamp = stamp;
#else
PRINT_CONFIG_MSG("Using fixed AHRS_PROPAGATE_FREQUENCY for AHRS dcm propagation.")
PRINT_CONFIG_VAR(AHRS_PROPAGATE_FREQUENCY)
if (ahrs_dcm.is_aligned) {
const float dt = 1. / (AHRS_PROPAGATE_FREQUENCY);
ahrs_dcm_propagate((struct Int32Rates *)gyro, dt);
ahrs_dcm_propagate(gyro, dt);
}
#endif
}

static void accel_cb(uint8_t sender_id __attribute__((unused)),
const uint32_t *stamp __attribute__((unused)),
const struct Int32Vect3 *accel)
uint32_t stamp __attribute__((unused)),
struct Int32Vect3 *accel)
{
if (ahrs_dcm.is_aligned) {
ahrs_dcm_update_accel((struct Int32Vect3 *)accel);
ahrs_dcm_update_accel(accel);
}
}

static void mag_cb(uint8_t sender_id __attribute__((unused)),
const uint32_t *stamp __attribute__((unused)),
const struct Int32Vect3 *mag)
uint32_t stamp __attribute__((unused)),
struct Int32Vect3 *mag)
{
if (ahrs_dcm.is_aligned) {
ahrs_dcm_update_mag((struct Int32Vect3 *)mag);
ahrs_dcm_update_mag(mag);
}
}

static void aligner_cb(uint8_t __attribute__((unused)) sender_id,
const uint32_t *stamp __attribute__((unused)),
const struct Int32Rates *lp_gyro, const struct Int32Vect3 *lp_accel,
const struct Int32Vect3 *lp_mag)
uint32_t stamp __attribute__((unused)),
struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel,
struct Int32Vect3 *lp_mag)
{
if (!ahrs_dcm.is_aligned) {
ahrs_dcm_align((struct Int32Rates *)lp_gyro, (struct Int32Vect3 *)lp_accel,
(struct Int32Vect3 *)lp_mag);
ahrs_dcm_align(lp_gyro, lp_accel, lp_mag);
}
}

static void body_to_imu_cb(uint8_t sender_id __attribute__((unused)),
const struct FloatQuat *q_b2i_f)
struct FloatQuat *q_b2i_f)
{
ahrs_dcm_set_body_to_imu_quat((struct FloatQuat *)q_b2i_f);
ahrs_dcm_set_body_to_imu_quat(q_b2i_f);
}

void ahrs_dcm_register(void)
Expand Down
37 changes: 18 additions & 19 deletions sw/airborne/subsystems/ahrs/ahrs_float_mlkf_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,62 +53,61 @@ static abi_event aligner_ev;
static abi_event body_to_imu_ev;


static void gyro_cb(uint8_t __attribute__((unused)) sender_id, const uint32_t *stamp,
const struct Int32Rates *gyro)
static void gyro_cb(uint8_t __attribute__((unused)) sender_id, uint32_t stamp,
struct Int32Rates *gyro)
{
#if USE_AUTO_AHRS_FREQ || !defined(AHRS_PROPAGATE_FREQUENCY)
PRINT_CONFIG_MSG("Calculating dt for AHRS_MLKF propagation.")
/* timestamp in usec when last callback was received */
static uint32_t last_stamp = 0;

if (last_stamp > 0 && ahrs_mlkf.is_aligned) {
float dt = (float)(*stamp - last_stamp) * 1e-6;
ahrs_mlkf_propagate((struct Int32Rates *)gyro, dt);
float dt = (float)(stamp - last_stamp) * 1e-6;
ahrs_mlkf_propagate(gyro, dt);
}
last_stamp = *stamp;
last_stamp = stamp;
#else
PRINT_CONFIG_MSG("Using fixed AHRS_PROPAGATE_FREQUENCY for AHRS_MLKF propagation.")
PRINT_CONFIG_VAR(AHRS_PROPAGATE_FREQUENCY)
if (ahrs_mlkf.status == AHRS_MLKF_RUNNING) {
const float dt = 1. / (AHRS_PROPAGATE_FREQUENCY);
ahrs_mlkf_propagate((struct Int32Rates *)gyro, dt);
ahrs_mlkf_propagate(gyro, dt);
}
#endif
}

static void accel_cb(uint8_t sender_id __attribute__((unused)),
const uint32_t *stamp __attribute__((unused)),
const struct Int32Vect3 *accel)
uint32_t stamp __attribute__((unused)),
struct Int32Vect3 *accel)
{
if (ahrs_mlkf.is_aligned) {
ahrs_mlkf_update_accel((struct Int32Vect3 *)accel);
ahrs_mlkf_update_accel(accel);
}
}

static void mag_cb(uint8_t sender_id __attribute__((unused)),
const uint32_t *stamp __attribute__((unused)),
const struct Int32Vect3 *mag)
uint32_t stamp __attribute__((unused)),
struct Int32Vect3 *mag)
{
if (ahrs_mlkf.is_aligned) {
ahrs_mlkf_update_mag((struct Int32Vect3 *)mag);
ahrs_mlkf_update_mag(mag);
}
}

static void aligner_cb(uint8_t __attribute__((unused)) sender_id,
const uint32_t *stamp __attribute__((unused)),
const struct Int32Rates *lp_gyro, const struct Int32Vect3 *lp_accel,
const struct Int32Vect3 *lp_mag)
uint32_t stamp __attribute__((unused)),
struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel,
struct Int32Vect3 *lp_mag)
{
if (!ahrs_mlkf.is_aligned) {
ahrs_mlkf_align((struct Int32Rates *)lp_gyro, (struct Int32Vect3 *)lp_accel,
(struct Int32Vect3 *)lp_mag);
ahrs_mlkf_align(lp_accel, lp_accel, lp_mag);
}
}

static void body_to_imu_cb(uint8_t sender_id __attribute__((unused)),
const struct FloatQuat *q_b2i_f)
struct FloatQuat *q_b2i_f)
{
ahrs_mlkf_set_body_to_imu_quat((struct FloatQuat *)q_b2i_f);
ahrs_mlkf_set_body_to_imu_quat(q_b2i_f);
}

void ahrs_mlkf_register(void)
Expand Down
6 changes: 3 additions & 3 deletions sw/airborne/subsystems/ahrs/ahrs_infrared.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ float heading;
static abi_event gyro_ev;

static void gyro_cb(uint8_t sender_id __attribute__((unused)),
const uint32_t *stamp __attribute__((unused)),
const struct Int32Rates *gyro)
uint32_t stamp __attribute__((unused)),
struct Int32Rates *gyro)
{
stateSetBodyRates_i((struct Int32Rates *)gyro);
stateSetBodyRates_i(gyro);
}


Expand Down
Loading

0 comments on commit 9f0240d

Please sign in to comment.