From 41d52d0c6a2a1174b8ec8ba533614c7c2341f1e8 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Sun, 13 Sep 2015 13:30:27 +0200 Subject: [PATCH] [modules] separate opticflow calculation and guidance hover loop --- .../TUDelft/airframes/ardrone2_opticflow.xml | 1 + conf/airframes/TUDelft/conf.xml | 6 +-- .../examples/ardrone2_opticflow_hover.xml | 1 + conf/conf_tests.xml | 2 +- conf/modules/cv_opticflow.xml | 35 ++----------- conf/modules/opticflow_hover.xml | 52 +++++++++++++++++++ .../computer_vision/opticflow_module.h | 6 +-- .../guidance_opticflow_hover.c} | 4 +- .../guidance_opticflow_hover.h} | 8 +-- 9 files changed, 71 insertions(+), 44 deletions(-) create mode 100644 conf/modules/opticflow_hover.xml rename sw/airborne/modules/{computer_vision/opticflow/stabilization_opticflow.c => guidance_opticflow/guidance_opticflow_hover.c} (97%) rename sw/airborne/modules/{computer_vision/opticflow/stabilization_opticflow.h => guidance_opticflow/guidance_opticflow_hover.h} (91%) diff --git a/conf/airframes/TUDelft/airframes/ardrone2_opticflow.xml b/conf/airframes/TUDelft/airframes/ardrone2_opticflow.xml index 671a5142905..5d6efd77e4f 100644 --- a/conf/airframes/TUDelft/airframes/ardrone2_opticflow.xml +++ b/conf/airframes/TUDelft/airframes/ardrone2_opticflow.xml @@ -29,6 +29,7 @@ + diff --git a/conf/airframes/TUDelft/conf.xml b/conf/airframes/TUDelft/conf.xml index f70fde2ed30..a9429a06e18 100644 --- a/conf/airframes/TUDelft/conf.xml +++ b/conf/airframes/TUDelft/conf.xml @@ -7,8 +7,8 @@ telemetry="telemetry/default_rotorcraft.xml" flight_plan="flight_plans/rotorcraft_basic.xml" settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_rate.xml settings/control/stabilization_att_int_quat.xml settings/estimation/ahrs_int_cmpl_quat.xml settings/estimation/body_to_imu.xml" - settings_modules="modules/gps_ubx_ucenter.xml modules/air_data.xml modules/geo_mag.xml" gui_color="red" + settings_modules="modules/gps_ubx_ucenter.xml modules/air_data.xml modules/geo_mag.xml" /> + diff --git a/conf/conf_tests.xml b/conf/conf_tests.xml index b2d32541ac2..848729b5e52 100644 --- a/conf/conf_tests.xml +++ b/conf/conf_tests.xml @@ -359,7 +359,7 @@ telemetry="telemetry/default_rotorcraft.xml" flight_plan="flight_plans/rotorcraft_basic.xml" settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_rate.xml settings/control/stabilization_att_int.xml" - settings_modules="modules/gps_ubx_ucenter.xml modules/cv_opticflow.xml" + settings_modules="modules/gps_ubx_ucenter.xml modules/cv_opticflow.xml modules/opticflow_hover.xml" gui_color="blue" /> - Hovers the drone based on optical flow made for Linux video Devices. - - Computes Pitch- and roll attide from downward looking camera looking at a textured floor. - - Sonar is required. - - Controller can hold position + Compute optical flow. + Made for Linux video Devices. + Computes x and y velocity using optical flow and distance to ground (using sonar). - -
- - - - - - -
-
@@ -51,16 +39,7 @@ - - - - - - - - - - + @@ -92,11 +71,10 @@ - + - @@ -116,9 +94,6 @@ else ap.CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_USE_NC endif - - ap.CFLAGS += -DGUIDANCE_V_MODE_MODULE_SETTING=GUIDANCE_V_MODE_HOVER - ap.CFLAGS += -DGUIDANCE_H_MODE_MODULE_SETTING=GUIDANCE_H_MODE_MODULE diff --git a/conf/modules/opticflow_hover.xml b/conf/modules/opticflow_hover.xml new file mode 100644 index 00000000000..744d2616375 --- /dev/null +++ b/conf/modules/opticflow_hover.xml @@ -0,0 +1,52 @@ + + + + + + Hovers the drone based on optical flow made for Linux video Devices. + + Computes Pitch- and roll attide from downward looking camera looking at a textured floor. + - Sonar is required. + - Controller can hold position + + + +
+ + + + + + +
+
+ + + + + + + + + + + + + + + + cv_opticflow + +
+ +
+ + + + + ap.CFLAGS += -DGUIDANCE_V_MODE_MODULE_SETTING=GUIDANCE_V_MODE_HOVER + ap.CFLAGS += -DGUIDANCE_H_MODE_MODULE_SETTING=GUIDANCE_H_MODE_MODULE + + + +
diff --git a/sw/airborne/modules/computer_vision/opticflow_module.h b/sw/airborne/modules/computer_vision/opticflow_module.h index eb158cc83c2..8ed930a51ac 100644 --- a/sw/airborne/modules/computer_vision/opticflow_module.h +++ b/sw/airborne/modules/computer_vision/opticflow_module.h @@ -20,17 +20,15 @@ /** * @file modules/computer_vision/opticflow_module.h - * @brief optical-flow based hovering for Parrot AR.Drone 2.0 + * @brief optical-flow calculation for Parrot Drones * - * Sensors from vertical camera and IMU of Parrot AR.Drone 2.0 */ #ifndef OPTICFLOW_MODULE_H #define OPTICFLOW_MODULE_H -// Include opticflow calculator and stabilization loops +// Include opticflow calculator #include "opticflow/opticflow_calculator.h" -#include "opticflow/stabilization_opticflow.h" // Needed for settings extern struct opticflow_t opticflow; diff --git a/sw/airborne/modules/computer_vision/opticflow/stabilization_opticflow.c b/sw/airborne/modules/guidance_opticflow/guidance_opticflow_hover.c similarity index 97% rename from sw/airborne/modules/computer_vision/opticflow/stabilization_opticflow.c rename to sw/airborne/modules/guidance_opticflow/guidance_opticflow_hover.c index 22f7a8e0f42..122493dd85d 100644 --- a/sw/airborne/modules/computer_vision/opticflow/stabilization_opticflow.c +++ b/sw/airborne/modules/guidance_opticflow/guidance_opticflow_hover.c @@ -20,7 +20,7 @@ */ /** - * @file modules/computer_vision/opticflow/stabilization_opticflow.c + * @file modules/guidance_opticflow/guidance_opticflow_hover.c * @brief Optical-flow based control for Linux based systems * * Control loops for optic flow based hovering. @@ -28,7 +28,7 @@ */ // Own Header -#include "stabilization_opticflow.h" +#include "guidance_opticflow_hover.h" #include "subsystems/abi.h" diff --git a/sw/airborne/modules/computer_vision/opticflow/stabilization_opticflow.h b/sw/airborne/modules/guidance_opticflow/guidance_opticflow_hover.h similarity index 91% rename from sw/airborne/modules/computer_vision/opticflow/stabilization_opticflow.h rename to sw/airborne/modules/guidance_opticflow/guidance_opticflow_hover.h index 881dd93828c..93fbe665a29 100644 --- a/sw/airborne/modules/computer_vision/opticflow/stabilization_opticflow.h +++ b/sw/airborne/modules/guidance_opticflow/guidance_opticflow_hover.h @@ -20,15 +20,15 @@ */ /** - * @file modules/computer_vision/opticflow/stabilization_opticflow.h + * @file modules/guidance_opticflow/guidance_opticflow_hover.h * @brief Optical-flow based control for Linux based systems * * Control loops for optic flow based hovering. * Computes setpoint for the lower level attitude stabilization to control horizontal velocity. */ -#ifndef CV_STABILIZATION_OPTICFLOW_H_ -#define CV_STABILIZATION_OPTICFLOW_H_ +#ifndef GUIDANCE_OPTICFLOW_HOVER_H_ +#define GUIDANCE_OPTICFLOW_HOVER_H_ #include "std.h" #include "math/pprz_algebra_int.h" @@ -54,4 +54,4 @@ extern void guidance_h_module_enter(void); extern void guidance_h_module_read_rc(void); extern void guidance_h_module_run(bool_t in_flight); -#endif /* CV_STABILIZATION_OPTICFLOW_H_ */ +#endif /* GUIDANCE_OPTICFLOW_HOVER_H_ */