mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 08:47:35 +08:00
commander: add sensors reset to factory calibration
This commit is contained in:
@@ -1327,6 +1327,10 @@ Commander::handle_command(const vehicle_command_s &cmd)
|
||||
} else if (((int)(cmd.param1)) == 2) {
|
||||
answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED);
|
||||
_worker_thread.startTask(WorkerThread::Request::ParamResetAll);
|
||||
|
||||
} else if (((int)(cmd.param1)) == 3) {
|
||||
answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED);
|
||||
_worker_thread.startTask(WorkerThread::Request::ParamResetSensorFactory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,8 +42,12 @@
|
||||
#include "rc_calibration.h"
|
||||
|
||||
#include <px4_platform_common/log.h>
|
||||
#include <px4_platform_common/shutdown.h>
|
||||
#include <parameters/param.h>
|
||||
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
WorkerThread::~WorkerThread()
|
||||
{
|
||||
if (_state.load() == (int)State::Running) {
|
||||
@@ -161,6 +165,15 @@ void WorkerThread::threadEntry()
|
||||
param_reset_all();
|
||||
_ret_value = 0;
|
||||
break;
|
||||
|
||||
case Request::ParamResetSensorFactory:
|
||||
const char *reset_cal[] = { "CAL_ACC*", "CAL_GYRO*", "CAL_MAG*" };
|
||||
param_reset_specific(reset_cal, sizeof(reset_cal) / sizeof(reset_cal[0]));
|
||||
_ret_value = param_save_default();
|
||||
#if defined(CONFIG_BOARDCTL_RESET)
|
||||
px4_reboot_request(false, 400_ms);
|
||||
#endif // CONFIG_BOARDCTL_RESET
|
||||
break;
|
||||
}
|
||||
|
||||
_state.store((int)State::Finished); // set this last to signal the main thread we're done
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
ParamLoadDefault,
|
||||
ParamSaveDefault,
|
||||
ParamResetAll,
|
||||
ParamResetSensorFactory,
|
||||
};
|
||||
|
||||
WorkerThread() = default;
|
||||
|
||||
Reference in New Issue
Block a user