PX4 / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
8.6k stars 13.56k forks source link

[Bug] `mc_pos_control` module `_parameter_update_sub.updated()` always return `false` #23788

Open hanhui03 opened 1 month ago

hanhui03 commented 1 month ago

Describe the bug

mc_pos_control module _parameter_update_sub.updated() always return false, so this module cannot sense the parameter changes. Restart this module will back to normal.

mc_pos_control stop
mc_pos_control start

To Reproduce

No response

Expected behavior

No response

Screenshot / Media

No response

Flight Log

No response

Software Version

No response

Flight controller

All

Vehicle type

Multicopter

How are the different components wired up (including port information)

In HIL mode

Additional context

No response

hanhui03 commented 1 month ago

Try adding px4_usleep(500_ms); at the beginning of the MulticopterPositionControl::MulticopterPositionControl() constructor. _parameter_update_sub.updated() can return true normally when the parameters change.

MulticopterPositionControl::MulticopterPositionControl(bool vtol) :
    ModuleParams(nullptr),
    ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::nav_and_controllers),
    _vehicle_attitude_setpoint_pub(vtol ? ORB_ID(mc_virtual_attitude_setpoint) : ORB_ID(vehicle_attitude_setpoint))
{
    px4_usleep(500_ms); // relax...

    _sample_interval_s.update(0.01f); // 100 Hz default
    parameters_update(true);
    _tilt_limit_slew_rate.setSlewRate(.2f);
    _takeoff_status_pub.advertise();
}

Suspect uORB subscription has multi-threaded safety problem.