2016-11-14 00:48:38 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "AP_Proximity.h"
|
|
|
|
#include "AP_Proximity_Backend.h"
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
|
|
|
#include <SITL/SITL.h>
|
|
|
|
#include <AC_Fence/AC_PolyFence_loader.h>
|
|
|
|
|
|
|
|
class AP_Proximity_SITL : public AP_Proximity_Backend
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
AP_Proximity_SITL(AP_Proximity &_frontend, AP_Proximity::Proximity_State &_state);
|
|
|
|
|
|
|
|
// update state
|
|
|
|
void update(void) override;
|
|
|
|
|
2016-11-25 01:01:21 -04:00
|
|
|
// get maximum and minimum distances (in meters) of sensor
|
|
|
|
float distance_max() const;
|
|
|
|
float distance_min() const;
|
|
|
|
|
2017-01-16 02:58:14 -04:00
|
|
|
// get distance upwards in meters. returns true on success
|
|
|
|
bool get_upward_distance(float &distance) const;
|
|
|
|
|
2016-11-14 00:48:38 -04:00
|
|
|
private:
|
|
|
|
SITL::SITL *sitl;
|
|
|
|
Vector2l *fence;
|
|
|
|
AP_Int8 *fence_count;
|
2017-01-16 02:58:14 -04:00
|
|
|
AP_Float *fence_alt_max;
|
2016-11-14 00:48:38 -04:00
|
|
|
uint32_t last_load_ms;
|
|
|
|
AC_PolyFence_loader fence_loader;
|
|
|
|
Location current_loc;
|
2016-11-15 03:12:45 -04:00
|
|
|
|
|
|
|
// latest sector updated
|
|
|
|
uint8_t last_sector;
|
|
|
|
|
2016-11-14 00:48:38 -04:00
|
|
|
void load_fence(void);
|
2016-11-15 03:12:45 -04:00
|
|
|
|
|
|
|
// get distance in meters to fence in a particular direction in degrees (0 is forward, angles increase in the clockwise direction)
|
|
|
|
bool get_distance_to_fence(float angle_deg, float &distance) const;
|
|
|
|
|
2016-11-14 00:48:38 -04:00
|
|
|
};
|
|
|
|
#endif // CONFIG_HAL_BOARD
|