forked from Archive/PX4-Autopilot
Append AUX mixer for HITL simulation (#5457)
This commit is contained in:
parent
cbbf5e2e7c
commit
79d8d580b1
|
@ -138,7 +138,18 @@ then
|
|||
then
|
||||
if fmu mode_$AUX_MODE
|
||||
then
|
||||
if [ -e $OUTPUT_AUX_DEV ]
|
||||
# Append aux mixer to main device
|
||||
if [ $OUTPUT_MODE == hil ]
|
||||
then
|
||||
if mixer append $OUTPUT_DEV $MIXER_AUX_FILE
|
||||
then
|
||||
echo "INFO [init] Mixer: $MIXER_AUX_FILE appended to $OUTPUT_DEV"
|
||||
else
|
||||
echo "ERROR [init] Error appending mixer: $MIXER_AUX_FILE"
|
||||
echo "ERROR [init] Could not append mixer: $MIXER_AUX_FILE" >> $LOG_FILE
|
||||
fi
|
||||
fi
|
||||
if [ -e $OUTPUT_AUX_DEV -a $OUTPUT_MODE != hil ]
|
||||
then
|
||||
if mixer load $OUTPUT_AUX_DEV $MIXER_AUX_FILE
|
||||
then
|
||||
|
|
|
@ -438,7 +438,7 @@ then
|
|||
|
||||
if [ $OUTPUT_MODE == hil ]
|
||||
then
|
||||
if pwm_out_sim mode_port2_pwm8
|
||||
if pwm_out_sim mode_pwm16
|
||||
then
|
||||
else
|
||||
tone_alarm $TUNE_ERR
|
||||
|
|
|
@ -2295,7 +2295,8 @@ protected:
|
|||
system_type == MAV_TYPE_HEXAROTOR ||
|
||||
system_type == MAV_TYPE_OCTOROTOR ||
|
||||
system_type == MAV_TYPE_VTOL_DUOROTOR ||
|
||||
system_type == MAV_TYPE_VTOL_QUADROTOR) {
|
||||
system_type == MAV_TYPE_VTOL_QUADROTOR ||
|
||||
system_type == MAV_TYPE_VTOL_RESERVED2) {
|
||||
|
||||
/* multirotors: set number of rotor outputs depending on type */
|
||||
|
||||
|
@ -2318,6 +2319,10 @@ protected:
|
|||
n = 4;
|
||||
break;
|
||||
|
||||
case MAV_TYPE_VTOL_RESERVED2:
|
||||
n = 8;
|
||||
break;
|
||||
|
||||
default:
|
||||
n = 8;
|
||||
break;
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
extern "C" __EXPORT int mixer_main(int argc, char *argv[]);
|
||||
|
||||
static void usage(const char *reason);
|
||||
static int load(const char *devname, const char *fname);
|
||||
static int load(const char *devname, const char *fname, bool append);
|
||||
|
||||
int
|
||||
mixer_main(int argc, char *argv[])
|
||||
|
@ -75,13 +75,26 @@ mixer_main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
int ret = load(argv[2], argv[3]);
|
||||
int ret = load(argv[2], argv[3], false);
|
||||
|
||||
if (ret != 0) {
|
||||
warnx("failed to load mixer");
|
||||
return 1;
|
||||
}
|
||||
|
||||
} else if (!strcmp(argv[1], "append")) {
|
||||
if (argc < 4) {
|
||||
usage("missing device or filename");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ret = load(argv[2], argv[3], true);
|
||||
|
||||
if (ret != 0) {
|
||||
warnx("failed to append mixer");
|
||||
return 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
usage("Unknown command");
|
||||
return 1;
|
||||
|
@ -102,7 +115,7 @@ usage(const char *reason)
|
|||
}
|
||||
|
||||
static int
|
||||
load(const char *devname, const char *fname)
|
||||
load(const char *devname, const char *fname, bool append)
|
||||
{
|
||||
// sleep a while to ensure device has been set up
|
||||
usleep(20000);
|
||||
|
@ -115,10 +128,12 @@ load(const char *devname, const char *fname)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* reset mixers on the device */
|
||||
if (px4_ioctl(dev, MIXERIOCRESET, 0)) {
|
||||
warnx("can't reset mixers on %s", devname);
|
||||
return 1;
|
||||
/* reset mixers on the device, but not if appending */
|
||||
if (!append) {
|
||||
if (px4_ioctl(dev, MIXERIOCRESET, 0)) {
|
||||
warnx("can't reset mixers on %s", devname);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
char buf[2048];
|
||||
|
|
Loading…
Reference in New Issue