mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-24 05:45:59 +08:00
fix simulation, sim_ir and sim_ahrs are now always compiled so the ocaml sim does not complain about non-existent functions
This commit is contained in:
@@ -18,28 +18,13 @@ ap.CFLAGS += $(AHRS_CFLAGS)
|
||||
ap.srcs += $(AHRS_SRCS)
|
||||
|
||||
|
||||
|
||||
# since there is currently no ocaml SITL sim for the IMU, we use the infrared sim
|
||||
# and the ahrs_infrared subsystem
|
||||
|
||||
ifeq ($(TARGET), sim)
|
||||
|
||||
sim.CFLAGS += -DIR_ROLL_NEUTRAL_DEFAULT=0
|
||||
sim.CFLAGS += -DIR_PITCH_NEUTRAL_DEFAULT=0
|
||||
|
||||
sim.CFLAGS += -DUSE_INFRARED
|
||||
sim.srcs += subsystems/sensors/infrared.c
|
||||
sim.srcs += subsystems/sensors/infrared_adc.c
|
||||
|
||||
sim.srcs += $(SRC_ARCH)/sim_ir.c
|
||||
sim.srcs += $(SRC_ARCH)/sim_imu.c
|
||||
|
||||
|
||||
sim.CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_infrared.h\"
|
||||
sim.CFLAGS += -DUSE_AHRS
|
||||
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_infrared.c
|
||||
sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_sim.c
|
||||
|
||||
endif
|
||||
|
||||
|
||||
@@ -22,27 +22,13 @@ ap.srcs += $(AHRS_SRCS)
|
||||
|
||||
|
||||
|
||||
# since there is currently no ocaml SITL sim for the IMU, we use the infrared sim
|
||||
# and the ahrs_infrared subsystem
|
||||
|
||||
ifeq ($(TARGET), sim)
|
||||
|
||||
sim.CFLAGS += -DIR_ROLL_NEUTRAL_DEFAULT=0
|
||||
sim.CFLAGS += -DIR_PITCH_NEUTRAL_DEFAULT=0
|
||||
|
||||
sim.CFLAGS += -DUSE_INFRARED
|
||||
sim.srcs += subsystems/sensors/infrared.c
|
||||
sim.srcs += subsystems/sensors/infrared_adc.c
|
||||
|
||||
sim.srcs += $(SRC_ARCH)/sim_ir.c
|
||||
sim.srcs += $(SRC_ARCH)/sim_imu.c
|
||||
|
||||
|
||||
sim.CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_infrared.h\"
|
||||
sim.CFLAGS += -DUSE_AHRS
|
||||
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_infrared.c
|
||||
sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_sim.c
|
||||
|
||||
endif
|
||||
|
||||
|
||||
@@ -195,6 +195,9 @@ sim.srcs += downlink.c $(SRC_FIRMWARE)/datalink.c $(SRC_ARCH)/sim_gps.c $(SRC_
|
||||
sim.srcs += subsystems/settings.c
|
||||
sim.srcs += $(SRC_ARCH)/subsystems/settings_arch.c
|
||||
|
||||
# hack: always compile some of the sim functions, so ocaml sim does not complain about no-existing functions
|
||||
sim.srcs += $(SRC_ARCH)/sim_ahrs.c $(SRC_ARCH)/sim_ir.c
|
||||
|
||||
######################################################################
|
||||
##
|
||||
## JSBSIM THREAD SPECIFIC
|
||||
|
||||
@@ -35,9 +35,6 @@ endif
|
||||
ap.CFLAGS += -DADC_CHANNEL_IR_NB_SAMPLES=$(ADC_IR_NB_SAMPLES)
|
||||
</raw>
|
||||
</makefile>
|
||||
<makefile target="sim">
|
||||
<file_arch name="sim_ir.c" dir="."/>
|
||||
</makefile>
|
||||
</module>
|
||||
|
||||
|
||||
|
||||
@@ -14,8 +14,5 @@
|
||||
<file name="infrared.c" dir="subsystems/sensors"/>
|
||||
<file name="infrared_i2c.c" dir="subsystems/sensors"/>
|
||||
</makefile>
|
||||
<makefile target="sim">
|
||||
<file_arch name="sim_ir.c" dir="."/>
|
||||
</makefile>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ value set_ir_and_airspeed(
|
||||
value air_speed
|
||||
) {
|
||||
// INFRARED_TELEMETRY : Stupid hack to use with modules
|
||||
//#if defined USE_INFRARED || USE_INFRARED_TELEMETRY
|
||||
#if defined USE_INFRARED || USE_INFRARED_TELEMETRY
|
||||
infrared.roll = Int_val(roll);
|
||||
infrared.pitch = Int_val(front);
|
||||
infrared.top = Int_val(top);
|
||||
//#endif
|
||||
#endif
|
||||
sim_air_speed = Double_val(air_speed);
|
||||
return Val_unit;
|
||||
}
|
||||
|
||||
@@ -768,7 +768,7 @@ static inline void on_mag_event(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#else // USE_IMU
|
||||
#else // USE_IMU not defined
|
||||
static inline void on_ahrs_event(void)
|
||||
{
|
||||
#ifdef AHRS_UPDATE_FW_ESTIMATOR
|
||||
|
||||
@@ -28,21 +28,10 @@
|
||||
#include <inttypes.h>
|
||||
#include <caml/mlvalues.h>
|
||||
|
||||
float sim_phi;
|
||||
float sim_theta;
|
||||
float sim_psi;
|
||||
bool_t ahrs_sim_available;
|
||||
|
||||
// Updates from Ocaml sim
|
||||
value set_attitude(value phi, value theta, value psi) {
|
||||
sim_phi = Double_val(phi);
|
||||
sim_theta = Double_val(theta);
|
||||
sim_psi = Double_val(psi);
|
||||
|
||||
ahrs_sim_available = TRUE;
|
||||
|
||||
return Val_unit;
|
||||
}
|
||||
extern float sim_phi;
|
||||
extern float sim_theta;
|
||||
extern float sim_psi;
|
||||
extern bool_t ahrs_sim_available;
|
||||
|
||||
|
||||
void compute_body_orientation_and_rates(void);
|
||||
@@ -50,9 +39,7 @@ void compute_body_orientation_and_rates(void);
|
||||
void update_attitude_from_sim(void) {
|
||||
ahrs_float.ltp_to_imu_euler.phi = sim_phi;
|
||||
ahrs_float.ltp_to_imu_euler.theta = sim_theta;
|
||||
ahrs_float.ltp_to_imu_euler.psi = -sim_psi;
|
||||
FLOAT_ANGLE_NORMALIZE(ahrs_float.ltp_to_imu_euler.psi);
|
||||
ahrs_float.ltp_to_imu_euler.psi += M_PI/2.;
|
||||
ahrs_float.ltp_to_imu_euler.psi = sim_psi;
|
||||
|
||||
/* set quaternion and rotation matrix representations as well */
|
||||
FLOAT_QUAT_OF_EULERS(ahrs_float.ltp_to_imu_quat, ahrs_float.ltp_to_imu_euler);
|
||||
@@ -98,15 +85,12 @@ void ahrs_align(void)
|
||||
|
||||
|
||||
void ahrs_propagate(void) {
|
||||
update_attitude_from_sim();
|
||||
}
|
||||
|
||||
void ahrs_update_accel(void) {
|
||||
update_attitude_from_sim();
|
||||
}
|
||||
|
||||
void ahrs_update_mag(void) {
|
||||
update_attitude_from_sim();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user