diff options
author | James Goppert <james.goppert@gmail.com> | 2015-02-11 21:05:40 -0500 |
---|---|---|
committer | James Goppert <james.goppert@gmail.com> | 2015-02-11 21:05:40 -0500 |
commit | 017f3ead475b78459d2e966429dc4c8e4f76ae1b (patch) | |
tree | c021a2a88c62cbbbf01540bcf85839b8b03207ef /src/examples | |
parent | 7ca2553da223bc9be68ad991bbfdd749272fd773 (diff) | |
download | px4-firmware-017f3ead475b78459d2e966429dc4c8e4f76ae1b.tar.gz px4-firmware-017f3ead475b78459d2e966429dc4c8e4f76ae1b.tar.bz2 px4-firmware-017f3ead475b78459d2e966429dc4c8e4f76ae1b.zip |
Flow example fix for divide by zero.
This prevented publishing and made the module unusable.
Diffstat (limited to 'src/examples')
-rw-r--r-- | src/examples/flow_position_estimator/flow_position_estimator_main.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/examples/flow_position_estimator/flow_position_estimator_main.c b/src/examples/flow_position_estimator/flow_position_estimator_main.c index 1ac0c2d04..da4ea825b 100644 --- a/src/examples/flow_position_estimator/flow_position_estimator_main.c +++ b/src/examples/flow_position_estimator/flow_position_estimator_main.c @@ -309,8 +309,13 @@ int flow_position_estimator_thread_main(int argc, char *argv[]) if (vehicle_liftoff || params.debug) { /* copy flow */ - flow_speed[0] = flow.pixel_flow_x_integral / (flow.integration_timespan / 1e6f) * flow.ground_distance_m; - flow_speed[1] = flow.pixel_flow_y_integral / (flow.integration_timespan / 1e6f) * flow.ground_distance_m; + if (flow.integration_timespan > 0) { + flow_speed[0] = flow.pixel_flow_x_integral / (flow.integration_timespan / 1e6f) * flow.ground_distance_m; + flow_speed[1] = flow.pixel_flow_y_integral / (flow.integration_timespan / 1e6f) * flow.ground_distance_m; + } else { + flow_speed[0] = 0; + flow_speed[1] = 0; + } flow_speed[2] = 0.0f; /* convert to bodyframe velocity */ |