From 04a8377462b1f120ae7b309955eab405f2eaf864 Mon Sep 17 00:00:00 2001 From: Victor Mayoral Vilches Date: Sat, 2 Aug 2014 17:15:25 -0700 Subject: [PATCH] Tools: Change sensor configurations easily. This shell script allows to change the sensor configuration (for now just supports IMU changes) so that the autopilot is compiled for different combinations of sensors. This has probed to be useful with Linux-based boards (e.g.: PXF, Erle-board) that include serveral, different sensors for each kind. --- Tools/Linux_HAL_Essentials/sensor-select.sh | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 Tools/Linux_HAL_Essentials/sensor-select.sh diff --git a/Tools/Linux_HAL_Essentials/sensor-select.sh b/Tools/Linux_HAL_Essentials/sensor-select.sh new file mode 100755 index 0000000000..f1c9188a87 --- /dev/null +++ b/Tools/Linux_HAL_Essentials/sensor-select.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# This script allows you to select which sensors you can use. For now it's resctricted to IMU use +# Coded by VĂ­ctor Mayoral Vilches + +IMU_CONFIG=$(grep -A 5 "#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLE" ../../libraries/AP_HAL/AP_HAL_Boards.h| grep HAL_INS_DEFAULT) +echo "Current setup is: "$IMU_CONFIG + +if [ $# -eq 0 ] + then + echo "No arguments supplied. Please provide one of the following sensors: mpu6000, mpu9250, lsm9ds0" + echo " Usage: source sensor-select.sh " + return 0 +fi + +if [ $1 == "mpu6000" ] +then + sed -i "s/$IMU_CONFIG/#define HAL_INS_DEFAULT HAL_INS_MPU6000/g" ../../libraries/AP_HAL/AP_HAL_Boards.h + echo "MPU6000 selected" +elif [ $1 == "mpu9250" ] +then + sed -i "s/$IMU_CONFIG/#define HAL_INS_DEFAULT HAL_INS_MPU9250/g" ../../libraries/AP_HAL/AP_HAL_Boards.h + echo "MPU9250 selected" +elif [ $1 == "lsm9ds0" ] +then + sed -i "s/$IMU_CONFIG/#define HAL_INS_DEFAULT HAL_INS_LSM9DS0/g" ../../libraries/AP_HAL/AP_HAL_Boards.h + echo "LSM9DS0 selected" +else + echo "Sensor supplied invaled. Please provide one of the following sensors: mpu6000, mpu9250, lsm9ds0" + echo " Usage: source sensor-select.sh " + return 0 +fi +