52 #include "generated/flight_plan.h"
61 #ifndef WEDGEBUG_CAMERA_RIGHT_FPS
62 #define WEDGEBUG_CAMERA_RIGHT_FPS 0
64 #ifndef WEDGEBUG_CAMERA_LEFT_FPS
65 #define WEDGEBUG_CAMERA_LEFT_FPS 0
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;
uint8_t autopilot_get_mode(void)
get autopilot mode
Core autopilot interface common to all firmwares.
bool autopilot_guided_goto_ned(float x, float y, float z, float heading)
Set position and heading setpoints in GUIDED mode.
Autopilot guided mode interface.
#define WaypointAlt(_wp)
waypoint altitude in m above MSL
struct video_listener * cv_add_to_device(struct video_config_t *device, cv_function func, uint16_t fps, uint8_t id)
Computer vision framework for onboard processing.
#define FLOAT_ANGLE_NORMALIZE(_a)
static void float_vect_copy(float *a, const float *b, const int n)
a = b
void float_rmat_transp_vmult(struct FloatVect3 *vb, struct FloatRMat *m_b2a, struct FloatVect3 *va)
rotate 3D vector by transposed rotation matrix.
static float float_vect3_norm(struct FloatVect3 *v)
void float_rmat_vmult(struct FloatVect3 *vb, struct FloatRMat *m_a2b, struct FloatVect3 *va)
rotate 3D vector by rotation matrix.
#define VECT2_DIFF(_c, _a, _b)
#define VECT3_DIFF(_c, _a, _b)
static struct FloatRMat * stateGetNedToBodyRMat_f(void)
Get vehicle body attitude rotation matrix (float).
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
static struct NedCoor_f * stateGetPositionNed_f(void)
Get position in local NED coordinates (float).
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.
void image_to_grayscale(struct image_t *input, struct image_t *output)
Convert an image to grayscale.
void image_create(struct image_t *img, uint16_t width, uint16_t height, enum image_type type)
Create a new image.
Image helper functions like resizing, color filter, converters...
uint16_t h
height of the cropped area
uint16_t w
Width of the cropped area.
uint32_t buf_size
The buffer size.
void * buf
Image buffer (depending on the image_type)
uint32_t x
The x coordinate of the point.
uint16_t x
Start position x (horizontal)
uint16_t y
Start position y (vertical)
uint32_t y
The y coordinate of the point.
enum image_type type
The image type.
@ IMAGE_GRAYSCALE
Grayscale image with only the Y part (uint8 per pixel)
@ IMAGE_YUV422
UYVY format (uint16 per pixel)
@ IMAGE_GRADIENT
An image gradient (int16 per pixel)
@ IMAGE_INT16
An image to hold disparity image data from openCV (int16 per pixel)
@ IMAGE_JPEG
An JPEG encoded image (not per pixel encoded)
Paparazzi generic algebra macros.
Paparazzi floating point algebra.
Paparazzi floating point math for geodetic calculations.
#define AP_MODE_ATTITUDE_DIRECT
#define AP_MODE_ATTITUDE_Z_HOLD
void guidance_h_set_pos(float x, float y)
Set horizontal position setpoint.
void guidance_h_hover_enter(void)
void guidance_h_set_heading(float heading)
Set heading setpoint.
void guidance_v_set_z(float z)
Set z position setpoint.
API to get/set the generic vehicle states.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
float max_edge_search_angle
Variable for storing the heading of the drone (psi in radians)
uint16_t K_median_h
Width of kernel for the median kernel.
struct FloatVect3 VHOLDINGPOINTwned
Declared a vector to hold the current position, which is needed for calculating the distance traveled...
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
uint16_t threshold_median_depth
Below this distance (in meters) it is considered that the robot has reached the goal,...
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)
float disp_to_depth_16bit(const int16_t d, const float b, const uint16_t f)
uint8_t allow_state_change_POSITION_EDGE
uint8_t is_obstacle_detected_flag
Set to 1 if setpoint is reached, 0 otherwise.
#define WEDGEBUG_CAMERA_LEFT_FPS
uint8_t is_setpoint_reached(struct FloatVect3 *VGOAL, struct FloatVect3 *VCURRENTPOSITION, float threshold)
enum control_mode_state current_mode
uint8_t is_no_edge_found_flag
Set to 1 if best edge (according to micro confidence) was found, 0 otherwise.
uint8_t is_mode_changed_flag
Set to 1 if state was changed, 0 otherwise.
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)
int16_t max_heading_confidence
This is the max confidence that a specific position was reached.
float threshold_distance_to_angle
Below this distance (in meters) it is considered that the robot has reached the goal.
float float_norm_two_angles(float target_angle, float current_angle)
navigation_state
Camera focal length, in pixels (i.e. distance between camera.
uint8_t allow_state_change_EDGE_SCAN
uint8_t is_heading_reached(float target_angle, float current_angle, float threshold)
struct FloatVect3 VGOALwenu
Declared vector of coordinates of start position in NED world coordinate system.
struct point_t c_img_cropped
Principal point of normal camera images.
struct img_size_t kernel_median_dims
Dimension of image after it has been cropped to remove pixel error due to block matching limitations.
void disp_to_depth_img(struct image_t *img8bit_input, struct image_t *img16bit_output)
struct img_size_t img_cropped_dims
Dimensions of images captured by the camera (left and right have same dimension)
int heat_map_type
Variable to hold distance from robot to edge to goal (used in EDGE_SCAN (9) state)
int SE_closing_OCV
SE size for the opening operation.
double time_state[NUMBER_OF_STATES]
struct FloatVect3 VPBESTEDGECOORDINATESwned
Declared a vector to hold the position of a holding point (offten used to make sure drone stays still...
void background_processes(uint8_t save_images_flag)
void show_rotation_matrix(struct FloatRMat *R)
struct image_t img_disparity_int8_cropped
Image obtained from right camera, converted into 8bit gray image.
int16_t max_edge_found_macro_confidence
This is the max confidence that edges (micro-see above) were found.
int32_t indx1d_a(const int32_t y, const int32_t x, const struct image_t *img)
float distance_robot_edge_goal
clock_t clock_background_processes
uint8_t is_edge_found_micro_flag
Set to 1 if best edge (according to macro confidence) was found, 0 otherwise.
uint32_t maximum_intensity(struct image_t *img)
void Va_to_Vb(struct FloatVect3 *Vb, struct FloatVect3 *Va, struct FloatRMat *Rba, struct FloatVect3 *VOa)
float heading_towards_setpoint_WNED(struct FloatVect3 *VSETPOINTwned)
uint8_t allow_state_change_POSITION_GOAL
uint16_t getMedian16bit(uint16_t *a, uint32_t n)
int16_t max_position_confidence
This is the max confidence that an obstacle was not spotted.
int16_t heading_confidence
This is the confidence that the desired position was reached.
struct image_t img_left_int8_cropped
Image obtained from left camera, converted into 8bit gray image.
uint8_t median_disparity_to_point(struct point_t *Vi, struct image_t *img, struct kernel_C1 *kernel_median)
enum navigation_state current_state
struct FloatVect3 VGOALwned
Declared vector of coordinates of goal in ENU world coordinate system.
uint16_t median_depth_to_point(struct point_t *Vi, struct image_t *img, struct kernel_C1 *kernel_median)
struct FloatVect3 VEDGECOORDINATESwned
Declared vector of coordinates of "best" edge detected in robot coordinate system.
int SE_dilation_OCV_1
SE size for the closing operation.
uint8_t is_right_reached_flag
const char * get_img_type(enum image_type img_type)
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 img_size_t img_dims
int min_disparity
Block size used for the block matching (SBM) function.
void thresholding_img(struct image_t *img, uint8_t threshold)
uint8_t is_path_free_flag
Set to 1 if obstacle is detected, 0 otherwise.
struct kernel_C1 median_kernel
Dimensions of the kernel that detect median disparity in front of drone (for obstacle detection)
int SE_sobel_OCV
SE size for the erosion operation (see state 3 "WEDGEBUG_START" and state 6 "POSITION_EDGE",...
float threshold_distance_to_goal_direct
Below this distance (in radians) it is considered that the robot has reached the target angle.
int16_t position_confidence
This is the confidence that no obstacle was spotted.
struct FloatVect3 VNEDwenu
clock_t clock_total_time_previous
void show_image_entry(struct image_t *img, int entry_position, const char *img_name)
float dispfixed_to_disp(const int16_t d)
float threshold_distance_to_goal
Above this disparity edges are eligible for WedgeBug algorithm (i.e. edges cannot be very far away)
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 is_heading_reached_flag
Set to 1 if no obstacle is detected, 0 otherwise.
struct FloatVect3 VSTARTwenu
Height of kernel for the median kernel.
int16_t max_edge_found_micro_confidence
This is the max confidence that a specific heading was reached.
int SE_erosion_OCV
SE size for the second dilation operation (see state 3 "WEDGEBUG_START" and state 6 "POSITION_EDGE" )
float threshold_distance_to_goal_manual
void UYVYs_interlacing_V(struct image_t *YY, struct image_t *left, struct image_t *right)
int SE_dilation_OCV_2
SE size for the first dilation operation.
uint8_t previous_mode
Variable that saves previous state the state machine was in, for some memory.
uint8_t allow_state_change_MOVE_TO_GOAL
uint8_t is_total_timer_on_flag
void background_processes_16bit(uint8_t save_images_flag)
struct crop_t edge_search_area
Principal point of cropped camera images.
uint8_t depth_to_disp(const float depth, const float b, const uint16_t f)
int16_t max_free_path_confidence
This is the max confidence that an obstacle was spotted.
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)
struct image_t img_middle_int8_cropped
Image holding depth values (cm) obtained from the disparity image.
int16_t free_path_confidence
This is the confidence that an obstacle was spotted.
float disp_to_depth(const uint8_t d, const float b, const uint16_t f)
int block_size_disparities
Number of disparity levels (0-this number)
float float_vect3_norm_two_points(struct FloatVect3 *V1, struct FloatVect3 *V2)
struct image_t img_depth_int16_cropped
Image obtained after simple block matching.
struct crop_t img_cropped_info
uint16_t K_median_w
SE size for the Sobel operation, to detect edges.
void Vb_to_Va(struct FloatVect3 *Va, struct FloatVect3 *Vb, struct FloatRMat *Rba, struct FloatVect3 *VOa)
uint8_t allow_state_change_WEDGEBUG_START
double counter_state[NUMBER_OF_STATES]
int16_t edge_found_macro_confidence
This is the confidence that the desired heading is reached.
struct FloatVect3 VGOALc
Declared vector of coordinates of goal in robot coordinate system.
int16_t max_no_edge_found_confidence
This is the max confidence that edges (macro-see above were found.
uint16_t median_depth_in_front
Variable to hold the median disparity in front of the drone. Needed to see if obstacle is there.
struct FloatVect3 VEDGECOORDINATESc
Declared vector of coordinates of goal in camera coordinate system.
uint8_t is_edge_found_macro_flag
Set to 1 if heading is reached, 0 otherwise.
void show_image_data(struct image_t *img)
struct image_t img_middle_int16_cropped
static struct image_t * copy_right_img_func(struct image_t *img, uint8_t camera_id)
#define WEDGEBUG_CAMERA_RIGHT_FPS
uint8_t is_start_reached_flag
This is the max confidence that no edges were found.
struct FloatVect3 VEDGECOORDINATESwenu
Declared vector of coordinates of "best" edge detected in NED world coordinate system.
uint8_t is_setpoint_reached_flag
int N_disparities
Variable that saves previous mode to control the drone, for some memory.
int16_t max_obstacle_confidence
This is the confidence that no edge was found.
float distance_traveled
Variable to hold the median depth in front of the drone. Needed to see if obstacle is there.
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)
struct FloatVect3 VGOALr
Declared vector of coordinates of goal in NED world coordinate system.
uint8_t allow_state_change_MOVE_TO_EDGE
uint8_t threshold_median_disparity
Edges with a magnitude above this value are detected. Above this value, edges are given the value 127...
uint8_t threshold_disparity_of_edges
Above this median disparity, an obstacle is considered to block the way (i.e. the blocking obstacle n...
struct FloatVect3 VEDGECOORDINATESr
Declared vector of coordinates of "best" edge detected in camera coordinate system.
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_state_changed_flag
Set to 1 if no edge was identified, 0 otherwise.
int16_t obstacle_confidence
Below this depth (m) edges are eligible for the WedgeBug algorithm (i.e. edges cannot be very far awa...
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)
int32_t indx1d_b(const int32_t y, const int32_t x, const struct img_size_t *img_dims)
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)
int16_t no_edge_found_confidence
This is the confidence that an edge was found - outside of the find_best_edge_coordinates function.
struct ES_angles initial_heading
struct kernel_C1 median_kernel16bit
struct image_t img_left_int8
Image obtained from right camera (UYVY format)
struct image_t img_edges_int8_cropped
static struct image_t * copy_left_img_func(struct image_t *img, uint8_t camera_id)
void principal_points(struct point_t *c_output, const struct point_t *c_old_input, struct crop_t *img_cropped_info)
float heading_towards_waypoint(uint8_t wp)
int threshold_edge_magnitude
Declared vector of coordinates of previous "best" edge detected in NED world coordinate system.
void UYVYs_interlacing_H(struct image_t *merged, struct image_t *left, struct image_t *right)
clock_t clock_total_time_current
uint8_t is_left_reached_flag
struct image_t img_right
Image obtained from left camera (UYVY format)
struct image_t img_right_int8
struct FloatRMat Rwnedwenu
This structure holds information about the window in which edges are searched in.
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)
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_disparity_int16_cropped
Image obtained from the external sobel edge detection function = sobel_OCV.
struct FloatVect3 VSTARTwned
Declared vector of coordinates of start position in ENU world coordinate system.
struct FloatVect3 VDISTANCEPOSITIONwned
Declared vector of coordinates of "best" edge detected in ENU world coordinate system.
uint8_t save_images_flag
Set to 1 if control mode of drone is changed, 0 otherwise.
void set_state(uint8_t _state, uint8_t change_allowed)
void * buf_weights
Kernel weight buffer.
uint32_t buf_size
Size of values of weight buffer and values buffer.
uint8_t getMedian(uint8_t *a, uint32_t n)
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)
void kernel_free(struct kernel_C1 *kernel)
void * buf_values
Kernel value buffer. These are the values underneath the kernel.
void kernel_create(struct kernel_C1 *kernel, uint16_t width, uint16_t height, enum image_type type)
void wedgebug_periodic(void)
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)
int closing_OCV(struct image_t *img_input, const struct image_t *img_output, const int SE_size, const int iteration)
int sobel_OCV(struct image_t *img_input, const struct image_t *img_output, const int kernel_size, const int thr)
int save_image_gray(struct image_t *img, char *myString)
int dilation_OCV(struct image_t *img_input, const struct image_t *img_output, const int SE_size, const int iteration)
int erosion_OCV(struct image_t *img_input, const struct image_t *img_output, const int SE_size, const int iteration)
int opening_OCV(struct image_t *img_input, const struct image_t *img_output, const int SE_size, const int iteration)
int save_image_HM(struct image_t *img, char *myString, int const heatmap)