mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 21:23:33 +08:00
MC mixer input limiting implemented.
This commit is contained in:
@@ -67,6 +67,11 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
float constrain(float val, float min, float max)
|
||||||
|
{
|
||||||
|
return (val < min) ? min : ((val > max) ? max : val);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These tables automatically generated by multi_tables - do not edit.
|
* These tables automatically generated by multi_tables - do not edit.
|
||||||
*/
|
*/
|
||||||
@@ -276,11 +281,11 @@ MultirotorMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handl
|
|||||||
unsigned
|
unsigned
|
||||||
MultirotorMixer::mix(float *outputs, unsigned space)
|
MultirotorMixer::mix(float *outputs, unsigned space)
|
||||||
{
|
{
|
||||||
float roll = get_control(0, 0) * _roll_scale;
|
float roll = constrain(get_control(0, 0) * _roll_scale, -1.0f, 1.0f);
|
||||||
//lowsyslog("roll: %d, get_control0: %d, %d\n", (int)(roll), (int)(get_control(0, 0)), (int)(_roll_scale));
|
//lowsyslog("roll: %d, get_control0: %d, %d\n", (int)(roll), (int)(get_control(0, 0)), (int)(_roll_scale));
|
||||||
float pitch = get_control(0, 1) * _pitch_scale;
|
float pitch = constrain(get_control(0, 1) * _pitch_scale, -1.0f, 1.0f);
|
||||||
float yaw = get_control(0, 2) * _yaw_scale;
|
float yaw = constrain(get_control(0, 2) * _yaw_scale, -1.0f, 1.0f);
|
||||||
float thrust = get_control(0, 3);
|
float thrust = constrain(get_control(0, 3), 0.0f, 1.0f);
|
||||||
//lowsyslog("thrust: %d, get_control3: %d\n", (int)(thrust), (int)(get_control(0, 3)));
|
//lowsyslog("thrust: %d, get_control3: %d\n", (int)(thrust), (int)(get_control(0, 3)));
|
||||||
float min_out = 0.0f;
|
float min_out = 0.0f;
|
||||||
float max_out = 0.0f;
|
float max_out = 0.0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user