mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 02:16:53 +08:00
add start wrapper for mc att ctl multip
This commit is contained in:
@@ -55,72 +55,8 @@
|
|||||||
#include "mc_att_control.h"
|
#include "mc_att_control.h"
|
||||||
|
|
||||||
bool thread_running = false; /**< Deamon status flag */
|
bool thread_running = false; /**< Deamon status flag */
|
||||||
static int daemon_task; /**< Handle of deamon task / thread */
|
|
||||||
namespace px4
|
|
||||||
{
|
|
||||||
bool task_should_exit = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
using namespace px4;
|
int main(int argc, char **argv)
|
||||||
|
|
||||||
PX4_MAIN_FUNCTION(mc_att_control_m);
|
|
||||||
|
|
||||||
#if !defined(__PX4_ROS)
|
|
||||||
/**
|
|
||||||
* Multicopter attitude control app start / stop handling function
|
|
||||||
*
|
|
||||||
* @ingroup apps
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern "C" __EXPORT int mc_att_control_m_main(int argc, char *argv[]);
|
|
||||||
int mc_att_control_m_main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
if (argc < 1) {
|
|
||||||
errx(1, "usage: mc_att_control_m {start|stop|status}");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(argv[1], "start")) {
|
|
||||||
|
|
||||||
if (thread_running) {
|
|
||||||
warnx("already running");
|
|
||||||
/* this is not an error */
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
task_should_exit = false;
|
|
||||||
|
|
||||||
daemon_task = task_spawn_cmd("mc_att_control_m",
|
|
||||||
SCHED_DEFAULT,
|
|
||||||
SCHED_PRIORITY_MAX - 5,
|
|
||||||
3000,
|
|
||||||
mc_att_control_m_task_main,
|
|
||||||
(argv) ? (char * const *)&argv[2] : (char * const *)NULL);
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(argv[1], "stop")) {
|
|
||||||
task_should_exit = true;
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(argv[1], "status")) {
|
|
||||||
if (thread_running) {
|
|
||||||
warnx("is running");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
warnx("not started");
|
|
||||||
}
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
warnx("unrecognized command");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PX4_MAIN_FUNCTION(mc_att_control_m)
|
|
||||||
{
|
{
|
||||||
px4::init(argc, argv, "mc_att_control_m");
|
px4::init(argc, argv, "mc_att_control_m");
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
MODULE_COMMAND = mc_att_control_m
|
MODULE_COMMAND = mc_att_control_m
|
||||||
|
|
||||||
SRCS = mc_att_control_main.cpp \
|
SRCS = mc_att_control_main.cpp \
|
||||||
|
mc_att_control_start_nuttx.cpp \
|
||||||
mc_att_control.cpp \
|
mc_att_control.cpp \
|
||||||
mc_att_control_base.cpp \
|
mc_att_control_base.cpp \
|
||||||
mc_att_control_params.c
|
mc_att_control_params.c
|
||||||
|
|||||||
Reference in New Issue
Block a user