mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-28 04:04:07 +08:00
Refactor set_publish() logic so that a default false value is not (re)set each loop in simulator_mapvlink.cpp and provide a default argument to set_publish() in simulator.h.
This commit is contained in:
parent
6e0fc150c0
commit
0bd5d6caff
@ -344,7 +344,7 @@ private:
|
||||
void send_controls();
|
||||
void send_heartbeat();
|
||||
void send_mavlink_message(const mavlink_message_t &aMsg);
|
||||
void set_publish(const bool publish);
|
||||
void set_publish(const bool publish = false);
|
||||
void update_sensors(mavlink_hil_sensor_t *imu);
|
||||
void update_gps(mavlink_hil_gps_t *gps_sim);
|
||||
|
||||
|
||||
@ -837,8 +837,10 @@ void Simulator::poll_for_MAVLink_messages()
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (mavlink_parse_char(MAVLINK_COMM_1, serial_buf[i], &msg, &serial_status)) {
|
||||
// have a message, handle it
|
||||
bool prev_publish = _publish;
|
||||
set_publish(true);
|
||||
handle_message(&msg);
|
||||
set_publish(prev_publish);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -846,8 +848,6 @@ void Simulator::poll_for_MAVLink_messages()
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
set_publish(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user