mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-04 21:23:57 +08:00
merge origin/master
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
############################################################################
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012 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
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in
|
||||||
|
# the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||||
|
# used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
#
|
||||||
|
# Interface driver for the PX4FMU board
|
||||||
|
#
|
||||||
|
|
||||||
|
APPNAME = hil
|
||||||
|
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||||
|
STACKSIZE = 2048
|
||||||
|
|
||||||
|
include $(APPDIR)/mk/app.mk
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -74,7 +74,6 @@ public:
|
|||||||
enum Mode {
|
enum Mode {
|
||||||
MODE_2PWM,
|
MODE_2PWM,
|
||||||
MODE_4PWM,
|
MODE_4PWM,
|
||||||
MODE_HIL_8PWM,
|
|
||||||
MODE_NONE
|
MODE_NONE
|
||||||
};
|
};
|
||||||
PX4FMU();
|
PX4FMU();
|
||||||
@@ -270,12 +269,6 @@ PX4FMU::set_mode(Mode mode)
|
|||||||
_update_rate = 50; /* default output rate */
|
_update_rate = 50; /* default output rate */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_HIL_8PWM:
|
|
||||||
debug("MODE_HIL_8PWM");
|
|
||||||
/* do not actually start a pwm device */
|
|
||||||
_update_rate = 50; /* default output rate */
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MODE_NONE:
|
case MODE_NONE:
|
||||||
debug("MODE_NONE");
|
debug("MODE_NONE");
|
||||||
/* disable servo outputs and set a very low update rate */
|
/* disable servo outputs and set a very low update rate */
|
||||||
@@ -328,26 +321,7 @@ PX4FMU::task_main()
|
|||||||
fds[1].fd = _t_armed;
|
fds[1].fd = _t_armed;
|
||||||
fds[1].events = POLLIN;
|
fds[1].events = POLLIN;
|
||||||
|
|
||||||
unsigned num_outputs;
|
unsigned num_outputs = (_mode == MODE_2PWM) ? 2 : 4;
|
||||||
|
|
||||||
/* select the number of (real or virtual) outputs */
|
|
||||||
switch (_mode) {
|
|
||||||
case MODE_2PWM:
|
|
||||||
num_outputs = 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MODE_4PWM:
|
|
||||||
num_outputs = 4;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MODE_HIL_8PWM:
|
|
||||||
num_outputs = 8;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MODE_NONE:
|
|
||||||
num_outputs = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
log("starting");
|
log("starting");
|
||||||
|
|
||||||
@@ -360,11 +334,7 @@ PX4FMU::task_main()
|
|||||||
if (update_rate_in_ms < 2)
|
if (update_rate_in_ms < 2)
|
||||||
update_rate_in_ms = 2;
|
update_rate_in_ms = 2;
|
||||||
orb_set_interval(_t_actuators, update_rate_in_ms);
|
orb_set_interval(_t_actuators, update_rate_in_ms);
|
||||||
|
|
||||||
if (_mode != MODE_HIL_8PWM) {
|
|
||||||
/* do not attempt to set servos in HIL mode */
|
|
||||||
up_pwm_servo_set_rate(_update_rate);
|
up_pwm_servo_set_rate(_update_rate);
|
||||||
}
|
|
||||||
_current_update_rate = _update_rate;
|
_current_update_rate = _update_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,13 +367,9 @@ PX4FMU::task_main()
|
|||||||
outputs.output[i] = 1500 + (600 * outputs.output[i]);
|
outputs.output[i] = 1500 + (600 * outputs.output[i]);
|
||||||
|
|
||||||
/* output to the servo */
|
/* output to the servo */
|
||||||
if (_mode != MODE_HIL_8PWM) {
|
|
||||||
/* do not attempt to set servos in HIL mode */
|
|
||||||
up_pwm_servo_set(i, outputs.output[i]);
|
up_pwm_servo_set(i, outputs.output[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* and publish for anyone that cares to see */
|
/* and publish for anyone that cares to see */
|
||||||
orb_publish(ORB_ID_VEHICLE_CONTROLS, _t_outputs, &outputs);
|
orb_publish(ORB_ID_VEHICLE_CONTROLS, _t_outputs, &outputs);
|
||||||
}
|
}
|
||||||
@@ -417,14 +383,7 @@ PX4FMU::task_main()
|
|||||||
orb_copy(ORB_ID(actuator_armed), _t_armed, &aa);
|
orb_copy(ORB_ID(actuator_armed), _t_armed, &aa);
|
||||||
|
|
||||||
/* update PWM servo armed status */
|
/* update PWM servo armed status */
|
||||||
|
up_pwm_servo_arm(aa.armed);
|
||||||
/*
|
|
||||||
* armed = system wants to fly
|
|
||||||
* locked = there is a low-level safety lock
|
|
||||||
* in place, such as in hardware-in-the-loop
|
|
||||||
* simulation setups.
|
|
||||||
*/
|
|
||||||
up_pwm_servo_arm(aa.armed && !aa.lockdown);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,7 +419,7 @@ PX4FMU::ioctl(file *filp, int cmd, unsigned long arg)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
// XXX disable debug output, users got confused
|
// XXX disabled, confusing users
|
||||||
//debug("ioctl 0x%04x 0x%08x", cmd, arg);
|
//debug("ioctl 0x%04x 0x%08x", cmd, arg);
|
||||||
|
|
||||||
/* try it as a GPIO ioctl first */
|
/* try it as a GPIO ioctl first */
|
||||||
@@ -474,11 +433,6 @@ PX4FMU::ioctl(file *filp, int cmd, unsigned long arg)
|
|||||||
case MODE_4PWM:
|
case MODE_4PWM:
|
||||||
ret = pwm_ioctl(filp, cmd, arg);
|
ret = pwm_ioctl(filp, cmd, arg);
|
||||||
break;
|
break;
|
||||||
case MODE_HIL_8PWM:
|
|
||||||
/* do nothing */
|
|
||||||
debug("loading mixer for virtual HIL device");
|
|
||||||
ret = 0;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
debug("not in a PWM mode");
|
debug("not in a PWM mode");
|
||||||
break;
|
break;
|
||||||
@@ -752,7 +706,6 @@ enum PortMode {
|
|||||||
PORT_GPIO_AND_SERIAL,
|
PORT_GPIO_AND_SERIAL,
|
||||||
PORT_PWM_AND_SERIAL,
|
PORT_PWM_AND_SERIAL,
|
||||||
PORT_PWM_AND_GPIO,
|
PORT_PWM_AND_GPIO,
|
||||||
PORT_HIL_PWM
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PortMode g_port_mode;
|
PortMode g_port_mode;
|
||||||
@@ -801,11 +754,6 @@ fmu_new_mode(PortMode new_mode, int update_rate)
|
|||||||
/* select 2-pin PWM mode */
|
/* select 2-pin PWM mode */
|
||||||
servo_mode = PX4FMU::MODE_2PWM;
|
servo_mode = PX4FMU::MODE_2PWM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PORT_HIL_PWM:
|
|
||||||
/* virtual PWM mode */
|
|
||||||
servo_mode = PX4FMU::MODE_HIL_8PWM;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* adjust GPIO config for serial mode(s) */
|
/* adjust GPIO config for serial mode(s) */
|
||||||
@@ -935,14 +883,11 @@ fmu_main(int argc, char *argv[])
|
|||||||
|
|
||||||
} else if (!strcmp(argv[i], "mode_pwm_gpio")) {
|
} else if (!strcmp(argv[i], "mode_pwm_gpio")) {
|
||||||
new_mode = PORT_PWM_AND_GPIO;
|
new_mode = PORT_PWM_AND_GPIO;
|
||||||
|
|
||||||
} else if (!strcmp(argv[i], "mode_hil_pwm")) {
|
|
||||||
new_mode = PORT_HIL_PWM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* look for the optional pwm update rate for the supported modes */
|
/* look for the optional pwm update rate for the supported modes */
|
||||||
if (strcmp(argv[i], "-u") == 0 || strcmp(argv[i], "--update-rate") == 0) {
|
if (strcmp(argv[i], "-u") == 0 || strcmp(argv[i], "--update-rate") == 0) {
|
||||||
if (new_mode == PORT_FULL_PWM || new_mode == PORT_PWM_AND_GPIO || PORT_HIL_PWM) {
|
if (new_mode == PORT_FULL_PWM || new_mode == PORT_PWM_AND_GPIO) {
|
||||||
if (argc > i + 1) {
|
if (argc > i + 1) {
|
||||||
pwm_update_rate_in_hz = atoi(argv[i + 1]);
|
pwm_update_rate_in_hz = atoi(argv[i + 1]);
|
||||||
} else {
|
} else {
|
||||||
@@ -968,7 +913,7 @@ fmu_main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* test, etc. here */
|
/* test, etc. here */
|
||||||
|
|
||||||
fprintf(stderr, "FMU: unrecognized command, try:\n");
|
fprintf(stderr, "FMU: unrecognised command, try:\n");
|
||||||
fprintf(stderr, " mode_gpio, mode_serial, mode_pwm [-u pwm_update_rate_in_hz], mode_gpio_serial,\n mode_pwm_serial, mode_pwm_gpio, mode_hil_pwm\n");
|
fprintf(stderr, " mode_gpio, mode_serial, mode_pwm [-u pwm_update_rate_in_hz], mode_gpio_serial, mode_pwm_serial, mode_pwm_gpio\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -436,7 +436,7 @@ l_actuator_outputs(struct listener *l)
|
|||||||
/* only send in HIL mode */
|
/* only send in HIL mode */
|
||||||
if (mavlink_hil_enabled) {
|
if (mavlink_hil_enabled) {
|
||||||
|
|
||||||
/* translate the current system state to mavlink state and mode */
|
/* translate the current syste state to mavlink state and mode */
|
||||||
uint8_t mavlink_state = 0;
|
uint8_t mavlink_state = 0;
|
||||||
uint8_t mavlink_mode = 0;
|
uint8_t mavlink_mode = 0;
|
||||||
get_mavlink_mode_and_state(&mavlink_state, &mavlink_mode);
|
get_mavlink_mode_and_state(&mavlink_state, &mavlink_mode);
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ accel(int argc, char *argv[])
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("\tACCEL values: acc: x:%8.4f\ty:%8.4f\tz:%8.4f\n", (double)buf.x, (double)buf.y, (double)buf.z);
|
printf("\tACCEL accel: x:%8.4f\ty:%8.4f\tz:%8.4f m/s^2\n", (double)buf.x, (double)buf.y, (double)buf.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /* wait at least 10ms, sensor should have data after no more than 2ms */
|
// /* wait at least 10ms, sensor should have data after no more than 2ms */
|
||||||
@@ -182,7 +182,7 @@ gyro(int argc, char *argv[])
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("\tGYRO values: rates: x:%8.4f\ty:%8.4f\tz:%8.4f\n", (double)buf.x, (double)buf.y, (double)buf.z);
|
printf("\tGYRO rates: x:%8.4f\ty:%8.4f\tz:%8.4f rad/s\n", (double)buf.x, (double)buf.y, (double)buf.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let user know everything is ok */
|
/* Let user know everything is ok */
|
||||||
@@ -219,7 +219,7 @@ mag(int argc, char *argv[])
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("\tMAG values: mag. field: x:%8.4f\ty:%8.4f\tz:%8.4f\n", (double)buf.x, (double)buf.y, (double)buf.z);
|
printf("\tMAG values: x:%8.4f\ty:%8.4f\tz:%8.4f\n", (double)buf.x, (double)buf.y, (double)buf.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let user know everything is ok */
|
/* Let user know everything is ok */
|
||||||
@@ -256,7 +256,7 @@ baro(int argc, char *argv[])
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("\tBARO values: pressure: %8.4f mbar\taltitude: %8.4f m\ttemperature: %8.4f deg Celsius\n", (double)buf.pressure, (double)buf.altitude, (double)buf.temperature);
|
printf("\tBARO pressure: %8.4f mbar\talt: %8.4f m\ttemp: %8.4f deg C\n", (double)buf.pressure, (double)buf.altitude, (double)buf.temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let user know everything is ok */
|
/* Let user know everything is ok */
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ mixer_load_simple(Mixer::ControlCallback control_cb, uintptr_t cb_handle, int fd
|
|||||||
|
|
||||||
/* let's assume we're going to read a simple mixer */
|
/* let's assume we're going to read a simple mixer */
|
||||||
mixinfo = (mixer_simple_s *)malloc(MIXER_SIMPLE_SIZE(inputs));
|
mixinfo = (mixer_simple_s *)malloc(MIXER_SIMPLE_SIZE(inputs));
|
||||||
|
mixinfo->control_count = inputs;
|
||||||
|
|
||||||
/* first, get the output scaler */
|
/* first, get the output scaler */
|
||||||
ret = mixer_getline(fd, buf, sizeof(buf));
|
ret = mixer_getline(fd, buf, sizeof(buf));
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ CONFIGURED_APPS += drivers/stm32
|
|||||||
CONFIGURED_APPS += drivers/led
|
CONFIGURED_APPS += drivers/led
|
||||||
CONFIGURED_APPS += drivers/stm32/tone_alarm
|
CONFIGURED_APPS += drivers/stm32/tone_alarm
|
||||||
CONFIGURED_APPS += drivers/px4fmu
|
CONFIGURED_APPS += drivers/px4fmu
|
||||||
|
CONFIGURED_APPS += drivers/hil
|
||||||
|
|
||||||
# Testing stuff
|
# Testing stuff
|
||||||
CONFIGURED_APPS += px4/sensors_bringup
|
CONFIGURED_APPS += px4/sensors_bringup
|
||||||
|
|||||||
Reference in New Issue
Block a user