mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-09 20:51:36 +08:00
simulator: use failure injection to block GPS
This uses the new failure injection system using vehicle_commands instead of specific parameters. For now it implements GPS only.
This commit is contained in:
@@ -72,6 +72,8 @@
|
||||
#include <uORB/topics/vehicle_local_position.h>
|
||||
#include <uORB/topics/vehicle_odometry.h>
|
||||
#include <uORB/topics/vehicle_status.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
#include <uORB/topics/vehicle_command_ack.h>
|
||||
|
||||
#include <random>
|
||||
|
||||
@@ -145,7 +147,8 @@ private:
|
||||
_instance = nullptr;
|
||||
}
|
||||
|
||||
// class methods
|
||||
|
||||
void check_failure_injections();
|
||||
|
||||
int publish_flow_topic(const mavlink_hil_optical_flow_t *flow);
|
||||
int publish_odometry_topic(const mavlink_message_t *odom_mavlink);
|
||||
@@ -176,6 +179,8 @@ private:
|
||||
uORB::Publication<vehicle_odometry_s> _visual_odometry_pub{ORB_ID(vehicle_visual_odometry)};
|
||||
uORB::Publication<vehicle_odometry_s> _mocap_odometry_pub{ORB_ID(vehicle_mocap_odometry)};
|
||||
|
||||
uORB::PublicationQueued<vehicle_command_ack_s> _command_ack_pub{ORB_ID(vehicle_command_ack)};
|
||||
|
||||
uORB::PublicationMulti<distance_sensor_s> *_dist_pubs[RANGE_FINDER_MAX_SENSORS] {};
|
||||
uint8_t _dist_sensor_ids[RANGE_FINDER_MAX_SENSORS] {};
|
||||
|
||||
@@ -235,6 +240,7 @@ private:
|
||||
actuator_outputs_s _actuator_outputs{};
|
||||
|
||||
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
|
||||
uORB::Subscription _vehicle_command_sub{ORB_ID(vehicle_command)};
|
||||
|
||||
// hil map_ref data
|
||||
struct map_projection_reference_s _hil_local_proj_ref {};
|
||||
@@ -246,20 +252,20 @@ private:
|
||||
float _hil_ref_alt{0.0f};
|
||||
uint64_t _hil_ref_timestamp{0};
|
||||
|
||||
// uORB data containers
|
||||
vehicle_status_s _vehicle_status{};
|
||||
|
||||
bool _accel_blocked{false};
|
||||
bool _gyro_blocked{false};
|
||||
bool _baro_blocked{false};
|
||||
bool _mag_blocked{false};
|
||||
bool _gps_blocked{false};
|
||||
bool _airspeed_blocked{false};
|
||||
|
||||
#if defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||
px4::atomic<bool> _has_initialized {false};
|
||||
#endif
|
||||
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamBool<px4::params::SIM_GPS_BLOCK>) _param_sim_gps_block,
|
||||
(ParamBool<px4::params::SIM_ACCEL_BLOCK>) _param_sim_accel_block,
|
||||
(ParamBool<px4::params::SIM_GYRO_BLOCK>) _param_sim_gyro_block,
|
||||
(ParamBool<px4::params::SIM_BARO_BLOCK>) _param_sim_baro_block,
|
||||
(ParamBool<px4::params::SIM_MAG_BLOCK>) _param_sim_mag_block,
|
||||
(ParamBool<px4::params::SIM_DPRES_BLOCK>) _param_sim_dpres_block,
|
||||
(ParamInt<px4::params::MAV_TYPE>) _param_mav_type,
|
||||
(ParamInt<px4::params::MAV_SYS_ID>) _param_mav_sys_id,
|
||||
(ParamInt<px4::params::MAV_COMP_ID>) _param_mav_comp_id
|
||||
|
||||
Reference in New Issue
Block a user