#define SMARTRTL_POINTS_DEFAULT 300 // default _POINTS parameter value. High numbers improve path pruning but use more memory and CPU for cleanup. Memory used will be 20bytes * this number.
#define SMARTRTL_POINTS_MAX 500 // the absolute maximum number of points this library can support.
#define SMARTRTL_TIMEOUT 15000 // the time in milliseconds with no points saved to the path (for whatever reason), before SmartRTL is disabled for the flight
#define SMARTRTL_CLEANUP_POINT_TRIGGER 50 // simplification will trigger when this many points are added to the path
#define SMARTRTL_CLEANUP_START_MARGIN 10 // routine cleanup algorithms begin when the path array has only this many empty slots remaining
#define SMARTRTL_CLEANUP_POINT_MIN 10 // cleanup algorithms will remove points if they remove at least this many points
#define SMARTRTL_SIMPLIFY_STACK_LEN_MULT (2.0f/3.0f)+1 // simplify buffer size as compared to maximum number of points.
// The minimum is int((s/2-1)+min(s/2, SMARTRTL_POINTS_MAX-s)), where s = pow(2, floor(log(SMARTRTL_POINTS_MAX)/log(2)))
// To avoid this annoying math, a good-enough overestimate is ceil(SMARTRTL_POINTS_MAX*2.0f/3.0f)
#define SMARTRTL_SIMPLIFY_TIME_US 200 // maximum time (in microseconds) the simplification algorithm will run before returning
#define SMARTRTL_PRUNING_DELTA (_accuracy * 0.99) // How many meters apart must two points be, such that we can assume that there is no obstacle between them. must be smaller than _ACCURACY parameter
#define SMARTRTL_PRUNING_LOOP_BUFFER_LEN_MULT 0.25f // pruning loop buffer size as compared to maximum number of points
#define SMARTRTL_PRUNING_LOOP_TIME_US 200 // maximum time (in microseconds) that the loop finding algorithm will run before returning
bool_active;// true if SmartRTL is usable. may become unusable if the path becomes too long to keep in memory, and too convoluted to be cleaned up, SmartRTL will be permanently deactivated (for the remainder of the flight)
uint32_t_last_good_position_ms;// the last system time a last good position was reported. If no position is available for a while, SmartRTL will be disabled.
uint32_t_last_position_save_ms;// the system time a position was saved to the path (used for timeout)
uint32_t_thorough_clean_request_ms;// the last system time the thorough cleanup was requested (set by thorough_cleanup method, used by background cleanup)
uint32_t_thorough_clean_complete_ms;// set to _thorough_clean_request_ms when the background thread completes the thorough cleanup
uint32_t_last_low_space_notify_ms;//last time low on SmartRTL space was notified on Mavlink. Minimum time is required before re-notification to avoid nagging.
ThoroughCleanupType_thorough_clean_type;// used by example sketch to test simplify and prune separately
// path variables
Vector3f*_path;// points are stored in meters from EKF origin in NED
uint16_t_path_points_max;// after the array has been allocated, we will need to know how big it is. We can't use the parameter, because a user could change the parameter in-flight
uint16_t_path_points_count;// number of points in the path array
uint16_t_path_points_completed_limit;// set by main thread to the path_point_count when a point is popped. used by simplify and prune algorithms to detect path shrinking
boolcomplete;// true after simplify_detection has completed
boolremoval_required;// true if some simplify-able points have been found on the path, set true by detect_simplifications, set false by remove_points_by_simplify_bitmask
uint16_tpath_points_count;// copy of _path_points_count taken when the simply algorithm started