diff --git a/quad/src/quad_app/control_algorithm.c b/quad/src/quad_app/control_algorithm.c index 3af6711615a34a8d24e2103215e79026afd9cdc2..c58886dd39e3fb0e83a3195c76eeba4a60b8cfc5 100644 --- a/quad/src/quad_app/control_algorithm.c +++ b/quad/src/quad_app/control_algorithm.c @@ -14,6 +14,7 @@ #include "timer.h" //#define USE_LIDAR +#define MAX_VALID_LIDAR (10.0) // Maximum valid distance to read from LiDAR to update #define PX4FLOW_QUAL_MIN (100) #define OF_OFFSET_ANGLE (-0.62204) // -35.64 degrees @@ -388,7 +389,9 @@ int control_algorithm_init(parameter_t * ps) graph_set_param_val(graph, ps->gyro_y, CONST_SET, sensor_struct->gyr_y); graph_set_param_val(graph, ps->gyro_x, CONST_SET, sensor_struct->gyr_x); graph_set_param_val(graph, ps->gyro_z, CONST_SET, sensor_struct->gyr_z); - graph_set_param_val(graph, ps->lidar, CONST_SET, sensor_struct->lidar_altitude); + if (fabs(sensor_struct->lidar_altitude) <= MAX_VALID_LIDAR) { + graph_set_param_val(graph, ps->lidar, CONST_SET, sensor_struct->lidar_altitude); + } graph_set_param_val(graph, ps->flow_quality, CONST_SET, sensor_struct->optical_flow.quality); //As per documentation, disregard frames with low quality, as they contain unreliable data if (sensor_struct->optical_flow.quality >= PX4FLOW_QUAL_MIN) {