mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-04 05:05:19 +08:00
Merge pull request #1427 from hsteinhaus/drive_testing
motor_test: cleanup
This commit is contained in:
@@ -57,7 +57,7 @@
|
|||||||
struct test_motor_s {
|
struct test_motor_s {
|
||||||
uint64_t timestamp; /**< output timestamp in us since system boot */
|
uint64_t timestamp; /**< output timestamp in us since system boot */
|
||||||
unsigned motor_number; /**< number of motor to spin */
|
unsigned motor_number; /**< number of motor to spin */
|
||||||
float value; /**< output data, in natural output units */
|
float value; /**< output power, range [0..1]
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -54,7 +54,8 @@
|
|||||||
#include "systemlib/err.h"
|
#include "systemlib/err.h"
|
||||||
|
|
||||||
|
|
||||||
__EXPORT int motor_test_main(int argc, char *argv[]);
|
__EXPORT int motor_test_main(int argc, char *argv[]);
|
||||||
|
|
||||||
static void motor_test(unsigned channel, float value);
|
static void motor_test(unsigned channel, float value);
|
||||||
static void usage(const char *reason);
|
static void usage(const char *reason);
|
||||||
|
|
||||||
@@ -67,13 +68,13 @@ void motor_test(unsigned channel, float value)
|
|||||||
_test_motor.timestamp = hrt_absolute_time();
|
_test_motor.timestamp = hrt_absolute_time();
|
||||||
_test_motor.value = value;
|
_test_motor.value = value;
|
||||||
|
|
||||||
if (_test_motor_pub > 0) {
|
if (_test_motor_pub > 0) {
|
||||||
/* publish armed state */
|
/* publish test state */
|
||||||
orb_publish(ORB_ID(test_motor), _test_motor_pub, &_test_motor);
|
orb_publish(ORB_ID(test_motor), _test_motor_pub, &_test_motor);
|
||||||
} else {
|
} else {
|
||||||
/* advertise and publish */
|
/* advertise and publish */
|
||||||
_test_motor_pub = orb_advertise(ORB_ID(test_motor), &_test_motor);
|
_test_motor_pub = orb_advertise(ORB_ID(test_motor), &_test_motor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage(const char *reason)
|
static void usage(const char *reason)
|
||||||
@@ -102,18 +103,18 @@ int motor_test_main(int argc, char *argv[])
|
|||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
/* Read in channels supplied as one int and convert to mask: 1234 -> 0xF */
|
/* Read in motor number */
|
||||||
channel = strtoul(optarg, NULL, 0);
|
channel = strtoul(optarg, NULL, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
/* Read in custom low value */
|
/* Read in power value */
|
||||||
lval = strtoul(optarg, NULL, 0);
|
lval = strtoul(optarg, NULL, 0);
|
||||||
|
|
||||||
if (lval > 100)
|
if (lval > 100)
|
||||||
usage("value invalid");
|
usage("value invalid");
|
||||||
|
|
||||||
value = (float)lval/100.f;
|
value = ((float)lval)/100.f;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage(NULL);
|
usage(NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user