From 3010f313dc2e291d3b2f1f6022f132ce227b1895 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 4 Mar 2015 09:04:01 +0100 Subject: [PATCH 01/12] Fix IO update when safety can not be set to on. From @zottgrammes Conflicts: ROMFS/px4fmu_common/init.d/rcS --- ROMFS/px4fmu_common/init.d/rcS | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index 580043a1d4..816b1152fe 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -198,8 +198,17 @@ then tone_alarm MLL32CP8MB - px4io start - px4io safety_on + if px4io start + then + # try to safe px4 io so motor outputs dont go crazy + if px4io safety_on + then + # success! no-op + else + # px4io did not respond to the safety command + px4io stop + fi + fi if px4io forceupdate 14662 ${IO_FILE} then From ec85918e40085f3e6133712317fa7a89fad2904f Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 4 Jul 2015 11:39:12 +0200 Subject: [PATCH 02/12] Set better defaults for fixed wing attitude controllers --- src/modules/fw_att_control/fw_att_control_params.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/fw_att_control/fw_att_control_params.c b/src/modules/fw_att_control/fw_att_control_params.c index d9ccd8bac8..234ff0c3fb 100644 --- a/src/modules/fw_att_control/fw_att_control_params.c +++ b/src/modules/fw_att_control/fw_att_control_params.c @@ -64,7 +64,7 @@ * @max 1.0 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_ATT_TC, 0.5f); +PARAM_DEFINE_FLOAT(FW_ATT_TC, 0.4f); /** * Pitch rate proportional gain. @@ -76,7 +76,7 @@ PARAM_DEFINE_FLOAT(FW_ATT_TC, 0.5f); * @max 1.0 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_PR_P, 0.05f); +PARAM_DEFINE_FLOAT(FW_PR_P, 0.08f); /** * Pitch rate integrator gain. @@ -88,7 +88,7 @@ PARAM_DEFINE_FLOAT(FW_PR_P, 0.05f); * @max 50.0 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_PR_I, 0.0f); +PARAM_DEFINE_FLOAT(FW_PR_I, 0.005f); /** * Maximum positive / up pitch rate. @@ -126,7 +126,7 @@ PARAM_DEFINE_FLOAT(FW_P_RMAX_NEG, 0.0f); * @max 1.0 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_PR_IMAX, 0.2f); +PARAM_DEFINE_FLOAT(FW_PR_IMAX, 0.4f); /** * Roll to Pitch feedforward gain. @@ -161,7 +161,7 @@ PARAM_DEFINE_FLOAT(FW_RR_P, 0.05f); * @max 100.0 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_RR_I, 0.0f); +PARAM_DEFINE_FLOAT(FW_RR_I, 0.005f); /** * Roll Integrator Anti-Windup @@ -247,7 +247,7 @@ PARAM_DEFINE_FLOAT(FW_Y_RMAX, 0.0f); * @max 10.0 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_RR_FF, 0.3f); +PARAM_DEFINE_FLOAT(FW_RR_FF, 0.5f); /** * Pitch rate feed forward From 3671ce716ad820a4d4a5d0e6c498cad9a55ce945 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 4 Jul 2015 11:39:31 +0200 Subject: [PATCH 03/12] Set better defaults for fixed wing position controllers --- .../fw_pos_control_l1_params.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c b/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c index c00d822327..78d66afe1e 100644 --- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c +++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c @@ -58,7 +58,7 @@ * @max 100.0 * @group L1 Control */ -PARAM_DEFINE_FLOAT(FW_L1_PERIOD, 25.0f); +PARAM_DEFINE_FLOAT(FW_L1_PERIOD, 20.0f); /** * L1 damping @@ -80,7 +80,7 @@ PARAM_DEFINE_FLOAT(FW_L1_DAMPING, 0.75f); * @max 1.0 * @group L1 Control */ -PARAM_DEFINE_FLOAT(FW_THR_CRUISE, 0.7f); +PARAM_DEFINE_FLOAT(FW_THR_CRUISE, 0.6f); /** * Throttle max slew rate @@ -123,10 +123,11 @@ PARAM_DEFINE_FLOAT(FW_P_LIM_MAX, 45.0f); * The maximum roll the controller will output. * * @unit degrees - * @min 0.0 + * @min 35.0 + * @max 65.0 * @group L1 Control */ -PARAM_DEFINE_FLOAT(FW_R_LIM, 45.0f); +PARAM_DEFINE_FLOAT(FW_R_LIM, 50.0f); /** * Throttle limit max @@ -151,6 +152,8 @@ PARAM_DEFINE_FLOAT(FW_THR_MAX, 1.0f); * For aircraft with internal combustion engine this parameter should be set * for desired idle rpm. * + * @min 0.0 + * @max 1.0 * @group L1 Control */ PARAM_DEFINE_FLOAT(FW_THR_MIN, 0.0f); @@ -161,6 +164,8 @@ PARAM_DEFINE_FLOAT(FW_THR_MIN, 0.0f); * This throttle value will be set as throttle limit at FW_LND_TLALT, * before arcraft will flare. * + * @min 0.0 + * @max 1.0 * @group L1 Control */ PARAM_DEFINE_FLOAT(FW_THR_LND_MAX, 1.0f); @@ -173,6 +178,8 @@ PARAM_DEFINE_FLOAT(FW_THR_LND_MAX, 1.0f); * distance to the desired altitude. Mostly used for takeoff waypoints / modes. * Set to zero to disable climbout mode (not recommended). * + * @min 0.0 + * @max 150.0 * @group L1 Control */ PARAM_DEFINE_FLOAT(FW_CLMBOUT_DIFF, 25.0f); @@ -193,6 +200,8 @@ PARAM_DEFINE_FLOAT(FW_CLMBOUT_DIFF, 25.0f); * FW_THR_MAX, then either FW_T_CLMB_MAX should be increased or * FW_THR_MAX reduced. * + * @min 2.0 + * @max 10.0 * @group L1 Control */ PARAM_DEFINE_FLOAT(FW_T_CLMB_MAX, 5.0f); From 134f3d8858b373e69aba461d410dfa69e652fff9 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 4 Jul 2015 11:39:54 +0200 Subject: [PATCH 04/12] Wing wing config: Remove tuning gains which are close to the defaults --- ROMFS/px4fmu_common/init.d/3033_wingwing | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/3033_wingwing b/ROMFS/px4fmu_common/init.d/3033_wingwing index 708c34491b..3c2312fc7d 100644 --- a/ROMFS/px4fmu_common/init.d/3033_wingwing +++ b/ROMFS/px4fmu_common/init.d/3033_wingwing @@ -23,12 +23,7 @@ then param set FW_LND_TLALT 5 param set FW_THR_LND_MAX 0 param set FW_PR_FF 0.35 - param set FW_PR_I 0.005 - param set FW_PR_IMAX 0.4 - param set FW_PR_P 0.08 param set FW_RR_FF 0.6 - param set FW_RR_I 0.005 - param set FW_RR_IMAX 0.2 param set FW_RR_P 0.04 fi From 939d475ef24cb02dee5b9d267995f85791128ba4 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 4 Jul 2015 11:59:10 +0200 Subject: [PATCH 05/12] Output flaps in all flight modes --- .../fw_att_control/fw_att_control_main.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/modules/fw_att_control/fw_att_control_main.cpp b/src/modules/fw_att_control/fw_att_control_main.cpp index ccf12a0791..9cbbe80cc3 100644 --- a/src/modules/fw_att_control/fw_att_control_main.cpp +++ b/src/modules/fw_att_control/fw_att_control_main.cpp @@ -803,6 +803,14 @@ FixedwingAttitudeControl::task_main() //warnx("_actuators_airframe.control[1] = -1.0f;"); } + /* default flaps to center */ + float flaps_control = 0.0f; + + /* map flaps by default to manual if valid */ + if (isfinite(_manual.flaps)) { + flaps_control = _manual.flaps; + } + /* decide if in stabilized or full manual control */ if (_vcontrol_mode.flag_control_attitude_enabled) { @@ -922,7 +930,6 @@ FixedwingAttitudeControl::task_main() /* allow manual control of rudder deflection */ yaw_manual = _manual.r; throttle_sp = _manual.z; - _actuators.control[4] = _manual.flaps; /* * in manual mode no external source should / does emit attitude setpoints. @@ -1085,13 +1092,13 @@ FixedwingAttitudeControl::task_main() } else { /* manual/direct control */ - _actuators.control[0] = _manual.y + _parameters.trim_roll; - _actuators.control[1] = -_manual.x + _parameters.trim_pitch; - _actuators.control[2] = _manual.r + _parameters.trim_yaw; - _actuators.control[3] = _manual.z; - _actuators.control[4] = _manual.flaps; + _actuators.control[actuator_controls_s::INDEX_ROLL] = _manual.y + _parameters.trim_roll; + _actuators.control[actuator_controls_s::INDEX_PITCH] = -_manual.x + _parameters.trim_pitch; + _actuators.control[actuator_controls_s::INDEX_YAW] = _manual.r + _parameters.trim_yaw; + _actuators.control[actuator_controls_s::INDEX_THROTTLE] = _manual.z; } + _actuators.control[actuator_controls_s::INDEX_FLAPS] = flaps_control; _actuators.control[5] = _manual.aux1; _actuators.control[6] = _manual.aux2; _actuators.control[7] = _manual.aux3; From 4372701dab5958253325baf4dbcbdafb5ec5f147 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 4 Jul 2015 17:24:55 +0200 Subject: [PATCH 06/12] EKF: Fix entirely unnecessary C++11 dependency --- .../estimator_utilities.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp b/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp index 284a099023..527420ba0b 100644 --- a/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp +++ b/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp @@ -38,7 +38,6 @@ */ #include "estimator_utilities.h" -#include // Define EKF_DEBUG here to enable the debug print calls // if the macro is not set, these will be completely @@ -72,6 +71,9 @@ ekf_debug(const char *fmt, ...) void ekf_debug(const char *fmt, ...) { while(0){} } #endif +/* we don't want to pull in the standard lib just to swap two floats */ +void swap_var(float &d1, float &d2); + float Vector3f::length(void) const { return sqrt(x*x + y*y + z*z); @@ -108,9 +110,9 @@ void Mat3f::identity() { Mat3f Mat3f::transpose() const { Mat3f ret = *this; - std::swap(ret.x.y, ret.y.x); - std::swap(ret.x.z, ret.z.x); - std::swap(ret.y.z, ret.z.y); + swap_var(ret.x.y, ret.y.x); + swap_var(ret.x.z, ret.z.x); + swap_var(ret.y.z, ret.z.y); return ret; } @@ -223,3 +225,10 @@ Vector3f operator/(const Vector3f &vec, const float scalar) vecOut.z = vec.z / scalar; return vecOut; } + +void swap_var(float &d1, float &d2) +{ + float tmp = d1; + d1 = d2; + d2 = tmp; +} From dac74db104f8fda5bd3b8b68f3b7f45878a27865 Mon Sep 17 00:00:00 2001 From: Simon Laube Date: Tue, 30 Jun 2015 17:53:19 +0200 Subject: [PATCH 07/12] change the nested if structure which tries all i2c busses to a loop. --- src/drivers/px4flow/px4flow.cpp | 81 ++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/src/drivers/px4flow/px4flow.cpp b/src/drivers/px4flow/px4flow.cpp index 2166258c15..8bf20290ca 100644 --- a/src/drivers/px4flow/px4flow.cpp +++ b/src/drivers/px4flow/px4flow.cpp @@ -616,65 +616,74 @@ start() errx(1, "already started"); } - /* create the driver */ - g_dev = new PX4FLOW(PX4_I2C_BUS_EXPANSION); - - if (g_dev == nullptr) { - goto fail; - } - - if (OK != g_dev->init()) { - + const int busses_to_try[] = { + PX4_I2C_BUS_EXPANSION, #ifdef PX4_I2C_BUS_ESC - delete g_dev; - /* try 2nd bus */ - g_dev = new PX4FLOW(PX4_I2C_BUS_ESC); + PX4_I2C_BUS_ESC, + #endif + PX4_I2C_BUS_ONBOARD, + -1 + }; + const int *cur_bus = busses_to_try; + while(*cur_bus != -1) { + /* create the driver */ + //warnx("trying bus %d", *cur_bus); + g_dev = new PX4FLOW(*cur_bus); if (g_dev == nullptr) { - goto fail; + /* this is a fatal error */ + break; } - - if (OK != g_dev->init()) { - #endif - - delete g_dev; - /* try 3rd bus */ - g_dev = new PX4FLOW(PX4_I2C_BUS_ONBOARD); - - if (g_dev == nullptr) { - goto fail; - } - - if (OK != g_dev->init()) { - goto fail; - } - - #ifdef PX4_I2C_BUS_ESC + + /* init the driver: */ + if (OK == g_dev->init()) { + /* success! */ + break; } - #endif + + /* destroy it again because it failed. */ + delete g_dev; + g_dev = nullptr; + + /* try next! */ + cur_bus++; } - + + /* check whether we found it: */ + if (*cur_bus == -1) { + goto not_found; + } + + /* check for failure: */ + if (g_dev == nullptr) { + goto fatal_fail; + } + /* set the poll rate to default, starts automatic data collection */ fd = open(PX4FLOW0_DEVICE_PATH, O_RDONLY); if (fd < 0) { - goto fail; + goto fatal_fail; } if (ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_MAX) < 0) { - goto fail; + goto fatal_fail; } exit(0); -fail: +not_found: + /* for now we do the same as if there was a fatal failure. */ + warnx("PX4FLOW not found on I2C busses"); + +fatal_fail: if (g_dev != nullptr) { delete g_dev; g_dev = nullptr; } - errx(1, "no PX4FLOW connected over I2C"); + errx(1, "PX4FLOW could not be started over I2C"); } /** From d9e6cb0f584f6e4016688a12a03e641af47cff4a Mon Sep 17 00:00:00 2001 From: Simon Laube Date: Tue, 30 Jun 2015 18:28:19 +0200 Subject: [PATCH 08/12] implemented retrying the connection to the px4flow sensor before giving up. --- src/drivers/px4flow/px4flow.cpp | 133 ++++++++++++++++++-------------- 1 file changed, 76 insertions(+), 57 deletions(-) diff --git a/src/drivers/px4flow/px4flow.cpp b/src/drivers/px4flow/px4flow.cpp index 8bf20290ca..8ee365d8df 100644 --- a/src/drivers/px4flow/px4flow.cpp +++ b/src/drivers/px4flow/px4flow.cpp @@ -596,7 +596,11 @@ namespace px4flow #endif const int ERROR = -1; -PX4FLOW *g_dev; +PX4FLOW *g_dev = nullptr; +bool start_in_progress = false; + +const int START_RETRY_COUNT = 5; +const int START_RETRY_TIMEOUT = 1000; void start(); void stop(); @@ -611,78 +615,93 @@ void start() { int fd; + + /* entry check: */ + if (start_in_progress) { + errx(1, "start in progress"); + } + start_in_progress = true; if (g_dev != nullptr) { + start_in_progress = false; errx(1, "already started"); } - const int busses_to_try[] = { - PX4_I2C_BUS_EXPANSION, - #ifdef PX4_I2C_BUS_ESC - PX4_I2C_BUS_ESC, - #endif - PX4_I2C_BUS_ONBOARD, - -1 - }; + int retry_nr = 0; + while (1) { + const int busses_to_try[] = { + PX4_I2C_BUS_EXPANSION, + #ifdef PX4_I2C_BUS_ESC + PX4_I2C_BUS_ESC, + #endif + PX4_I2C_BUS_ONBOARD, + -1 + }; - const int *cur_bus = busses_to_try; - while(*cur_bus != -1) { - /* create the driver */ - //warnx("trying bus %d", *cur_bus); - g_dev = new PX4FLOW(*cur_bus); - if (g_dev == nullptr) { - /* this is a fatal error */ - break; + const int *cur_bus = busses_to_try; + + while(*cur_bus != -1) { + /* create the driver */ + /* warnx("trying bus %d", *cur_bus); */ + g_dev = new PX4FLOW(*cur_bus); + if (g_dev == nullptr) { + /* this is a fatal error */ + break; + } + + /* init the driver: */ + if (OK == g_dev->init()) { + /* success! */ + break; + } + + /* destroy it again because it failed. */ + delete g_dev; + g_dev = nullptr; + + /* try next! */ + cur_bus++; } - - /* init the driver: */ - if (OK == g_dev->init()) { + + /* check whether we found it: */ + if (*cur_bus != -1) { + + /* check for failure: */ + if (g_dev == nullptr) { + break; + } + + /* set the poll rate to default, starts automatic data collection */ + fd = open(PX4FLOW0_DEVICE_PATH, O_RDONLY); + + if (fd < 0) { + break; + } + + if (ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_MAX) < 0) { + break; + } + /* success! */ + start_in_progress = false; + exit(0); + } + + if (retry_nr < START_RETRY_COUNT) { + warnx("PX4FLOW not found on I2C busses. Retrying in %d ms. Giving up in %d retries.", START_RETRY_TIMEOUT, START_RETRY_COUNT - retry_nr); + usleep(START_RETRY_TIMEOUT * 1000); + retry_nr++; + } else { break; } - - /* destroy it again because it failed. */ - delete g_dev; - g_dev = nullptr; - - /* try next! */ - cur_bus++; } - /* check whether we found it: */ - if (*cur_bus == -1) { - goto not_found; - } - - /* check for failure: */ - if (g_dev == nullptr) { - goto fatal_fail; - } - - /* set the poll rate to default, starts automatic data collection */ - fd = open(PX4FLOW0_DEVICE_PATH, O_RDONLY); - - if (fd < 0) { - goto fatal_fail; - } - - if (ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_MAX) < 0) { - goto fatal_fail; - } - - exit(0); - -not_found: - /* for now we do the same as if there was a fatal failure. */ - warnx("PX4FLOW not found on I2C busses"); - -fatal_fail: - if (g_dev != nullptr) { delete g_dev; g_dev = nullptr; } - + + start_in_progress = false; errx(1, "PX4FLOW could not be started over I2C"); } From 440aedebadc3db8ee750736ab297b25a4c04ec4a Mon Sep 17 00:00:00 2001 From: Simon Laube Date: Tue, 30 Jun 2015 21:10:48 +0200 Subject: [PATCH 09/12] change start script to launch the px4flow driver in background. Fixes issue #2145 --- ROMFS/px4fmu_common/init.d/rc.sensors | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/rc.sensors b/ROMFS/px4fmu_common/init.d/rc.sensors index 474db36ef7..e5d527dd71 100644 --- a/ROMFS/px4fmu_common/init.d/rc.sensors +++ b/ROMFS/px4fmu_common/init.d/rc.sensors @@ -111,7 +111,7 @@ else fi # Check for flow sensor -if px4flow start +if px4flow start & then fi From cf8307f039f328a42afc719fe1a74492c7edb527 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 4 Jul 2015 18:57:59 +0200 Subject: [PATCH 10/12] Commander: Low-pass battery throttle to better match battery dynamics --- src/modules/commander/commander_helper.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/commander/commander_helper.cpp b/src/modules/commander/commander_helper.cpp index 68949eec1d..491ce32a5c 100644 --- a/src/modules/commander/commander_helper.cpp +++ b/src/modules/commander/commander_helper.cpp @@ -108,6 +108,7 @@ static float bat_v_load_drop = 0.06f; static int bat_n_cells = 3; static float bat_capacity = -1.0f; static unsigned int counter = 0; +static float throttle_lowpassed = 0.0f; int battery_init() { @@ -381,8 +382,15 @@ float battery_remaining_estimate_voltage(float voltage, float discharged, float counter++; + // XXX this time constant needs to become tunable + // but really, the right fix are smart batteries. + float val = throttle_lowpassed * 0.97f + throttle_normalized * 0.03f; + if (isfinite(val)) { + throttle_lowpassed = val; + } + /* remaining charge estimate based on voltage and internal resistance (drop under load) */ - float bat_v_empty_dynamic = bat_v_empty - (bat_v_load_drop * throttle_normalized); + float bat_v_empty_dynamic = bat_v_empty - (bat_v_load_drop * throttle_lowpassed); /* the range from full to empty is the same for batteries under load and without load, * since the voltage drop applies to both the full and empty state */ From 6e0aa90bb832d4cf9a0d5e3619914f91109cbe7b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 4 Jul 2015 18:57:59 +0200 Subject: [PATCH 11/12] Commander: Low-pass battery throttle to better match battery dynamics --- src/modules/commander/commander_helper.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/commander/commander_helper.cpp b/src/modules/commander/commander_helper.cpp index 68949eec1d..491ce32a5c 100644 --- a/src/modules/commander/commander_helper.cpp +++ b/src/modules/commander/commander_helper.cpp @@ -108,6 +108,7 @@ static float bat_v_load_drop = 0.06f; static int bat_n_cells = 3; static float bat_capacity = -1.0f; static unsigned int counter = 0; +static float throttle_lowpassed = 0.0f; int battery_init() { @@ -381,8 +382,15 @@ float battery_remaining_estimate_voltage(float voltage, float discharged, float counter++; + // XXX this time constant needs to become tunable + // but really, the right fix are smart batteries. + float val = throttle_lowpassed * 0.97f + throttle_normalized * 0.03f; + if (isfinite(val)) { + throttle_lowpassed = val; + } + /* remaining charge estimate based on voltage and internal resistance (drop under load) */ - float bat_v_empty_dynamic = bat_v_empty - (bat_v_load_drop * throttle_normalized); + float bat_v_empty_dynamic = bat_v_empty - (bat_v_load_drop * throttle_lowpassed); /* the range from full to empty is the same for batteries under load and without load, * since the voltage drop applies to both the full and empty state */ From a74cc5bf494b05f48e796190d3ea3e43c849aa31 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 4 Jul 2015 19:07:08 +0200 Subject: [PATCH 12/12] MAVLink app: Fix scaling of battery current --- src/modules/mavlink/mavlink_messages.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/mavlink/mavlink_messages.cpp b/src/modules/mavlink/mavlink_messages.cpp index 0b6dfcab5f..cb56331e95 100644 --- a/src/modules/mavlink/mavlink_messages.cpp +++ b/src/modules/mavlink/mavlink_messages.cpp @@ -537,7 +537,7 @@ protected: msg.onboard_control_sensors_health = status.onboard_control_sensors_health; msg.load = status.load * 1000.0f; msg.voltage_battery = status.battery_voltage * 1000.0f; - msg.current_battery = status.battery_current * 100.0f; + msg.current_battery = status.battery_current / 10.0f; msg.drop_rate_comm = status.drop_rate_comm; msg.errors_comm = status.errors_comm; msg.errors_count1 = status.errors_count1; @@ -562,7 +562,7 @@ protected: bat_msg.voltages[i] = 0; } } - bat_msg.current_battery = status.battery_current * 100.0f; + bat_msg.current_battery = status.battery_current / 10.0f; bat_msg.current_consumed = status.battery_discharged_mah; bat_msg.energy_consumed = -1.0f; bat_msg.battery_remaining = (status.battery_voltage > 0) ?