/* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #if CONFIG_HAL_BOARD == HAL_BOARD_SITL #include "AP_Proximity_AirSimSITL.h" #include extern const AP_HAL::HAL& hal; #define PROXIMITY_MAX_RANGE 100.0f #define PROXIMITY_ACCURACY 0.1f // update the state of the sensor void AP_Proximity_AirSimSITL::update(void) { SITL::vector3f_array &points = sitl->state.scanner.points; if (points.length == 0) { set_status(AP_Proximity::Status::NoData); return; } set_status(AP_Proximity::Status::Good); memset(_distance_valid, 0, sizeof(_distance_valid)); for (uint16_t i=0; i distance_min()) { if (_last_sector == sector) { if (_distance_m_last > distance_m) { _distance_m_last = distance_m; _angle_deg_last = angle_deg; } } else { // new sector started, previous one can be updated _distance_valid[_last_sector] = true; _angle[_last_sector] = _angle_deg_last; _distance[_last_sector] = _distance_m_last; // update boundary update_boundary_for_sector(_last_sector, true); // initialize new sector _last_sector = sector; _distance_m_last = INT16_MAX; _angle_deg_last = angle_deg; } } else { _distance_valid[sector] = false; } } #if 0 printf("npoints=%u\n", points.length); for (uint16_t i=0; i