mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 22:23:33 +08:00
mixer: move MixerGroup out of Mixer hierarchy and delete mixer.h header
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
#include <uORB/topics/battery_status.h>
|
||||
#include <uORB/topics/esc_status.h>
|
||||
|
||||
#include <lib/mixer/mixer.h>
|
||||
#include <lib/mixer/MixerGroup.hpp>
|
||||
#include <lib/mixer/mixer_load.h>
|
||||
#include <battery/battery.h>
|
||||
|
||||
@@ -307,7 +307,7 @@ int initialize_mixers(const char *mixers_filename)
|
||||
}
|
||||
|
||||
if (_mixers == nullptr) {
|
||||
_mixers = new MixerGroup(mixers_control_callback, (uintptr_t)_controls);
|
||||
_mixers = new MixerGroup();
|
||||
}
|
||||
|
||||
if (_mixers == nullptr) {
|
||||
@@ -315,7 +315,7 @@ int initialize_mixers(const char *mixers_filename)
|
||||
return -1;
|
||||
|
||||
} else {
|
||||
int ret = _mixers->load_from_buf(buf, buflen);
|
||||
int ret = _mixers->load_from_buf(mixers_control_callback, (uintptr_t)_controls, buf, buflen);
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_ERR("Unable to parse mixers file");
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/drv_mixer.h>
|
||||
#include <lib/mixer/mixer.h>
|
||||
#include <lib/mixer/MixerGroup.hpp>
|
||||
#include <lib/mixer/mixer_load.h>
|
||||
#include <parameters/param.h>
|
||||
#include <output_limit/output_limit.h>
|
||||
@@ -155,12 +155,12 @@ int initialize_mixer(const char *mixer_filename)
|
||||
unsigned buflen = sizeof(buf);
|
||||
memset(buf, '\0', buflen);
|
||||
|
||||
_mixer_group = new MixerGroup(mixer_control_callback, (uintptr_t) &_controls);
|
||||
_mixer_group = new MixerGroup();
|
||||
|
||||
// PX4_INFO("Trying to initialize mixer from config file %s", mixer_filename);
|
||||
|
||||
if (load_mixer_file(mixer_filename, buf, buflen) == 0) {
|
||||
if (_mixer_group->load_from_buf(buf, buflen) == 0) {
|
||||
if (_mixer_group->load_from_buf(mixer_control_callback, (uintptr_t) &_controls, buf, buflen) == 0) {
|
||||
PX4_INFO("Loaded mixer from file %s", mixer_filename);
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
#include <drivers/drv_tone_alarm.h>
|
||||
|
||||
#include <systemlib/err.h>
|
||||
#include <lib/mixer/mixer.h>
|
||||
#include <lib/mixer/MixerGroup.hpp>
|
||||
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/actuator_outputs.h>
|
||||
@@ -1045,7 +1045,7 @@ MK::pwm_ioctl(file *filp, int cmd, unsigned long arg)
|
||||
unsigned buflen = strlen(buf);
|
||||
|
||||
if (_mixers == nullptr) {
|
||||
_mixers = new MixerGroup(control_callback, (uintptr_t)&_controls);
|
||||
_mixers = new MixerGroup();
|
||||
}
|
||||
|
||||
if (_mixers == nullptr) {
|
||||
@@ -1053,7 +1053,7 @@ MK::pwm_ioctl(file *filp, int cmd, unsigned long arg)
|
||||
|
||||
} else {
|
||||
|
||||
ret = _mixers->load_from_buf(buf, buflen);
|
||||
ret = _mixers->load_from_buf(control_callback, (uintptr_t)&_controls, buf, buflen);
|
||||
|
||||
if (ret != 0) {
|
||||
DEVICE_DEBUG("mixer load failed with %d", ret);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012-2018 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2012-2019 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -37,7 +37,6 @@
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/drv_mixer.h>
|
||||
#include <drivers/drv_pwm_output.h>
|
||||
#include <lib/mixer/mixer.h>
|
||||
#include <lib/mixer_module/mixer_module.hpp>
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
#include <px4_platform_common/module.h>
|
||||
|
||||
@@ -70,7 +70,8 @@
|
||||
#include <rc/dsm.h>
|
||||
|
||||
#include <lib/mathlib/mathlib.h>
|
||||
#include <lib/mixer/mixer.h>
|
||||
#include <lib/mixer/MixerGroup.hpp>
|
||||
#include <lib/mixer/MultirotorMixer.hpp>
|
||||
#include <perf/perf_counter.h>
|
||||
#include <systemlib/err.h>
|
||||
#include <parameters/param.h>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/drv_mixer.h>
|
||||
#include <lib/mixer/mixer.h>
|
||||
#include <lib/mixer/MixerGroup.hpp>
|
||||
#include <lib/mixer/mixer_multirotor_normalized.generated.h>
|
||||
#include <parameters/param.h>
|
||||
|
||||
|
||||
@@ -48,12 +48,13 @@
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/drv_mixer.h>
|
||||
#include <mixer/mixer.h>
|
||||
#include <mixer/mixer_load.h>
|
||||
#include <mixer/mixer_multirotor_normalized.generated.h>
|
||||
#include <parameters/param.h>
|
||||
#include <perf/perf_counter.h>
|
||||
#include <output_limit/output_limit.h>
|
||||
#include <lib/mixer/MultirotorMixer.hpp>
|
||||
#include <lib/mixer/MixerGroup.hpp>
|
||||
#include <lib/mixer/mixer_load.h>
|
||||
#include <lib/parameters/param.h>
|
||||
#include <lib/perf/perf_counter.h>
|
||||
#include <lib/output_limit/output_limit.h>
|
||||
|
||||
#include <dev_fs_lib_pwm.h>
|
||||
|
||||
/*
|
||||
@@ -174,55 +175,30 @@ void update_params(Mixer::Airmode &airmode)
|
||||
|
||||
int initialize_mixer(const char *mixer_filename)
|
||||
{
|
||||
|
||||
char buf[2048];
|
||||
size_t buflen = sizeof(buf);
|
||||
PX4_INFO("Trying to initialize mixer from config file %s", mixer_filename);
|
||||
int fd_load = ::open(mixer_filename, O_RDONLY);
|
||||
|
||||
if (fd_load != -1) {
|
||||
int nRead = ::read(fd_load, buf, buflen);
|
||||
close(fd_load);
|
||||
int nRead = ::read(fd_load, buf, buflen);
|
||||
close(fd_load);
|
||||
|
||||
if (nRead > 0) {
|
||||
_mixer = MultirotorMixer::from_text(mixer_control_callback, (uintptr_t)&_controls, buf, buflen);
|
||||
if (nRead > 0) {
|
||||
_mixer = MultirotorMixer::from_text(mixer_control_callback, (uintptr_t)&_controls, buf, buflen);
|
||||
|
||||
if (_mixer != nullptr) {
|
||||
PX4_INFO("Successfully initialized mixer from config file");
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
PX4_ERR("Unable to parse from mixer config file");
|
||||
return -1;
|
||||
}
|
||||
if (_mixer != nullptr) {
|
||||
PX4_INFO("Successfully initialized mixer from config file");
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
PX4_WARN("Unable to read from mixer config file");
|
||||
return -2;
|
||||
}
|
||||
|
||||
} else {
|
||||
PX4_WARN("No mixer config file found, using default mixer.");
|
||||
|
||||
/* Mixer file loading failed, fall back to default mixer configuration for
|
||||
* QUAD_X airframe. */
|
||||
float roll_scale = 1;
|
||||
float pitch_scale = 1;
|
||||
float yaw_scale = 1;
|
||||
float deadband = 0;
|
||||
|
||||
_mixer = new MultirotorMixer(mixer_control_callback, (uintptr_t)&_controls,
|
||||
MultirotorGeometry::QUAD_X,
|
||||
roll_scale, pitch_scale, yaw_scale, deadband);
|
||||
|
||||
if (_mixer == nullptr) {
|
||||
PX4_ERR("Unable to parse from mixer config file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
PX4_WARN("Unable to read from mixer config file");
|
||||
return -2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void subscribe()
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/drv_mixer.h>
|
||||
#include <mixer/mixer.h>
|
||||
#include <lib/mixer/MixerGroup.hpp>
|
||||
|
||||
#include "tap_esc_common.h"
|
||||
|
||||
@@ -677,7 +677,7 @@ int TAP_ESC::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
|
||||
unsigned buflen = strlen(buf);
|
||||
|
||||
if (_mixers == nullptr) {
|
||||
_mixers = new MixerGroup(control_callback_trampoline, (uintptr_t)this);
|
||||
_mixers = new MixerGroup();
|
||||
}
|
||||
|
||||
if (_mixers == nullptr) {
|
||||
@@ -685,8 +685,7 @@ int TAP_ESC::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
|
||||
ret = -ENOMEM;
|
||||
|
||||
} else {
|
||||
|
||||
ret = _mixers->load_from_buf(buf, buflen);
|
||||
ret = _mixers->load_from_buf(control_callback_trampoline, (uintptr_t)this, buf, buflen);
|
||||
|
||||
if (ret != 0) {
|
||||
PX4_DEBUG("mixer load failed with %d", ret);
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <systemlib/err.h>
|
||||
#include <parameters/param.h>
|
||||
#include <lib/mixer/mixer.h>
|
||||
#include <version/version.h>
|
||||
#include <arch/board/board.h>
|
||||
#include <arch/chip/chip.h>
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include <mathlib/mathlib.h>
|
||||
#include <systemlib/err.h>
|
||||
#include <parameters/param.h>
|
||||
#include <lib/mixer/mixer.h>
|
||||
#include <version/version.h>
|
||||
#include <arch/board/board.h>
|
||||
#include <arch/chip/chip.h>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <systemlib/err.h>
|
||||
#include <parameters/param.h>
|
||||
#include <lib/mixer/mixer.h>
|
||||
#include <lib/mixer/MixerGroup.hpp>
|
||||
#include <version/version.h>
|
||||
#include <arch/board/board.h>
|
||||
#include <arch/chip/chip.h>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <systemlib/err.h>
|
||||
#include <parameters/param.h>
|
||||
#include <lib/mixer/mixer.h>
|
||||
#include <lib/mixer/MixerGroup.hpp>
|
||||
#include <version/version.h>
|
||||
__BEGIN_DECLS
|
||||
#include <nuttx/board.h>
|
||||
|
||||
Reference in New Issue
Block a user