AP_RangeFinder: enable SITL rangefinder for sim-on-hardware

This commit is contained in:
Peter Barker 2022-05-23 19:27:35 +10:00 committed by Andrew Tridgell
parent 73190d075a
commit 51246fda45
3 changed files with 16 additions and 8 deletions

View File

@ -565,7 +565,7 @@ void RangeFinder::detect_instance(uint8_t instance, uint8_t& serial_instance)
break;
case Type::SIM:
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#if AP_SIM_RANGEFINDER_ENABLED
_add_backend(new AP_RangeFinder_SITL(state[instance], params[instance], instance), instance);
#endif
break;

View File

@ -12,12 +12,13 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <AP_HAL/AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#include "AP_RangeFinder_SITL.h"
#if AP_SIM_RANGEFINDER_ENABLED
#include <AP_HAL/AP_HAL.h>
extern const AP_HAL::HAL& hal;
/*
@ -49,4 +50,5 @@ void AP_RangeFinder_SITL::update(void)
update_status();
}
#endif
#endif // AP_SIM_RANGEFINDER_ENABLED

View File

@ -14,9 +14,15 @@
*/
#pragma once
#include "AP_RangeFinder_Backend.h"
#include <AP_BoardConfig/AP_BoardConfig.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#ifndef AP_SIM_RANGEFINDER_ENABLED
#define AP_SIM_RANGEFINDER_ENABLED (AP_SIM_ENABLED && !defined(HAL_BUILD_AP_PERIPH))
#endif
#if AP_SIM_RANGEFINDER_ENABLED
#include "AP_RangeFinder_Backend.h"
#include <SITL/SITL.h>
@ -41,4 +47,4 @@ private:
};
#endif
#endif // AP_SIM_RANGEFINDER_ENABLED