Skip to content

Commit

Permalink
fix compilation of modules tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierhattenberger authored and fvantienen committed Sep 19, 2022
1 parent d6fa1a0 commit 5277ae7
Show file tree
Hide file tree
Showing 21 changed files with 75 additions and 49 deletions.
2 changes: 2 additions & 0 deletions conf/modules/gps_nps.xml
Expand Up @@ -21,7 +21,9 @@
<file name="gps_sim_nps.c"/>
<define name="GPS_TYPE_H" value="modules/gps/gps_sim_nps.h" type="string"/>
<test>
<define name="PERIODIC_FREQUENCY" value="500"/>
<include name="../simulator/nps"/>
<include name="../../conf/simulator/nps"/>
<shell cmd="pkg-config glib-2.0 --cflags"/>
</test>
</makefile>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/imu_vectornav.xml
Expand Up @@ -30,6 +30,6 @@
<define name="$(VN_PORT_UPPER)_BAUD" value="$(VN_BAUD)"/>

<file name="vn200_serial.c" dir="peripherals"/>
<file name="imu_vectornav.c"/
<file name="imu_vectornav.c"/>
</makefile>
</module>
2 changes: 2 additions & 0 deletions conf/modules/ins_nps.xml
Expand Up @@ -23,7 +23,9 @@
<!-- use attitude from nps sim -->
<define name="NPS_BYPASS_AHRS" value="TRUE"/>
<test>
<define name="PERIODIC_FREQUENCY" value="500"/>
<include name="../simulator/nps"/>
<include name="../../conf/simulator/nps"/>
<shell cmd="pkg-config glib-2.0 --cflags"/>
</test>
</makefile>
Expand Down
1 change: 0 additions & 1 deletion sw/airborne/modules/ahrs/ahrs_madgwick.c
Expand Up @@ -79,7 +79,6 @@ void ahrs_madgwick_propagate(struct FloatRates* gyro, float dt)
}

// unbias gyro
struct FloatRates gyro_unbiased;
RATES_DIFF(ahrs_madgwick.rates, *gyro, ahrs_madgwick.bias);

// Rate of change of quaternion from gyroscope
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/modules/imu/imu_bmi088_i2c.c
Expand Up @@ -102,7 +102,7 @@ void imu_bmi088_init(void)

// Set the default scaling
imu_set_defaults_gyro(IMU_BMI088_ID, NULL, NULL, BMI088_GYRO_SENS_FRAC[IMU_BMI088_GYRO_RANGE]);
imu_set_defaults_accel(IMU_BMI088_ID, NULL, NULL, MI088_ACCEL_SENS_FRAC[IMU_BMI088_ACCEL_RANGE]);
imu_set_defaults_accel(IMU_BMI088_ID, NULL, NULL, BMI088_ACCEL_SENS_FRAC[IMU_BMI088_ACCEL_RANGE]);
}

void imu_bmi088_periodic(void)
Expand Down
10 changes: 8 additions & 2 deletions sw/airborne/modules/imu/imu_disco.c
Expand Up @@ -139,7 +139,13 @@ void imu_disco_event(void)
ak8963_event(&imu_disco.ak);

if (imu_disco.ak.data_available) {
AbiSendMsgIMU_MAG_RAW(IMU_BOARD_ID, now_ts, &imu_disco.ak.data.vect);
imu_disco.ak.data_available = false;
struct Int32Vect3 mag;
VECT3_ASSIGN(mag,
imu_disco.ak.data.vect.x,
imu_disco.ak.data.vect.y,
imu_disco.ak.data.vect.z);

AbiSendMsgIMU_MAG_RAW(IMU_BOARD_ID, now_ts, &mag);
imu_disco.ak.data_available = false;
}
}
2 changes: 1 addition & 1 deletion sw/airborne/modules/imu/imu_mpu6000_hmc5883.c
Expand Up @@ -167,7 +167,7 @@ void imu_mpu_hmc_event(void)
};

imu_mpu_hmc.mpu.data_available = false;
AbiSendMsgIMU_GYRO_RAW(IMU_MPU6000_HMC_ID, now_ts, &gyro, 1);
AbiSendMsgIMU_GYRO_RAW(IMU_MPU6000_HMC_ID, now_ts, &rates, 1);
AbiSendMsgIMU_ACCEL_RAW(IMU_MPU6000_HMC_ID, now_ts, &accel, 1);
}

Expand Down
9 changes: 6 additions & 3 deletions sw/airborne/modules/imu/imu_mpu9250.c
Expand Up @@ -51,28 +51,31 @@ void imu_mpu9250_event(void)

#include "math/pprz_algebra_int.h"
#include "modules/datalink/downlink.h"
#include "modules/core/abi.h"

