Starting the IMU/AHRS/INS organization. Step 1: attempt to nicely add an INS + its simulation model into a subsystem.

This commit is contained in:
Christophe De Wagter
2011-10-26 09:53:03 +02:00
parent 6f82311504
commit cf0d5b9316
8 changed files with 120 additions and 57 deletions
+6 -8
View File
@@ -191,10 +191,6 @@
<modules> <modules>
<load name="ins_xsens_MTiG_fixedwing.xml">
<configure name="XSENS_UART_NR" value="0"/>
</load>
<load name="light.xml"> <load name="light.xml">
<define name="LIGHT_LED_STROBE" value="3"/> <define name="LIGHT_LED_STROBE" value="3"/>
<define name="LIGHT_LED_NAV" value="2"/> <define name="LIGHT_LED_NAV" value="2"/>
@@ -212,15 +208,15 @@
<firmware name="fixedwing"> <firmware name="fixedwing">
<target name="ap" board="tiny_2.11"> <target name="ap" board="tiny_2.11" />
<target name="sim" board="pc"/>
<define name="STRONG_WIND"/> <define name="STRONG_WIND"/>
<define name="WIND_INFO"/> <define name="WIND_INFO"/>
<define name="WIND_INFO_RET"/> <define name="WIND_INFO_RET"/>
<define name="LOITER_TRIM"/> <define name="LOITER_TRIM"/>
<define name="TUNE_AGRESSIVE_CLIMB"/> <define name="TUNE_AGRESSIVE_CLIMB"/>
<define name="AGR_CLIMB"/> <define name="AGR_CLIMB"/>
</target>
<target name="sim" board="pc"/>
<subsystem name="radio_control" type="ppm"/> <subsystem name="radio_control" type="ppm"/>
@@ -233,7 +229,9 @@
<subsystem name="control"/> <subsystem name="control"/>
<!-- Sensors --> <!-- Sensors -->
<subsystem name="navigation"/> <subsystem name="navigation"/>
<subsystem name="gps" type="xsens"/> <subsystem name="ins" type="xsens">
<configure name="XSENS_UART_NR" value="0" />
</subsystem>
</firmware> </firmware>
@@ -1,9 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
# XSens Mti-G
# ap.CFLAGS += -DGPS
$(TARGET).srcs += $(SRC_SUBSYSTEMS)/gps.c
@@ -0,0 +1,79 @@
# Hey Emacs, this is a -*- makefile -*-
# XSens Mti-G
# <load name="ins_xsens_MTiG_fixedwing.xml">
# <configure name="XSENS_UART_NR" value="0"/>
# </load>
#########################################
## ATTITUDE
ifeq ($(TARGET), ap)
# <init fun="ins_init()"/>
# <periodic fun="ins_periodic_task()" freq="60"/>
# <event fun="InsEventCheckAndHandle(handle_ins_msg())"/>
# <makefile target="ap">
# <define name="AHRS_TYPE_H" value="\\\"modules/ins/ins_xsens.h\\\"" />
# <define name="INS_MODULE_H" value="\\\"modules/ins/ins_xsens.h\\\"" />
# <define name="USE_UART$(XSENS_UART_NR)"/>
# <define name="INS_LINK" value="Uart$(XSENS_UART_NR)"/>
# <define name="UART$(XSENS_UART_NR)_BAUD" value="B230400"/>
# <define name="USE_GPS_XSENS"/>
# <define name="USE_GPS_XSENS_RAW_DATA" />
# <define name="GPS_NB_CHANNELS" value="16" />
# <define name="XSENS_OUTPUT_MODE" value="0x1836" />
# <file name="ins_xsens.c"/>
# <define name="AHRS_TRIGGERED_ATTITUDE_LOOP" />
# </makefile>
# ImuEvent -> XSensEvent
ap.CFLAGS += -DUSE_IMU
ap.CFLAGS += -DIMU_TYPE_H=\"modules/ins/ins_xsens.h\"
# AHRS Results
ap.CFLAGS += -DAHRS_TYPE_H=\"modules/ins/ins_xsens.h\"
ap.CFLAGS += -DINS_MODULE_H=\"modules/ins/ins_xsens.h\"
ap.CFLAGS += -DUSE_UART$(XSENS_UART_NR)
ap.CFLAGS += -DINS_LINK=Uart$(XSENS_UART_NR)
ap.CFLAGS += -DUART$(XSENS_UART_NR)_BAUD=B230400
ap.CFLAGS += -DUSE_GPS_XSENS
ap.CFLAGS += -DUSE_GPS_XSENS_RAW_DATA
ap.CFLAGS += -DGPS_NB_CHANNELS=16
ap.CFLAGS += -DXSENS_OUTPUT_MODE=0x1836
ap.srcs += $(SRC_MODULES)/ins/ins_xsens.c
ap.CFLAGS += -DAHRS_TRIGGERED_ATTITUDE_LOOP
endif
ifeq ($(TARGET), sim)
sim.CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_sim.h\"
sim.CFLAGS += -DUSE_AHRS -DAHRS_UPDATE_FW_ESTIMATOR
sim.srcs += $(SRC_SUBSYSTEMS)/ahrs.c
sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_sim.c
endif
#########################################
## GPS
# ap.CFLAGS += -DGPS
$(TARGET).srcs += $(SRC_SUBSYSTEMS)/gps.c
sim.CFLAGS += -DUSE_GPS -DGPS_USE_LATLONG
sim.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_sim.h\"
sim.srcs += $(SRC_SUBSYSTEMS)/gps/gps_sim.c
-26
View File
@@ -1,26 +0,0 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="ins">
<!-- <depend conflict="ins" -->
<!-- <depend require="gps_xsens" -->
<header>
<file name="ins_module.h"/>
</header>
<init fun="ins_init()"/>
<periodic fun="ins_periodic_task()" freq="60"/>
<event fun="InsEventCheckAndHandle(handle_ins_msg())"/>
<makefile>
<define name="AHRS_TYPE_H" value="\\\"modules/ins/ins_xsens.h\\\"" />
<define name="INS_MODULE_H" value="\\\"modules/ins/ins_xsens.h\\\"" />
<define name="USE_UART$(XSENS_UART_NR)"/>
<define name="INS_LINK" value="Uart$(XSENS_UART_NR)"/>
<define name="UART$(XSENS_UART_NR)_BAUD" value="B230400"/>
<define name="USE_GPS_XSENS"/>
<define name="USE_GPS_XSENS_RAW_DATA" />
<define name="GPS_NB_CHANNELS" value="16" />
<define name="XSENS_OUTPUT_MODE" value="0x1836" />
<file name="ins_xsens.c"/>
<define name="AHRS_TRIGGERED_ATTITUDE_LOOP" />
</makefile>
</module>
+1 -1
View File
@@ -89,7 +89,7 @@ case "$choice" in
4 ) 4 )
echo ""; echo -e "Here is the list of all saved versions [\033[1mgit tag\033[0m]: \033[1m"; git tag; echo ""; echo -e "Here is the list of all saved versions [\033[1mgit tag\033[0m]: \033[1m"; git tag;
echo -e "\033[0m"; echo -e "\033[0m";
echo -e "-Make a new TAG: \033[1mgit tag TAGNAME\033[0m (=save an easy link to this revision)" echo -e "-Make a new TAG: \033[1mgit tag -f TAGNAME\033[0m (=save an easy link to this revision) (-f = overwrite existing with given name)"
echo -e "-Send it to github: \033[1mgit push REMOTE_NAME --tags\033[0m (find your available REMOTE_NAMEs using \033[1mgit remote\033[0m )" echo -e "-Send it to github: \033[1mgit push REMOTE_NAME --tags\033[0m (find your available REMOTE_NAMEs using \033[1mgit remote\033[0m )"
echo -e "-Download all tags from github: \033[1mgit fetch REMOTE_NAME\033[0m " echo -e "-Download all tags from github: \033[1mgit fetch REMOTE_NAME\033[0m "
echo -e "-Now use one of your tags: \033[1mgit checkout TAG_NAME\033[0m (find the available TAG_NAMEs using \033[1mgit tag\033[0m ) (note that after this command you will be in detached head state which means that you are using a older revision and you can not commit changes here. If you want to make changes you have to make a branch from your tag)" echo -e "-Now use one of your tags: \033[1mgit checkout TAG_NAME\033[0m (find the available TAG_NAMEs using \033[1mgit tag\033[0m ) (note that after this command you will be in detached head state which means that you are using a older revision and you can not commit changes here. If you want to make changes you have to make a branch from your tag)"
+13 -13
View File
@@ -148,18 +148,6 @@
#define PERIODIC_SEND_SEGMENT(_chan) if (nav_in_segment) { DOWNLINK_SEND_SEGMENT(_chan, &nav_segment_x_1, &nav_segment_y_1, &nav_segment_x_2, &nav_segment_y_2); } #define PERIODIC_SEND_SEGMENT(_chan) if (nav_in_segment) { DOWNLINK_SEND_SEGMENT(_chan, &nav_segment_x_1, &nav_segment_y_1, &nav_segment_x_2, &nav_segment_y_2); }
#ifdef IMU_TYPE_H #ifdef IMU_TYPE_H
# include "subsystems/imu.h"
# define PERIODIC_SEND_IMU_ACCEL_RAW(_chan) { DOWNLINK_SEND_IMU_ACCEL_RAW(_chan, &imu.accel_unscaled.x, &imu.accel_unscaled.y, &imu.accel_unscaled.z)}
# define PERIODIC_SEND_IMU_GYRO_RAW(_chan) { DOWNLINK_SEND_IMU_GYRO_RAW(_chan, &imu.gyro_unscaled.p, &imu.gyro_unscaled.q, &imu.gyro_unscaled.r)}
# define PERIODIC_SEND_IMU_MAG_RAW(_chan) { DOWNLINK_SEND_IMU_MAG_RAW(_chan, &imu.mag_unscaled.x, &imu.mag_unscaled.y, &imu.mag_unscaled.z)}
# define PERIODIC_SEND_IMU_ACCEL(_chan) { struct FloatVect3 accel_float; ACCELS_FLOAT_OF_BFP(accel_float, imu.accel); DOWNLINK_SEND_IMU_ACCEL(_chan, &accel_float.x, &accel_float.y, &accel_float.z)}
# define PERIODIC_SEND_IMU_GYRO(_chan) { struct FloatRates gyro_float; RATES_FLOAT_OF_BFP(gyro_float, imu.gyro); DOWNLINK_SEND_IMU_GYRO(_chan, &gyro_float.p, &gyro_float.q, &gyro_float.r)}
# ifdef USE_MAGNETOMETER
# define PERIODIC_SEND_IMU_MAG(_chan) { struct FloatVect3 mag_float; MAGS_FLOAT_OF_BFP(mag_float, imu.mag); DOWNLINK_SEND_IMU_MAG(_chan, &mag_float.x, &mag_float.y, &mag_float.z)}
# else
# define PERIODIC_SEND_IMU_MAG(_chan) {}
# endif
#else
# ifdef INS_MODULE_H # ifdef INS_MODULE_H
# include "modules/ins/ins_module.h" # include "modules/ins/ins_module.h"
# define PERIODIC_SEND_IMU_ACCEL_RAW(_chan) {} # define PERIODIC_SEND_IMU_ACCEL_RAW(_chan) {}
@@ -169,13 +157,25 @@
# define PERIODIC_SEND_IMU_ACCEL(_chan) { DOWNLINK_SEND_IMU_ACCEL(_chan, &ins_ax, &ins_ay, &ins_az)} # define PERIODIC_SEND_IMU_ACCEL(_chan) { DOWNLINK_SEND_IMU_ACCEL(_chan, &ins_ax, &ins_ay, &ins_az)}
# define PERIODIC_SEND_IMU_MAG(_chan) { DOWNLINK_SEND_IMU_MAG(_chan, &ins_mx, &ins_my, &ins_mz)} # define PERIODIC_SEND_IMU_MAG(_chan) { DOWNLINK_SEND_IMU_MAG(_chan, &ins_mx, &ins_my, &ins_mz)}
# else # else
# include "subsystems/imu.h"
# define PERIODIC_SEND_IMU_ACCEL_RAW(_chan) { DOWNLINK_SEND_IMU_ACCEL_RAW(_chan, &imu.accel_unscaled.x, &imu.accel_unscaled.y, &imu.accel_unscaled.z)}
# define PERIODIC_SEND_IMU_GYRO_RAW(_chan) { DOWNLINK_SEND_IMU_GYRO_RAW(_chan, &imu.gyro_unscaled.p, &imu.gyro_unscaled.q, &imu.gyro_unscaled.r)}
# define PERIODIC_SEND_IMU_MAG_RAW(_chan) { DOWNLINK_SEND_IMU_MAG_RAW(_chan, &imu.mag_unscaled.x, &imu.mag_unscaled.y, &imu.mag_unscaled.z)}
# define PERIODIC_SEND_IMU_ACCEL(_chan) { struct FloatVect3 accel_float; ACCELS_FLOAT_OF_BFP(accel_float, imu.accel); DOWNLINK_SEND_IMU_ACCEL(_chan, &accel_float.x, &accel_float.y, &accel_float.z)}
# define PERIODIC_SEND_IMU_GYRO(_chan) { struct FloatRates gyro_float; RATES_FLOAT_OF_BFP(gyro_float, imu.gyro); DOWNLINK_SEND_IMU_GYRO(_chan, &gyro_float.p, &gyro_float.q, &gyro_float.r)}
# ifdef USE_MAGNETOMETER
# define PERIODIC_SEND_IMU_MAG(_chan) { struct FloatVect3 mag_float; MAGS_FLOAT_OF_BFP(mag_float, imu.mag); DOWNLINK_SEND_IMU_MAG(_chan, &mag_float.x, &mag_float.y, &mag_float.z)}
# else
# define PERIODIC_SEND_IMU_MAG(_chan) {}
# endif
# endif
#else
# define PERIODIC_SEND_IMU_ACCEL_RAW(_chan) {} # define PERIODIC_SEND_IMU_ACCEL_RAW(_chan) {}
# define PERIODIC_SEND_IMU_GYRO_RAW(_chan) {} # define PERIODIC_SEND_IMU_GYRO_RAW(_chan) {}
# define PERIODIC_SEND_IMU_MAG_RAW(_chan) {} # define PERIODIC_SEND_IMU_MAG_RAW(_chan) {}
# define PERIODIC_SEND_IMU_ACCEL(_chan) {} # define PERIODIC_SEND_IMU_ACCEL(_chan) {}
# define PERIODIC_SEND_IMU_GYRO(_chan) {} # define PERIODIC_SEND_IMU_GYRO(_chan) {}
# define PERIODIC_SEND_IMU_MAG(_chan) {} # define PERIODIC_SEND_IMU_MAG(_chan) {}
# endif
#endif #endif
#ifdef IMU_ANALOG #ifdef IMU_ANALOG
+15
View File
@@ -73,6 +73,21 @@ float ins_roll_neutral;
volatile uint8_t new_ins_attitude; volatile uint8_t new_ins_attitude;
#include "subsystems/imu.h"
void imu_init(void)
{
ins_init();
}
void imu_periodic(void)
{
ins_periodic_task();
}
//struct Imu imu;
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// //
// XSens Specific // XSens Specific
+6
View File
@@ -31,6 +31,8 @@
#include "std.h" #include "std.h"
#include "ins_module.h"
extern int8_t xsens_hour; extern int8_t xsens_hour;
extern int8_t xsens_min; extern int8_t xsens_min;
extern int8_t xsens_sec; extern int8_t xsens_sec;
@@ -41,5 +43,9 @@ extern int8_t xsens_day;
extern uint8_t xsens_msg_status; extern uint8_t xsens_msg_status;
extern uint16_t xsens_time_stamp; extern uint16_t xsens_time_stamp;
#define ImuEvent(_gyro_handler, _accel_handler, _mag_handler) { \
InsEventCheckAndHandle(handle_ins_msg()) \
}
#endif #endif