mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 10:26:52 +08:00
UAVCAN driver: support throttle linearization (THR_MLD_FAC parameter)
Signed-off-by: RomanBapst <bapstroman@gmail.com>
This commit is contained in:
@@ -1178,9 +1178,8 @@ PX4FMU::cycle()
|
|||||||
_mixers->set_max_delta_out_once(delta_out_max);
|
_mixers->set_max_delta_out_once(delta_out_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_thr_mdl_fac > FLT_EPSILON) {
|
|
||||||
_mixers->set_thrust_factor(_thr_mdl_fac);
|
_mixers->set_thrust_factor(_thr_mdl_fac);
|
||||||
}
|
_mixers->set_airmode(_airmode);
|
||||||
|
|
||||||
/* do mixing */
|
/* do mixing */
|
||||||
float outputs[_max_actuators];
|
float outputs[_max_actuators];
|
||||||
@@ -1246,8 +1245,6 @@ PX4FMU::cycle()
|
|||||||
orb_publish_auto(ORB_ID(multirotor_motor_limits), &_to_mixer_status, &motor_limits, &_class_instance, ORB_PRIO_DEFAULT);
|
orb_publish_auto(ORB_ID(multirotor_motor_limits), &_to_mixer_status, &motor_limits, &_class_instance, ORB_PRIO_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
_mixers->set_airmode(_airmode);
|
|
||||||
|
|
||||||
// use first valid timestamp_sample for latency tracking
|
// use first valid timestamp_sample for latency tracking
|
||||||
for (int i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) {
|
for (int i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) {
|
||||||
const bool required = _groups_required & (1 << i);
|
const bool required = _groups_required & (1 << i);
|
||||||
|
|||||||
@@ -425,6 +425,12 @@ void UavcanNode::update_params()
|
|||||||
if (param_handle != PARAM_INVALID) {
|
if (param_handle != PARAM_INVALID) {
|
||||||
param_get(param_handle, &_airmode);
|
param_get(param_handle, &_airmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
param_handle = param_find("THR_MDL_FAC");
|
||||||
|
|
||||||
|
if (param_handle != PARAM_INVALID) {
|
||||||
|
param_get(param_handle, &_thr_mdl_factor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int UavcanNode::start_fw_server()
|
int UavcanNode::start_fw_server()
|
||||||
@@ -905,6 +911,7 @@ int UavcanNode::run()
|
|||||||
// but this driver could well serve multiple groups.
|
// but this driver could well serve multiple groups.
|
||||||
unsigned num_outputs_max = 8;
|
unsigned num_outputs_max = 8;
|
||||||
|
|
||||||
|
_mixers->set_thrust_factor(_thr_mdl_factor);
|
||||||
_mixers->set_airmode(_airmode);
|
_mixers->set_airmode(_airmode);
|
||||||
|
|
||||||
// Do mixing
|
// Do mixing
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ private:
|
|||||||
perf_counter_t _perf_control_latency;
|
perf_counter_t _perf_control_latency;
|
||||||
|
|
||||||
Mixer::Airmode _airmode = Mixer::Airmode::disabled;
|
Mixer::Airmode _airmode = Mixer::Airmode::disabled;
|
||||||
|
float _thr_mdl_factor = 0.0f;
|
||||||
|
|
||||||
// index into _poll_fds for each _control_subs handle
|
// index into _poll_fds for each _control_subs handle
|
||||||
uint8_t _poll_ids[NUM_ACTUATOR_CONTROL_GROUPS_UAVCAN];
|
uint8_t _poll_ids[NUM_ACTUATOR_CONTROL_GROUPS_UAVCAN];
|
||||||
|
|||||||
@@ -128,6 +128,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <lib/mathlib/mathlib.h>
|
||||||
|
|
||||||
/** simple channel scaler */
|
/** simple channel scaler */
|
||||||
struct mixer_scaler_s {
|
struct mixer_scaler_s {
|
||||||
@@ -707,7 +708,10 @@ public:
|
|||||||
*
|
*
|
||||||
* @param[in] val The value
|
* @param[in] val The value
|
||||||
*/
|
*/
|
||||||
void set_thrust_factor(float val) override { _thrust_factor = val; }
|
void set_thrust_factor(float val) override
|
||||||
|
{
|
||||||
|
_thrust_factor = math::constrain(val, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
void set_airmode(Airmode airmode) override;
|
void set_airmode(Airmode airmode) override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user