Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
#include "modules/orange_avoider/orange_avoider_guided.h"
#include "firmwares/rotorcraft/guidance/guidance_h.h"
#include "generated/airframe.h"
#include "state.h"
#include "subsystems/abi.h"
#include <stdio.h>
#include <time.h>
Go to the source code of this file.
Macros | |
#define | ORANGE_AVOIDER_VERBOSE TRUE |
#define | PRINT(string, ...) fprintf(stderr, "[orange_avoider_guided->%s()] " string,__FUNCTION__ , ##__VA_ARGS__) |
#define | VERBOSE_PRINT(...) |
Enumerations | |
enum | navigation_state_t { SAFE, OBSTACLE_FOUND, OUT_OF_BOUNDS, HOLD, SAFE, OBSTACLE_FOUND, SEARCH_FOR_SAFE_HEADING, OUT_OF_BOUNDS, SAFE, OBSTACLE_FOUND, SEARCH_FOR_SAFE_HEADING, OUT_OF_BOUNDS, REENTER_ARENA } |
Functions | |
uint8_t | chooseRandomIncrementAvoidance (void) |
static void | color_detection_cb (uint8_t sender_id, int16_t pixel_x, int16_t pixel_y, int16_t pixel_width, int16_t pixel_height, int32_t quality, int16_t extra) |
static void | floor_detection_cb (uint8_t sender_id, int16_t pixel_x, int16_t pixel_y, int16_t pixel_width, int16_t pixel_height, int32_t quality, int16_t extra) |
void | orange_avoider_guided_init (void) |
void | orange_avoider_guided_periodic (void) |
Variables | |
float | oag_color_count_frac = 0.18f |
float | oag_floor_count_frac = 0.05f |
float | oag_max_speed = 0.5f |
float | oag_heading_rate = RadOfDeg(20.f) |
enum navigation_state_t | navigation_state = SEARCH_FOR_SAFE_HEADING |
int32_t | color_count = 0 |
int32_t | floor_count = 0 |
int32_t | floor_centroid = 0 |
float | avoidance_heading_direction = 0 |
int16_t | obstacle_free_confidence = 0 |
const int16_t | max_trajectory_confidence = 5 |
static abi_event | color_detection_ev |
static abi_event | floor_detection_ev |
The color filter settings are set using the cv_detect_color_object. This module can run multiple filters simultaneously so you have to define which filter to use with the ORANGE_AVOIDER_VISUAL_DETECTION_ID setting. This module differs from the simpler orange_avoider.xml in that this is flown in guided mode. This flight mode is less dependent on a global positioning estimate as witht the navigation mode. This module can be used with a simple speed estimate rather than a global position.
Here we also need to use our onboard sensors to stay inside of the cyberzoo and not collide with the nets. For this we employ a simple color detector, similar to the orange poles but for green to detect the floor. When the total amount of green drops below a given threshold (given by floor_count_frac) we assume we are near the edge of the zoo and turn around. The color detection is done by the cv_detect_color_object module, use the FLOOR_VISUAL_DETECTION_ID setting to define which filter to use.
Definition in file orange_avoider_guided.c.
#define ORANGE_AVOIDER_VERBOSE TRUE |
Definition at line 36 of file orange_avoider_guided.c.
#define PRINT | ( | string, | |
... | |||
) | fprintf(stderr, "[orange_avoider_guided->%s()] " string,__FUNCTION__ , ##__VA_ARGS__) |
Definition at line 38 of file orange_avoider_guided.c.
#define VERBOSE_PRINT | ( | ... | ) |
Definition at line 42 of file orange_avoider_guided.c.
enum navigation_state_t |
Enumerator | |
---|---|
SAFE | |
OBSTACLE_FOUND | |
OUT_OF_BOUNDS | |
HOLD | |
SAFE | |
OBSTACLE_FOUND | |
SEARCH_FOR_SAFE_HEADING | |
OUT_OF_BOUNDS | |
SAFE | |
OBSTACLE_FOUND | |
SEARCH_FOR_SAFE_HEADING | |
OUT_OF_BOUNDS | |
REENTER_ARENA |
Definition at line 47 of file orange_avoider_guided.c.
uint8_t chooseRandomIncrementAvoidance | ( | void | ) |
Definition at line 208 of file orange_avoider_guided.c.
References avoidance_heading_direction, oag_heading_rate, and VERBOSE_PRINT.
Referenced by orange_avoider_guided_init(), and orange_avoider_guided_periodic().
|
static |
Definition at line 77 of file orange_avoider_guided.c.
References color_count.
Referenced by orange_avoider_guided_init().
|
static |
Definition at line 90 of file orange_avoider_guided.c.
References floor_centroid, and floor_count.
Referenced by orange_avoider_guided_init().
void orange_avoider_guided_init | ( | void | ) |
Definition at line 102 of file orange_avoider_guided.c.
References chooseRandomIncrementAvoidance(), color_detection_cb(), color_detection_ev, floor_detection_cb(), floor_detection_ev, and ORANGE_AVOIDER_VISUAL_DETECTION_ID.
void orange_avoider_guided_periodic | ( | void | ) |
Definition at line 116 of file orange_avoider_guided.c.
References avoidance_heading_direction, chooseRandomIncrementAvoidance(), color_count, f, floor_centroid, floor_count, front_camera, guidance_h, GUIDANCE_H_MODE_GUIDED, guidance_h_set_guided_body_vel(), guidance_h_set_guided_heading(), guidance_h_set_guided_heading_rate(), max_trajectory_confidence, HorizontalGuidance::mode, oag_color_count_frac, oag_floor_count_frac, oag_heading_rate, oag_max_speed, OBSTACLE_FOUND, obstacle_free_confidence, OUT_OF_BOUNDS, REENTER_ARENA, SAFE, SEARCH_FOR_SAFE_HEADING, speed_sp, stateGetNedToBodyEulers_f(), and VERBOSE_PRINT.
float avoidance_heading_direction = 0 |
Definition at line 66 of file orange_avoider_guided.c.
Referenced by chooseRandomIncrementAvoidance(), and orange_avoider_guided_periodic().
int32_t color_count = 0 |
Definition at line 63 of file orange_avoider_guided.c.
Referenced by color_detection_cb(), and orange_avoider_guided_periodic().
|
static |
Definition at line 76 of file orange_avoider_guided.c.
Referenced by orange_avoider_guided_init().
int32_t floor_centroid = 0 |
Definition at line 65 of file orange_avoider_guided.c.
Referenced by floor_detection_cb(), and orange_avoider_guided_periodic().
int32_t floor_count = 0 |
Definition at line 64 of file orange_avoider_guided.c.
Referenced by floor_detection_cb(), and orange_avoider_guided_periodic().
|
static |
Definition at line 89 of file orange_avoider_guided.c.
Referenced by orange_avoider_guided_init().
const int16_t max_trajectory_confidence = 5 |
Definition at line 69 of file orange_avoider_guided.c.
Referenced by orange_avoider_guided_periodic().
Definition at line 62 of file orange_avoider_guided.c.
float oag_color_count_frac = 0.18f |
Definition at line 56 of file orange_avoider_guided.c.
Referenced by orange_avoider_guided_periodic().
float oag_floor_count_frac = 0.05f |
Definition at line 57 of file orange_avoider_guided.c.
Referenced by orange_avoider_guided_periodic().
float oag_heading_rate = RadOfDeg(20.f) |
Definition at line 59 of file orange_avoider_guided.c.
Referenced by chooseRandomIncrementAvoidance(), and orange_avoider_guided_periodic().
float oag_max_speed = 0.5f |
Definition at line 58 of file orange_avoider_guided.c.
Referenced by orange_avoider_guided_periodic().
int16_t obstacle_free_confidence = 0 |
Definition at line 67 of file orange_avoider_guided.c.
Referenced by orange_avoider_guided_periodic().