93 #if CONFIG_HAL_BOARD == HAL_BOARD_SITL 245 for (uint8_t index = 0; index <
num_beacons; index++) {
247 beacon_points[index].
x = point_3d.
x;
248 beacon_points[index].
y = point_3d.
y;
259 uint8_t curr_boundary_idx = 0;
260 uint8_t curr_beacon_idx = 0;
263 boundary_points[curr_boundary_idx] = beacon_points[curr_beacon_idx];
265 bool boundary_success =
false;
266 bool boundary_failure =
false;
267 float start_angle = 0.0f;
268 while (!boundary_success && !boundary_failure) {
275 boundary_points[curr_boundary_idx] = beacon_points[next_idx];
276 curr_beacon_idx = next_idx;
277 start_angle = next_angle;
281 bool dup_found =
false;
282 while (dup_idx < curr_boundary_idx && !dup_found) {
283 dup_found = (boundary_points[dup_idx] == boundary_points[curr_boundary_idx]);
290 uint8_t num_pts = curr_boundary_idx - dup_idx + 1;
293 for (uint8_t j = 0; j < num_pts; j++) {
294 boundary[j] = boundary_points[j+dup_idx] * 100.0f;
297 boundary_success =
true;
300 boundary_failure =
true;
305 boundary_failure =
true;
310 if (boundary_failure) {
324 if (boundary_pts ==
nullptr || current_index >= num_points) {
329 Vector2f curr_point = boundary_pts[current_index];
332 float lowest_angle =
M_PI_2;
333 float lowest_angle_relative =
M_PI_2;
334 bool lowest_found =
false;
335 uint8_t lowest_index = 0;
336 for (uint8_t i=0; i < num_points; i++) {
337 if (i != current_index) {
338 Vector2f vec = boundary_pts[i] - curr_point;
341 float angle_relative =
wrap_2PI(angle - start_angle);
342 if ((angle_relative < lowest_angle_relative) || !lowest_found) {
343 lowest_angle = angle;
344 lowest_angle_relative = angle_relative;
354 next_index = lowest_index;
355 next_angle = lowest_angle;
static AP_SerialManager serial_manager
bool device_ready(void) const
float beacon_distance(uint8_t beacon_instance) const
const Vector2f * get_boundary_points(uint16_t &num_points) const
#define AP_GROUPINFO(name, idx, clazz, element, def)
AP_Beacon(AP_SerialManager &_serial_manager)
#define AP_BEACON_MINIMUM_FENCE_BEACONS
#define AP_BEACON_MAX_BEACONS
AP_SerialManager & serial_manager
static bool get_next_boundary_point(const Vector2f *boundary, uint8_t num_points, uint8_t current_index, float start_angle, uint8_t &next_index, float &next_angle)
int32_t lat
param 3 - Latitude * 10**7
bool beacon_healthy(uint8_t beacon_instance) const
uint32_t distance_update_ms
bool get_origin(Location &origin_loc) const
int32_t alt
param 2 - Altitude in centimeters (meters * 100) see LOCATION_ALT_MAX_M
uint8_t beacon_id(uint8_t beacon_instance) const
bool get_vehicle_position_ned(Vector3f &pos, float &accuracy_estimate) const
bool is_zero(const T fVal1)
Vector2f boundary[AP_BEACON_MAX_BEACONS+1]
#define AP_BEACON_TIMEOUT_MS
Vector3f beacon_position(uint8_t beacon_instance) const
AP_Beacon_Backend * _driver
uint32_t veh_pos_update_ms
bool get_beacon_data(uint8_t beacon_instance, struct BeaconState &state) const
uint32_t beacon_last_update_ms(uint8_t beacon_instance) const
int32_t lng
param 4 - Longitude * 10**7
float wrap_2PI(const T radian)
uint8_t boundary_num_points
uint8_t boundary_num_beacons
BeaconState beacon_state[AP_BEACON_MAX_BEACONS]
static const struct AP_Param::GroupInfo var_info[]
void update_boundary_points()
static void setup_object_defaults(const void *object_pointer, const struct GroupInfo *group_info)