mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 01:03:33 +08:00
Merge branch 'beta' into stable
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
uint64 timestamp # Microseconds since system boot
|
uint64 timestamp # Microseconds since system boot
|
||||||
bool armed # Set to true if system is armed
|
bool armed # Set to true if system is armed
|
||||||
|
bool prearmed # Set to true if the actuator safety is disabled but motors are not armed
|
||||||
bool ready_to_arm # Set to true if system is ready to be armed
|
bool ready_to_arm # Set to true if system is ready to be armed
|
||||||
bool lockdown # Set to true if actuators are forced to being disabled (due to emergency or HIL)
|
bool lockdown # Set to true if actuators are forced to being disabled (due to emergency or HIL)
|
||||||
bool force_failsafe # Set to true if the actuators are forced to the failsafe position
|
bool force_failsafe # Set to true if the actuators are forced to the failsafe position
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ private:
|
|||||||
unsigned _num_failsafe_set;
|
unsigned _num_failsafe_set;
|
||||||
unsigned _num_disarmed_set;
|
unsigned _num_disarmed_set;
|
||||||
|
|
||||||
static bool arm_nothrottle() { return (_armed.ready_to_arm && !_armed.armed); }
|
static bool arm_nothrottle() { return (_armed.prearmed && !_armed.armed); }
|
||||||
|
|
||||||
static void task_main_trampoline(int argc, char *argv[]);
|
static void task_main_trampoline(int argc, char *argv[]);
|
||||||
void task_main();
|
void task_main();
|
||||||
@@ -733,7 +733,7 @@ PX4FMU::task_main()
|
|||||||
orb_copy(ORB_ID(actuator_armed), _armed_sub, &_armed);
|
orb_copy(ORB_ID(actuator_armed), _armed_sub, &_armed);
|
||||||
|
|
||||||
/* update the armed status and check that we're not locked down */
|
/* update the armed status and check that we're not locked down */
|
||||||
bool set_armed = (_armed.armed || _armed.ready_to_arm) && !_armed.lockdown;
|
bool set_armed = (_armed.armed || _armed.prearmed) && !_armed.lockdown;
|
||||||
|
|
||||||
if (_servo_armed != set_armed) {
|
if (_servo_armed != set_armed) {
|
||||||
_servo_armed = set_armed;
|
_servo_armed = set_armed;
|
||||||
|
|||||||
@@ -2144,6 +2144,19 @@ int commander_thread_main(int argc, char *argv[])
|
|||||||
orb_publish(ORB_ID(vehicle_status), status_pub, &status);
|
orb_publish(ORB_ID(vehicle_status), status_pub, &status);
|
||||||
|
|
||||||
armed.timestamp = now;
|
armed.timestamp = now;
|
||||||
|
|
||||||
|
/* set prearmed state if safety is off, or safety is not present and 5 seconds passed */
|
||||||
|
if (safety.safety_switch_available) {
|
||||||
|
|
||||||
|
/* safety is off, go into prearmed */
|
||||||
|
armed.prearmed = safety.safety_off;
|
||||||
|
} else {
|
||||||
|
/* safety is not present, go into prearmed
|
||||||
|
* (all output drivers should be started / unlocked last in the boot process
|
||||||
|
* when the rest of the system is fully initialized)
|
||||||
|
*/
|
||||||
|
armed.prearmed = (hrt_elapsed_time(&commander_boot_timestamp) > 5 * 1000 * 1000);
|
||||||
|
}
|
||||||
orb_publish(ORB_ID(actuator_armed), armed_pub, &armed);
|
orb_publish(ORB_ID(actuator_armed), armed_pub, &armed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,9 @@
|
|||||||
#include <mavlink/mavlink_log.h>
|
#include <mavlink/mavlink_log.h>
|
||||||
#include <platforms/px4_defines.h>
|
#include <platforms/px4_defines.h>
|
||||||
|
|
||||||
|
#include <controllib/blocks.hpp>
|
||||||
|
#include <controllib/block/BlockParam.hpp>
|
||||||
|
|
||||||
#define TILT_COS_MAX 0.7f
|
#define TILT_COS_MAX 0.7f
|
||||||
#define SIGMA 0.000001f
|
#define SIGMA 0.000001f
|
||||||
#define MIN_DIST 0.01f
|
#define MIN_DIST 0.01f
|
||||||
@@ -92,7 +95,7 @@
|
|||||||
*/
|
*/
|
||||||
extern "C" __EXPORT int mc_pos_control_main(int argc, char *argv[]);
|
extern "C" __EXPORT int mc_pos_control_main(int argc, char *argv[]);
|
||||||
|
|
||||||
class MulticopterPositionControl
|
class MulticopterPositionControl : public control::SuperBlock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@@ -146,6 +149,8 @@ private:
|
|||||||
struct vehicle_local_position_setpoint_s _local_pos_sp; /**< vehicle local position setpoint */
|
struct vehicle_local_position_setpoint_s _local_pos_sp; /**< vehicle local position setpoint */
|
||||||
struct vehicle_global_velocity_setpoint_s _global_vel_sp; /**< vehicle global velocity setpoint */
|
struct vehicle_global_velocity_setpoint_s _global_vel_sp; /**< vehicle global velocity setpoint */
|
||||||
|
|
||||||
|
control::BlockParamFloat _manual_thr_min;
|
||||||
|
control::BlockParamFloat _manual_thr_max;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
param_t thr_min;
|
param_t thr_min;
|
||||||
@@ -290,7 +295,7 @@ MulticopterPositionControl *g_control;
|
|||||||
}
|
}
|
||||||
|
|
||||||
MulticopterPositionControl::MulticopterPositionControl() :
|
MulticopterPositionControl::MulticopterPositionControl() :
|
||||||
|
SuperBlock(NULL, "MPC"),
|
||||||
_task_should_exit(false),
|
_task_should_exit(false),
|
||||||
_control_task(-1),
|
_control_task(-1),
|
||||||
_mavlink_fd(-1),
|
_mavlink_fd(-1),
|
||||||
@@ -310,7 +315,8 @@ MulticopterPositionControl::MulticopterPositionControl() :
|
|||||||
_att_sp_pub(-1),
|
_att_sp_pub(-1),
|
||||||
_local_pos_sp_pub(-1),
|
_local_pos_sp_pub(-1),
|
||||||
_global_vel_sp_pub(-1),
|
_global_vel_sp_pub(-1),
|
||||||
|
_manual_thr_min(this, "MANTHR_MIN"),
|
||||||
|
_manual_thr_max(this, "MANTHR_MAX"),
|
||||||
_ref_alt(0.0f),
|
_ref_alt(0.0f),
|
||||||
_ref_timestamp(0),
|
_ref_timestamp(0),
|
||||||
|
|
||||||
@@ -410,6 +416,10 @@ MulticopterPositionControl::parameters_update(bool force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (updated || force) {
|
if (updated || force) {
|
||||||
|
/* update C++ param system */
|
||||||
|
updateParams();
|
||||||
|
|
||||||
|
/* update legacy C interface params */
|
||||||
param_get(_params_handles.thr_min, &_params.thr_min);
|
param_get(_params_handles.thr_min, &_params.thr_min);
|
||||||
param_get(_params_handles.thr_max, &_params.thr_max);
|
param_get(_params_handles.thr_max, &_params.thr_max);
|
||||||
param_get(_params_handles.tilt_max_air, &_params.tilt_max_air);
|
param_get(_params_handles.tilt_max_air, &_params.tilt_max_air);
|
||||||
@@ -1413,11 +1423,11 @@ MulticopterPositionControl::task_main()
|
|||||||
|
|
||||||
/* control throttle directly if no climb rate controller is active */
|
/* control throttle directly if no climb rate controller is active */
|
||||||
if (!_control_mode.flag_control_climb_rate_enabled) {
|
if (!_control_mode.flag_control_climb_rate_enabled) {
|
||||||
_att_sp.thrust = math::min(_manual.z, _params.thr_max);
|
_att_sp.thrust = math::min(_manual.z, _manual_thr_max.get());
|
||||||
|
|
||||||
/* enforce minimum throttle if not landed */
|
/* enforce minimum throttle if not landed */
|
||||||
if (!_vehicle_status.condition_landed) {
|
if (!_vehicle_status.condition_landed) {
|
||||||
_att_sp.thrust = math::max(_att_sp.thrust, _params.thr_min);
|
_att_sp.thrust = math::max(_att_sp.thrust, _manual_thr_min.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,32 @@
|
|||||||
#include <systemlib/param/param.h>
|
#include <systemlib/param/param.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimum thrust
|
* Minimum thrust in auto thrust control
|
||||||
|
*
|
||||||
|
* It's recommended to set it > 0 to avoid free fall with zero thrust.
|
||||||
|
*
|
||||||
|
* @min 0.05
|
||||||
|
* @max 1.0
|
||||||
|
* @group Multicopter Position Control
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_FLOAT(MPC_THR_MIN, 0.12f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum thrust in auto thrust control
|
||||||
|
*
|
||||||
|
* Limit max allowed thrust. Setting a value of one can put
|
||||||
|
* the system into actuator saturation as no spread between
|
||||||
|
* the motors is possible any more. A value of 0.8 - 0.9
|
||||||
|
* is recommended.
|
||||||
|
*
|
||||||
|
* @min 0.0
|
||||||
|
* @max 0.95
|
||||||
|
* @group Multicopter Position Control
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_FLOAT(MPC_THR_MAX, 0.9f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum manual thrust
|
||||||
*
|
*
|
||||||
* Minimum vertical thrust. It's recommended to set it > 0 to avoid free fall with zero thrust.
|
* Minimum vertical thrust. It's recommended to set it > 0 to avoid free fall with zero thrust.
|
||||||
*
|
*
|
||||||
@@ -49,10 +74,10 @@
|
|||||||
* @max 1.0
|
* @max 1.0
|
||||||
* @group Multicopter Position Control
|
* @group Multicopter Position Control
|
||||||
*/
|
*/
|
||||||
PARAM_DEFINE_FLOAT(MPC_THR_MIN, 0.12f);
|
PARAM_DEFINE_FLOAT(MPC_MANTHR_MIN, 0.12f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum thrust
|
* Maximum manual thrust
|
||||||
*
|
*
|
||||||
* Limit max allowed thrust. Setting a value of one can put
|
* Limit max allowed thrust. Setting a value of one can put
|
||||||
* the system into actuator saturation as no spread between
|
* the system into actuator saturation as no spread between
|
||||||
@@ -63,7 +88,7 @@ PARAM_DEFINE_FLOAT(MPC_THR_MIN, 0.12f);
|
|||||||
* @max 1.0
|
* @max 1.0
|
||||||
* @group Multicopter Position Control
|
* @group Multicopter Position Control
|
||||||
*/
|
*/
|
||||||
PARAM_DEFINE_FLOAT(MPC_THR_MAX, 0.9f);
|
PARAM_DEFINE_FLOAT(MPC_MANTHR_MAX, 0.9f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Proportional gain for vertical position error
|
* Proportional gain for vertical position error
|
||||||
|
|||||||
Reference in New Issue
Block a user