diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2014-12-28 21:57:30 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2014-12-28 22:55:04 +0100 |
commit | ef8abfbf148ac6fd7a405acdd4ee8eeb156867b6 (patch) | |
tree | 75455befdabb36c3269f9281f78a6cfe04ae8e11 /src/modules/sensors | |
parent | e9b41528dc39ac8a8c565a4c16fc5aa512e37b1a (diff) | |
download | px4-firmware-ef8abfbf148ac6fd7a405acdd4ee8eeb156867b6.tar.gz px4-firmware-ef8abfbf148ac6fd7a405acdd4ee8eeb156867b6.tar.bz2 px4-firmware-ef8abfbf148ac6fd7a405acdd4ee8eeb156867b6.zip |
rc2param: min and max values
Diffstat (limited to 'src/modules/sensors')
-rw-r--r-- | src/modules/sensors/sensors.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/modules/sensors/sensors.cpp b/src/modules/sensors/sensors.cpp index d404d8a4c..3fa1575f0 100644 --- a/src/modules/sensors/sensors.cpp +++ b/src/modules/sensors/sensors.cpp @@ -1440,11 +1440,13 @@ Sensors::rc_parameter_map_poll(bool forced) } warnx("rc to parameter map updated"); for (int i = 0; i < RC_PARAM_MAP_NCHAN; i++) { - warnx("\ti %d param_id %s scale %.3f value0 %.3f", + warnx("\ti %d param_id %s scale %.3f value0 %.3f, min %.3f, max %.3f", i, _rc_parameter_map.param_id[i], (double)_rc_parameter_map.scale[i], - (double)_rc_parameter_map.value0[i] + (double)_rc_parameter_map.value0[i], + (double)_rc_parameter_map.value_min[i], + (double)_rc_parameter_map.value_max[i] ); } } @@ -1645,7 +1647,9 @@ Sensors::set_params_from_rc() * maybe we need to introduce a more aggressive limit here */ if (rc_val > param_rc_values[i] + FLT_EPSILON || rc_val < param_rc_values[i] - FLT_EPSILON) { param_rc_values[i] = rc_val; - float param_val = _rc_parameter_map.value0[i] + _rc_parameter_map.scale[i] * rc_val; + float param_val = math::constrain( + _rc_parameter_map.value0[i] + _rc_parameter_map.scale[i] * rc_val, + _rc_parameter_map.value_min[i], _rc_parameter_map.value_max[i]); param_set(_parameter_handles.rc_param[i], ¶m_val); } } |