mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 07:03:34 +08:00
Merge remote-tracking branch 'upstream/master' into offboard2_externalsetpointmessages
This commit is contained in:
@@ -165,7 +165,7 @@ Airspeed::probe()
|
|||||||
*/
|
*/
|
||||||
_retries = 4;
|
_retries = 4;
|
||||||
int ret = measure();
|
int ret = measure();
|
||||||
_retries = 2;
|
_retries = 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +381,10 @@ Airspeed::cycle_trampoline(void *arg)
|
|||||||
Airspeed *dev = (Airspeed *)arg;
|
Airspeed *dev = (Airspeed *)arg;
|
||||||
|
|
||||||
dev->cycle();
|
dev->cycle();
|
||||||
dev->update_status();
|
// XXX we do not know if this is
|
||||||
|
// really helping - do not update the
|
||||||
|
// subsys state right now
|
||||||
|
//dev->update_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ float ECL_PitchController::control_bodyrate(float roll, float pitch,
|
|||||||
|
|
||||||
if (!lock_integrator && _k_i > 0.0f && airspeed > 0.5f * airspeed_min) {
|
if (!lock_integrator && _k_i > 0.0f && airspeed > 0.5f * airspeed_min) {
|
||||||
|
|
||||||
float id = _rate_error * dt;
|
float id = _rate_error * dt * scaler;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* anti-windup: do not allow integrator to increase if actuator is at limit
|
* anti-windup: do not allow integrator to increase if actuator is at limit
|
||||||
@@ -190,7 +190,9 @@ float ECL_PitchController::control_bodyrate(float roll, float pitch,
|
|||||||
float integrator_constrained = math::constrain(_integrator * _k_i, -_integrator_max, _integrator_max);
|
float integrator_constrained = math::constrain(_integrator * _k_i, -_integrator_max, _integrator_max);
|
||||||
|
|
||||||
/* Apply PI rate controller and store non-limited output */
|
/* Apply PI rate controller and store non-limited output */
|
||||||
_last_output = (_bodyrate_setpoint * _k_ff +_rate_error * _k_p + integrator_constrained) * scaler * scaler; //scaler is proportional to 1/airspeed
|
_last_output = _bodyrate_setpoint * _k_ff * scaler +
|
||||||
|
_rate_error * _k_p * scaler * scaler
|
||||||
|
+ integrator_constrained; //scaler is proportional to 1/airspeed
|
||||||
// warnx("pitch: _integrator: %.4f, _integrator_max: %.4f, airspeed %.4f, _k_i %.4f, _k_p: %.4f", (double)_integrator, (double)_integrator_max, (double)airspeed, (double)_k_i, (double)_k_p);
|
// warnx("pitch: _integrator: %.4f, _integrator_max: %.4f, airspeed %.4f, _k_i %.4f, _k_p: %.4f", (double)_integrator, (double)_integrator_max, (double)airspeed, (double)_k_i, (double)_k_p);
|
||||||
// warnx("roll: _last_output %.4f", (double)_last_output);
|
// warnx("roll: _last_output %.4f", (double)_last_output);
|
||||||
return math::constrain(_last_output, -1.0f, 1.0f);
|
return math::constrain(_last_output, -1.0f, 1.0f);
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ float ECL_RollController::control_bodyrate(float pitch,
|
|||||||
|
|
||||||
if (!lock_integrator && _k_i > 0.0f && airspeed > 0.5f * airspeed_min) {
|
if (!lock_integrator && _k_i > 0.0f && airspeed > 0.5f * airspeed_min) {
|
||||||
|
|
||||||
float id = _rate_error * dt;
|
float id = _rate_error * dt * scaler;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* anti-windup: do not allow integrator to increase if actuator is at limit
|
* anti-windup: do not allow integrator to increase if actuator is at limit
|
||||||
@@ -157,7 +157,9 @@ float ECL_RollController::control_bodyrate(float pitch,
|
|||||||
//warnx("roll: _integrator: %.4f, _integrator_max: %.4f", (double)_integrator, (double)_integrator_max);
|
//warnx("roll: _integrator: %.4f, _integrator_max: %.4f", (double)_integrator, (double)_integrator_max);
|
||||||
|
|
||||||
/* Apply PI rate controller and store non-limited output */
|
/* Apply PI rate controller and store non-limited output */
|
||||||
_last_output = (_bodyrate_setpoint * _k_ff + _rate_error * _k_p + integrator_constrained) * scaler * scaler; //scaler is proportional to 1/airspeed
|
_last_output = _bodyrate_setpoint * _k_ff * scaler +
|
||||||
|
_rate_error * _k_p * scaler * scaler
|
||||||
|
+ integrator_constrained; //scaler is proportional to 1/airspeed
|
||||||
|
|
||||||
return math::constrain(_last_output, -1.0f, 1.0f);
|
return math::constrain(_last_output, -1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ extern struct system_load_s system_load;
|
|||||||
#define POSITION_TIMEOUT (2 * 1000 * 1000) /**< consider the local or global position estimate invalid after 600ms */
|
#define POSITION_TIMEOUT (2 * 1000 * 1000) /**< consider the local or global position estimate invalid after 600ms */
|
||||||
#define FAILSAFE_DEFAULT_TIMEOUT (3 * 1000 * 1000) /**< hysteresis time - the failsafe will trigger after 3 seconds in this state */
|
#define FAILSAFE_DEFAULT_TIMEOUT (3 * 1000 * 1000) /**< hysteresis time - the failsafe will trigger after 3 seconds in this state */
|
||||||
#define RC_TIMEOUT 500000
|
#define RC_TIMEOUT 500000
|
||||||
#define DL_TIMEOUT 5 * 1000* 1000
|
#define DL_TIMEOUT (10 * 1000 * 1000)
|
||||||
#define OFFBOARD_TIMEOUT 500000
|
#define OFFBOARD_TIMEOUT 500000
|
||||||
#define DIFFPRESS_TIMEOUT 2000000
|
#define DIFFPRESS_TIMEOUT 2000000
|
||||||
|
|
||||||
|
|||||||
@@ -218,6 +218,8 @@ Mavlink::Mavlink() :
|
|||||||
errx(1, "instance ID is out of range");
|
errx(1, "instance ID is out of range");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_rstatus.type = TELEMETRY_STATUS_RADIO_TYPE_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mavlink::~Mavlink()
|
Mavlink::~Mavlink()
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ MavlinkReceiver::MavlinkReceiver(Mavlink *parent) :
|
|||||||
_telemetry_status_pub(-1),
|
_telemetry_status_pub(-1),
|
||||||
_rc_pub(-1),
|
_rc_pub(-1),
|
||||||
_manual_pub(-1),
|
_manual_pub(-1),
|
||||||
_radio_status_available(false),
|
|
||||||
_control_mode_sub(orb_subscribe(ORB_ID(vehicle_control_mode))),
|
_control_mode_sub(orb_subscribe(ORB_ID(vehicle_control_mode))),
|
||||||
_hil_frames(0),
|
_hil_frames(0),
|
||||||
_old_timestamp(0),
|
_old_timestamp(0),
|
||||||
@@ -691,9 +690,6 @@ MavlinkReceiver::handle_message_radio_status(mavlink_message_t *msg)
|
|||||||
} else {
|
} else {
|
||||||
orb_publish(telemetry_status_orb_id[_mavlink->get_channel()], _telemetry_status_pub, &tstatus);
|
orb_publish(telemetry_status_orb_id[_mavlink->get_channel()], _telemetry_status_pub, &tstatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this means that heartbeats alone won't be published to the radio status no more */
|
|
||||||
_radio_status_available = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -735,25 +731,17 @@ MavlinkReceiver::handle_message_heartbeat(mavlink_message_t *msg)
|
|||||||
|
|
||||||
struct telemetry_status_s &tstatus = _mavlink->get_rx_status();
|
struct telemetry_status_s &tstatus = _mavlink->get_rx_status();
|
||||||
|
|
||||||
hrt_abstime tnow = hrt_absolute_time();
|
/* set heartbeat time and topic time and publish -
|
||||||
|
* the telem status also gets updated on telemetry events
|
||||||
|
*/
|
||||||
|
tstatus.timestamp = hrt_absolute_time();
|
||||||
|
tstatus.heartbeat_time = tstatus.timestamp;
|
||||||
|
|
||||||
/* always set heartbeat, publish only if telemetry link not up */
|
if (_telemetry_status_pub < 0) {
|
||||||
tstatus.heartbeat_time = tnow;
|
_telemetry_status_pub = orb_advertise(telemetry_status_orb_id[_mavlink->get_channel()], &tstatus);
|
||||||
|
|
||||||
/* if no radio status messages arrive, lets at least publish that heartbeats were received */
|
} else {
|
||||||
if (!_radio_status_available) {
|
orb_publish(telemetry_status_orb_id[_mavlink->get_channel()], _telemetry_status_pub, &tstatus);
|
||||||
|
|
||||||
tstatus.timestamp = tnow;
|
|
||||||
/* telem_time indicates the timestamp of a telemetry status packet and we got none */
|
|
||||||
tstatus.telem_time = 0;
|
|
||||||
tstatus.type = TELEMETRY_STATUS_RADIO_TYPE_GENERIC;
|
|
||||||
|
|
||||||
if (_telemetry_status_pub < 0) {
|
|
||||||
_telemetry_status_pub = orb_advertise(telemetry_status_orb_id[_mavlink->get_channel()], &tstatus);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
orb_publish(telemetry_status_orb_id[_mavlink->get_channel()], _telemetry_status_pub, &tstatus);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,6 @@ private:
|
|||||||
orb_advert_t _telemetry_status_pub;
|
orb_advert_t _telemetry_status_pub;
|
||||||
orb_advert_t _rc_pub;
|
orb_advert_t _rc_pub;
|
||||||
orb_advert_t _manual_pub;
|
orb_advert_t _manual_pub;
|
||||||
bool _radio_status_available;
|
|
||||||
int _control_mode_sub;
|
int _control_mode_sub;
|
||||||
int _hil_frames;
|
int _hil_frames;
|
||||||
uint64_t _old_timestamp;
|
uint64_t _old_timestamp;
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ mag(int argc, char *argv[])
|
|||||||
|
|
||||||
float len = sqrtf(buf.x * buf.x + buf.y * buf.y + buf.z * buf.z);
|
float len = sqrtf(buf.x * buf.x + buf.y * buf.y + buf.z * buf.z);
|
||||||
|
|
||||||
if (len < 1.0f || len > 3.0f) {
|
if (len < 0.25f || len > 3.0f) {
|
||||||
warnx("MAG scale error!");
|
warnx("MAG scale error!");
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user