Make osam ugear a module

This commit is contained in:
Martin Mueller
2010-10-22 21:51:01 +00:00
parent 55c4e8114a
commit 67bdf13f29
8 changed files with 131 additions and 138 deletions
+54 -39
View File
@@ -2,6 +2,51 @@
<airframe name="OSAMUGEAR">
<firmware name="fixedwing">
<target name="ap" board="tiny_2.11">
<define name="AGR_CLIMB"/>
<define name="LOITER_TRIM"/>
<define name="ALT_KALMAN"/>
<define name="WIND_INFO"/>
<define name="UGEAR"/>
<define name="UGEAR_LED" value="2"/>
<define name="UGEAR_LINK" value="Uart0"/>
<define name="USE_UART0"/>
<define name="UART0_BAUD" value="B115200"/>
</target>
<target name="sim" board="pc">
<define name="AGR_CLIMB"/>
<define name="LOITER_TRIM"/>
<define name="ALT_KALMAN"/>
</target>
<subsystem name="radio_control" type="ppm"/>
<!-- Communication -->
<subsystem name="telemetry" type="transparent">
<param name="MODEM_BAUD" value="B38400"/>
</subsystem>
<!-- Actuators are automatically chosen according to board-->
<subsystem name="control"/>
<!-- Sensors -->
<!--subsystem name="attitude" type="infrared"/-->
<subsystem name="gps" type="ugear"/>
<subsystem name="navigation"/>
</firmware>
<firmware name="setup">
<target name="tunnel" board="tiny_2.11"/>
<target name="usb_tunnel_0" board="tiny_2.11"/>
<target name="usb_tunnel_1" board="tiny_2.11"/>
<target name="setup_actuators" board="tiny_2.11"/>
</firmware>
<!-- modules -->
<modules>
<load name="ins_osam_ugear.xml"/>
</modules>
<!-- commands section -->
<servos>
<servo name="AILEVON_RIGHT" no="3" min="1900" neutral="1450" max="1000"/>
@@ -72,6 +117,12 @@
<define name="CORRECTION_LEFT" value="1.0"/>
<define name="CORRECTION_RIGHT" value="1.0"/>
</section>
<section name="INS" prefix="INS_">
<define name="ROLL_NEUTRAL_DEFAULT" value="-5.73" unit="deg"/>
<define name="PITCH_NEUTRAL_DEFAULT" value="5.73" unit="deg"/>
</section>
<!--
<section name="GYRO" prefix="GYRO_">
<define name="ADC_ROLL_NEUTRAL" value="497"/>
@@ -83,7 +134,7 @@
</section>
-->
<section name="BAT">
<define name="MILLIAMP_PER_PERCENT" value="0.86"/>
<define name="MILLIAMP_AT_FULL_THROTTLE" value="10000."/>
<define name="CATASTROPHIC_BAT_LEVEL" value="9.3" unit="V"/>
</section>
@@ -159,56 +210,20 @@
<define name="YAW_RESPONSE_FACTOR" value="0.5"/>
</section>
-->
<makefile>
CONFIG=\"tiny_2_1.h\"
include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile
FLASH_MODE=IAP
ap.CFLAGS += -DFBW -DAP -DBOARD_CONFIG=$(CONFIG) -DLED -DTIME_LED=1
ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_fbw.c main_ap.c main.c
ap.srcs += commands.c
ap.CFLAGS += -DACTUATORS=\"servos_4017_hw.h\" -DSERVOS_4017
ap.srcs += $(SRC_ARCH)/servos_4017_hw.c actuators.c
# 72MHz
ap.CFLAGS += -DRADIO_CONTROL
ap.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c
<!--makefile>
# Maxstream
ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart1 -DDOWNLINK_AP_DEVICE=Uart1 -DPPRZ_UART=Uart1 -DDATALINK=PPRZ -DUART1_BAUD=B38400
ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c pprz_transport.c
ap.CFLAGS += -DINTER_MCU
ap.srcs += inter_mcu.c
ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2 -DUSE_ADC_3
ap.srcs += $(SRC_ARCH)/adc_hw.c
#ap.CFLAGS += -DGYRO -DADXRS150
#ap.srcs += gyro.c
# Commented out the following two lines for adding stuffs about communication with Gumstix+MNAV Haiyang 20080507
#ap.CFLAGS += -DGPS -DGPS_LED=2 -DUBX -DUSE_UART1 -DGPS_LINK=Uart1 -DUART1_BAUD=B38400
#ap.srcs += gps_ubx.c gps.c latlong.c
ap.CFLAGS += -DUGEAR -DUGEAR_LED=2 -DUSE_UART0 -DUGEAR_LINK=Uart0 -DUART0_BAUD=B115200 -DDOWNLINK_GPS_1Hz
ap.srcs += osam_imu_ugear.c gps.c latlong.c
#ap.CFLAGS += -DINFRARED -DIMUIR 20080821
ap.CFLAGS += -DINFRARED
ap.srcs += infrared.c estimator.c
ap.CFLAGS += -DNAV -DAGR_CLIMB -DLOITER_TRIM -DALT_KALMAN -DWIND_INFO
ap.srcs += nav.c fw_h_ctl.c fw_v_ctl.c
ap.srcs += nav_line.c nav_survey_rectangle.c
# Config for SITL simulation
include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile
sim.CFLAGS += -DBOARD_CONFIG=\"tiny.h\" -DAGR_CLIMB -DLOITER_TRIM -DALT_KALMAN
sim.srcs += nav_survey_rectangle.c nav_line.c
</makefile>
</makefile-->
</airframe>
@@ -0,0 +1,5 @@
# OSAM UGEAR
#ap.CFLAGS += -DGPS
$(TARGET).srcs += $(SRC_FIXEDWING)/gps.c $(SRC_FIXEDWING)/latlong.c
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="ins_osam_ugear" dir="ins">
<header>
<file name="ins_osam_ugear.h"/>
</header>
<init fun="ugear_init()"/>
<event fun="ugear_event()"/>
<makefile target="ap">
<file name="ins_osam_ugear.c"/>
</makefile>
</module>
+4 -42
View File
@@ -6,38 +6,13 @@ Configuration files in 5 are generated by Daniel Morgan & Haiyang Chao.
1. Brief
This file is to explain what we have done to make the pprz compatible with IMU (xsens-mtig and microstrain-gx2).
Haiyang Chao on 20080912 for version 1
adapted to new build config 20101022
2. New Airborne files added
~/paparazzi3/sw/airborne/osam_imu_ugear.h
~/paparazzi3/sw/airborne/osam_imu_ugear.c
~/paparazzi3/sw/airborne/modules/ins/ins_osam_ugear.h
~/paparazzi3/sw/airborne/modules/ins/ins_osam_ugear.c
3. Airborne Files modified (all modifications we made are triggered only if UGEAR is defined)
~/paparazzi3/sw/airborne/main_ap.c
-----Line 122------------------------
#ifdef UGEAR
#include "osam_imu_ugear.h"
#endif
#ifdef XSENS
#include "xsens_ins.h"
#endif
-----Line 733------------------------
#ifdef UGEAR
if (UgearBuffer()){
ReadUgearBuffer();
}
if (ugear_msg_received){
parse_ugear_msg();
ugear_msg_received = FALSE;
if (gps_pos_available){
gps_downlink();
gps_verbose_downlink = !launch;
UseGpsPos(estimator_update_state_gps);
gps_pos_available = FALSE;
}
}
#endif /* UGEAR*/
-----------------------------
~/paparazzi3/sw/airborne/ap_downlink.h
-----Line 165------------------------
#if defined UGEAR
@@ -51,20 +26,6 @@ Haiyang Chao on 20080912 for version 1
#elif defined UGEAR
#define GPS_NB_CHANNELS 16
-----------------------------
~/paparazzi3/sw/airborne/infrared.c
-----Line 42------------------------
#ifdef UGEAR
#include "osam_imu_ugear.h"
#endif
-----Line 239------------------------
#if defined UGEAR
#if !(defined IMUIR)
ugear_debug3 = 333;
estimator_phi = (float)ugear_phi/10000 - ir_roll_neutral;
estimator_theta = (float)ugear_theta/10000 - ir_pitch_neutral;
#endif
#endif
-----------------------------
4. Configuration files changed
~/paparazzi3/conf/message.xml
@@ -83,4 +44,5 @@ Haiyang Chao on 20080912 for version 1
~/paparazzi3/conf/telemetry/osam_imu.xml
~/paparazzi3/conf/flight_plans/xsens_cachejunction.xml
~/paparazzi3/conf/airframes/osam_xsens_twog.xml
~/paparazzi3/conf/settings/tuning_ins.xml
-12
View File
@@ -39,10 +39,6 @@
#include "sys_time.h"
#include "airframe.h"
#ifdef UGEAR
#include "osam_imu_ugear.h"
#endif
#if defined IR_ESTIMATED_PHI_PI_4 || defined IR_ESTIMATED_PHI_MINUS_PI_4 || defined IR_ESTIMATED_THETA_PI_4
#error "IR_ESTIMATED_PHI_PI_4 correction has been deprecated. Please remove the definition from your airframe config file"
#endif
@@ -229,12 +225,4 @@ void estimator_update_state_infrared( void ) {
else
estimator_theta *= ir_correction_down;
#if defined UGEAR
#if !(defined IMUIR)
ugear_debug3 = 333;
estimator_phi = (float)ugear_phi/10000 - ir_roll_neutral;
estimator_theta = (float)ugear_theta/10000 - ir_pitch_neutral;
#endif
#endif
}
+1 -40
View File
@@ -99,15 +99,8 @@
#include "baro_ets.h"
#endif // USE_BARO_ETS
/*code added by Haiyang Chao for using Xsens IMU for fixed wing UAV 20080804*/
#ifdef UGEAR
#include "osam_imu_ugear.h"
#endif
/*code added by Haiyang Chao ends*/
#if ! defined CATASTROPHIC_BAT_LEVEL && defined LOW_BATTERY
#warning "LOW_BATTERY deprecated. Renammed into CATASTROPHIC_BAT_LEVEL (in aiframe file)"
#warning "LOW_BATTERY deprecated. Renamed into CATASTROPHIC_BAT_LEVEL (in airframe file)"
#define CATASTROPHIC_BAT_LEVEL LOW_BATTERY
#endif
@@ -614,10 +607,6 @@ void init_ap( void ) {
gps_configure_uart();
#endif
#ifdef UGEAR
ugear_init();
#endif /*added by haiyang for ugear communication*/
#if defined DATALINK
#if DATALINK == XBEE
@@ -647,34 +636,6 @@ void init_ap( void ) {
/*********** EVENT ***********************************************************/
void event_task_ap( void ) {
#ifdef UGEAR
if (UgearBuffer()){
ReadUgearBuffer();
}
if (ugear_msg_received){
parse_ugear_msg();
ugear_msg_received = FALSE;
if (gps_pos_available){
//gps_downlink();
gps_verbose_downlink = !launch;
UseGpsPosNoSend(estimator_update_state_gps);
gps_msg_received_counter = gps_msg_received_counter+1;
#ifdef GX2
if (gps_msg_received_counter == 1){
gps_send();
gps_msg_received_counter = 0;
}
#endif
#ifdef XSENSDL
if (gps_msg_received_counter == 25){
gps_send();
gps_msg_received_counter = 0;
}
#endif
gps_pos_available = FALSE;
}
}
#endif /* UGEAR*/
#ifdef GPS
#if !(defined HITL) && !(defined UBX_EXTERNAL) /** else comes through the datalink */
@@ -30,8 +30,9 @@
#include <stdlib.h>
#include <string.h>
#include "osam_imu_ugear.h"
#include "ins_osam_ugear.h"
#include "gps.h"
#include "gps_ubx.h"
#include "latlong.h"
#include "sys_time.h"
#include "airframe.h"
@@ -56,10 +57,15 @@
#define RAD2DEG 57.3
#define WrapUp(x) (x < 0 ? x+3600 : x)
/* from main_ap.c */
extern bool_t launch;
/* variable defined for dlsetting generated by Haiyang 20080717*/
bool_t imu1_ir0 = 0;
float fd_alpha = 0;
float fi_alpha = 0;
float ins_roll_neutral;
float ins_pitch_neutral;
/* variable definition copied from gps_ubx.c 20080508*/
uint16_t gps_week;
@@ -89,7 +95,7 @@ uint8_t gps_nb_channels;
/* variable definition copied from gps.c20080515*/
uint16_t last_gps_msg_t; /** cputime of the last gps message */
//uint16_t last_gps_msg_t; /** cputime of the last gps message */
volatile bool_t ugear_msg_received;
@@ -114,7 +120,7 @@ int32_t ugear_debug4;
int32_t ugear_debug5;
int32_t ugear_debug6;
bool_t gps_verbose_downlink;
//bool_t gps_verbose_downlink;
uint8_t ugear_msg_buf[UGEAR_MAX_PAYLOAD] __attribute__ ((aligned));
@@ -138,6 +144,8 @@ void ugear_init( void ) {
ugear_psi = 0;
ugear_theta = 0;
ugear_debug2 = 0;
ins_roll_neutral = INS_ROLL_NEUTRAL_DEFAULT;
ins_pitch_neutral = INS_PITCH_NEUTRAL_DEFAULT;
}
void parse_ugear( uint8_t c ) {
@@ -211,6 +219,8 @@ void decode_imupacket( struct imu *data, uint8_t* buffer){
*/
void parse_ugear_msg( void ){
float ins_phi, ins_psi, ins_theta;
switch (ugear_type){
case 0: /*gps*/
ugear_debug1 = ugear_debug1+1;
@@ -251,6 +261,13 @@ void parse_ugear_msg( void ){
ugear_debug4 = (int32_t)ugear_phi;
ugear_debug5 = (int32_t)ugear_theta;
ugear_debug6 = (int32_t)ugear_psi;
ugear_debug3 = 333;
ins_phi = (float)ugear_phi/10000 - ins_roll_neutral;
ins_psi = 0;
ins_theta = (float)ugear_theta/10000 - ins_pitch_neutral;
#ifndef INFRARED
EstimatorSetAtt(ins_phi, ins_psi, ins_theta);
#endif
break;
case 2: /*GPS status*/
// ugear_debug1 = 2;
@@ -280,3 +297,33 @@ void parse_ugear_msg( void ){
void ubxsend_cfg_rst(uint16_t bbr , uint8_t reset_mode) {
}
void ugear_event( void ) {
if (UgearBuffer()){
ReadUgearBuffer();
}
if (ugear_msg_received){
parse_ugear_msg();
ugear_msg_received = FALSE;
if (gps_pos_available){
//gps_downlink();
gps_verbose_downlink = !launch;
UseGpsPosNoSend(estimator_update_state_gps);
gps_msg_received_counter = gps_msg_received_counter+1;
#ifdef GX2
if (gps_msg_received_counter == 1){
gps_send();
gps_msg_received_counter = 0;
}
#endif
#ifdef XSENSDL
if (gps_msg_received_counter == 25){
gps_send();
gps_msg_received_counter = 0;
}
#endif
gps_pos_available = FALSE;
}
}
}
@@ -32,6 +32,7 @@
void ugear_init( void );
void parse_ugear(uint8_t c);
void parse_ugear_msg( void );
void ugear_event( void );
#define __UgearLink(dev, _x) dev##_x
#define _UgearLink(dev, _x) __UgearLink(dev, _x)
@@ -89,5 +90,6 @@ extern struct imu imupacket;
extern struct gps gpspacket;
extern uint8_t ugear_msg_buf[UGEAR_MAX_PAYLOAD];
/* add the following function only to get rid of compilation error in datalink.c 20080608 Haiyang*/
void ubxsend_cfg_rst(uint16_t, uint8_t);
extern float ins_roll_neutral;
extern float ins_pitch_neutral;