mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
set actuator commands to zero if vehicle status is still unknown
This commit is contained in:
parent
95af5fc3d0
commit
980217468f
@ -64,7 +64,7 @@ static socklen_t _addrlen = sizeof(_srcaddr);
|
||||
using namespace simulator;
|
||||
|
||||
void Simulator::pack_actuator_message(mavlink_hil_controls_t &actuator_msg) {
|
||||
float out[8];
|
||||
float out[8] = {};
|
||||
|
||||
const float pwm_center = (PWM_HIGHEST_MAX + PWM_LOWEST_MIN) / 2;
|
||||
|
||||
@ -95,6 +95,12 @@ void Simulator::pack_actuator_message(mavlink_hil_controls_t &actuator_msg) {
|
||||
}
|
||||
}
|
||||
|
||||
// if vehicle status has not yet been updated, set actuator commands to zero
|
||||
// this is to prevent the simulation getting into a bad state
|
||||
if (_vehicle_status.timestamp == 0) {
|
||||
memset(out, 0, sizeof(out));
|
||||
}
|
||||
|
||||
actuator_msg.time_usec = hrt_absolute_time();
|
||||
actuator_msg.roll_ailerons = out[0];
|
||||
actuator_msg.pitch_elevator = _vehicle_status.is_rotary_wing ? out[1] : -out[1];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user