mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 04:21:36 +08:00
motor_ramp: add documentation
This commit is contained in:
@@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @file motor_ramp.cpp
|
* @file motor_ramp.cpp
|
||||||
* Application to test motor ramp up.
|
|
||||||
*
|
*
|
||||||
* @author Andreas Antener <andreas@uaventure.com>
|
* @author Andreas Antener <andreas@uaventure.com>
|
||||||
* @author Roman Bapst <bapstroman@gmail.com>
|
* @author Roman Bapst <bapstroman@gmail.com>
|
||||||
@@ -41,6 +40,7 @@
|
|||||||
|
|
||||||
#include <px4_config.h>
|
#include <px4_config.h>
|
||||||
#include <px4_defines.h>
|
#include <px4_defines.h>
|
||||||
|
#include <px4_module.h>
|
||||||
#include <px4_tasks.h>
|
#include <px4_tasks.h>
|
||||||
#include <px4_posix.h>
|
#include <px4_posix.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -113,14 +113,30 @@ usage(const char *reason)
|
|||||||
PX4_ERR("%s", reason);
|
PX4_ERR("%s", reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
PX4_WARN("\n\nWARNING: motors will ramp up to full speed!\n\n"
|
PRINT_MODULE_DESCRIPTION(
|
||||||
"Usage: motor_ramp <mode> <min_pwm> <time> [<max_pwm>]\n"
|
R"DESCR_STR(
|
||||||
"<mode> can be one of (ramp|sine|square)\n\n"
|
### Description
|
||||||
"Example:\n"
|
Application to test motor ramp up.
|
||||||
"sdlog2 on\n"
|
|
||||||
"mc_att_control stop\n"
|
Before starting, make sure to stop any running attitude controller:
|
||||||
"fw_att_control stop\n"
|
$ mc_att_control stop
|
||||||
"motor_ramp sine 1100 0.5\n");
|
$ fw_att_control stop
|
||||||
|
|
||||||
|
When starting, a background task is started, runs for several seconds (as specified), then exits.
|
||||||
|
|
||||||
|
Note: this command currently only supports the `/dev/pwm_output0` output.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
$ motor_ramp sine 1100 0.5
|
||||||
|
)DESCR_STR");
|
||||||
|
|
||||||
|
|
||||||
|
PRINT_MODULE_USAGE_NAME_SIMPLE("motor_ramp", "command");
|
||||||
|
PRINT_MODULE_USAGE_ARG("ramp|sine|square", "mode", false);
|
||||||
|
PRINT_MODULE_USAGE_ARG("<min_pwm> <time> [<max_pwm>]", "pwm value in us, time in sec", false);
|
||||||
|
|
||||||
|
PRINT_MODULE_USAGE_PARAM_COMMENT("WARNING: motors will ramp up to full speed!");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -341,7 +357,7 @@ int motor_ramp_thread_main(int argc, char *argv[])
|
|||||||
|
|
||||||
switch (ramp_state) {
|
switch (ramp_state) {
|
||||||
case RAMP_INIT: {
|
case RAMP_INIT: {
|
||||||
PX4_WARN("setting pwm min: %d", _min_pwm);
|
PX4_INFO("setting pwm min: %d", _min_pwm);
|
||||||
set_min_pwm(fd, max_channels, _min_pwm);
|
set_min_pwm(fd, max_channels, _min_pwm);
|
||||||
ramp_state = RAMP_MIN;
|
ramp_state = RAMP_MIN;
|
||||||
break;
|
break;
|
||||||
@@ -349,7 +365,7 @@ int motor_ramp_thread_main(int argc, char *argv[])
|
|||||||
|
|
||||||
case RAMP_MIN: {
|
case RAMP_MIN: {
|
||||||
if (timer > 3.0f) {
|
if (timer > 3.0f) {
|
||||||
PX4_WARN("starting %s: %.2f sec", _mode_c, (double)_ramp_time);
|
PX4_INFO("starting %s: %.2f sec", _mode_c, (double)_ramp_time);
|
||||||
start = hrt_absolute_time();
|
start = hrt_absolute_time();
|
||||||
ramp_state = RAMP_RAMP;
|
ramp_state = RAMP_RAMP;
|
||||||
}
|
}
|
||||||
@@ -376,7 +392,7 @@ int motor_ramp_thread_main(int argc, char *argv[])
|
|||||||
output = _mode != RAMP ? output : 1.0f;
|
output = _mode != RAMP ? output : 1.0f;
|
||||||
start = hrt_absolute_time();
|
start = hrt_absolute_time();
|
||||||
ramp_state = RAMP_WAIT;
|
ramp_state = RAMP_WAIT;
|
||||||
PX4_WARN("%s finished, waiting", _mode_c);
|
PX4_INFO("%s finished, waiting", _mode_c);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_out(fd, max_channels, output);
|
set_out(fd, max_channels, output);
|
||||||
@@ -386,7 +402,7 @@ int motor_ramp_thread_main(int argc, char *argv[])
|
|||||||
case RAMP_WAIT: {
|
case RAMP_WAIT: {
|
||||||
if (timer > 0.5f) {
|
if (timer > 0.5f) {
|
||||||
_thread_should_exit = true;
|
_thread_should_exit = true;
|
||||||
PX4_WARN("stopping");
|
PX4_INFO("stopping");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user