Merge branch 'master' into dev

This commit is contained in:
Felix Ruess
2011-10-31 15:31:39 +01:00
18 changed files with 134 additions and 96 deletions
+3 -2
View File
@@ -65,8 +65,9 @@ OCAML=$(shell which ocaml)
OCAMLRUN=$(shell which ocamlrun)
# try to find the paparazzi multilib toolchain
TOOLCHAIN_DIR=$(shell find -L /opt/paparazzi/arm-multilib ~/sat -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1 | xargs dirname )
ifneq ($(TOOLCHAIN_DIR),)
TOOLCHAIN=$(shell find -L /opt/paparazzi/arm-multilib ~/sat -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1)
ifneq ($(TOOLCHAIN),)
TOOLCHAIN_DIR=$(shell dirname $(TOOLCHAIN))
#found the compiler from the paparazzi multilib package
ARMGCC=$(TOOLCHAIN_DIR)/bin/arm-none-eabi-gcc
else
+3 -2
View File
@@ -34,12 +34,13 @@ SRC_ARCH = arch/lpc21
# Programs location
# try to find the paparazzi multilib toolchain
TOOLCHAIN_DIR=$(shell find -L /opt/paparazzi/arm-multilib ~/sat -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1 | xargs dirname )
TOOLCHAIN=$(shell find -L /opt/paparazzi/arm-multilib ~/sat -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1)
#
# found the new paparazzi toolchain, use it
#
ifneq ($(TOOLCHAIN_DIR),)
ifneq ($(TOOLCHAIN),)
TOOLCHAIN_DIR=$(shell dirname $(TOOLCHAIN))
GCC_BIN_DIR=$(TOOLCHAIN_DIR)/bin
GCC_LIB_DIR=$(TOOLCHAIN_DIR)/arm-none-eabi/lib
GCC_BIN_PREFIX=$(GCC_BIN_DIR)/arm-none-eabi
+4 -2
View File
@@ -38,7 +38,9 @@ OPT = s
#OPT = 0
# Programs location
TOOLCHAIN_DIR=$(shell find -L /opt/paparazzi/arm-multilib ~/sat /opt/paparazzi/stm32 -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1 | xargs dirname )
TOOLCHAIN=$(shell find -L /opt/paparazzi/arm-multilib ~/sat /opt/paparazzi/stm32 -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1)
ifneq ($(TOOLCHAIN),)
TOOLCHAIN_DIR=$(shell dirname $(TOOLCHAIN))
GCC_BIN_DIR=$(TOOLCHAIN_DIR)/bin
GCC_LIB_DIR=$(TOOLCHAIN_DIR)/arm-none-eabi/lib
@@ -54,7 +56,7 @@ RM = rm
OOCD = $(TOOLCHAIN_DIR)/bin/openocd
# If we can't find the toolchain then try picking up the compilers from the path
ifeq ($(TOOLCHAIN_DIR),)
else
CC = $(shell which arm-none-eabi-gcc)
LD = $(shell which arm-none-eabi-gcc)
CP = $(shell which arm-none-eabi-objcopy)
@@ -37,13 +37,18 @@ ap.CFLAGS += -DAHRS_CORRECT_FREQUENCY=$(AHRS_CORRECT_FREQUENCY)
endif
ifeq ($(TARGET), sim)
#
# Simple simulation of the AHRS result
#
ahrssim_CFLAGS = -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_sim.h\"
ahrssim_CFLAGS += -DUSE_AHRS -DAHRS_UPDATE_FW_ESTIMATOR
sim.CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_sim.h\"
sim.CFLAGS += -DUSE_AHRS -DAHRS_UPDATE_FW_ESTIMATOR
ahrssim_srcs = $(SRC_SUBSYSTEMS)/ahrs.c
ahrssim_srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_sim.c
sim.srcs += $(SRC_SUBSYSTEMS)/ahrs.c
sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_sim.c
sim.CFLAGS += $(ahrssim_CFLAGS)
sim.srcs += $(ahrssim_srcs)
endif
jsbsim.CFLAGS += $(ahrssim_CFLAGS)
jsbsim.srcs += $(ahrssim_srcs)
@@ -18,17 +18,6 @@ ap.CFLAGS += $(AHRS_CFLAGS)
ap.srcs += $(AHRS_SRCS)
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
# Extra stuff for fixedwings
@@ -49,3 +38,18 @@ endif
ap.CFLAGS += -DAHRS_PROPAGATE_FREQUENCY=$(AHRS_PROPAGATE_FREQUENCY)
ap.CFLAGS += -DAHRS_CORRECT_FREQUENCY=$(AHRS_CORRECT_FREQUENCY)
#
# Simple simulation of the AHRS result
#
ahrssim_CFLAGS = -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_sim.h\"
ahrssim_CFLAGS += -DUSE_AHRS -DAHRS_UPDATE_FW_ESTIMATOR
ahrssim_srcs = $(SRC_SUBSYSTEMS)/ahrs.c
ahrssim_srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_sim.c
sim.CFLAGS += $(ahrssim_CFLAGS)
sim.srcs += $(ahrssim_srcs)
jsbsim.CFLAGS += $(ahrssim_CFLAGS)
jsbsim.srcs += $(ahrssim_srcs)
@@ -22,17 +22,6 @@ ap.srcs += $(AHRS_SRCS)
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
# Extra stuff for fixedwings
ifdef CPU_LED
@@ -52,3 +41,18 @@ endif
ap.CFLAGS += -DAHRS_PROPAGATE_FREQUENCY=$(AHRS_PROPAGATE_FREQUENCY)
ap.CFLAGS += -DAHRS_CORRECT_FREQUENCY=$(AHRS_CORRECT_FREQUENCY)
#
# Simple simulation of the AHRS result
#
ahrssim_CFLAGS = -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_sim.h\"
ahrssim_CFLAGS += -DUSE_AHRS -DAHRS_UPDATE_FW_ESTIMATOR
ahrssim_srcs = $(SRC_SUBSYSTEMS)/ahrs.c
ahrssim_srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_sim.c
sim.CFLAGS += $(ahrssim_CFLAGS)
sim.srcs += $(ahrssim_srcs)
jsbsim.CFLAGS += $(ahrssim_CFLAGS)
jsbsim.srcs += $(ahrssim_srcs)
@@ -218,7 +218,7 @@ jsbsim.CFLAGS += -I$(SIMDIR) -I/usr/include -I$(JSBSIM_INC) -I$(OCAMLLIBDIR) `
jsbsim.LDFLAGS += `pkg-config glib-2.0 --libs` -lglibivy -lm -L/usr/lib -lJSBSim
jsbsim.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=IvyTransport
jsbsim.srcs += downlink.c $(SRC_FIRMWARE)/datalink.c $(SRC_ARCH)/jsbsim_hw.c $(SRC_ARCH)/jsbsim_ir.c $(SRC_ARCH)/jsbsim_gps.c $(SRC_ARCH)/ivy_transport.c $(SRC_ARCH)/jsbsim_transport.c
jsbsim.srcs += downlink.c $(SRC_FIRMWARE)/datalink.c $(SRC_ARCH)/jsbsim_hw.c $(SRC_ARCH)/jsbsim_ir.c $(SRC_ARCH)/jsbsim_gps.c $(SRC_ARCH)/jsbsim_ahrs.c $(SRC_ARCH)/ivy_transport.c $(SRC_ARCH)/jsbsim_transport.c
jsbsim.srcs += subsystems/settings.c
jsbsim.srcs += $(SRC_ARCH)/subsystems/settings_arch.c
+2
View File
@@ -10,9 +10,11 @@
<!-- these parameters should be set for that module in the airframe file unless you want the defaults
Servo value in usec
<load name="servo_switch.xml">
<define name="SERVO_SWITCH_ON_VALUE" value="2000"/>
<define name="SERVO_SWITCH_OFF_VALUE" value="1000"/>
<define name="SERVO_SWITCH_SERVO" value="SERVO_SWITCH"/>
</load>
-->
<file name="servo_switch.c"/>
+3 -2
View File
@@ -6,12 +6,13 @@ DATE = $$(date +%Y%m%d)
# Tool definitions
# try to find the paparazzi multilib toolchain
TOOLCHAIN_DIR=$(shell find -L /opt/paparazzi/arm-multilib ~/sat -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1 | xargs dirname )
TOOLCHAIN=$(shell find -L /opt/paparazzi/arm-multilib ~/sat -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1)
#
# found the new paparazzi toolchain, use it
#
ifneq ($(TOOLCHAIN_DIR),)
ifneq ($(TOOLCHAIN),)
TOOLCHAIN_DIR=$(shell dirname $(TOOLCHAIN))
GCC_BIN_DIR=$(TOOLCHAIN_DIR)/bin
GCC_LIB_DIR=$(TOOLCHAIN_DIR)/arm-none-eabi/lib
GCC_BIN_PREFIX=$(GCC_BIN_DIR)/arm-none-eabi
+27
View File
@@ -0,0 +1,27 @@
/** \file jsbsim_ahrs.c
* \brief Regroup functions to simulate an ahrs
*
* Ahrs soft simulation.
*/
#include "std.h"
float sim_phi; ///< in radians
float sim_theta; ///< in radians
float sim_psi; ///< in radians
float sim_p; ///< in radians/s
float sim_q; ///< in radians/s
bool_t ahrs_sim_available;
// Updates from jsbsim
void provide_attitude_and_rates(float phi, float theta, float psi, float p, float q) {
sim_phi = phi;
sim_theta = theta;
sim_psi = psi;
sim_p = p;
sim_q = q;
ahrs_sim_available = TRUE;
}
+1
View File
@@ -52,6 +52,7 @@ void sim_use_gps_pos(double lat, double lon, double alt, double course, double g
void sim_update_sv(void);
void set_ir(double roll, double pitch);
void provide_attitude_and_rates(float phi, float theta, float psi, float p, float q);
void update_bat(double bat);
+2 -6
View File
@@ -17,19 +17,15 @@
#endif
void set_ir(double roll __attribute__ ((unused)), double pitch __attribute__ ((unused))) {
#ifdef USE_INFRARED
// INFRARED_TELEMETRY : Stupid hack to use with modules
#if defined USE_INFRARED || USE_INFRARED_TELEMETRY
double ir_contrast = 150; //FIXME
double roll_sensor = roll + JSBSIM_IR_ROLL_NEUTRAL; // ir_roll_neutral;
double pitch_sensor = pitch + JSBSIM_IR_PITCH_NEUTRAL; // ir_pitch_neutral;
infrared.roll = sin(roll_sensor) * ir_contrast;
infrared.pitch = sin(pitch_sensor) * ir_contrast;
infrared.top = cos(roll_sensor) * cos(pitch_sensor) * ir_contrast;
#else
estimator_phi = roll; // - ins_roll_neutral;
estimator_theta = pitch; // - ins_pitch_neutral;
#endif
}
-14
View File
@@ -1,14 +0,0 @@
/** \file sim_ir.c
* \brief Regroup functions to simulate autopilot/infrared.c
*
* Infrared soft simulation. OCaml binding.
*/
#include <inttypes.h>
#include "generated/airframe.h"
#include <caml/mlvalues.h>
float ins_roll_neutral = INS_ROLL_NEUTRAL_DEFAULT;
float ins_pitch_neutral = INS_PITCH_NEUTRAL_DEFAULT;
View File
View File
+16 -16
View File
@@ -34,14 +34,14 @@
#include "flight_gear.h"
#include "sim_ac_flightgear.h"
static struct
static struct
{
int socket;
struct sockaddr_in addr;
} flightgear;
void sim_ac_flightgear_init(const char* host, unsigned int port)
void sim_ac_flightgear_init(const char* host, unsigned int port)
{
int so_reuseaddr = 1;
struct protoent * pte = getprotobyname("UDP");
@@ -53,51 +53,51 @@ void sim_ac_flightgear_init(const char* host, unsigned int port)
flightgear.addr.sin_addr.s_addr = inet_addr(host);
}
static inline double get_value(JSBSim::FGFDMExec* FDMExec, string name)
static inline double get_value(JSBSim::FGFDMExec* FDMExec, string name)
{
return FDMExec->GetPropertyManager()->GetNode(name)->getDoubleValue();
}
void sim_ac_flightgear_send(JSBSim::FGFDMExec* FDMExec)
void sim_ac_flightgear_send(JSBSim::FGFDMExec* FDMExec)
{
struct FGNetGUI gui;
gui.version = FG_NET_GUI_VERSION;
gui.latitude = get_value(FDMExec, "position/lat-gc-rad");
gui.longitude = get_value(FDMExec, "position/long-gc-rad");
gui.altitude = get_value(FDMExec, "position/h-sl-meters");
// printf("%f %f %f\n", gui.latitude, gui.longitude, gui.altitude);
gui.agl = 1.111652;
gui.phi = get_value(FDMExec, "attitude/roll-rad");
gui.theta = get_value(FDMExec, "attitude/pitch-rad");
gui.psi = get_value(FDMExec, "attitude/heading-true-rad");
gui.vcas = 0.;
gui.climb_rate = 0.;
gui.num_tanks = 1;
gui.fuel_quantity[0] = get_value(FDMExec, "propulsion/total-fuel-lbs");;
//gui.cur_time = 3198060679ul;
//gui.cur_time = 3198060679ul + rint(fdm.time);
gui.cur_time = 3198101679ul;
gui.warp = 1122474394ul;
gui.ground_elev = 0.;
gui.tuned_freq = 125.65;
gui.nav_radial = 90.;
gui.in_range = 1;
gui.dist_nm = 10.;
gui.course_deviation_deg = 0.;
gui.gs_deviation_deg = 0.;
if (sendto(flightgear.socket, (char*)(&gui), sizeof(gui), 0,
(struct sockaddr*)&flightgear.addr, sizeof(flightgear.addr)) == -1)
printf("error sending\n");
}
+10 -2
View File
@@ -185,10 +185,18 @@ void copy_outputs_from_jsbsim(FGFDMExec* FDMExec) {
gps_period = 0.;
}
//print(FDMExec);
// copy IR
//print(FDMExec);
double roll = get_value(FDMExec, "attitude/roll-rad");
double pitch = get_value(FDMExec, "attitude/pitch-rad");
double yaw = get_value(FDMExec, "attitude/heading-true-rad");
double p = get_value(FDMExec, "velocities/p-rad_sec");
double q = get_value(FDMExec, "velocities/q-rad_sec");
// copy to AHRS
provide_attitude_and_rates(roll, pitch, yaw, p, q);
// copy IR
set_ir(roll, pitch);
// copy Bat level
+21 -21
View File
@@ -87,7 +87,7 @@ static gboolean sim_periodic(gpointer data __attribute__ ((unused))) {
/* read actuators positions and feed JSBSim inputs */
copy_inputs_to_jsbsim(FDMExec);
/* run JSBSim flight model */
bool result = true;
if (run_model) {
@@ -98,17 +98,17 @@ static gboolean sim_periodic(gpointer data __attribute__ ((unused))) {
/* read outputs from model state */
copy_outputs_from_jsbsim(FDMExec);
/* send outputs to flightgear for visualisation */
if (run_fg == true)
sim_ac_flightgear_send(FDMExec);
if (run_fg == true)
sim_ac_flightgear_send(FDMExec);
/* run the airborne code
with 60 Hz, even if JSBSim runs with a multiple of this */
if (ncalls == 0) {
// airborne_run_one_step();
autopilot_event_task();
autopilot_periodic_task();
// airborne_run_one_step();
autopilot_event_task();
autopilot_periodic_task();
}
++ncalls;
if (ncalls == JSBSIM_SPEEDUP) ncalls = 0;
@@ -122,9 +122,9 @@ int main ( int argc, char** argv) {
sim_parse_options(argc, argv);
sim_init();
if (run_fg == true)
sim_ac_flightgear_init(fgAddress.c_str(), 5501);
if (run_fg == true)
sim_ac_flightgear_init(fgAddress.c_str(), 5501);
GMainLoop *ml = g_main_loop_new(NULL, FALSE);
@@ -180,8 +180,8 @@ static void sim_parse_options(int argc, char** argv) {
ivyBus = string(argv[++i]);
}
else if (argument == "-fg") {
run_fg = true;
fgAddress = string(argv[++i]);
run_fg = true;
fgAddress = string(argv[++i]);
}
else {
cerr << "Unknown argument" << endl;
@@ -247,21 +247,21 @@ void jsbsim_init(void) {
}
}
else {
// FGInitialCondition::SetAltitudeASLFtIC
// FGInitialCondition::SetAltitudeASLFtIC
// requires this function to be called
// before itself
// before itself
IC->SetVgroundFpsIC(0.);
// Use flight plan initial conditions
IC->SetLatitudeDegIC(NAV_LAT0 / 1e7);
IC->SetLongitudeDegIC(NAV_LON0 / 1e7);
IC->SetAltitudeASLFtIC((GROUND_ALT + 2.0) / FT2M);
IC->SetTerrainElevationFtIC(GROUND_ALT / FT2M);
IC->SetPsiDegIC(QFU);
IC->SetVgroundFpsIC(0.);
//initRunning for all engines
FDMExec->GetPropulsion()->InitRunning(-1);
if (!FDMExec->RunIC()) {
@@ -286,11 +286,11 @@ void jsbsim_init(void) {
}
bool check_crash_jsbsim(JSBSim::FGFDMExec* FDMExec) {
double agl = FDMExec->GetPropagate()->GetDistanceAGL(), // in ft
lat = FDMExec->GetPropagate()->GetLatitude(), // in rad
lon = FDMExec->GetPropagate()->GetLongitude(); // in rad
if (agl< -1e-5) {
cerr << "Crash detected: agl < 0" << endl << endl;
return false;
@@ -301,7 +301,7 @@ bool check_crash_jsbsim(JSBSim::FGFDMExec* FDMExec) {
<< endl;
return false;
}
if (isnan(agl) || isnan(lat) || isnan(lon)) {
cerr << "JSBSim is producing NaNs. Exiting." << endl << endl;
return false;