mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 13:23:35 +08:00
EKF2: Fix polling code
This commit is contained in:
@@ -228,7 +228,6 @@ void Ekf2::task_main()
|
|||||||
{
|
{
|
||||||
// subscribe to relevant topics
|
// subscribe to relevant topics
|
||||||
_sensors_sub = orb_subscribe(ORB_ID(sensor_combined));
|
_sensors_sub = orb_subscribe(ORB_ID(sensor_combined));
|
||||||
_params_sub = orb_subscribe(ORB_ID(sensor_combined));
|
|
||||||
_gps_sub = orb_subscribe(ORB_ID(vehicle_gps_position));
|
_gps_sub = orb_subscribe(ORB_ID(vehicle_gps_position));
|
||||||
_airspeed_sub = orb_subscribe(ORB_ID(airspeed));
|
_airspeed_sub = orb_subscribe(ORB_ID(airspeed));
|
||||||
_params_sub = orb_subscribe(ORB_ID(parameter_update));
|
_params_sub = orb_subscribe(ORB_ID(parameter_update));
|
||||||
@@ -243,14 +242,14 @@ void Ekf2::task_main()
|
|||||||
updateParams();
|
updateParams();
|
||||||
|
|
||||||
while (!_task_should_exit) {
|
while (!_task_should_exit) {
|
||||||
int ret = px4_poll(fds, sizeof(fds) / sizeof(fds[0]), 8);
|
int ret = px4_poll(fds, sizeof(fds) / sizeof(fds[0]), 1000);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
// Poll error, sleep and try again
|
// Poll error, sleep and try again
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else if (ret == 0 || fds[0].revents != POLLIN) {
|
} else if (ret == 0) {
|
||||||
// Poll timeout or no new data, do nothing
|
// Poll timeout or no new data, do nothing
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -263,6 +262,9 @@ void Ekf2::task_main()
|
|||||||
|
|
||||||
// fetch sensor data in next loop
|
// fetch sensor data in next loop
|
||||||
continue;
|
continue;
|
||||||
|
} else if (!(fds[0].revents & POLLIN)) {
|
||||||
|
// no new data
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gps_updated = false;
|
bool gps_updated = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user