|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
52 #include "generated/flight_plan.h"
61 #ifndef WEDGEBUG_CAMERA_RIGHT_FPS
62 #define WEDGEBUG_CAMERA_RIGHT_FPS 0 //< Default FPS (zero means run at camera fps)
64 #ifndef WEDGEBUG_CAMERA_LEFT_FPS
65 #define WEDGEBUG_CAMERA_LEFT_FPS 0 //< Default FPS (zero means run at camera fps)
202 float b = WEDGEBUG_CAMERA_BASELINE /
289 const char *img_name);
332 float threshold_setpoint,
float target_angle,
float current_angle,
float threshold_angle);
364 default:
return "Image type not found";
373 printf(
"Image-Width: %d\n", img->
w);
374 printf(
"Image-Height: %d\n", img->
h);
375 printf(
"Image-Buf_Size: %d\n", img->
buf_size);
376 printf(
"Image-Buf_Memory_Occupied: %lu\n",
sizeof(img->
buf));
383 printf(
"Pixel %d value - %s: %d\n", entry_position, img_name, ((
uint8_t *)img->
buf)[entry_position]);
389 printf(
"[[%f, %f, %f]\n", R->
m[0], R->
m[1], R->
m[2]);
390 printf(
" [%f, %f, %f]\n", R->
m[3], R->
m[4], R->
m[5]);
391 printf(
" [%f, %f, %f]]\n", R->
m[6], R->
m[7], R->
m[8]);
402 const int block_size)
405 uint16_t block_size_black = block_size / 2;
406 uint16_t left_black = disp_n + block_size_black;
409 _img_cropped_info->
y = block_size_black;
410 _img_cropped_info->
h = _original_img_dims->
h - block_size_black;
411 _img_cropped_info->
h = _img_cropped_info->
h - _img_cropped_info->
y;
413 _img_cropped_info->
x = left_black - 1;
414 _img_cropped_info->
w = _original_img_dims->
w - block_size_black;
415 _img_cropped_info->
w = _img_cropped_info->
w - _img_cropped_info->
x;
475 for (i = 0; i < n; ++i) {
478 for (i = n - 1; i > 0; --i) {
479 for (j = 0; j < i; ++j) {
480 if (dpSorted[j] > dpSorted[j + 1]) {
482 dpSorted[j] = dpSorted[j + 1];
483 dpSorted[j + 1] = dTemp;
491 dMedian = (dpSorted[n / 2] + dpSorted[(n / 2) - 1]) / 2.0;
493 dMedian = dpSorted[n / 2];
506 for (i = 0; i < n; ++i) {
509 for (i = n - 1; i > 0; --i) {
510 for (j = 0; j < i; ++j) {
511 if (dpSorted[j] > dpSorted[j + 1]) {
513 dpSorted[j] = dpSorted[j + 1];
514 dpSorted[j + 1] = dTemp;
522 dMedian = (dpSorted[n / 2] + dpSorted[(n / 2) - 1]) / 2.0;
524 dMedian = dpSorted[n / 2];
558 if (left->
w != right->
w || left->
h != right->
h) {
559 printf(
"The dimensions of the left and right image to not match!");
562 if ((merged->
w * merged->
h) != (2 * right->
w) * right->
w) {
563 printf(
"The dimensions of the empty image template for merger are not sufficient to merge gray left and right pixel values.");
577 for (
uint32_t i = 0; i < loop_length; i++) {
597 if (left->
w != right->
w || left->
h != right->
h) {
598 printf(
"The dimensions of the left and right image to not match!");
601 if ((merged->
w * merged->
h) != (2 * right->
w) * right->
w) {
602 printf(
"The dimensions of the empty image template for merger are not sufficient to merge gray left and right pixel values.");
640 if (*intensity > max) {
647 for (
uint32_t i = 0; i < (img->
w * img->
h); i++) {
650 if (*intensity > max) {
652 printf(
"%d\n", *intensity);
653 printf(
"location = %d\n", i);
658 printf(
"ERROR: function does not support image type %d. Breaking out of function.", img->
type);
672 if (*intensity >= threshold) {
685 c_output->
y = c_old_input->
y - _img_cropped_info->
y;
686 c_output->
x = c_old_input->
x - _img_cropped_info->
x;
714 return round(_b * _f / _depth);
734 scene_point->
z = 0.0001;
743 scene_point->
y = image_point_y * scene_point -> z / _f;
746 scene_point->
x = image_point_x * scene_point -> z / _f;
756 const float depth ,
const uint16_t _f)
759 scene_point->
z = depth;
762 scene_point->
y = image_point_y * scene_point -> z / _f;
765 scene_point->
x = image_point_x * scene_point -> z / _f;
786 scene_point->
z = 0.0001;
795 scene_point->
y = image_point_y * scene_point -> z / _f;
798 scene_point->
x = image_point_x * scene_point -> z / _f;
809 if (x >= (img->
w) || x < 0) {
810 printf(
"Error: index x=%d is out of bounds for axis 0 with size %d. Returning -1\n", x, img->
w);
812 }
else if (y >= (img->
h) || y < 0) {
813 printf(
"Error: index y=%d is out of bounds for axis 0 with size %d. Returning -1\n", y, img->
h);
816 return x + img->
w * y;
824 if (x >= (_img_dims->
w) || x < 0) {
825 printf(
"Error: index %d is out of bounds for axis 0 with size %d. Returning -1\n", x, _img_dims->
w);
827 }
else if (y >= (_img_dims->
h) || y < 0) {
828 printf(
"Error: index %d is out of bounds for axis 0 with size %d. Returning -1\n", y, _img_dims->
h);
831 return x + _img_dims->
w * y;
838 if (x >= (img_width) || x < 0) {
839 printf(
"Error: index x=%d is out of bounds for axis 0 with size %d. Returning -1\n", x, img_width);
841 }
else if (y >= (img_height) || y < 0) {
842 printf(
"Error: index y=%d is out of bounds for axis 1 with size %d. Returning -1\n", y, img_height);
845 return x + img_width * y;
861 Va_temp.x = Va->
x - VOa->
x;
862 Va_temp.y = Va->
y - VOa->
y;
863 Va_temp.z = Va->
z - VOa->
z;
879 Va->
x = Va->
x + VOa->
x;
880 Va->
y = Va->
y + VOa->
y;
881 Va->
z = Va->
z + VOa->
z;
895 printf(
"%f, %f, %f,\n", Rrw->
m[0], Rrw->
m[1], Rrw->
m[2]);
896 printf(
"%f, %f, %f,\n", Rrw->
m[3], Rrw->
m[4], Rrw->
m[5]);
897 printf(
"%f, %f, %f\n\n", Rrw->
m[6], Rrw->
m[7], Rrw->
m[8]);
900 printf(
"VRw (drone location)\n");
901 printf(
" %f\n %f\n %f\n\n", VRw->
x, VRw->
y, VRw->
z);
905 printf(
" %f\n %f\n %f\n\n", Vw->
x, Vw->
y, Vw->
z);
916 printf(
" %f\n %f\n %f\n\n", Vr.x, Vr.y, Vr.z);
920 printf(
"%f, %f, %f,\n", _Rcr->
m[0], _Rcr->
m[1], _Rcr->
m[2]);
921 printf(
"%f, %f, %f,\n", _Rcr->
m[3], _Rcr->
m[4], _Rcr->
m[5]);
922 printf(
"%f, %f, %f\n\n", _Rcr->
m[6], _Rcr->
m[7], _Rcr->
m[8]);
925 printf(
"VCa (camera location)\n");
926 printf(
" %f\n %f\n %f\n\n", _VCr->
x, _VCr->
y, _VCr->
z);
936 printf(
" %f\n %f\n %f\n\n", Vc->
x, Vc->
y, Vc->
z);
953 printf(
"Vr - back calculated\n"); \
954 printf(
" %f\n %f\n %f\n\n", Vr.x, Vr.y, Vr.z);
964 printf(
"Vw - back calculated\n");
965 printf(
" %f\n %f\n %f\n\n", Vw->
x, Vw->
y, Vw->
z);
985 angle = atan2f(difference.x, difference.y);
997 angle = atan2f(difference.y, difference.x);
1006 uint8_t VSTARTi_y = Vi->
y - (kernel_median->
h / 2);
1007 uint8_t VSTARTi_x = Vi->
x - (kernel_median->
w / 2);
1008 uint8_t VSTOPi_y = Vi->
y + (kernel_median->
h / 2);
1009 uint8_t VSTOPi_x = Vi->
x + (kernel_median->
w / 2);
1013 if (VSTOPi_y > img->
h) {
1014 VSTOPi_y = (img->
h - 1);
1016 if (VSTOPi_x > img->
w) {
1017 VSTOPi_x = (img->
w - 1);
1035 for (
uint8_t Vi_y = VSTARTi_y; Vi_y < (VSTOPi_y + 1); Vi_y++) {
1036 for (
uint8_t Vi_x = VSTARTi_x; Vi_x < (VSTOPi_x + 1); Vi_x++) {
1038 Vk_y = Vi_y - VSTARTi_y;
1039 Vk_x = Vi_x - VSTARTi_x;
1042 index_img =
indx1d_a(Vi_y, Vi_x, img);
1062 uint16_t VSTARTi_y = Vi->
y - (kernel_median->
h / 2);
1063 uint16_t VSTARTi_x = Vi->
x - (kernel_median->
w / 2);
1064 uint16_t VSTOPi_y = Vi->
y + (kernel_median->
h / 2);
1065 uint16_t VSTOPi_x = Vi->
x + (kernel_median->
w / 2);
1069 if (VSTOPi_y > img->
h) {
1070 VSTOPi_y = (img->
h - 1);
1072 if (VSTOPi_x > img->
w) {
1073 VSTOPi_x = (img->
w - 1);
1091 for (
uint16_t Vi_y = VSTARTi_y; Vi_y < (VSTOPi_y + 1); Vi_y++) {
1092 for (
uint16_t Vi_x = VSTARTi_x; Vi_x < (VSTOPi_x + 1); Vi_x++) {
1094 Vk_y = Vi_y - VSTARTi_y;
1095 Vk_x = Vi_x - VSTARTi_x;
1098 index_img =
indx1d_a(Vi_y, Vi_x, img);
1121 *_VEDGECOORDINATESc,
1124 struct image_t *img_disparity,
1125 struct crop_t *_edge_search_area,
1136 float f_distance_edge_to_goal;
1137 float f_distance_robot_to_edge;
1146 VROBOTCENTERc.
x = 0.0; VROBOTCENTERc.y = 0.0; VROBOTCENTERc.z = 0.0;
1147 VCLOSESTEDGEi.x = 0; VCLOSESTEDGEi.y = 0;
1154 for (
uint16_t y = _edge_search_area->
y;
y < (_edge_search_area->
y + _edge_search_area->
h);
1156 for (
uint16_t x = _edge_search_area->
x;
x < (_edge_search_area->
x + _edge_search_area->
w);
x++) {
1158 edge_value = ((
uint8_t *) img_edges->
buf)[indx];
1159 disparity = ((
uint8_t *) img_disparity->
buf)[indx];
1165 if ((edge_value != 0) && (disparity > threshold)) {
1168 Bound(confidence, 0, max_confidence);
1174 Vi_to_Vc(&VEDGEc, y_from_c, x_from_c, disparity,
b,
f);
1183 if ((f_distance_robot_to_edge + f_distance_edge_to_goal) < distance) {
1185 _VEDGECOORDINATESc->
x = VEDGEc.x;
1186 _VEDGECOORDINATESc->
y = VEDGEc.y;
1187 _VEDGECOORDINATESc->
z = VEDGEc.z;
1189 disparity_best = disparity;
1191 distance = (f_distance_robot_to_edge + f_distance_edge_to_goal);
1193 VCLOSESTEDGEi.y =
y;
1194 VCLOSESTEDGEi.x =
x;
1215 if (confidence == max_confidence) {
1216 ((
uint8_t *) img_edges->
buf)[
indx1d_a(VCLOSESTEDGEi.y, VCLOSESTEDGEi.x, img_edges)] = 255;
1217 printf(
"Viable closest edge found: [%d, %d] (disparity = %d)\n", VCLOSESTEDGEi.y, VCLOSESTEDGEi.x, disparity_best);
1219 printf(
"At distance: %f\n", distance);
1223 printf(
"No viable edge found\n");
1235 *_VEDGECOORDINATESc,
1239 struct crop_t *_edge_search_area,
1250 float f_distance_edge_to_goal;
1251 float f_distance_robot_to_edge;
1260 VROBOTCENTERc.
x = 0.0; VROBOTCENTERc.y = 0.0; VROBOTCENTERc.z = 0.0;
1261 VCLOSESTEDGEi.x = 0; VCLOSESTEDGEi.y = 0;
1268 for (
uint16_t y = _edge_search_area->
y;
y < (_edge_search_area->
y + _edge_search_area->
h);
1270 for (
uint16_t x = _edge_search_area->
x;
x < (_edge_search_area->
x + _edge_search_area->
w);
x++) {
1272 edge_value = ((
uint8_t *) img_edges->
buf)[indx];
1279 if ((edge_value != 0) && (depth < threshold)) {
1282 Bound(confidence, 0, max_confidence);
1299 if ((f_distance_robot_to_edge + f_distance_edge_to_goal) < distance) {
1301 _VEDGECOORDINATESc->
x = VEDGEc.x;
1302 _VEDGECOORDINATESc->
y = VEDGEc.y;
1303 _VEDGECOORDINATESc->
z = VEDGEc.z;
1307 distance = (f_distance_robot_to_edge + f_distance_edge_to_goal);
1309 VCLOSESTEDGEi.y =
y;
1310 VCLOSESTEDGEi.x =
x;
1331 if (confidence == max_confidence) {
1332 ((
uint8_t *) img_edges->
buf)[
indx1d_a(VCLOSESTEDGEi.y, VCLOSESTEDGEi.x, img_edges)] = 255;
1333 printf(
"Viable closest edge found: [%d, %d] (depth = %f)\n", VCLOSESTEDGEi.y, VCLOSESTEDGEi.x, (depth_best / 100.00));
1335 printf(
"At distance: %f\n", distance);
1339 printf(
"No viable edge found\n");
1358 float target_current_diff;
1359 target_current_diff = target_angle - current_angle;
1363 return sqrt(pow(target_current_diff, 2));
1376 float target_angle,
float current_angle,
float threshold_angle)
1388 float disparity = 1;
1394 for (
int32_t i = 0; i < (img_input->
h * img_input->
w); i++) {
1401 printf(
"ERROR: function does not support image type %d. Breaking out of function.", img_input->
type);
1411 disparity = disparity * 100;
1419 ((
uint16_t *)img16bit_output->
buf)[i] = round(disparity);
1608 printf(
"img_cropped_info [w, h, x, y] = [%d, %d, %d, %d]\n",
img_cropped_info.
w,
img_cropped_info.
h,
img_cropped_info.
x,
1860 default: {printf(
"Unsupported control mode");}
break;
1966 printf(
"median_depth_in_front = %f\n", depth);
1967 printf(
"depth to goal = %f\n",
VGOALc.
z);
1971 printf(
"Obstacle is in front of goal\n");
1973 printf(
"The path to the goal is free!\n");
2007 printf(
"Goal is reached\n");
2034 printf(
"Total time to reach goal = %f\n", ((
double)
clock_total_time) / CLOCKS_PER_SEC);
2042 printf(
"default = %d\n", 0);
2047 printf(
"Time elapsed since start = %f\n", (((
double)clock()) - ((
double)
clock_total_time_current)) / CLOCKS_PER_SEC);
2086 printf(
"Metric 1 was started\n");
2132 printf(
"Goal is reached\n");
2161 printf(
"Object detected!!!!!!!!\n");
2171 printf(
"median_depth_in_front = %f\n", depth);
2172 printf(
"depth to goal = %f\n",
VGOALc.
z);
2178 printf(
"Increasing confidence\n");
2210 printf(
"Total time to reach goal = %f\n", ((
double)
clock_total_time) / CLOCKS_PER_SEC);
2212 printf(
"Average runtime of background processes = %f\n",
2233 printf(
"Holding point is reached\n");
2286 printf(
"Edge not found!!!!!!!!!!!!!!!!!\n");
2355 printf(
"Heading is reached\n");
2383 printf(
"Edge is reached\n");
2414 printf(
"Position and Heading are reached\n");
2434 printf(
"Heading is reached\n");
2464 printf(
"Object detected!!!!!!!!\n");
2473 printf(
"Path is free\n");
2482 printf(
"Depth to goal = %f\n",
VGOALc.
z);
2561 float distance_total = f_distance_robot_to_edge + f_distance_edge_to_goal;
2562 printf(
"distance_total =%f\n", distance_total);
2592 printf(
"Left heading is/was reached\n");
2618 printf(
"Right heading is/was reached\n");
2642 printf(
"Edge has been found\n");
2645 printf(
"Minimum has been encountered\n");
2669 printf(
"default = %d\n", 0);
2681 printf(
"Time elapsed since start = %f\n", ((
double)
clock_total_time) / CLOCKS_PER_SEC);
2695 printf(
"median_depth_in_front = %f\n", depth);
2696 printf(
"depth to goal = %f\n",
VGOALc.
z);
2700 printf(
"Obstacle is in front of goal\n");
2702 printf(
"The path to the goal is free!\n");
2742 {printf(
"Unsupported control mode");}
break;
struct image_t img_right
Image obtained from left camera (UYVY format)
void show_image_data(struct image_t *img)
uint8_t is_obstacle_detected_flag
Set to 1 if setpoint is reached, 0 otherwise.
uint16_t h
height of the cropped area
struct image_t img_left_int8
Image obtained from right camera (UYVY format)
float heading_towards_setpoint_WNED(struct FloatVect3 *VSETPOINTwned)
void image_create(struct image_t *img, uint16_t width, uint16_t height, enum image_type type)
Create a new image.
void show_image_entry(struct image_t *img, int entry_position, const char *img_name)
static struct NedCoor_f * stateGetPositionNed_f(void)
Get position in local NED coordinates (float).
struct FloatVect3 VEDGECOORDINATESc
Declared vector of coordinates of goal in camera coordinate system.
enum image_type type
The image type.
uint8_t are_setpoint_and_angle_reached(struct FloatVect3 *VGOAL, struct FloatVect3 *VCURRENTPOSITION, float threshold_setpoint, float target_angle, float current_angle, float threshold_angle)
int sobel_OCV(struct image_t *img_input, const struct image_t *img_output, const int kernel_size, const int thr)
uint16_t median_depth_in_front
Variable to hold the median disparity in front of the drone. Needed to see if obstacle is there.
void Vw_to_Vc(struct FloatVect3 *Vc, struct FloatVect3 *Vw, struct FloatRMat *Rrw, struct FloatVect3 *VRw, struct FloatRMat *Rcr, struct FloatVect3 *VCr, const uint8_t verbose)
#define FLOAT_ANGLE_NORMALIZE(_a)
#define AP_MODE_ATTITUDE_DIRECT
float max_edge_search_angle
Variable for storing the heading of the drone (psi in radians)
struct image_t img_disparity_int16_cropped
Image obtained from the external sobel edge detection function = sobel_OCV.
struct image_t img_middle_int8_cropped
Image holding depth values (cm) obtained from the disparity image.
void background_processes(uint8_t save_images_flag)
uint16_t K_median_h
Width of kernel for the median kernel.
struct FloatVect3 VEDGECOORDINATESwned
Declared vector of coordinates of "best" edge detected in robot coordinate system.
struct kernel_C1 median_kernel
Dimensions of the kernel that detect median disparity in front of drone (for obstacle detection)
uint32_t buf_size
Size of values of weight buffer and values buffer.
float dispfixed_to_disp(const int16_t d)
void * buf_weights
Kernel weight buffer.
static struct image_t * copy_right_img_func(struct image_t *img, uint8_t camera_id)
uint8_t allow_state_change_POSITION_GOAL
int32_t indx1d_b(const int32_t y, const int32_t x, const struct img_size_t *img_dims)
uint8_t is_path_free_flag
Set to 1 if obstacle is detected, 0 otherwise.
int save_image_gray(struct image_t *img, char *myString)
uint8_t threshold_median_disparity
Edges with a magnitude above this value are detected. Above this value, edges are given the value 127...
struct video_listener * cv_add_to_device(struct video_config_t *device, cv_function func, uint16_t fps, uint8_t id)
void wedgebug_periodic(void)
int16_t max_edge_found_macro_confidence
This is the max confidence that edges (micro-see above) were found.
enum control_mode_state current_mode
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
void UYVYs_interlacing_V(struct image_t *YY, struct image_t *left, struct image_t *right)
void * buf_values
Kernel value buffer. These are the values underneath the kernel.
uint16_t w
Width of the cropped area.
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
int16_t max_no_edge_found_confidence
This is the max confidence that edges (macro-see above were found.
uint8_t is_left_reached_flag
struct FloatVect3 VGOALr
Declared vector of coordinates of goal in NED world coordinate system.
void Va_to_Vb(struct FloatVect3 *Vb, struct FloatVect3 *Va, struct FloatRMat *Rba, struct FloatVect3 *VOa)
#define VECT3_DIFF(_c, _a, _b)
struct FloatRMat Rwnedwenu
This structure holds information about the window in which edges are searched in.
int dilation_OCV(struct image_t *img_input, const struct image_t *img_output, const int SE_size, const int iteration)
float threshold_distance_to_goal_direct
Below this distance (in radians) it is considered that the robot has reached the target angle.
struct FloatVect3 VGOALwenu
Declared vector of coordinates of start position in NED world coordinate system.
int16_t max_obstacle_confidence
This is the confidence that no edge was found.
uint8_t is_total_timer_on_flag
#define AP_MODE_ATTITUDE_Z_HOLD
int32_t indx1d_a(const int32_t y, const int32_t x, const struct image_t *img)
uint8_t allow_state_change_WEDGEBUG_START
int block_size_disparities
Number of disparity levels (0-this number)
uint8_t is_heading_reached_flag
Set to 1 if no obstacle is detected, 0 otherwise.
int16_t no_edge_found_confidence
This is the confidence that an edge was found - outside of the find_best_edge_coordinates function.
void principal_points(struct point_t *c_output, const struct point_t *c_old_input, struct crop_t *img_cropped_info)
uint16_t threshold_depth_of_edges
Below this median disparity, an obstacle is considered to block the way (i.e. the blocking obstacle n...
struct image_t img_right_int8
Paparazzi floating point algebra.
bool guidance_h_set_guided_pos(float x, float y)
Set horizontal position setpoint in GUIDED mode.
static struct image_t * copy_left_img_func(struct image_t *img, uint8_t camera_id)
struct image_t img_disparity_int8_cropped
Image obtained from right camera, converted into 8bit gray image.
int SE_closing_OCV
SE size for the opening operation.
bool autopilot_guided_goto_ned(float x, float y, float z, float heading)
Set position and heading setpoints in GUIDED mode.
@ IMAGE_GRAYSCALE
Grayscale image with only the Y part (uint8 per pixel)
void Vi_to_Vc(struct FloatVect3 *scene_point, int32_t image_point_y, int32_t image_point_x, const uint8_t d, const float b, const uint16_t f)
navigation_state
Camera focal length, in pixels (i.e. distance between camera.
uint8_t allow_state_change_MOVE_TO_EDGE
struct ES_angles initial_heading
int heat_map_type
Variable to hold distance from robot to edge to goal (used in EDGE_SCAN (9) state)
uint32_t buf_size
The buffer size.
int16_t max_position_confidence
This is the max confidence that an obstacle was not spotted.
uint8_t is_heading_reached(float target_angle, float current_angle, float threshold)
uint16_t median_depth_to_point(struct point_t *Vi, struct image_t *img, struct kernel_C1 *kernel_median)
void thresholding_img(struct image_t *img, uint8_t threshold)
#define VECT2_DIFF(_c, _a, _b)
void disp_to_depth_img(struct image_t *img8bit_input, struct image_t *img16bit_output)
void image_to_grayscale(struct image_t *input, struct image_t *output)
Convert an image to grayscale.
void Vi_to_Vc_depth(struct FloatVect3 *scene_point, int32_t image_point_y, int32_t image_point_x, const float depth, const uint16_t f)
struct image_t img_left_int8_cropped
Image obtained from left camera, converted into 8bit gray image.
void float_rmat_transp_vmult(struct FloatVect3 *vb, struct FloatRMat *m_b2a, struct FloatVect3 *va)
rotate 3D vector by transposed rotation matrix.
int16_t obstacle_confidence
Below this depth (m) edges are eligible for the WedgeBug algorithm (i.e. edges cannot be very far awa...
void float_rmat_vmult(struct FloatVect3 *vb, struct FloatRMat *m_a2b, struct FloatVect3 *va)
rotate 3D vector by rotation matrix.
float threshold_distance_to_goal_manual
struct FloatVect3 VDISTANCEPOSITIONwned
Declared vector of coordinates of "best" edge detected in ENU world coordinate system.
struct FloatVect3 VEDGECOORDINATESwenu
Declared vector of coordinates of "best" edge detected in NED world coordinate system.
@ IMAGE_INT16
An image to hold disparity image data from openCV (int16 per pixel)
struct FloatVect3 VGOALwned
Declared vector of coordinates of goal in ENU world coordinate system.
Paparazzi floating point math for geodetic calculations.
uint8_t threshold_disparity_of_edges
Above this median disparity, an obstacle is considered to block the way (i.e. the blocking obstacle n...
void UYVYs_interlacing_H(struct image_t *merged, struct image_t *left, struct image_t *right)
static float float_vect3_norm(struct FloatVect3 *v)
uint8_t median_disparity_in_front
The maximum angle (in adians) to the left and right of the drone, that edges can be detected in....
uint8_t getMedian(uint8_t *a, uint32_t n)
struct FloatVect3 VHOLDINGPOINTwned
Declared a vector to hold the current position, which is needed for calculating the distance traveled...
int SE_dilation_OCV_2
SE size for the first dilation operation.
void background_processes_16bit(uint8_t save_images_flag)
struct img_size_t kernel_median_dims
Dimension of image after it has been cropped to remove pixel error due to block matching limitations.
int16_t free_path_confidence
This is the confidence that an obstacle was spotted.
uint8_t is_edge_found_micro_flag
Set to 1 if best edge (according to macro confidence) was found, 0 otherwise.
uint8_t find_best_edge_coordinates(struct FloatVect3 *VEDGECOORDINATESc, struct FloatVect3 *VTARGETc, struct image_t *img_edges, struct image_t *img_disparity, struct crop_t *edge_search_area, uint8_t threshold, int16_t max_confidence)
int SBM_OCV(struct image_t *img_disp, const struct image_t *img_left, const struct image_t *img_right, const int ndisparities, const int SADWindowSize, const bool cropped)
struct point_t c_img_cropped
Principal point of normal camera images.
uint16_t threshold_median_depth
Below this distance (in meters) it is considered that the robot has reached the goal,...
int16_t heading_confidence
This is the confidence that the desired position was reached.
int32_t indx1d_c(const int32_t y, const int32_t x, const uint16_t img_height, const uint16_t img_width)
uint8_t is_no_edge_found_flag
Set to 1 if best edge (according to micro confidence) was found, 0 otherwise.
int min_disparity
Block size used for the block matching (SBM) function.
int threshold_edge_magnitude
Declared vector of coordinates of previous "best" edge detected in NED world coordinate system.
uint8_t previous_mode
Variable that saves previous state the state machine was in, for some memory.
void image_copy(struct image_t *input, struct image_t *output)
Copy an image from inut to output This will only work if the formats are the same.
int16_t max_free_path_confidence
This is the max confidence that an obstacle was spotted.
@ IMAGE_JPEG
An JPEG encoded image (not per pixel encoded)
int SE_dilation_OCV_1
SE size for the closing operation.
struct img_size_t img_dims
int16_t edge_found_macro_confidence
This is the confidence that the desired heading is reached.
float float_norm_two_angles(float target_angle, float current_angle)
enum navigation_state current_state
void Vi_to_Vc16bit(struct FloatVect3 *scene_point, int32_t image_point_y, int32_t image_point_x, const uint16_t d, const float b, const uint16_t f)
bool guidance_h_set_guided_heading(float heading)
Set heading setpoint in GUIDED mode.
uint16_t getMedian16bit(uint16_t *a, uint32_t n)
struct crop_t edge_search_area
Principal point of cropped camera images.
uint8_t find_best_edge_coordinates2(struct FloatVect3 *VEDGECOORDINATESc, struct FloatVect3 *VTARGETc, struct image_t *img_edges, struct image_t *img_depth, struct crop_t *edge_search_area, uint16_t threshold, int16_t max_confidence)
float float_vect3_norm_two_points(struct FloatVect3 *V1, struct FloatVect3 *V2)
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
void kernel_create(struct kernel_C1 *kernel, uint16_t width, uint16_t height, enum image_type type)
static struct FloatRMat * stateGetNedToBodyRMat_f(void)
Get vehicle body attitude rotation matrix (float).
uint32_t x
The x coordinate of the point.
uint8_t depth_to_disp(const float depth, const float b, const uint16_t f)
float threshold_distance_to_goal
Above this disparity edges are eligible for WedgeBug algorithm (i.e. edges cannot be very far away)
uint8_t is_edge_found_macro_flag
Set to 1 if heading is reached, 0 otherwise.
void post_disparity_crop_rect(struct crop_t *_img_cropped_info, struct img_size_t *_original_img_dims, const int disp_n, const int block_size)
struct image_t img_middle_int16_cropped
bool guidance_v_set_guided_z(float z)
Set z setpoint in GUIDED mode.
uint8_t is_state_changed_flag
Set to 1 if no edge was identified, 0 otherwise.
int16_t max_heading_confidence
This is the max confidence that a specific position was reached.
struct FloatVect3 VNEDwenu
#define WaypointAlt(_wp)
waypoint altitude in m above MSL
struct FloatVect3 VPBESTEDGECOORDINATESwned
Declared a vector to hold the position of a holding point (offten used to make sure drone stays still...
int N_disparities
Variable that saves previous mode to control the drone, for some memory.
float heading_towards_waypoint(uint8_t wp)
@ IMAGE_YUV422
UYVY format (uint16 per pixel)
void Vc_to_Vw(struct FloatVect3 *Vw, struct FloatVect3 *Vc, struct FloatRMat *Rrw, struct FloatVect3 *VRw, struct FloatRMat *Rcr, struct FloatVect3 *VCr, const uint8_t verbose)
double counter_state[NUMBER_OF_STATES]
#define WEDGEBUG_CAMERA_LEFT_FPS
uint8_t allow_state_change_EDGE_SCAN
int opening_OCV(struct image_t *img_input, const struct image_t *img_output, const int SE_size, const int iteration)
int SE_erosion_OCV
SE size for the second dilation operation (see state 3 "WEDGEBUG_START" and state 6 "POSITION_EDGE" )
int16_t position_confidence
This is the confidence that no obstacle was spotted.
uint32_t y
The y coordinate of the point.
const char * get_img_type(enum image_type img_type)
uint16_t K_median_w
SE size for the Sobel operation, to detect edges.
clock_t clock_total_time_previous
void guidance_h_hover_enter(void)
uint16_t y
Start position y (vertical)
struct crop_t img_cropped_info
uint8_t save_images_flag
Set to 1 if control mode of drone is changed, 0 otherwise.
struct img_size_t img_cropped_dims
Dimensions of images captured by the camera (left and right have same dimension)
uint8_t allow_state_change_POSITION_EDGE
int erosion_OCV(struct image_t *img_input, const struct image_t *img_output, const int SE_size, const int iteration)
uint8_t median_disparity_to_point(struct point_t *Vi, struct image_t *img, struct kernel_C1 *kernel_median)
double time_state[NUMBER_OF_STATES]
void kernel_free(struct kernel_C1 *kernel)
timer subsystem type(config options) --------------------------------------------(advanced timers using RCC_APB1) TIM1 adc(if USE_AD_TIM1) radio_control/ppm(if USE_PPM_TIM1
uint8_t allow_state_change_MOVE_TO_GOAL
struct FloatVect3 VSTARTwned
Declared vector of coordinates of start position in ENU world coordinate system.
clock_t clock_background_processes
static void float_vect_copy(float *a, const float *b, const int n)
a = b
float disp_to_depth_16bit(const int16_t d, const float b, const uint16_t f)
clock_t clock_total_time_current
void Vb_to_Va(struct FloatVect3 *Va, struct FloatVect3 *Vb, struct FloatRMat *Rba, struct FloatVect3 *VOa)
int SE_sobel_OCV
SE size for the erosion operation (see state 3 "WEDGEBUG_START" and state 6 "POSITION_EDGE",...
uint8_t is_setpoint_reached(struct FloatVect3 *VGOAL, struct FloatVect3 *VCURRENTPOSITION, float threshold)
Paparazzi generic algebra macros.
int16_t max_edge_found_micro_confidence
This is the max confidence that a specific heading was reached.
struct FloatVect3 VSTARTwenu
Height of kernel for the median kernel.
void * buf
Image buffer (depending on the image_type)
uint8_t is_setpoint_reached_flag
float distance_traveled
Variable to hold the median depth in front of the drone. Needed to see if obstacle is there.
#define WEDGEBUG_CAMERA_RIGHT_FPS
@ IMAGE_GRADIENT
An image gradient (int16 per pixel)
uint8_t autopilot_get_mode(void)
get autopilot mode
float disp_to_depth(const uint8_t d, const float b, const uint16_t f)
int save_image_HM(struct image_t *img, char *myString, int const heatmap)
float distance_robot_edge_goal
struct kernel_C1 median_kernel16bit
struct FloatVect3 VGOALc
Declared vector of coordinates of goal in robot coordinate system.
uint8_t is_right_reached_flag
uint16_t x
Start position x (horizontal)
float threshold_distance_to_angle
Below this distance (in meters) it is considered that the robot has reached the goal.
struct image_t img_depth_int16_cropped
Image obtained after simple block matching.
struct FloatVect3 VEDGECOORDINATESr
Declared vector of coordinates of "best" edge detected in camera coordinate system.
uint32_t maximum_intensity(struct image_t *img)
void set_state(uint8_t _state, uint8_t change_allowed)
struct image_t img_edges_int8_cropped
void show_rotation_matrix(struct FloatRMat *R)
int closing_OCV(struct image_t *img_input, const struct image_t *img_output, const int SE_size, const int iteration)
uint8_t is_start_reached_flag
This is the max confidence that no edges were found.
uint8_t is_mode_changed_flag
Set to 1 if state was changed, 0 otherwise.