mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 03:49:12 +08:00
set actuator commands to zero if vehicle status is still unknown
This commit is contained in:
@@ -64,7 +64,7 @@ static socklen_t _addrlen = sizeof(_srcaddr);
|
|||||||
using namespace simulator;
|
using namespace simulator;
|
||||||
|
|
||||||
void Simulator::pack_actuator_message(mavlink_hil_controls_t &actuator_msg) {
|
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;
|
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.time_usec = hrt_absolute_time();
|
||||||
actuator_msg.roll_ailerons = out[0];
|
actuator_msg.roll_ailerons = out[0];
|
||||||
actuator_msg.pitch_elevator = _vehicle_status.is_rotary_wing ? out[1] : -out[1];
|
actuator_msg.pitch_elevator = _vehicle_status.is_rotary_wing ? out[1] : -out[1];
|
||||||
|
|||||||
Reference in New Issue
Block a user