diff --git a/conf/TUDELFT/tudelft_course2016_conf.xml b/conf/TUDELFT/tudelft_course2016_conf.xml new file mode 100644 index 0000000000..40d0fc733c --- /dev/null +++ b/conf/TUDELFT/tudelft_course2016_conf.xml @@ -0,0 +1,24 @@ + + + + diff --git a/conf/TUDELFT/tudelft_course2016_control_panel.xml b/conf/TUDELFT/tudelft_course2016_control_panel.xml new file mode 100644 index 0000000000..bab145702f --- /dev/null +++ b/conf/TUDELFT/tudelft_course2016_control_panel.xml @@ -0,0 +1,92 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/conf/airframes/TUDELFT/tudelft_course2016_bebop_avoider.xml b/conf/airframes/TUDELFT/tudelft_course2016_bebop_avoider.xml new file mode 100644 index 0000000000..cfedd57b09 --- /dev/null +++ b/conf/airframes/TUDELFT/tudelft_course2016_bebop_avoider.xml @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + +
+ + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + +
+ + + + + +
+ +
+ + +
+ +
+ + + + + + + +
+ +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ +
+ + +
+ +
+ + + +
+ + + + +
+ + + + + +
+ +
+ +
+
+ + + + + +
+
diff --git a/conf/airframes/examples/course_bebop_colorfilter.xml b/conf/airframes/examples/course_bebop_colorfilter.xml new file mode 100644 index 0000000000..6e1f2585f9 --- /dev/null +++ b/conf/airframes/examples/course_bebop_colorfilter.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + +
+ + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + +
+ + + + + +
+ +
+ + +
+ +
+ + + + + + + +
+ +
+ + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + + + + +
+ +
+ + +
+ + + + +
+ + + + +
+ +
+ + + + + +
+
diff --git a/conf/flight_plans/TUDELFT/tudelft_course2016_avoid_orange_cyberzoo.xml b/conf/flight_plans/TUDELFT/tudelft_course2016_avoid_orange_cyberzoo.xml new file mode 100644 index 0000000000..4623dd7b64 --- /dev/null +++ b/conf/flight_plans/TUDELFT/tudelft_course2016_avoid_orange_cyberzoo.xml @@ -0,0 +1,124 @@ + + + +
+#include "autopilot.h" +#include "subsystems/ahrs.h" +#include "subsystems/electrical.h" +#include "subsystems/datalink/datalink.h" +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/conf/flight_plans/rotorcraft_optitrack.xml b/conf/flight_plans/rotorcraft_optitrack.xml index 6e22f60c05..f55fe40b8d 100644 --- a/conf/flight_plans/rotorcraft_optitrack.xml +++ b/conf/flight_plans/rotorcraft_optitrack.xml @@ -27,6 +27,15 @@ + + + + + + + + + diff --git a/conf/modules/orange_avoider.xml b/conf/modules/orange_avoider.xml new file mode 100644 index 0000000000..ef7b0744f7 --- /dev/null +++ b/conf/modules/orange_avoider.xml @@ -0,0 +1,21 @@ + + + + + + Avoid all objects that are orange! + This example module shows how you can use the camera stream and colorfilter to detect orange objects. + By adding this module to your flightplan and flying in the cyberzoo with the flightplan TUDELFT/tudelft_course2016_avoid_orange_cyberzoo.xml you will avoid every obstacle that is orange. + + + cv_colorfilter.xml +
+ +
+ + + + + +
+ diff --git a/sw/airborne/modules/orange_avoider/orange_avoider.c b/sw/airborne/modules/orange_avoider/orange_avoider.c new file mode 100644 index 0000000000..3bff8c81a4 --- /dev/null +++ b/sw/airborne/modules/orange_avoider/orange_avoider.c @@ -0,0 +1,88 @@ +/* + * Copyright (C) Roland Meertens + * + * This file is part of paparazzi + * + */ +/** + * @file "modules/orange_avoider/orange_avoider.c" + * @author Roland Meertens + * Example on how to use the colours detected to avoid orange pole in the cyberzoo + */ + +#include "modules/orange_avoider/orange_avoider.h" +#include "modules/computer_vision/colorfilter.h" +#include "firmwares/rotorcraft/navigation.h" +#include "state.h" +#include +#include + +uint8_t safeToGoForwards = FALSE; +int tresholdColorCount = 200; +int32_t incrementForAvoidance; + +void orange_avoider_init() +{ + // Initialise the variables of the colorfilter to accept orange + color_lum_min = 0; + color_lum_max = 131; + color_cb_min = 93; + color_cb_max = 255; + color_cr_min = 134; + color_cr_max = 255; + // Initialise random values + srand(time(NULL)); + chooseRandomIncrementAvoidance(); +} +void orange_avoider_periodic() +{ + // Check the amount of orange. If this is above a threshold + // you want to turn a certain amount of degrees + safeToGoForwards = color_count < tresholdColorCount; + printf("Checking if this funciton is called %d treshold: %d now: %d \n", color_count, tresholdColorCount, + safeToGoForwards); +} + + +/** + * Increases the NAV heading. Assumes heading is an INT32_ANGLE. It is bound in this function. + */ +uint8_t increase_nav_heading(int32_t *heading, int32_t increment) +{ + *heading = *heading + increment; + // Check if your turn made it go out of bounds... + INT32_ANGLE_NORMALIZE(*heading); // HEADING HAS INT32_ANGLE_FRAC.... + return FALSE; +} +uint8_t moveWaypointForwards(uint8_t waypoint, float distanceMeters) +{ + struct EnuCoor_i new_coor; + struct EnuCoor_i *pos = stateGetPositionEnu_i(); // Get your current position + + // Calculate the sine and cosine of the heading the drone is keeping + float sin_heading = sinf(ANGLE_FLOAT_OF_BFP(nav_heading)); + float cos_heading = cosf(ANGLE_FLOAT_OF_BFP(nav_heading)); + + // Now determine where to place the waypoint you want to go to + new_coor.x = pos->x + POS_BFP_OF_REAL(sin_heading * (distanceMeters)); + new_coor.y = pos->y + POS_BFP_OF_REAL(cos_heading * (distanceMeters)); + new_coor.z = pos->z; // Keep the height the same + + // Set the waypoint to the calculated position + waypoint_set_xy_i(waypoint, new_coor.x, new_coor.y); + + return FALSE; +} + +uint8_t chooseRandomIncrementAvoidance() +{ + + int r = rand() % 2; + if (r == 0) { + incrementForAvoidance = 350; + } else { + incrementForAvoidance = -350; + } + return FALSE; +} + diff --git a/sw/airborne/modules/orange_avoider/orange_avoider.h b/sw/airborne/modules/orange_avoider/orange_avoider.h new file mode 100644 index 0000000000..cc9f6faf9c --- /dev/null +++ b/sw/airborne/modules/orange_avoider/orange_avoider.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) Roland Meertens + * + * This file is part of paparazzi + * + */ +/** + * @file "modules/orange_avoider/orange_avoider.h" + * @author Roland Meertens + * Example on how to use the colours detected to avoid orange pole in the cyberzoo + */ + +#ifndef ORANGE_AVOIDER_H +#define ORANGE_AVOIDER_H +#include + +extern uint8_t safeToGoForwards; +extern int32_t incrementForAvoidance; +extern void orange_avoider_init(void); +extern void orange_avoider_periodic(void); +extern uint8_t moveWaypointForwards(uint8_t waypoint, float distanceMeters); +extern uint8_t increase_nav_heading(int32_t *heading, int32_t increment); +extern uint8_t chooseRandomIncrementAvoidance(void); + +#endif +