void imu_mpu9250_report(void)
{
uint8_t id = IMU_MPU9250_ID;

struct Int32Vect3 accel = {
(int32_t)(mpu9250.data_accel.vect.x),
(int32_t)(mpu9250.data_accel.vect.y),
(int32_t)(mpu9250.data_accel.vect.z)
};
DOWNLINK_SEND_IMU_ACCEL_RAW(DefaultChannel, DefaultDevice, &accel.x, &accel.y, &accel.z);
DOWNLINK_SEND_IMU_ACCEL_RAW(DefaultChannel, DefaultDevice, &id, &accel.x, &accel.y, &accel.z);

struct Int32Rates rates = {
(int32_t)(mpu9250.data_rates.rates.p),
(int32_t)(mpu9250.data_rates.rates.q),
(int32_t)(mpu9250.data_rates.rates.r)
};
DOWNLINK_SEND_IMU_GYRO_RAW(DefaultChannel, DefaultDevice, &rates.p, &rates.q, &rates.r);
DOWNLINK_SEND_IMU_GYRO_RAW(DefaultChannel, DefaultDevice, &id, &rates.p, &rates.q, &rates.r);

struct Int32Vect3 mag = {
(int32_t)(mpu9250.akm.data.vect.x),
(int32_t)(mpu9250.akm.data.vect.y),
(int32_t)(mpu9250.akm.data.vect.z)
};
DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice, &mag.x, &mag.y, &mag.z);
DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice, &id, &mag.x, &mag.y, &mag.z);
}

4 changes: 2 additions & 2 deletions sw/airborne/modules/imu/imu_mpu9250_i2c.c
Expand Up @@ -142,8 +142,8 @@ void imu_mpu9250_event(void)
};

