mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-17 01:40:34 +08:00
Merge remote-tracking branch 'upstream/master' into mtecs
This commit is contained in:
@@ -199,15 +199,9 @@ int led_init()
|
||||
}
|
||||
|
||||
/* the blue LED is only available on FMUv1 but not FMUv2 */
|
||||
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V1
|
||||
|
||||
if (ioctl(leds, LED_ON, LED_BLUE)) {
|
||||
warnx("Blue LED: ioctl fail\n");
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
(void)ioctl(leds, LED_ON, LED_BLUE);
|
||||
|
||||
/* we consider the amber led mandatory */
|
||||
if (ioctl(leds, LED_ON, LED_AMBER)) {
|
||||
warnx("Amber LED: ioctl fail\n");
|
||||
return ERROR;
|
||||
@@ -217,11 +211,7 @@ int led_init()
|
||||
rgbleds = open(RGBLED_DEVICE_PATH, 0);
|
||||
|
||||
if (rgbleds == -1) {
|
||||
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V2
|
||||
errx(1, "Unable to open " RGBLED_DEVICE_PATH);
|
||||
#else
|
||||
warnx("No RGB LED found");
|
||||
#endif
|
||||
warnx("No RGB LED found at " RGBLED_DEVICE_PATH);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -416,26 +416,26 @@ static int
|
||||
_restart(dm_reset_reason reason)
|
||||
{
|
||||
unsigned char buffer[2];
|
||||
int offset, result = 0;
|
||||
int offset = 0, result = 0;
|
||||
|
||||
/* We need to scan the entire file and invalidate and data that should not persist after the last reset */
|
||||
|
||||
/* Loop through all of the data segments and delete those that are not persistent */
|
||||
offset = 0;
|
||||
|
||||
while (1) {
|
||||
size_t len;
|
||||
|
||||
/* Get data segment at current offset */
|
||||
if (lseek(g_task_fd, offset, SEEK_SET) != offset) {
|
||||
result = -1;
|
||||
/* must be at eof */
|
||||
break;
|
||||
}
|
||||
|
||||
len = read(g_task_fd, buffer, sizeof(buffer));
|
||||
|
||||
if (len == 0)
|
||||
if (len != sizeof(buffer)) {
|
||||
/* must be at eof */
|
||||
break;
|
||||
}
|
||||
|
||||
/* check if segment contains data */
|
||||
if (buffer[0]) {
|
||||
@@ -443,12 +443,12 @@ _restart(dm_reset_reason reason)
|
||||
|
||||
/* Whether data gets deleted depends on reset type and data segment's persistence setting */
|
||||
if (reason == DM_INIT_REASON_POWER_ON) {
|
||||
if (buffer[1] != DM_PERSIST_POWER_ON_RESET) {
|
||||
if (buffer[1] > DM_PERSIST_POWER_ON_RESET) {
|
||||
clear_entry = 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ((buffer[1] != DM_PERSIST_POWER_ON_RESET) && (buffer[1] != DM_PERSIST_IN_FLIGHT_RESET)) {
|
||||
if (buffer[1] > DM_PERSIST_IN_FLIGHT_RESET) {
|
||||
clear_entry = 1;
|
||||
}
|
||||
}
|
||||
@@ -628,6 +628,23 @@ task_main(int argc, char *argv[])
|
||||
|
||||
fsync(g_task_fd);
|
||||
|
||||
/* see if we need to erase any items based on restart type */
|
||||
int sys_restart_val;
|
||||
if (param_get(param_find("SYS_RESTART_TYPE"), &sys_restart_val) == OK) {
|
||||
if (sys_restart_val == DM_INIT_REASON_POWER_ON) {
|
||||
warnx("Power on restart");
|
||||
_restart(DM_INIT_REASON_POWER_ON);
|
||||
}
|
||||
else if (sys_restart_val == DM_INIT_REASON_IN_FLIGHT) {
|
||||
warnx("In flight restart");
|
||||
_restart(DM_INIT_REASON_IN_FLIGHT);
|
||||
}
|
||||
else
|
||||
warnx("Unknown restart");
|
||||
}
|
||||
else
|
||||
warnx("Unknown restart");
|
||||
|
||||
/* We use two file descriptors, one for the caller context and one for the worker thread */
|
||||
/* They are actually the same but we need to some way to reject caller request while the */
|
||||
/* worker thread is shutting down but still processing requests */
|
||||
@@ -724,7 +741,7 @@ start(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* wait for the thread to actuall initialize */
|
||||
/* wait for the thread to actually initialize */
|
||||
sem_wait(&g_init_sema);
|
||||
sem_destroy(&g_init_sema);
|
||||
|
||||
|
||||
@@ -75,7 +75,8 @@ extern "C" {
|
||||
/* The reason for the last reset */
|
||||
typedef enum {
|
||||
DM_INIT_REASON_POWER_ON = 0, /* Data survives resets */
|
||||
DM_INIT_REASON_IN_FLIGHT /* Data survives in-flight resets only */
|
||||
DM_INIT_REASON_IN_FLIGHT, /* Data survives in-flight resets only */
|
||||
DM_INIT_REASON_VOLATILE /* Data does not survive reset */
|
||||
} dm_reset_reason;
|
||||
|
||||
/* Maximum size in bytes of a single item instance */
|
||||
@@ -100,7 +101,7 @@ extern "C" {
|
||||
size_t buflen /* Length in bytes of data to retrieve */
|
||||
);
|
||||
|
||||
/* Retrieve from the data manager store */
|
||||
/* Erase all items of this type */
|
||||
__EXPORT int
|
||||
dm_clear(
|
||||
dm_item_t item /* The item type to clear */
|
||||
|
||||
@@ -496,7 +496,8 @@ MulticopterAttitudeControl::control_attitude(float dt)
|
||||
//}
|
||||
} else {
|
||||
/* move yaw setpoint */
|
||||
_v_att_sp.yaw_body = _wrap_pi(_v_att_sp.yaw_body + _manual_control_sp.yaw * _params.man_yaw_max * dt);
|
||||
yaw_sp_move_rate = _manual_control_sp.yaw * _params.man_yaw_max;
|
||||
_v_att_sp.yaw_body = _wrap_pi(_v_att_sp.yaw_body + yaw_sp_move_rate * dt);
|
||||
_v_att_sp.R_valid = false;
|
||||
publish_att_sp = true;
|
||||
}
|
||||
|
||||
@@ -148,17 +148,17 @@ private:
|
||||
param_t xy_vel_d;
|
||||
param_t xy_vel_max;
|
||||
param_t xy_ff;
|
||||
param_t tilt_max;
|
||||
param_t tilt_max_air;
|
||||
param_t land_speed;
|
||||
param_t land_tilt_max;
|
||||
param_t tilt_max_land;
|
||||
} _params_handles; /**< handles for interesting parameters */
|
||||
|
||||
struct {
|
||||
float thr_min;
|
||||
float thr_max;
|
||||
float tilt_max;
|
||||
float tilt_max_air;
|
||||
float land_speed;
|
||||
float land_tilt_max;
|
||||
float tilt_max_land;
|
||||
|
||||
math::Vector<3> pos_p;
|
||||
math::Vector<3> vel_p;
|
||||
@@ -308,9 +308,9 @@ MulticopterPositionControl::MulticopterPositionControl() :
|
||||
_params_handles.xy_vel_d = param_find("MPC_XY_VEL_D");
|
||||
_params_handles.xy_vel_max = param_find("MPC_XY_VEL_MAX");
|
||||
_params_handles.xy_ff = param_find("MPC_XY_FF");
|
||||
_params_handles.tilt_max = param_find("MPC_TILT_MAX");
|
||||
_params_handles.tilt_max_air = param_find("MPC_TILTMAX_AIR");
|
||||
_params_handles.land_speed = param_find("MPC_LAND_SPEED");
|
||||
_params_handles.land_tilt_max = param_find("MPC_LAND_TILT");
|
||||
_params_handles.tilt_max_land = param_find("MPC_TILTMAX_LND");
|
||||
|
||||
/* fetch initial parameter values */
|
||||
parameters_update(true);
|
||||
@@ -355,11 +355,11 @@ MulticopterPositionControl::parameters_update(bool force)
|
||||
if (updated || force) {
|
||||
param_get(_params_handles.thr_min, &_params.thr_min);
|
||||
param_get(_params_handles.thr_max, &_params.thr_max);
|
||||
param_get(_params_handles.tilt_max, &_params.tilt_max);
|
||||
_params.tilt_max = math::radians(_params.tilt_max);
|
||||
param_get(_params_handles.tilt_max_air, &_params.tilt_max_air);
|
||||
_params.tilt_max_air = math::radians(_params.tilt_max_air);
|
||||
param_get(_params_handles.land_speed, &_params.land_speed);
|
||||
param_get(_params_handles.land_tilt_max, &_params.land_tilt_max);
|
||||
_params.land_tilt_max = math::radians(_params.land_tilt_max);
|
||||
param_get(_params_handles.tilt_max_land, &_params.tilt_max_land);
|
||||
_params.tilt_max_land = math::radians(_params.tilt_max_land);
|
||||
|
||||
float v;
|
||||
param_get(_params_handles.xy_p, &v);
|
||||
@@ -841,13 +841,13 @@ MulticopterPositionControl::task_main()
|
||||
thr_min = 0.0f;
|
||||
}
|
||||
|
||||
float tilt_max = _params.tilt_max;
|
||||
float tilt_max = _params.tilt_max_air;
|
||||
|
||||
/* adjust limits for landing mode */
|
||||
if (!_control_mode.flag_control_manual_enabled && _pos_sp_triplet.current.valid &&
|
||||
_pos_sp_triplet.current.type == SETPOINT_TYPE_LAND) {
|
||||
/* limit max tilt and min lift when landing */
|
||||
tilt_max = _params.land_tilt_max;
|
||||
tilt_max = _params.tilt_max_land;
|
||||
|
||||
if (thr_min < 0.0f) {
|
||||
thr_min = 0.0f;
|
||||
|
||||
@@ -211,6 +211,10 @@ enum { /* DSM bind states */
|
||||
/* 12 occupied by CRC */
|
||||
#define PX4IO_P_SETUP_RC_THR_FAILSAFE_US 13 /**< the throttle failsafe pulse length in microseconds */
|
||||
|
||||
#define PX4IO_P_SETUP_FORCE_SAFETY_OFF 12 /* force safety switch into
|
||||
'armed' (PWM enabled) state */
|
||||
#define PX4IO_FORCE_SAFETY_MAGIC 22027 /* required argument for force safety (random) */
|
||||
|
||||
/* autopilot control values, -10000..10000 */
|
||||
#define PX4IO_PAGE_CONTROLS 51 /**< actuator control groups, one after the other, 8 wide */
|
||||
#define PX4IO_P_CONTROLS_GROUP_0 (PX4IO_PROTOCOL_MAX_CONTROL_COUNT * 0) /**< 0..PX4IO_PROTOCOL_MAX_CONTROL_COUNT - 1 */
|
||||
|
||||
@@ -570,6 +570,12 @@ registers_set_one(uint8_t page, uint8_t offset, uint16_t value)
|
||||
dsm_bind(value & 0x0f, (value >> 4) & 0xF);
|
||||
break;
|
||||
|
||||
case PX4IO_P_SETUP_FORCE_SAFETY_OFF:
|
||||
if (value == PX4IO_FORCE_SAFETY_MAGIC) {
|
||||
r_status_flags |= PX4IO_P_STATUS_FLAGS_SAFETY_OFF;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -62,12 +62,23 @@ PARAM_DEFINE_INT32(SYS_AUTOSTART, 0);
|
||||
PARAM_DEFINE_INT32(SYS_AUTOCONFIG, 0);
|
||||
|
||||
/**
|
||||
* Set usage of IO board
|
||||
*
|
||||
* Can be used to use a standard startup script but with a FMU only set-up. Set to 0 to force the FMU only set-up.
|
||||
*
|
||||
* @min 0
|
||||
* @max 1
|
||||
* @group System
|
||||
*/
|
||||
* Set usage of IO board
|
||||
*
|
||||
* Can be used to use a standard startup script but with a FMU only set-up. Set to 0 to force the FMU only set-up.
|
||||
*
|
||||
* @min 0
|
||||
* @max 1
|
||||
* @group System
|
||||
*/
|
||||
PARAM_DEFINE_INT32(SYS_USE_IO, 1);
|
||||
|
||||
/**
|
||||
* Set restart type
|
||||
*
|
||||
* Set by px4io to indicate type of restart
|
||||
*
|
||||
* @min 0
|
||||
* @max 2
|
||||
* @group System
|
||||
*/
|
||||
PARAM_DEFINE_INT32(SYS_RESTART_TYPE, 2);
|
||||
|
||||
Reference in New Issue
Block a user