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 navigation 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.
Example for airframe file
Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!
<module name="orange_avoider">
b'<define name="ORANGE_AVOIDER_VISUAL_DETECTION_ID" value="ABI_BROADCAST" />\n '
</module>
Module configuration options
Define Options
- name:
ORANGE_AVOIDER_VISUAL_DETECTION_ID
value: ABI_BROADCAST
Description: which VISUAL_DETECTION message to recieve for orange pole detection.
Module functions
Init Functions
These initialization functions are called once on startup.
Periodic Functions
These functions are called periodically at the specified frequency from the module periodic loop.
- orange_avoider_periodic()
- Frequency in Hz: 4
- Autorun: LOCK
Periodic function automatically starts after init and can't be stopped.
Files
Header Files
The following headers are automatically included in modules.h
Source Files
Raw orange_avoider.xml file:
<!DOCTYPE module SYSTEM "module.dtd">
<module name="orange_avoider">
<doc>
<description>
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 navigation 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.
</description>
<define name="ORANGE_AVOIDER_VISUAL_DETECTION_ID" value="ABI_BROADCAST" description="which VISUAL_DETECTION message to recieve for orange pole detection."/>
</doc>
<settings>
<dl_settings>
<dl_settings name="OrangeAvoider">
<dl_setting var="oa_color_count_frac" min="0" step="0.01" max="0.5"/>
</dl_settings>
</dl_settings>
</settings>
<dep>
<depends>cv_detect_color_object</depends>
</dep>
<header>
<file name="orange_avoider.h"/>
</header>
<init fun="orange_avoider_init()"/>
<periodic fun="orange_avoider_periodic()" freq="4"/>
<makefile target="ap|nps">
<file name="orange_avoider.c"/>
</makefile>
</module>