imu_mpu9250.mpu.data_available = false;
AbiSendMsgIMU_GYRO_RAW(IMU_MPU9250_ID, now_ts, &gyro, 1);
AbiSendMsgIMU_ACCEL_INT32(IMU_MPU9250_ID, now_ts, &accel, 1);
AbiSendMsgIMU_GYRO_RAW(IMU_MPU9250_ID, now_ts, &rates, 1);
AbiSendMsgIMU_ACCEL_RAW(IMU_MPU9250_ID, now_ts, &accel, 1);
}
#if IMU_MPU9250_READ_MAG
// Test if mag data are updated
Expand Down
7 changes: 6 additions & 1 deletion sw/airborne/modules/imu/imu_px4fmu_v2.4.c
Expand Up @@ -104,7 +104,12 @@ void imu_px4_event(void) {
#if !IMU_PX4_DISABLE_MAG
lsm303d_spi_event(&imu_px4.lsm_mag);
if (imu_px4.lsm_mag.data_available_mag) {
AbiSendMsgIMU_MAG_RAW(IMU_PX4_ID, now_ts, &imu_px4.lsm_mag.data_mag.vect);
struct Int32Vect3 mag;
VECT3_ASSIGN(mag,
imu_px4.lsm_mag.data_mag.vect.x,
imu_px4.lsm_mag.data_mag.vect.y,
imu_px4.lsm_mag.data_mag.vect.z);
AbiSendMsgIMU_MAG_RAW(IMU_PX4_ID, now_ts, &mag);
imu_px4.lsm_mag.data_available_mag = FALSE;
}
#endif
Expand Down
33 changes: 24 additions & 9 deletions sw/airborne/modules/ins/imu_xsens.c
Expand Up @@ -65,33 +65,48 @@ static void handle_ins_msg(void)
}
if (xsens.accel_available) {
struct Int32Vect3 accel = {
-ACCEL_BFP_OF_REAL(xsens.accel.ax),
-ACCEL_BFP_OF_REAL(xsens.accel.ay),
ACCEL_BFP_OF_REAL(xsens.accel.az)
-ACCEL_BFP_OF_REAL(xsens.accel.x),
-ACCEL_BFP_OF_REAL(xsens.accel.y),
ACCEL_BFP_OF_REAL(xsens.accel.z)
};
xsens.accel_available = FALSE;
AbiSendMsgIMU_ACCEL_RAW(IMU_XSENS_ID, now_ts, &accel, 1);
}
if (xsens.mag_available) {
struct Int32Vect3 mag = {
-MAG_BFP_OF_REAL(xsens.mag.mx),
-MAG_BFP_OF_REAL(xsens.mag.my),
MAG_BFP_OF_REAL(xsens.mag.mz)
-MAG_BFP_OF_REAL(xsens.mag.x),
-MAG_BFP_OF_REAL(xsens.mag.y),
MAG_BFP_OF_REAL(xsens.mag.z)
};
xsens.mag_available = FALSE;
AbiSendMsgIMU_MAG_RAW(IMU_XSENS_ID, now_ts, &mag);
}
#else
if (xsens.gyro_available) {
AbiSendMsgIMU_GYRO_RAW(IMU_XSENS_ID, now_ts, &xsens.gyro, 1);
struct Int32Rates gyro = {
RATE_BFP_OF_REAL(xsens.gyro.p),
RATE_BFP_OF_REAL(xsens.gyro.q),
RATE_BFP_OF_REAL(xsens.gyro.r)
};
AbiSendMsgIMU_GYRO_RAW(IMU_XSENS_ID, now_ts, &gyro, 1);
xsens.gyro_available = FALSE;
}
if (xsens.accel_available) {
AbiSendMsgIMU_ACCEL_RAW(IMU_XSENS_ID, now_ts, &xsens.accel, 1);
struct Int32Vect3 accel = {
ACCEL_BFP_OF_REAL(xsens.accel.x),
ACCEL_BFP_OF_REAL(xsens.accel.y),
ACCEL_BFP_OF_REAL(xsens.accel.z)
};
AbiSendMsgIMU_ACCEL_RAW(IMU_XSENS_ID, now_ts, &accel, 1);
xsens.accel_available = FALSE;
}
if (xsens.mag_available) {
AbiSendMsgIMU_MAG_RAW(IMU_XSENS_ID, now_ts, &xsens.mag);
struct Int32Vect3 mag = {
MAG_BFP_OF_REAL(xsens.mag.x),
MAG_BFP_OF_REAL(xsens.mag.y),
MAG_BFP_OF_REAL(xsens.mag.z)
};
AbiSendMsgIMU_MAG_RAW(IMU_XSENS_ID, now_ts, &mag);
xsens.mag_available = FALSE;
}
#endif /* XSENS_BACKWARDS */
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/modules/ins/ins_mekf_wind_wrapper.c
Expand Up @@ -301,7 +301,7 @@ static void gyro_cb(uint8_t sender_id __attribute__((unused)),
uint32_t stamp, struct Int32Rates *gyro)
{
if (ins_mekf_wind.is_aligned) {
struct FloatRates gyro_f, gyro_body;
struct FloatRates gyro_body;
RATES_FLOAT_OF_BFP(gyro_body, *gyro);

#if USE_AUTO_INS_FREQ || !defined(INS_PROPAGATE_FREQUENCY)
Expand Down
12 changes: 8 additions & 4 deletions sw/airborne/modules/ins/ins_vectornav.c
Expand Up @@ -74,25 +74,29 @@ static void send_vn_info(struct transport_tx *trans, struct link_device *dev)

static void send_accel(struct transport_tx *trans, struct link_device *dev)
{
pprz_msg_send_IMU_ACCEL(trans, dev, AC_ID,
uint8_t id = IMU_VECTORNAV_ID;
pprz_msg_send_IMU_ACCEL(trans, dev, AC_ID, &id,
&ins_vn.vn_data.accel.x, &ins_vn.vn_data.accel.y, &ins_vn.vn_data.accel.z);
}

static void send_gyro(struct transport_tx *trans, struct link_device *dev)
{
pprz_msg_send_IMU_GYRO(trans, dev, AC_ID,
uint8_t id = IMU_VECTORNAV_ID;
pprz_msg_send_IMU_GYRO(trans, dev, AC_ID, &id,
&ins_vn.vn_data.gyro.p, &ins_vn.vn_data.gyro.q, &ins_vn.vn_data.gyro.r);
}

static void send_accel_scaled(struct transport_tx *trans, struct link_device *dev)
{
pprz_msg_send_IMU_ACCEL_SCALED(trans, dev, AC_ID,
uint8_t id = IMU_VECTORNAV_ID;
pprz_msg_send_IMU_ACCEL_SCALED(trans, dev, AC_ID, &id,
&ins_vn.accel_i.x, &ins_vn.accel_i.y, &ins_vn.accel_i.z);
}

static void send_gyro_scaled(struct transport_tx *trans, struct link_device *dev)
{
pprz_msg_send_IMU_GYRO_SCALED(trans, dev, AC_ID,
uint8_t id = IMU_VECTORNAV_ID;
pprz_msg_send_IMU_GYRO_SCALED(trans, dev, AC_ID, &id,
&ins_vn.gyro_i.p, &ins_vn.gyro_i.q, &ins_vn.gyro_i.r);
}
#endif
Expand Down
5 changes: 3 additions & 2 deletions sw/airborne/modules/sensors/mag_hmc5843.c
Expand Up @@ -22,7 +22,7 @@
#include "pprzlink/messages.h"
#include "modules/datalink/downlink.h"
#include <math.h>

#include "modules/core/abi.h"
#include "../../peripherals/hmc5843.h"


Expand All @@ -43,7 +43,8 @@ void hmc5843_module_periodic(void)
mag_x = hmc5843.data.value[0];
mag_y = hmc5843.data.value[1];
mag_z = hmc5843.data.value[2];
RunOnceEvery(30, DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice, &mag_x, &mag_y, &mag_z));
uint8_t id = MAG_HMC58XX_SENDER_ID;
RunOnceEvery(30, DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice, &id, &mag_x, &mag_y, &mag_z));
}

void hmc5843_module_event(void)
Expand Down
5 changes: 2 additions & 3 deletions sw/airborne/modules/sensors/mag_hmc58xx.c
Expand Up @@ -30,6 +30,7 @@
#include "pprzlink/messages.h"
#include "modules/datalink/downlink.h"
#include "generated/airframe.h"
#include "modules/core/abi.h"

#ifndef HMC58XX_CHAN_X
#define HMC58XX_CHAN_X 0
Expand All @@ -51,8 +52,6 @@
#endif

#if MODULE_HMC58XX_UPDATE_AHRS
#include "modules/imu/imu.h"
#include "modules/core/abi.h"

#if defined HMC58XX_MAG_TO_IMU_PHI && defined HMC58XX_MAG_TO_IMU_THETA && defined HMC58XX_MAG_TO_IMU_PSI
#define USE_MAG_TO_IMU 1
Expand Down Expand Up @@ -106,7 +105,7 @@ void mag_hmc58xx_module_event(void)
// unscaled vector
VECT3_COPY(mag, imu_mag);
#endif

AbiSendMsgIMU_MAG_RAW(MAG_HMC58XX_SENDER_ID, now_ts, &mag);
#endif
#if MODULE_HMC58XX_SYNC_SEND
Expand Down
6 changes: 1 addition & 5 deletions sw/airborne/modules/sensors/mag_ist8310.c
Expand Up @@ -29,6 +29,7 @@
#include "pprzlink/messages.h"
#include "modules/datalink/downlink.h"
#include "generated/airframe.h"
#include "modules/core/abi.h"

#ifndef IST8310_CHAN_X
#define IST8310_CHAN_X 1
Expand All @@ -49,11 +50,6 @@
#define IST8310_CHAN_Z_SIGN +
#endif

#if MODULE_IST8310_UPDATE_AHRS
#include "modules/imu/imu.h"
#include "modules/core/abi.h"
#endif

struct IST8310 mag_ist8310;

void mag_ist8310_module_init(void)
Expand Down
6 changes: 1 addition & 5 deletions sw/airborne/modules/sensors/mag_lis3mdl.c
Expand Up @@ -29,6 +29,7 @@
#include "pprzlink/messages.h"
#include "modules/datalink/downlink.h"
#include "generated/airframe.h"
#include "modules/core/abi.h"

#ifndef LIS3MDL_CHAN_X
#define LIS3MDL_CHAN_X 0
Expand All @@ -49,11 +50,6 @@
#define LIS3MDL_CHAN_Z_SIGN +
#endif

#if MODULE_LIS3MDL_UPDATE_AHRS
#include "modules/imu/imu.h"
#include "modules/core/abi.h"
#endif

struct Lis3mdl mag_lis3mdl;

void mag_lis3mdl_module_init(void)
Expand Down
3 changes: 1 addition & 2 deletions sw/airborne/modules/sensors/mag_rm3100.c
Expand Up @@ -29,6 +29,7 @@
#include "pprzlink/messages.h"
#include "modules/datalink/downlink.h"
#include "generated/airframe.h"
#include "modules/core/abi.h"

#ifndef RM3100_CHAN_X
#define RM3100_CHAN_X 0
Expand Down Expand Up @@ -58,8 +59,6 @@
#endif

#if MODULE_RM3100_UPDATE_AHRS
#include "modules/imu/imu.h"
#include "modules/core/abi.h"

#if defined RM3100_MAG_TO_IMU_PHI && defined RM3100_MAG_TO_IMU_THETA && defined RM3100_MAG_TO_IMU_PSI
#define USE_MAG_TO_IMU 1
Expand Down
1 change: 1 addition & 0 deletions sw/airborne/peripherals/bmi088.h
Expand Up @@ -28,6 +28,7 @@
#define BMI088_H

#include "std.h"
#include "math/pprz_algebra_int.h"

/* Include address and register definition */
#include "peripherals/bmi088_regs.h"
Expand Down
5 changes: 2 additions & 3 deletions sw/airborne/peripherals/mpu60x0.c
Expand Up @@ -14,9 +14,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* along with paparazzi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/

/**
Expand Down
5 changes: 2 additions & 3 deletions sw/airborne/peripherals/mpu60x0.h
Expand Up @@ -14,9 +14,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* along with paparazzi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/

/**
Expand Down

0 comments on commit 5277ae7

Please sign in to comment.