mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 13:43:33 +08:00
Ported mc_att_control
This commit is contained in:
committed by
Mark Charlebois
parent
509f7f9fdb
commit
a2a113ee28
@@ -894,10 +894,8 @@ MulticopterAttitudeControl::task_main()
|
|||||||
perf_end(_loop_perf);
|
perf_end(_loop_perf);
|
||||||
}
|
}
|
||||||
|
|
||||||
warnx("exit");
|
|
||||||
|
|
||||||
_control_task = -1;
|
_control_task = -1;
|
||||||
_exit(0);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -924,43 +922,53 @@ MulticopterAttitudeControl::start()
|
|||||||
int mc_att_control_main(int argc, char *argv[])
|
int mc_att_control_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
errx(1, "usage: mc_att_control {start|stop|status}");
|
warnx("usage: mc_att_control {start|stop|status}");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(argv[1], "start")) {
|
if (!strcmp(argv[1], "start")) {
|
||||||
|
|
||||||
if (mc_att_control::g_control != nullptr)
|
if (mc_att_control::g_control != nullptr) {
|
||||||
errx(1, "already running");
|
warnx("already running");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
mc_att_control::g_control = new MulticopterAttitudeControl;
|
mc_att_control::g_control = new MulticopterAttitudeControl;
|
||||||
|
|
||||||
if (mc_att_control::g_control == nullptr)
|
if (mc_att_control::g_control == nullptr) {
|
||||||
errx(1, "alloc failed");
|
warnx("alloc failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (OK != mc_att_control::g_control->start()) {
|
if (OK != mc_att_control::g_control->start()) {
|
||||||
delete mc_att_control::g_control;
|
delete mc_att_control::g_control;
|
||||||
mc_att_control::g_control = nullptr;
|
mc_att_control::g_control = nullptr;
|
||||||
err(1, "start failed");
|
warnx("start failed");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(argv[1], "stop")) {
|
if (!strcmp(argv[1], "stop")) {
|
||||||
if (mc_att_control::g_control == nullptr)
|
if (mc_att_control::g_control == nullptr) {
|
||||||
errx(1, "not running");
|
warnx("not running");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
delete mc_att_control::g_control;
|
delete mc_att_control::g_control;
|
||||||
mc_att_control::g_control = nullptr;
|
mc_att_control::g_control = nullptr;
|
||||||
exit(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(argv[1], "status")) {
|
if (!strcmp(argv[1], "status")) {
|
||||||
if (mc_att_control::g_control) {
|
if (mc_att_control::g_control) {
|
||||||
errx(0, "running");
|
warnx("running");
|
||||||
|
return 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
errx(1, "not running");
|
warnx("not running");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user