Paparazzi UAS  v5.15_devel-112-g521f3cf
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
orange_avoider_guided.c File Reference
#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>
+ Include dependency graph for orange_avoider_guided.c:

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, 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
 

Detailed Description

Author
Kirk Scheper This module is an example module for the course AE4317 Autonomous Flight of Micro Air Vehicles at the TU Delft. This module is used in combination with a color filter (cv_detect_color_object) and the guided mode of the autopilot. The avoidance strategy is to simply count the total number of orange pixels. When above a certain percentage threshold, (given by color_count_frac) we assume that there is an obstacle and we turn.

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.

Macro Definition Documentation

#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 (   ...)

Enumeration Type Documentation

Enumerator
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.

Function Documentation

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().

+ Here is the caller graph for this function:

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

Definition at line 77 of file orange_avoider_guided.c.

References color_count.

Referenced by orange_avoider_guided_init().

+ Here is the caller graph for this function:

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 
)
static

Definition at line 90 of file orange_avoider_guided.c.

References floor_centroid, and floor_count.

Referenced by orange_avoider_guided_init().

+ Here is the caller graph for this function:

void orange_avoider_guided_init ( void  )

Definition at line 102 of file orange_avoider_guided.c.

References chooseRandomIncrementAvoidance(), color_detection_cb(), floor_detection_cb(), and ORANGE_AVOIDER_VISUAL_DETECTION_ID.

+ Here is the call graph for this function:

Variable Documentation

float avoidance_heading_direction = 0
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().

abi_event color_detection_ev
static

Definition at line 76 of file orange_avoider_guided.c.

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().

abi_event floor_detection_ev
static

Definition at line 89 of file orange_avoider_guided.c.

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.

Referenced by orange_avoider_guided_periodic().

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)
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().