Compare commits

...

6 Commits

Author SHA1 Message Date
Matthias Grob 435e06af1f TEMP 2025-05-15 18:51:11 +02:00
Matthias Grob a3902157fb mavlink: adhere to parameter naming convention 2025-05-15 18:50:54 +02:00
Matthias Grob db18501b40 FilaureDetector: publish failure_detector_status and just call that from commander 2025-05-15 18:15:22 +02:00
Matthias Grob 8eb57d4f5b FailureDetector: write out status veriable name for clarity 2025-05-15 16:52:07 +02:00
Matthias Grob 70784e83d7 FailureDetector: adhere to the parameter naming convention 2025-05-15 16:41:44 +02:00
Matthias Grob 06575a5e14 SIH: add Hexacopter X
to enable easy simulation of a motor failure.
2025-05-15 16:05:52 +02:00
14 changed files with 160 additions and 74 deletions
@@ -0,0 +1,49 @@
#!/bin/sh
#
# @name HexarotorX SITL for SIH
#
# @type Hexarotor x
# @class Copter
#
# @maintainer Matthias Grob <maetugr@gmail.com>
#
. ${R}etc/init.d/rc.mc_defaults
PX4_SIMULATOR=${PX4_SIMULATOR:=sihsim}
PX4_SIM_MODEL=${PX4_SIM_MODEL:=hex}
param set-default SENS_EN_GPSSIM 1
param set-default SENS_EN_BAROSIM 1
param set-default SENS_EN_MAGSIM 1
param set SIH_VEHICLE_TYPE 4
# Symmetric hexacopter X clockwise motor numbering
param set-default CA_ROTOR_COUNT 6
param set-default CA_ROTOR0_PX 0.866
param set-default CA_ROTOR0_PY 0.5
param set-default CA_ROTOR1_PX 0
param set-default CA_ROTOR1_PY 1
param set-default CA_ROTOR1_KM -0.05
param set-default CA_ROTOR2_PX -0.866
param set-default CA_ROTOR2_PY 0.5
param set-default CA_ROTOR3_PX -0.866
param set-default CA_ROTOR3_PY -0.5
param set-default CA_ROTOR3_KM -0.05
param set-default CA_ROTOR4_PX 0
param set-default CA_ROTOR4_PY -1
param set-default CA_ROTOR5_PX 0.866
param set-default CA_ROTOR5_PY -0.5
param set-default CA_ROTOR5_KM -0.05
#param set-default MC_YAW_WEIGHT 0
param set-default PWM_MAIN_FUNC1 101
param set-default PWM_MAIN_FUNC2 102
param set-default PWM_MAIN_FUNC3 103
param set-default PWM_MAIN_FUNC4 104
param set-default PWM_MAIN_FUNC5 105
param set-default PWM_MAIN_FUNC6 106
param set-default EKF2_GPS_DELAY 0
@@ -109,6 +109,7 @@ px4_add_romfs_files(
10041_sihsim_airplane
10042_sihsim_xvert
10043_sihsim_standard_vtol
10044_sihsim_hex
17001_flightgear_tf-g1
17002_flightgear_tf-g2
+13 -5
View File
@@ -58,6 +58,7 @@ To set up/start SIH:
1. Open QGroundControl and wait for the flight controller too boot and connect.
1. Open [Vehicle Setup > Airframe](../config/airframe.md) then select the desired frame:
- [SIH Quadcopter X](../airframes/airframe_reference.md#copter_simulation_sih_quadcopter_x)
- SIH Hexacopter X currently only has an airframe for SITL to safe flash so on flight control hardware it has to be manually configured equivalently.
- [SIH plane AERT](../airframes/airframe_reference.md#plane_simulation_sih_plane_aert)
- [SIH Tailsitter Duo](../airframes/airframe_reference.md#vtol_simulation_sih_tailsitter_duo)
- [SIH Standard VTOL QuadPlane](../airframes/airframe_reference.md#vtol_simulation_sih_standard_vtol_quadplane)
@@ -114,25 +115,31 @@ To run SIH as SITL:
1. Install the [PX4 Development toolchain](../dev_setup/dev_env.md).
1. Run the appropriate make command for each vehicle type (at the root of the PX4-Autopilot repository):
- quadrotor:
- Quadcopter
```sh
make px4_sitl sihsim_quadx
```
- Fixed-wing (plane):
- Hexacopter
```sh
make px4_sitl sihsim_hex
```
- Fixed-wing (plane)
```sh
make px4_sitl sihsim_airplane
```
- XVert VTOL tailsitter:
- XVert VTOL tailsitter
```sh
make px4_sitl sihsim_xvert
```
- Standard VTOL:
- Standard VTOL
```sh
make px4_sitl sihsim_standard_vtol
@@ -231,7 +238,8 @@ For specific examples see the `_sihsim_` airframes in [ROMFS/px4fmu_common/init.
The dynamic models for the various vehicles are:
- Quadrotor: [pdf report](https://github.com/PX4/PX4-user_guide/raw/main/assets/simulation/SIH_dynamic_model.pdf).
- Quadcopter: [pdf report](https://github.com/PX4/PX4-user_guide/raw/main/assets/simulation/SIH_dynamic_model.pdf).
- Hexacopter: Equivalent to the Quadcopter but with a symmetric hexacopter x actuation setup.
- Fixed-wing: Inspired by the PhD thesis: "Dynamics modeling of agile fixed-wing unmanned aerial vehicles." Khan, Waqas, supervised by Nahon, Meyer, McGill University, PhD thesis, 2016.
- Tailsitter: Inspired by the master's thesis: "Modeling and control of a flying wing tailsitter unmanned aerial vehicle." Chiappinelli, Romain, supervised by Nahon, Meyer, McGill University, Masters thesis, 2018.
@@ -14,8 +14,8 @@ Questions about these tools should be raised on the [discussion forums](../contr
| Simulator | Description |
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Simulation-In-Hardware](../sim_sih/index.md) (SIH) | <p>A simulator implemented in C++ as a PX4 module directly in the Firmware [code](https://github.com/PX4/PX4-Autopilot/tree/main/src/modules/simulation/simulator_sih). It can be ran in SITL directly on the computer or as an alternative to HITL offering a hard real-time simulation directly on the hardware autopilot. </p><p><strong>Supported Vehicles:</strong> Quad, Hexa, Plane, Tailsitter, Standard VTOL</p> |
| [FlightGear](../sim_flightgear/index.md) | <p>A simulator that provides physically and visually realistic simulations. In particular it can simulate many weather conditions, including thunderstorms, snow, rain and hail, and can also simulate thermals and different types of atmospheric flows. [Multi-vehicle simulation](../sim_flightgear/multi_vehicle.md) is also supported.</p> <p><strong>Supported Vehicles:</strong> Plane, Autogyro, Rover</p> |
| [JMAVSim](../sim_jmavsim/index.md) | <p>A simple multirotor/quad simulator. This was previously part of the PX4 development toolchain but was removed in favour of [Gazebo](../sim_gazebo_gz/index.md).</p> <p><strong>Supported Vehicles:</strong> Quad</p> |
| [JSBSim](../sim_jsbsim/index.md) | <p>A simulator that provides advanced flight dynamics models. This can be used to model realistic flight dynamics based on wind tunnel data.</p> <p><strong>Supported Vehicles:</strong> Plane, Quad, Hex</p> |
| [AirSim](../sim_airsim/index.md) | <p>A cross platform simulator that provides physically and visually realistic simulations. This simulator is resource intensive, and requires a very significantly more powerful computer than the other simulators described here.</p><p><strong>Supported Vehicles:</strong> Iris (MultiRotor model and a configuration for PX4 QuadRotor in the X configuration).</p> |
| [Simulation-In-Hardware](../sim_sih/index.md) (SIH) | <p>An alternative to HITL that offers a hard real-time simulation directly on the hardware autopilot. This simulator is implemented in C++ as a PX4 module directly in the Firmware [code](https://github.com/PX4/PX4-Autopilot/tree/main/src/modules/simulation/simulator_sih). </p><p><strong>Supported Vehicles:</strong> Plane, Quad, Tailsitter, Standard VTOL</p> |
+1 -13
View File
@@ -1921,19 +1921,7 @@ void Commander::run()
_vehicle_status_pub.publish(_vehicle_status);
// failure_detector_status publish
failure_detector_status_s fd_status{};
fd_status.fd_roll = _failure_detector.getStatusFlags().roll;
fd_status.fd_pitch = _failure_detector.getStatusFlags().pitch;
fd_status.fd_alt = _failure_detector.getStatusFlags().alt;
fd_status.fd_ext = _failure_detector.getStatusFlags().ext;
fd_status.fd_arm_escs = _failure_detector.getStatusFlags().arm_escs;
fd_status.fd_battery = _failure_detector.getStatusFlags().battery;
fd_status.fd_imbalanced_prop = _failure_detector.getStatusFlags().imbalanced_prop;
fd_status.fd_motor = _failure_detector.getStatusFlags().motor;
fd_status.imbalanced_prop_metric = _failure_detector.getImbalancedPropMetric();
fd_status.motor_failure_mask = _failure_detector.getMotorFailures();
fd_status.timestamp = hrt_absolute_time();
_failure_detector_status_pub.publish(fd_status);
_failure_detector.publishStatus();
}
checkWorkerThread();
-2
View File
@@ -54,7 +54,6 @@
#include <uORB/Publication.hpp>
#include <uORB/topics/actuator_armed.h>
#include <uORB/topics/actuator_test.h>
#include <uORB/topics/failure_detector_status.h>
#include <uORB/topics/vehicle_command_ack.h>
#include <uORB/topics/vehicle_control_mode.h>
#include <uORB/topics/vehicle_status.h>
@@ -312,7 +311,6 @@ private:
// Publications
uORB::Publication<actuator_armed_s> _actuator_armed_pub{ORB_ID(actuator_armed)};
uORB::Publication<actuator_test_s> _actuator_test_pub{ORB_ID(actuator_test)};
uORB::Publication<failure_detector_status_s> _failure_detector_status_pub{ORB_ID(failure_detector_status)};
uORB::Publication<vehicle_command_ack_s> _vehicle_command_ack_pub{ORB_ID(vehicle_command_ack)};
uORB::Publication<vehicle_command_s> _vehicle_command_pub{ORB_ID(vehicle_command)};
uORB::Publication<vehicle_control_mode_s> _vehicle_control_mode_pub{ORB_ID(vehicle_control_mode)};
@@ -168,7 +168,7 @@ bool FailureDetector::update(const vehicle_status_s &vehicle_status, const vehic
{
_failure_injector.update();
failure_detector_status_u status_prev = _status;
failure_detector_status_u status_prev = _failure_detector_status;
if (vehicle_control_mode.flag_control_attitude_enabled) {
updateAttitudeStatus(vehicle_status);
@@ -178,10 +178,10 @@ bool FailureDetector::update(const vehicle_status_s &vehicle_status, const vehic
}
} else {
_status.flags.roll = false;
_status.flags.pitch = false;
_status.flags.alt = false;
_status.flags.ext = false;
_failure_detector_status.flags.roll = false;
_failure_detector_status.flags.pitch = false;
_failure_detector_status.flags.alt = false;
_failure_detector_status.flags.ext = false;
}
// esc_status subscriber is shared between subroutines
@@ -194,7 +194,7 @@ bool FailureDetector::update(const vehicle_status_s &vehicle_status, const vehic
updateEscsStatus(vehicle_status, esc_status);
}
if (_param_fd_actuator_en.get()) {
if (_param_fd_act_en.get()) {
updateMotorStatus(vehicle_status, esc_status);
}
}
@@ -203,7 +203,24 @@ bool FailureDetector::update(const vehicle_status_s &vehicle_status, const vehic
updateImbalancedPropStatus();
}
return _status.value != status_prev.value;
return _failure_detector_status.value != status_prev.value;
}
void FailureDetector::publishStatus()
{
failure_detector_status_s failure_detector_status{};
failure_detector_status.fd_roll = _failure_detector_status.flags.roll;
failure_detector_status.fd_pitch = _failure_detector_status.flags.pitch;
failure_detector_status.fd_alt = _failure_detector_status.flags.alt;
failure_detector_status.fd_ext = _failure_detector_status.flags.ext;
failure_detector_status.fd_arm_escs = _failure_detector_status.flags.arm_escs;
failure_detector_status.fd_battery = _failure_detector_status.flags.battery;
failure_detector_status.fd_imbalanced_prop = _failure_detector_status.flags.imbalanced_prop;
failure_detector_status.fd_motor = _failure_detector_status.flags.motor;
failure_detector_status.imbalanced_prop_metric = _imbalanced_prop_lpf.getState();
failure_detector_status.motor_failure_mask = _motor_failure_esc_timed_out_mask | _motor_failure_esc_under_current_mask;
failure_detector_status.timestamp = hrt_absolute_time();
_failure_detector_status_pub.publish(failure_detector_status);
}
void FailureDetector::updateAttitudeStatus(const vehicle_status_s &vehicle_status)
@@ -249,8 +266,8 @@ void FailureDetector::updateAttitudeStatus(const vehicle_status_s &vehicle_statu
_pitch_failure_hysteresis.set_state_and_update(pitch_status, time_now);
// Update status
_status.flags.roll = _roll_failure_hysteresis.get_state();
_status.flags.pitch = _pitch_failure_hysteresis.get_state();
_failure_detector_status.flags.roll = _roll_failure_hysteresis.get_state();
_failure_detector_status.flags.pitch = _pitch_failure_hysteresis.get_state();
}
}
@@ -269,7 +286,7 @@ void FailureDetector::updateExternalAtsStatus()
_ext_ats_failure_hysteresis.set_hysteresis_time_from(false, 100_ms); // 5 consecutive pulses at 50hz
_ext_ats_failure_hysteresis.set_state_and_update(ats_trigger_status, time_now);
_status.flags.ext = _ext_ats_failure_hysteresis.get_state();
_failure_detector_status.flags.ext = _ext_ats_failure_hysteresis.get_state();
}
}
@@ -292,13 +309,13 @@ void FailureDetector::updateEscsStatus(const vehicle_status_s &vehicle_status, c
_esc_failure_hysteresis.set_state_and_update(is_esc_failure, time_now);
if (_esc_failure_hysteresis.get_state()) {
_status.flags.arm_escs = true;
_failure_detector_status.flags.arm_escs = true;
}
} else {
// reset ESC bitfield
_esc_failure_hysteresis.set_state_and_update(false, time_now);
_status.flags.arm_escs = false;
_failure_detector_status.flags.arm_escs = false;
}
}
@@ -354,7 +371,7 @@ void FailureDetector::updateImbalancedPropStatus()
const float metric_lpf = _imbalanced_prop_lpf.update(metric);
const bool is_imbalanced = metric_lpf > _param_fd_imb_prop_thr.get();
_status.flags.imbalanced_prop = is_imbalanced;
_failure_detector_status.flags.imbalanced_prop = is_imbalanced;
}
}
}
@@ -426,9 +443,9 @@ void FailureDetector::updateMotorStatus(const vehicle_status_s &vehicle_status,
esc_throttle = fabsf(actuator_motors.control[i_esc]);
}
const bool throttle_above_threshold = esc_throttle > _param_fd_motor_throttle_thres.get();
const bool throttle_above_threshold = esc_throttle > _param_fd_act_mot_thr.get();
const bool current_too_low = cur_esc_report.esc_current < esc_throttle *
_param_fd_motor_current2throttle_thres.get();
_param_fd_act_mot_c2t.get();
if (throttle_above_threshold && current_too_low && !esc_timed_out) {
if (_motor_failure_undercurrent_start_time[i_esc] == 0) {
@@ -442,7 +459,7 @@ void FailureDetector::updateMotorStatus(const vehicle_status_s &vehicle_status,
}
if (_motor_failure_undercurrent_start_time[i_esc] != 0
&& (time_now - _motor_failure_undercurrent_start_time[i_esc]) > _param_fd_motor_time_thres.get() * 1_ms
&& (time_now - _motor_failure_undercurrent_start_time[i_esc]) > _param_fd_act_mot_tout.get() * 1_ms
&& (_motor_failure_esc_under_current_mask & (1 << i_esc)) == 0) {
// Set flag
_motor_failure_esc_under_current_mask |= (1 << i_esc);
@@ -453,13 +470,13 @@ void FailureDetector::updateMotorStatus(const vehicle_status_s &vehicle_status,
bool critical_esc_failure = (_motor_failure_esc_timed_out_mask != 0 || _motor_failure_esc_under_current_mask != 0);
if (critical_esc_failure && !(_status.flags.motor)) {
if (critical_esc_failure && !(_failure_detector_status.flags.motor)) {
// Add motor failure flag to bitfield
_status.flags.motor = true;
_failure_detector_status.flags.motor = true;
} else if (!critical_esc_failure && _status.flags.motor) {
} else if (!critical_esc_failure && _failure_detector_status.flags.motor) {
// Reset motor failure flag
_status.flags.motor = false;
_failure_detector_status.flags.motor = false;
}
} else { // Disarmed
@@ -469,6 +486,6 @@ void FailureDetector::updateMotorStatus(const vehicle_status_s &vehicle_status,
}
_motor_failure_esc_under_current_mask = 0;
_status.flags.motor = false;
_failure_detector_status.flags.motor = false;
}
}
@@ -50,9 +50,12 @@
#include <px4_platform_common/module_params.h>
// subscriptions
#include <uORB/Subscription.hpp>
#include <uORB/Publication.hpp>
#include <uORB/Subscription.hpp>
#include <uORB/topics/actuator_motors.h>
#include <uORB/topics/esc_status.h>
#include <uORB/topics/failure_detector_status.h>
#include <uORB/topics/pwm_input.h>
#include <uORB/topics/sensor_selection.h>
#include <uORB/topics/vehicle_attitude_setpoint.h>
#include <uORB/topics/vehicle_attitude.h>
@@ -61,8 +64,6 @@
#include <uORB/topics/vehicle_control_mode.h>
#include <uORB/topics/vehicle_imu_status.h>
#include <uORB/topics/vehicle_status.h>
#include <uORB/topics/esc_status.h>
#include <uORB/topics/pwm_input.h>
union failure_detector_status_u {
struct {
@@ -101,10 +102,9 @@ public:
~FailureDetector() = default;
bool update(const vehicle_status_s &vehicle_status, const vehicle_control_mode_s &vehicle_control_mode);
const failure_detector_status_u &getStatus() const { return _status; }
const decltype(failure_detector_status_u::flags) &getStatusFlags() const { return _status.flags; }
float getImbalancedPropMetric() const { return _imbalanced_prop_lpf.getState(); }
uint16_t getMotorFailures() const { return _motor_failure_esc_timed_out_mask | _motor_failure_esc_under_current_mask; }
const failure_detector_status_u &getStatus() const { return _failure_detector_status; }
void publishStatus();
private:
void updateAttitudeStatus(const vehicle_status_s &vehicle_status);
@@ -113,7 +113,7 @@ private:
void updateMotorStatus(const vehicle_status_s &vehicle_status, const esc_status_s &esc_status);
void updateImbalancedPropStatus();
failure_detector_status_u _status{};
failure_detector_status_u _failure_detector_status{};
systemlib::Hysteresis _roll_failure_hysteresis{false};
systemlib::Hysteresis _pitch_failure_hysteresis{false};
@@ -139,6 +139,8 @@ private:
uORB::Subscription _vehicle_imu_status_sub{ORB_ID(vehicle_imu_status)};
uORB::Subscription _actuator_motors_sub{ORB_ID(actuator_motors)};
uORB::Publication<failure_detector_status_s> _failure_detector_status_pub{ORB_ID(failure_detector_status)};
FailureInjector _failure_injector;
DEFINE_PARAMETERS(
@@ -152,9 +154,9 @@ private:
(ParamInt<px4::params::FD_IMB_PROP_THR>) _param_fd_imb_prop_thr,
// Actuator failure
(ParamBool<px4::params::FD_ACT_EN>) _param_fd_actuator_en,
(ParamFloat<px4::params::FD_ACT_MOT_THR>) _param_fd_motor_throttle_thres,
(ParamFloat<px4::params::FD_ACT_MOT_C2T>) _param_fd_motor_current2throttle_thres,
(ParamInt<px4::params::FD_ACT_MOT_TOUT>) _param_fd_motor_time_thres
(ParamBool<px4::params::FD_ACT_EN>) _param_fd_act_en,
(ParamFloat<px4::params::FD_ACT_MOT_THR>) _param_fd_act_mot_thr,
(ParamFloat<px4::params::FD_ACT_MOT_C2T>) _param_fd_act_mot_c2t,
(ParamInt<px4::params::FD_ACT_MOT_TOUT>) _param_fd_act_mot_tout
)
};
@@ -137,6 +137,7 @@ ActuatorEffectivenessRotors::addActuators(Configuration &configuration)
int num_actuators = computeEffectivenessMatrix(_geometry,
configuration.effectiveness_matrices[configuration.selected_matrix],
configuration.num_actuators_matrix[configuration.selected_matrix]);
configuration.effectiveness_matrices[configuration.selected_matrix].print();
configuration.actuatorsAdded(ActuatorType::MOTORS, num_actuators);
return true;
}
+2 -2
View File
@@ -503,7 +503,7 @@ public:
bool hash_check_enabled() const { return _param_mav_hash_chk_en.get(); }
bool forward_heartbeats_enabled() const { return _param_mav_hb_forw_en.get(); }
bool failure_injection_enabled() const { return _param_sys_failure_injection_enabled.get(); }
bool failure_injection_enabled() const { return _param_sys_failure_en.get(); }
struct ping_statistics_s {
uint64_t last_ping_time;
@@ -668,7 +668,7 @@ private:
(ParamBool<px4::params::MAV_HB_FORW_EN>) _param_mav_hb_forw_en,
(ParamInt<px4::params::MAV_RADIO_TOUT>) _param_mav_radio_timeout,
(ParamInt<px4::params::SYS_HITL>) _param_sys_hitl,
(ParamBool<px4::params::SYS_FAILURE_EN>) _param_sys_failure_injection_enabled
(ParamBool<px4::params::SYS_FAILURE_EN>) _param_sys_failure_en
)
perf_counter_t _loop_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": tx run elapsed")}; /**< loop performance counter */
@@ -54,6 +54,7 @@ if(PX4_PLATFORM MATCHES "posix")
quadx
xvert
standard_vtol
hex
)
# find corresponding airframes
+31 -10
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2019-2022 PX4 Development Team. All rights reserved.
* Copyright (c) 2019-2025 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
@@ -75,8 +75,9 @@ void Sih::run()
_last_run = task_start;
_airspeed_time = task_start;
_dist_snsr_time = task_start;
_vehicle = (VehicleType)constrain(_sih_vtype.get(), static_cast<typeof _sih_vtype.get()>(0),
static_cast<typeof _sih_vtype.get()>(3));
_vehicle = static_cast<VehicleType>(constrain(_sih_vtype.get(),
static_cast<int32_t>(VehicleType::First),
static_cast<int32_t>(VehicleType::Last)));
_actuator_out_sub = uORB::Subscription{ORB_ID(actuator_outputs_sim)};
@@ -319,7 +320,7 @@ void Sih::read_motors(const float dt)
void Sih::generate_force_and_torques()
{
if (_vehicle == VehicleType::Multicopter) {
if (_vehicle == VehicleType::Quadcopter) {
_T_B = Vector3f(0.0f, 0.0f, -_T_MAX * (+_u[0] + _u[1] + _u[2] + _u[3]));
_Mt_B = Vector3f(_L_ROLL * _T_MAX * (-_u[0] + _u[1] + _u[2] - _u[3]),
_L_PITCH * _T_MAX * (+_u[0] - _u[1] + _u[2] - _u[3]),
@@ -327,6 +328,22 @@ void Sih::generate_force_and_torques()
_Fa_E = -_KDV * _v_E; // first order drag to slow down the aircraft
_Ma_B = -_KDW * _w_B; // first order angular damper
} else if (_vehicle == VehicleType::Hexacopter) {
/* m5 m0 ┬
\ / √3/2
m4 -- + -- m1 ┴
/ \
m3 m2
├1/2┤
├ 1 ┤ */
_u[1] = 0.f;
_T_B = Vector3f(0.0f, 0.0f, -_T_MAX * (+_u[0] + _u[1] + _u[2] + _u[3] + _u[4] + _u[5]));
_Mt_B = Vector3f(_L_ROLL * _T_MAX * (-.5f * _u[0] - _u[1] - .5f * _u[2] + .5f * _u[3] + _u[4] + .5f * _u[5]),
_L_PITCH * _T_MAX * (M_SQRT3_F / 2.f) * (+_u[0] - _u[2] - _u[3] + _u[5]),
_Q_MAX * (+_u[0] - _u[1] + _u[2] - _u[3] + _u[4] - _u[5]));
_Fa_E = -_KDV * _v_E; // first order drag to slow down the aircraft
_Ma_B = -_KDW * _w_B; // first order angular damper
} else if (_vehicle == VehicleType::FixedWing) {
_T_B = Vector3f(_T_MAX * _u[3], 0.0f, 0.0f); // forward thruster
// _Mt_B = Vector3f(_Q_MAX*_u[3], 0.0f,0.0f); // thruster torque
@@ -429,7 +446,8 @@ void Sih::equations_of_motion(const float dt)
Vector3f ground_force_E;
if ((_lla.altitude() - _lpos_ref_alt) < 0.f && force_down > 0.f) {
if (_vehicle == VehicleType::Multicopter
if (_vehicle == VehicleType::Quadcopter
|| _vehicle == VehicleType::Hexacopter
|| _vehicle == VehicleType::TailsitterVTOL
|| _vehicle == VehicleType::StandardVTOL) {
ground_force_E = -sum_of_forces_E;
@@ -715,20 +733,23 @@ int Sih::print_status()
PX4_INFO("Achieved speedup: %.2fX", (double)_achieved_speedup);
#endif
if (_vehicle == VehicleType::Multicopter) {
PX4_INFO("Running MultiCopter");
if (_vehicle == VehicleType::Quadcopter) {
PX4_INFO("Quadcopter");
} else if (_vehicle == VehicleType::Hexacopter) {
PX4_INFO("Hexacopter");
} else if (_vehicle == VehicleType::FixedWing) {
PX4_INFO("Running Fixed-Wing");
PX4_INFO("Fixed-Wing");
} else if (_vehicle == VehicleType::TailsitterVTOL) {
PX4_INFO("Running TailSitter");
PX4_INFO("TailSitter");
PX4_INFO("aoa [deg]: %d", (int)(degrees(_ts[4].get_aoa())));
PX4_INFO("v segment (m/s)");
_ts[4].get_vS().print();
} else if (_vehicle == VehicleType::StandardVTOL) {
PX4_INFO("Running Standard VTOL");
PX4_INFO("Standard VTOL");
}
PX4_INFO("vehicle landed: %d", _grounded);
+4 -5
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2019-2022 PX4 Development Team. All rights reserved.
* Copyright (c) 2019-2025 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
@@ -218,11 +218,10 @@ private:
matrix::Vector3f _v_E_dot{};
matrix::Dcmf _R_N2E; // local navigation to ECEF frame rotation matrix
float _u[NUM_ACTUATORS_MAX] {}; // thruster signals
float _u[NUM_ACTUATORS_MAX] {}; // thruster signals
enum class VehicleType {Multicopter, FixedWing, TailsitterVTOL, StandardVTOL};
VehicleType _vehicle = VehicleType::Multicopter;
enum class VehicleType {Quadcopter, FixedWing, TailsitterVTOL, StandardVTOL, Hexacopter, First = Quadcopter, Last = Hexacopter}; // numbering dependent on parameter SIH_VEHICLE_TYPE
VehicleType _vehicle = VehicleType::Quadcopter;
// aerodynamic segments for the fixedwing
AeroSeg _wing_l = AeroSeg(SPAN / 2.0f, MAC, -4.0f, matrix::Vector3f(0.0f, -SPAN / 4.0f, 0.0f), 3.0f,
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2013-2022 PX4 Development Team. All rights reserved.
* Copyright (c) 2013-2025 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
@@ -33,7 +33,7 @@
/**
* @file sih_params.c
* Parameters for quadcopter X simulator in hardware.
* Parameters for simulator in hardware.
*
* @author Romain Chiappinelli <romain.chiap@gmail.com>
* February 2019
@@ -329,10 +329,11 @@ PARAM_DEFINE_FLOAT(SIH_T_TAU, 0.05f);
/**
* Vehicle type
*
* @value 0 Multicopter
* @value 0 Quadcopter
* @value 1 Fixed-Wing
* @value 2 Tailsitter
* @value 3 Standard VTOL
* @value 4 Hexacopter
* @reboot_required true
* @group Simulation In Hardware
*/