mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 03:03:34 +08:00
Merged
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
Passthrough mixer for PX4IO
|
||||||
|
============================
|
||||||
|
|
||||||
|
This file defines passthrough mixers suitable for testing.
|
||||||
|
|
||||||
|
Channel group 0, channels 0-7 are passed directly through to the outputs.
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 0 10000 10000 0 -10000 10000
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 1 10000 10000 0 -10000 10000
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 2 10000 10000 0 -10000 10000
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 3 10000 10000 0 -10000 10000
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 4 10000 10000 0 -10000 10000
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 5 10000 10000 0 -10000 10000
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 6 10000 10000 0 -10000 10000
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 7 10000 10000 0 -10000 10000
|
||||||
@@ -176,6 +176,12 @@ GLOBAL_DEPS += $(MAKEFILE_LIST)
|
|||||||
#
|
#
|
||||||
EXTRA_CLEANS =
|
EXTRA_CLEANS =
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# NuttX libraries and paths
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
include $(PX4_MK_DIR)/nuttx.mk
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Modules
|
# Modules
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -296,12 +302,6 @@ $(LIBRARY_CLEANS):
|
|||||||
LIBRARY_MK=$(mkfile) \
|
LIBRARY_MK=$(mkfile) \
|
||||||
clean
|
clean
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# NuttX libraries and paths
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
include $(PX4_MK_DIR)/nuttx.mk
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# ROMFS generation
|
# ROMFS generation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
+5
-1
@@ -69,10 +69,14 @@ INCLUDE_DIRS += $(NUTTX_EXPORT_DIR)include \
|
|||||||
|
|
||||||
LIB_DIRS += $(NUTTX_EXPORT_DIR)libs
|
LIB_DIRS += $(NUTTX_EXPORT_DIR)libs
|
||||||
LIBS += -lapps -lnuttx
|
LIBS += -lapps -lnuttx
|
||||||
LINK_DEPS += $(NUTTX_EXPORT_DIR)libs/libapps.a \
|
NUTTX_LIBS = $(NUTTX_EXPORT_DIR)libs/libapps.a \
|
||||||
$(NUTTX_EXPORT_DIR)libs/libnuttx.a
|
$(NUTTX_EXPORT_DIR)libs/libnuttx.a
|
||||||
|
LINK_DEPS += $(NUTTX_LIBS)
|
||||||
|
|
||||||
$(NUTTX_CONFIG_HEADER): $(NUTTX_ARCHIVE)
|
$(NUTTX_CONFIG_HEADER): $(NUTTX_ARCHIVE)
|
||||||
@$(ECHO) %% Unpacking $(NUTTX_ARCHIVE)
|
@$(ECHO) %% Unpacking $(NUTTX_ARCHIVE)
|
||||||
$(Q) $(UNZIP_CMD) -q -o -d $(WORK_DIR) $(NUTTX_ARCHIVE)
|
$(Q) $(UNZIP_CMD) -q -o -d $(WORK_DIR) $(NUTTX_ARCHIVE)
|
||||||
$(Q) $(TOUCH) $@
|
$(Q) $(TOUCH) $@
|
||||||
|
|
||||||
|
$(LDSCRIPT): $(NUTTX_CONFIG_HEADER)
|
||||||
|
$(NUTTX_LIBS): $(NUTTX_CONFIG_HEADER)
|
||||||
|
|||||||
@@ -1302,7 +1302,7 @@ PX4IO::print_status()
|
|||||||
io_reg_get(PX4IO_PAGE_STATUS, PX4IO_P_STATUS_VBATT),
|
io_reg_get(PX4IO_PAGE_STATUS, PX4IO_P_STATUS_VBATT),
|
||||||
io_reg_get(PX4IO_PAGE_STATUS, PX4IO_P_STATUS_IBATT),
|
io_reg_get(PX4IO_PAGE_STATUS, PX4IO_P_STATUS_IBATT),
|
||||||
io_reg_get(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_VBATT_SCALE));
|
io_reg_get(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_VBATT_SCALE));
|
||||||
printf("amp_per_volt %.3f amp_offset %.3f mAhDischarged %.3f\n",
|
printf("amp_per_volt %.3f amp_offset %.3f mAh discharged %.3f\n",
|
||||||
(double)_battery_amp_per_volt,
|
(double)_battery_amp_per_volt,
|
||||||
(double)_battery_amp_bias,
|
(double)_battery_amp_bias,
|
||||||
(double)_battery_mamphour_total);
|
(double)_battery_mamphour_total);
|
||||||
@@ -1496,7 +1496,7 @@ PX4IO::ioctl(file *filep, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
case MIXERIOCLOADBUF: {
|
case MIXERIOCLOADBUF: {
|
||||||
const char *buf = (const char *)arg;
|
const char *buf = (const char *)arg;
|
||||||
ret = mixer_send(buf, strnlen(buf, 1024));
|
ret = mixer_send(buf, strnlen(buf, 2048));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1637,6 +1637,13 @@ test(void)
|
|||||||
if (ioctl(fd, PWM_SERVO_ARM, 0))
|
if (ioctl(fd, PWM_SERVO_ARM, 0))
|
||||||
err(1, "failed to arm servos");
|
err(1, "failed to arm servos");
|
||||||
|
|
||||||
|
/* Open console directly to grab CTRL-C signal */
|
||||||
|
int console = open("/dev/console", O_NONBLOCK | O_RDONLY | O_NOCTTY);
|
||||||
|
if (!console)
|
||||||
|
err(1, "failed opening console");
|
||||||
|
|
||||||
|
warnx("Press CTRL-C or 'c' to abort.");
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
/* sweep all servos between 1000..2000 */
|
/* sweep all servos between 1000..2000 */
|
||||||
@@ -1671,6 +1678,16 @@ test(void)
|
|||||||
if (value != servos[i])
|
if (value != servos[i])
|
||||||
errx(1, "servo %d readback error, got %u expected %u", i, value, servos[i]);
|
errx(1, "servo %d readback error, got %u expected %u", i, value, servos[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if user wants to quit */
|
||||||
|
char c;
|
||||||
|
if (read(console, &c, 1) == 1) {
|
||||||
|
if (c == 0x03 || c == 0x63) {
|
||||||
|
warnx("User abort\n");
|
||||||
|
close(console);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <systemlib/systemlib.h>
|
#include <systemlib/systemlib.h>
|
||||||
#include <systemlib/param/param.h>
|
#include <systemlib/param/param.h>
|
||||||
|
#include <systemlib/err.h>
|
||||||
#include <drivers/drv_hrt.h>
|
#include <drivers/drv_hrt.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "KalmanNav.hpp"
|
#include "KalmanNav.hpp"
|
||||||
@@ -73,7 +74,7 @@ usage(const char *reason)
|
|||||||
if (reason)
|
if (reason)
|
||||||
fprintf(stderr, "%s\n", reason);
|
fprintf(stderr, "%s\n", reason);
|
||||||
|
|
||||||
fprintf(stderr, "usage: kalman_demo {start|stop|status} [-p <additional params>]\n\n");
|
warnx("usage: att_pos_estimator_ekf {start|stop|status} [-p <additional params>]");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,13 +95,14 @@ int att_pos_estimator_ekf_main(int argc, char *argv[])
|
|||||||
if (!strcmp(argv[1], "start")) {
|
if (!strcmp(argv[1], "start")) {
|
||||||
|
|
||||||
if (thread_running) {
|
if (thread_running) {
|
||||||
printf("kalman_demo already running\n");
|
warnx("already running");
|
||||||
/* this is not an error */
|
/* this is not an error */
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_should_exit = false;
|
thread_should_exit = false;
|
||||||
deamon_task = task_spawn_cmd("kalman_demo",
|
|
||||||
|
deamon_task = task_spawn_cmd("att_pos_estimator_ekf",
|
||||||
SCHED_DEFAULT,
|
SCHED_DEFAULT,
|
||||||
SCHED_PRIORITY_MAX - 5,
|
SCHED_PRIORITY_MAX - 5,
|
||||||
4096,
|
4096,
|
||||||
@@ -116,10 +118,10 @@ int att_pos_estimator_ekf_main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!strcmp(argv[1], "status")) {
|
if (!strcmp(argv[1], "status")) {
|
||||||
if (thread_running) {
|
if (thread_running) {
|
||||||
printf("\tkalman_demo app is running\n");
|
warnx("is running\n");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("\tkalman_demo app not started\n");
|
warnx("not started\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
@@ -132,7 +134,7 @@ int att_pos_estimator_ekf_main(int argc, char *argv[])
|
|||||||
int kalman_demo_thread_main(int argc, char *argv[])
|
int kalman_demo_thread_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
printf("[kalman_demo] starting\n");
|
warnx("starting\n");
|
||||||
|
|
||||||
using namespace math;
|
using namespace math;
|
||||||
|
|
||||||
@@ -144,7 +146,7 @@ int kalman_demo_thread_main(int argc, char *argv[])
|
|||||||
nav.update();
|
nav.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[kalman_demo] exiting.\n");
|
printf("exiting.\n");
|
||||||
|
|
||||||
thread_running = false;
|
thread_running = false;
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include <systemlib/systemlib.h>
|
#include <systemlib/systemlib.h>
|
||||||
#include <controllib/fixedwing.hpp>
|
#include <controllib/fixedwing.hpp>
|
||||||
#include <systemlib/param/param.h>
|
#include <systemlib/param/param.h>
|
||||||
|
#include <systemlib/err.h>
|
||||||
#include <drivers/drv_hrt.h>
|
#include <drivers/drv_hrt.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ usage(const char *reason)
|
|||||||
if (reason)
|
if (reason)
|
||||||
fprintf(stderr, "%s\n", reason);
|
fprintf(stderr, "%s\n", reason);
|
||||||
|
|
||||||
fprintf(stderr, "usage: control_demo {start|stop|status} [-p <additional params>]\n\n");
|
fprintf(stderr, "usage: fixedwing_backside {start|stop|status} [-p <additional params>]\n\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,13 +102,14 @@ int fixedwing_backside_main(int argc, char *argv[])
|
|||||||
if (!strcmp(argv[1], "start")) {
|
if (!strcmp(argv[1], "start")) {
|
||||||
|
|
||||||
if (thread_running) {
|
if (thread_running) {
|
||||||
printf("control_demo already running\n");
|
warnx("already running");
|
||||||
/* this is not an error */
|
/* this is not an error */
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_should_exit = false;
|
thread_should_exit = false;
|
||||||
deamon_task = task_spawn_cmd("control_demo",
|
|
||||||
|
deamon_task = task_spawn_cmd("fixedwing_backside",
|
||||||
SCHED_DEFAULT,
|
SCHED_DEFAULT,
|
||||||
SCHED_PRIORITY_MAX - 10,
|
SCHED_PRIORITY_MAX - 10,
|
||||||
5120,
|
5120,
|
||||||
@@ -128,10 +130,10 @@ int fixedwing_backside_main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!strcmp(argv[1], "status")) {
|
if (!strcmp(argv[1], "status")) {
|
||||||
if (thread_running) {
|
if (thread_running) {
|
||||||
printf("\tcontrol_demo app is running\n");
|
warnx("is running");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("\tcontrol_demo app not started\n");
|
warnx("not started");
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
@@ -144,7 +146,7 @@ int fixedwing_backside_main(int argc, char *argv[])
|
|||||||
int control_demo_thread_main(int argc, char *argv[])
|
int control_demo_thread_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
printf("[control_Demo] starting\n");
|
warnx("starting");
|
||||||
|
|
||||||
using namespace control;
|
using namespace control;
|
||||||
|
|
||||||
@@ -156,7 +158,7 @@ int control_demo_thread_main(int argc, char *argv[])
|
|||||||
autopilot.update();
|
autopilot.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[control_demo] exiting.\n");
|
warnx("exiting.");
|
||||||
|
|
||||||
thread_running = false;
|
thread_running = false;
|
||||||
|
|
||||||
@@ -165,6 +167,6 @@ int control_demo_thread_main(int argc, char *argv[])
|
|||||||
|
|
||||||
void test()
|
void test()
|
||||||
{
|
{
|
||||||
printf("beginning control lib test\n");
|
warnx("beginning control lib test");
|
||||||
control::basicBlocksTest();
|
control::basicBlocksTest();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,8 +294,7 @@ mixer_handle_text(const void *buffer, size_t length)
|
|||||||
case F2I_MIXER_ACTION_APPEND:
|
case F2I_MIXER_ACTION_APPEND:
|
||||||
isr_debug(2, "append %d", length);
|
isr_debug(2, "append %d", length);
|
||||||
|
|
||||||
/* check for overflow - this is really fatal */
|
/* check for overflow - this would be really fatal */
|
||||||
/* XXX could add just what will fit & try to parse, then repeat... */
|
|
||||||
if ((mixer_text_length + text_length + 1) > sizeof(mixer_text)) {
|
if ((mixer_text_length + text_length + 1) > sizeof(mixer_text)) {
|
||||||
r_status_flags &= ~PX4IO_P_STATUS_FLAGS_MIXER_OK;
|
r_status_flags &= ~PX4IO_P_STATUS_FLAGS_MIXER_OK;
|
||||||
return;
|
return;
|
||||||
@@ -314,8 +313,13 @@ mixer_handle_text(const void *buffer, size_t length)
|
|||||||
/* if anything was parsed */
|
/* if anything was parsed */
|
||||||
if (resid != mixer_text_length) {
|
if (resid != mixer_text_length) {
|
||||||
|
|
||||||
/* ideally, this should test resid == 0 ? */
|
/* only set mixer ok if no residual is left over */
|
||||||
r_status_flags |= PX4IO_P_STATUS_FLAGS_MIXER_OK;
|
if (resid == 0) {
|
||||||
|
r_status_flags |= PX4IO_P_STATUS_FLAGS_MIXER_OK;
|
||||||
|
} else {
|
||||||
|
/* not yet reached the end of the mixer, set as not ok */
|
||||||
|
r_status_flags &= ~PX4IO_P_STATUS_FLAGS_MIXER_OK;
|
||||||
|
}
|
||||||
|
|
||||||
isr_debug(2, "used %u", mixer_text_length - resid);
|
isr_debug(2, "used %u", mixer_text_length - resid);
|
||||||
|
|
||||||
@@ -338,11 +342,13 @@ mixer_set_failsafe()
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Check if a custom failsafe value has been written,
|
* Check if a custom failsafe value has been written,
|
||||||
* else use the opportunity to set decent defaults.
|
* or if the mixer is not ok and bail out.
|
||||||
*/
|
*/
|
||||||
if (r_setup_arming & PX4IO_P_SETUP_ARMING_FAILSAFE_CUSTOM)
|
if ((r_setup_arming & PX4IO_P_SETUP_ARMING_FAILSAFE_CUSTOM) ||
|
||||||
|
!(r_status_flags & PX4IO_P_STATUS_FLAGS_MIXER_OK))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* set failsafe defaults to the values for all inputs = 0 */
|
||||||
float outputs[IO_SERVO_COUNT];
|
float outputs[IO_SERVO_COUNT];
|
||||||
unsigned mixed;
|
unsigned mixed;
|
||||||
|
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ load(const char *devname, const char *fname)
|
|||||||
{
|
{
|
||||||
int dev;
|
int dev;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char line[80];
|
char line[120];
|
||||||
char buf[512];
|
char buf[2048];
|
||||||
|
|
||||||
/* open the device */
|
/* open the device */
|
||||||
if ((dev = open(devname, 0)) < 0)
|
if ((dev = open(devname, 0)) < 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user