Compare commits

...

7 Commits

Author SHA1 Message Date
Jaeyoung Lim 0e1e1afcf9 Correct dates in the license headers 2023-02-15 01:37:32 +09:00
Jaeyoung Lim 0b3f4dd385 Inject failure for airspeed sim 2023-02-15 01:37:32 +09:00
Jaeyoung Lim 3f50bd051f Optionally enable airspeed sensor sim
Enable and disable sensor sim module with parameter
2023-02-15 01:37:32 +09:00
PX4 BuildBot 192764387d Update submodule mavlink to latest Tue Feb 14 12:38:55 UTC 2023
- mavlink in PX4/Firmware (e7a5dedf48f967465d1f9e6c96a9bf304e1a74b1): https://github.com/mavlink/mavlink/commit/e3b8756e37cd2cd01ba658461bb4dbffb2fdf914
    - mavlink current upstream: https://github.com/mavlink/mavlink/commit/2bdcab78b53d1e349079b43c9d726036abe0617c
    - Changes: https://github.com/mavlink/mavlink/compare/e3b8756e37cd2cd01ba658461bb4dbffb2fdf914...2bdcab78b53d1e349079b43c9d726036abe0617c

    2bdcab78 2023-02-09 Hamish Willee - undo last commit
9c60f17a 2023-02-09 Hamish Willee - param_id char[] description
841b7683 2023-02-08 Alessandro Ros - remove invalid enum reference from storm32.xml (#1947)
8d4e50ee 2023-02-08 Julian Oes - scripts: install npm dependencies first
72a9b2c3 2023-02-08 Julian Oes - pymavlink: update submodule
2023-02-14 09:53:11 -05:00
Knut Hjorth db539d15bd mavlink: fix bug when opening /dev/null as default stdin/stdout/stderr
Prior commit added opening of /dev/null as 0, 1 and/or 2 file
descriptors, if they where not present. However, if the temporary
file descriptor used to open /dev/null matched the target file
descriptor, it would be immediately closed again. This commit fixes that,
and does not duplicate and close the temporary file descriptor if it is
already at the correct number.
2023-02-14 08:18:01 +01:00
Christian Rauch 5880fe4153 remove deprecated check for CONFIG_STM32_STM32F4XXX in STM32F1 micro_hal.h 2023-02-14 08:08:24 +01:00
Daniel Agar b3eb563db4 boards: cubepilot_cubeorange_test restore sd_bench (used on test rack) 2023-02-13 23:53:54 -05:00
10 changed files with 93 additions and 61 deletions
@@ -10,6 +10,8 @@ PX4_SIMULATOR=${PX4_SIMULATOR:=gz}
PX4_GZ_WORLD=${PX4_GZ_WORLD:=default}
PX4_SIM_MODEL=${PX4_SIM_MODEL:=rc_cessna}
param set-default SENS_EN_ARSPDSIM 1
param set-default EKF2_MAG_ACCLIM 0
param set-default EKF2_MAG_YAWLIM 0
@@ -11,6 +11,8 @@ PX4_SIMULATOR=${PX4_SIMULATOR:=gz}
PX4_GZ_WORLD=${PX4_GZ_WORLD:=default}
PX4_SIM_MODEL=${PX4_SIM_MODEL:=standard_vtol}
param set-default SENS_EN_ARSPDSIM 1
# TODO: Enable motor failure detection when the
# VTOL no longer reports 0A for all ESCs in SITL
param set-default FD_ACT_EN 0
@@ -80,7 +80,10 @@ elif [ "$PX4_SIMULATOR" = "gz" ] || [ "$(param show -q SIM_GZ_EN)" -eq "1" ]; th
sensor_baro_sim start
sensor_gps_sim start
sensor_mag_sim start
sensor_airspeed_sim start
if param compare -s SENS_EN_ARSPDSIM 1
then
sensor_airspeed_sim start
fi
else
echo "ERROR [init] gz_bridge failed to start"
@@ -94,7 +97,10 @@ elif [ "$PX4_SIMULATOR" = "gz" ] || [ "$(param show -q SIM_GZ_EN)" -eq "1" ]; th
sensor_baro_sim start
sensor_gps_sim start
sensor_mag_sim start
sensor_airspeed_sim start
if param compare -s SENS_EN_ARSPDSIM 1
then
sensor_airspeed_sim start
fi
else
echo "ERROR [init] gz_bridge failed to start"
@@ -109,7 +115,10 @@ elif [ "$PX4_SIMULATOR" = "gz" ] || [ "$(param show -q SIM_GZ_EN)" -eq "1" ]; th
sensor_baro_sim start
sensor_gps_sim start
sensor_mag_sim start
sensor_airspeed_sim start
if param compare -s SENS_EN_ARSPDSIM 1
then
sensor_airspeed_sim start
fi
else
echo "ERROR [init] gz_bridge failed to start"
+1 -1
View File
@@ -3,9 +3,9 @@ CONFIG_DRIVERS_IMU_ANALOG_DEVICES_ADIS16448=n
CONFIG_DRIVERS_IRLOCK=n
CONFIG_DRIVERS_PCA9685_PWM_OUT=n
CONFIG_DRIVERS_UAVCAN=n
CONFIG_MODULES_ROVER_POS_CONTROL=n
CONFIG_MODULES_TEMPERATURE_COMPENSATION=n
CONFIG_BOARD_TESTING=y
CONFIG_DRIVERS_TEST_PPM=y
CONFIG_SYSTEMCMDS_MICROBENCH=y
CONFIG_SYSTEMCMDS_SD_BENCH=y
CONFIG_SYSTEMCMDS_SD_STRESS=y
@@ -40,14 +40,6 @@ __BEGIN_DECLS
#include <stm32.h>
#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_STM32F4
#define PX4_FLASH_BASE STM32_FLASH_BASE
#if defined(CONFIG_STM32_STM32F4XXX)
# include <stm32_bbsram.h>
# define PX4_BBSRAM_SIZE STM32_BBSRAM_SIZE
# define PX4_HF_GETDESC_IOCTL STM32_BBSRAM_GETDESC_IOCTL
# define HAS_BBSRAM CONFIG_STM32_BBSRAM
# define BBSRAM_FILE_COUNT CONFIG_STM32_BBSRAM_FILES
# define SAVE_CRASHDUMP CONFIG_STM32_SAVE_CRASHDUMP
#endif
#define PX4_NUMBER_I2C_BUSES STM32_NI2C
#define PX4_ADC_INTERNAL_TEMP_SENSOR_CHANNEL 16
+16 -6
View File
@@ -1864,20 +1864,30 @@ Mavlink::task_main(int argc, char *argv[])
// use default /dev/null so that these numbers are not used by other other files.
if (fcntl(0, F_GETFD) == -1) {
int tmp = open("/dev/null", O_RDONLY);
dup2(tmp, 0);
close(tmp);
if (tmp != 0) {
dup2(tmp, 0);
close(tmp);
}
}
if (fcntl(1, F_GETFD) == -1) {
int tmp = open("/dev/null", O_WRONLY);
dup2(tmp, 1);
close(tmp);
if (tmp != 1) {
dup2(tmp, 1);
close(tmp);
}
}
if (fcntl(2, F_GETFD) == -1) {
int tmp = open("/dev/null", O_WRONLY);
dup2(tmp, 2);
close(tmp);
if (tmp != 2) {
dup2(tmp, 2);
close(tmp);
}
}
int ch;
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2021 PX4 Development Team. All rights reserved.
* Copyright (c) 2023 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -106,47 +106,49 @@ void SensorAirspeedSim::Run()
updateParams();
}
if (_vehicle_local_position_sub.updated() && _vehicle_global_position_sub.updated()
&& _vehicle_attitude_sub.updated()) {
if (_sim_failure.get() == 0) {
if (_vehicle_local_position_sub.updated() && _vehicle_global_position_sub.updated()
&& _vehicle_attitude_sub.updated()) {
vehicle_local_position_s lpos{};
_vehicle_local_position_sub.copy(&lpos);
vehicle_local_position_s lpos{};
_vehicle_local_position_sub.copy(&lpos);
vehicle_global_position_s gpos{};
_vehicle_global_position_sub.copy(&gpos);
vehicle_global_position_s gpos{};
_vehicle_global_position_sub.copy(&gpos);
vehicle_attitude_s attitude{};
_vehicle_attitude_sub.copy(&attitude);
vehicle_attitude_s attitude{};
_vehicle_attitude_sub.copy(&attitude);
Vector3f local_velocity = Vector3f{lpos.vx, lpos.vy, lpos.vz};
Vector3f body_velocity = Dcmf{Quatf{attitude.q}} .transpose() * local_velocity;
Vector3f local_velocity = Vector3f{lpos.vx, lpos.vy, lpos.vz};
Vector3f body_velocity = Dcmf{Quatf{attitude.q}} .transpose() * local_velocity;
// device id
device::Device::DeviceId device_id;
device_id.devid_s.bus_type = device::Device::DeviceBusType::DeviceBusType_SIMULATION;
device_id.devid_s.bus = 0;
device_id.devid_s.address = 0;
device_id.devid_s.devtype = DRV_DIFF_PRESS_DEVTYPE_SIM;
// device id
device::Device::DeviceId device_id;
device_id.devid_s.bus_type = device::Device::DeviceBusType::DeviceBusType_SIMULATION;
device_id.devid_s.bus = 0;
device_id.devid_s.address = 0;
device_id.devid_s.devtype = DRV_DIFF_PRESS_DEVTYPE_SIM;
const float alt_amsl = gpos.alt;
const float temperature_local = TEMPERATURE_MSL - LAPSE_RATE * alt_amsl;
const float density_ratio = powf(TEMPERATURE_MSL / temperature_local, 4.256f);
const float air_density = AIR_DENSITY_MSL / density_ratio;
const float alt_amsl = gpos.alt;
const float temperature_local = TEMPERATURE_MSL - LAPSE_RATE * alt_amsl;
const float density_ratio = powf(TEMPERATURE_MSL / temperature_local, 4.256f);
const float air_density = AIR_DENSITY_MSL / density_ratio;
// calculate differential pressure + noise in hPa
const float diff_pressure_noise = (float)generate_wgn() * 0.01f;
float diff_pressure = sign(body_velocity(0)) * 0.005f * air_density * body_velocity(0) * body_velocity(
0) + diff_pressure_noise;
// calculate differential pressure + noise in hPa
const float diff_pressure_noise = (float)generate_wgn() * 0.01f;
float diff_pressure = sign(body_velocity(0)) * 0.005f * air_density * body_velocity(0) * body_velocity(
0) + diff_pressure_noise;
differential_pressure_s differential_pressure{};
// report.timestamp_sample = time;
differential_pressure.device_id = 1377548; // 1377548: DRV_DIFF_PRESS_DEVTYPE_SIM, BUS: 1, ADDR: 5, TYPE: SIMULATION
differential_pressure.differential_pressure_pa = (double)diff_pressure * 100.0; // hPa to Pa;
differential_pressure.temperature = temperature_local;
differential_pressure.timestamp = hrt_absolute_time();
_differential_pressure_pub.publish(differential_pressure);
differential_pressure_s differential_pressure{};
// report.timestamp_sample = time;
differential_pressure.device_id = 1377548; // 1377548: DRV_DIFF_PRESS_DEVTYPE_SIM, BUS: 1, ADDR: 5, TYPE: SIMULATION
differential_pressure.differential_pressure_pa = (double)diff_pressure * 100.0; // hPa to Pa;
differential_pressure.temperature = temperature_local;
differential_pressure.timestamp = hrt_absolute_time();
_differential_pressure_pub.publish(differential_pressure);
}
}
perf_end(_loop_perf);
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2021 PX4 Development Team. All rights reserved.
* Copyright (c) 2023 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -89,7 +89,7 @@ private:
perf_counter_t _loop_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")};
// DEFINE_PARAMETERS(
// (ParamInt<px4::params::SIM_GPS_USED>) _sim_gps_used
// )
DEFINE_PARAMETERS(
(ParamInt<px4::params::SIM_ARSPD_FAIL>) _sim_failure
)
};
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2021 PX4 Development Team. All rights reserved.
* Copyright (c) 2023 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,10 +32,25 @@
****************************************************************************/
/**
* simulated GPS number of satellites used
* Enable simulated airspeed sensor instance
*
* @reboot_required true
* @min 0
* @max 50
* @group Simulator
*/
// PARAM_DEFINE_INT32(SIM_GPS_USED, 10);
* @max 1
* @group Sensors
* @value 0 Disabled
* @value 1 Enabled
*/
PARAM_DEFINE_INT32(SENS_EN_ARSPDSIM, 0);
/**
* Dynamically simulate failure of airspeed sensor instance
*
* @reboot_required true
* @min 0
* @max 1
* @group Sensors
* @value 0 Disabled
* @value 1 Enabled
*/
PARAM_DEFINE_INT32(SIM_ARSPD_FAIL, 0);