mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-10 06:59:54 +08:00
[modules] add baro_sim
as a temporary workaround to get baro simulation in ocaml sim
This commit is contained in:
@@ -54,6 +54,7 @@ twog_1.0 + aspirin + ETS baro + ETS speed
|
||||
<define name="BARO_ETS_ALT_SCALE" value="0.3"/>
|
||||
<define name="BARO_ETS_SYNC_SEND"/>
|
||||
</load>
|
||||
<load name="baro_sim.xml"/>
|
||||
<load name="digital_cam.xml">
|
||||
<define name="DC_SHUTTER_LED" value="5"/><!-- led4:aux led5:camsw-->
|
||||
</load>
|
||||
|
||||
@@ -125,8 +125,9 @@ endif
|
||||
#
|
||||
# add it for simulators
|
||||
#
|
||||
sim.srcs += $(SRC_BOARD)/baro_board.c
|
||||
jsbsim.srcs += $(SRC_BOARD)/baro_board.c
|
||||
# only NPS for now...
|
||||
#sim.srcs += $(SRC_BOARD)/baro_board.c
|
||||
#jsbsim.srcs += $(SRC_BOARD)/baro_board.c
|
||||
nps.srcs += $(SRC_BOARD)/baro_board.c
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
|
||||
<module name="baro_sim" dir="sensors">
|
||||
<doc>
|
||||
<description>
|
||||
Simulated barometer.
|
||||
Sends the BARO_ABS ABI message with gps.hmsl converted to absolute pressure.
|
||||
</description>
|
||||
</doc>
|
||||
|
||||
<header>
|
||||
<file name="baro_sim.h"/>
|
||||
</header>
|
||||
<init fun="baro_sim_init()"/>
|
||||
<periodic fun="baro_sim_periodic()" freq="10."/>
|
||||
|
||||
<makefile target="sim|jsbsim">
|
||||
<file name="baro_sim.c"/>
|
||||
<define name="USE_BARO_BOARD" value="FALSE"/>
|
||||
</makefile>
|
||||
|
||||
</module>
|
||||
@@ -11,7 +11,8 @@
|
||||
|
||||
#define DefaultVoltageOfAdc(adc) (1.0*adc)
|
||||
|
||||
|
||||
#ifndef USE_BARO_BOARD
|
||||
#define USE_BARO_BOARD 1
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_PC_SIM_H */
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Felix Ruess <felix.ruess@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file baro_sim.c
|
||||
*
|
||||
* Simulate barometer pressure measurement using gps.hmsl
|
||||
*/
|
||||
|
||||
#include "math/pprz_isa.h"
|
||||
#include "subsystems/gps.h"
|
||||
#include "subsystems/abi.h"
|
||||
|
||||
#ifndef BARO_SIM_SENDER_ID
|
||||
#define BARO_SIM_SENDER_ID 1
|
||||
#endif
|
||||
PRINT_CONFIG_VAR(BARO_SIM_SENDER_ID)
|
||||
|
||||
void baro_sim_init(void) {
|
||||
|
||||
}
|
||||
|
||||
void baro_sim_periodic(void) {
|
||||
float pressure = pprz_isa_pressure_of_altitude(gps.hmsl / 1000.0);
|
||||
AbiSendMsgBARO_ABS(BARO_SIM_SENDER_ID, &pressure);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Felix Ruess <felix.ruess@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file baro_sim.h
|
||||
*
|
||||
* Simulate barometer pressure measurement using gps.hmsl
|
||||
*/
|
||||
|
||||
#ifndef BARO_SIM_H
|
||||
#define BARO_SIM_H
|
||||
|
||||
/// new measurement every baro_sim_periodic
|
||||
#define BARO_SIM_DT BARO_SIM_PERIODIC_PERIOD
|
||||
|
||||
extern void baro_sim_init(void);
|
||||
extern void baro_sim_periodic(void);
|
||||
|
||||
#endif
|
||||
@@ -193,7 +193,11 @@ void alt_kalman(float z_meas) {
|
||||
float SIGMA2;
|
||||
|
||||
#if USE_BAROMETER
|
||||
#if USE_BARO_MS5534A
|
||||
#ifdef SITL
|
||||
DT = BARO_SIM_DT;
|
||||
R = 0.5;
|
||||
SIGMA2 = 0.1;
|
||||
#elif USE_BARO_MS5534A
|
||||
if (alt_baro_enabled) {
|
||||
DT = BARO_DT;
|
||||
R = baro_MS5534A_r;
|
||||
|
||||
Reference in New Issue
Block a user