mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_Terrain: Add singleton
This commit is contained in:
parent
50b76a27aa
commit
fc9b102b28
@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
|
AP_Terrain *AP_Terrain::singleton;
|
||||||
|
|
||||||
// table of user settable parameters
|
// table of user settable parameters
|
||||||
const AP_Param::GroupInfo AP_Terrain::var_info[] = {
|
const AP_Param::GroupInfo AP_Terrain::var_info[] = {
|
||||||
// @Param: ENABLE
|
// @Param: ENABLE
|
||||||
@ -62,6 +64,13 @@ AP_Terrain::AP_Terrain(const AP_Mission &_mission) :
|
|||||||
fd(-1)
|
fd(-1)
|
||||||
{
|
{
|
||||||
AP_Param::setup_object_defaults(this, var_info);
|
AP_Param::setup_object_defaults(this, var_info);
|
||||||
|
|
||||||
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
||||||
|
if (singleton != nullptr) {
|
||||||
|
AP_HAL::panic("Terrain must be singleton");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
singleton = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -82,6 +82,8 @@ public:
|
|||||||
AP_Terrain(const AP_Terrain &other) = delete;
|
AP_Terrain(const AP_Terrain &other) = delete;
|
||||||
AP_Terrain &operator=(const AP_Terrain&) = delete;
|
AP_Terrain &operator=(const AP_Terrain&) = delete;
|
||||||
|
|
||||||
|
static AP_Terrain *get_singleton(void) { return singleton; }
|
||||||
|
|
||||||
enum TerrainStatus {
|
enum TerrainStatus {
|
||||||
TerrainStatusDisabled = 0, // not enabled
|
TerrainStatusDisabled = 0, // not enabled
|
||||||
TerrainStatusUnhealthy = 1, // no terrain data for current location
|
TerrainStatusUnhealthy = 1, // no terrain data for current location
|
||||||
@ -413,5 +415,7 @@ private:
|
|||||||
|
|
||||||
// status
|
// status
|
||||||
enum TerrainStatus system_status = TerrainStatusDisabled;
|
enum TerrainStatus system_status = TerrainStatusDisabled;
|
||||||
|
|
||||||
|
static AP_Terrain *singleton;
|
||||||
};
|
};
|
||||||
#endif // AP_TERRAIN_AVAILABLE
|
#endif // AP_TERRAIN_AVAILABLE
|
||||||
|
Loading…
Reference in New Issue
Block a user