From 017f3ead475b78459d2e966429dc4c8e4f76ae1b Mon Sep 17 00:00:00 2001 From: James Goppert Date: Wed, 11 Feb 2015 21:05:40 -0500 Subject: Flow example fix for divide by zero. This prevented publishing and made the module unusable. --- .../flow_position_estimator/flow_position_estimator_main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/examples') 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 */ -- cgit v1.2.3