Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Obstacle avoidance methods. More...
#include <stdio.h>
#include <sys/fcntl.h>
#include <math.h>
#include <unistd.h>
#include <inttypes.h>
#include "state.h"
#include "math/pprz_algebra_float.h"
#include "math/pprz_geodetic_int.h"
#include "subsystems/datalink/telemetry.h"
#include "modules/stereocam/stereocam.h"
#include "modules/obstacle_avoidance/guidance_OA.h"
#include "modules/obstacle_avoidance/obstacle_avoidance.h"
Go to the source code of this file.
Macros | |
#define | AVOIDANCES_DISTANCES_HOR_COUNT 36 |
#define | AVOIDANCE_AMOUNT_OF_BOARDS 6 |
#define | AVOIDANCE_HEIGHT_IN_MEASUREMENT_VALUES 6 |
#define | AVOIDANCE_WIDTH_IN_MEASUREMENT_VALUES 6 |
Functions | |
void | serial_init (void) |
void | serial_start (void) |
void | setAnglesMeasurements (float *anglesMeasurements, float *centersensorRad, float *fieldOfViewRad, uint16_t *size_matrix_local) |
void | serial_update (void) |
void | matrix_2_pingpong (float *distancesMeters, uint16_t *size_matrix_local, float *distances_hor_local) |
void | CN_matrix_Kalman_filter (void) |
void | CN_matrix_butterworth (void) |
void | CN_calculate_target (void) |
void | pingpong_euler (float *distances_hor_local, float *horizontalAnglesMeasurements, int horizontalAmountOfMeasurements, float attitude_reference_pitch, float attitude_reference_roll, float dist_treshold_local) |
void | CN_potential_heading (void) |
void | CN_potential_velocity (void) |
void | CN_vector_velocity (void) |
void | CN_vector_escape_velocity (void) |
void | CN_escape_velocity (void) |
Obstacle avoidance methods.
Definition in file obstacle_avoidance.c.
#define AVOIDANCE_AMOUNT_OF_BOARDS 6 |
Definition at line 45 of file obstacle_avoidance.c.
#define AVOIDANCE_HEIGHT_IN_MEASUREMENT_VALUES 6 |
Definition at line 49 of file obstacle_avoidance.c.
#define AVOIDANCE_WIDTH_IN_MEASUREMENT_VALUES 6 |
Definition at line 53 of file obstacle_avoidance.c.
#define AVOIDANCES_DISTANCES_HOR_COUNT 36 |
Definition at line 41 of file obstacle_avoidance.c.
void CN_calculate_target | ( | void | ) |
Definition at line 321 of file obstacle_avoidance.c.
References current_pos, dx_ref, dy_ref, heading_goal_f, init_target, OA_method_flag, pos_diff, FloatEulers::psi, stateGetNedToBodyEulers_f(), stateGetPositionNed_f(), target, waypoint_rot, FloatVect2::x, NedCoor_f::x, FloatVect2::y, and NedCoor_f::y.
Referenced by serial_update().
void CN_escape_velocity | ( | void | ) |
Definition at line 1032 of file obstacle_avoidance.c.
References angle_hor_board, baseline, direction, FLOAT_ANGLE_NORMALIZE, focal, heading_goal_f, heading_goal_ref, min_disparity, new_heading, new_heading_old, obstacle_flag, pos_diff, FloatEulers::psi, ref_pitch, ref_roll, set_bias, size_matrix, speed_pot, stateGetNedToBodyEulers_f(), stereo_fow, VECT2_NORM2, vref_max, and waypoint_rot.
Referenced by serial_update().
void CN_matrix_butterworth | ( | void | ) |
Definition at line 295 of file obstacle_avoidance.c.
References butter_old, READimageBuffer_old, and size_matrix.
void CN_matrix_Kalman_filter | ( | void | ) |
Definition at line 263 of file obstacle_avoidance.c.
References A_kal, H_kal, Pest_new, Q_kal, R_kal, size_matrix, and Xest_new.
void CN_potential_heading | ( | void | ) |
Definition at line 404 of file obstacle_avoidance.c.
References angle_hor_board, b_damp, baseline, c1_oa, c2_oa, c3_oa, c4_oa, epsilon, FLOAT_ANGLE_NORMALIZE, focal, heading_goal_f, heading_goal_ref, K_goal, K_obst, kv, min_disparity, pos_diff, FloatEulers::psi, FloatRates::r, r_dot_new, size_matrix, speed_pot, stateGetBodyRates_f(), stateGetNedToBodyEulers_f(), stereo_fow, VECT2_NORM2, and vref_max.
Referenced by serial_update().
void CN_potential_velocity | ( | void | ) |
Definition at line 506 of file obstacle_avoidance.c.
References alpha_fil, angle_hor_board, b_damp, baseline, c1_oa, c2_oa, c3_oa, c4_oa, epsilon, FLOAT_ANGLE_NORMALIZE, focal, heading_goal_f, heading_goal_ref, K_goal, K_obst, kv, min_disparity, new_heading, pos_diff, FloatEulers::psi, FloatRates::r, r_dot_new, ref_pitch, size_matrix, speed_pot, stateGetBodyRates_f(), stateGetNedToBodyEulers_f(), stereo_fow, VECT2_NORM2, vmin, and vref_max.
Referenced by serial_update().
void CN_vector_escape_velocity | ( | void | ) |
Definition at line 777 of file obstacle_avoidance.c.
References angle_hor_board, Attractforce_goal, baseline, Cfreq, direction, Dist_offset, escape_flag, F1, F2, filter_repforce_old, FLOAT_ANGLE_NORMALIZE, focal, heading_goal_f, heading_goal_ref, Kg, Ko, min_disparity, new_heading, new_heading_old, obstacle_flag, pos_diff, FloatEulers::psi, ref_pitch, ref_roll, repulsionforce_filter_flag, Repulsionforce_Kan, Repulsionforce_Kan_old, Repulsionforce_Used, set_bias, size_matrix, speed_pot, stateGetNedToBodyEulers_f(), stereo_fow, v_max, v_min, VECT2_NORM2, VECT3_ADD, VECT3_COPY, VECT3_SMUL, vref_max, waypoint_rot, FloatVect3::x, FloatVect3::y, and FloatVect3::z.
Referenced by serial_update().
void CN_vector_velocity | ( | void | ) |
Definition at line 590 of file obstacle_avoidance.c.
References angle_hor_board, Attractforce_goal, baseline, Cfreq, Dist_offset, F1, F2, filter_repforce_old, focal, heading_goal_f, heading_goal_ref, hysteris_flag, Kg, Ko, min_disparity, pos_diff, FloatEulers::psi, ref_pitch, ref_roll, repulsionforce_filter_flag, Repulsionforce_Kan, Repulsionforce_Kan_old, Repulsionforce_Used, size_matrix, stateGetNedToBodyEulers_f(), stereo_fow, V_hys_high, V_hys_low, VECT2_NORM2, VECT3_ADD, VECT3_COPY, VECT3_SMUL, FloatVect3::x, FloatVect3::y, and FloatVect3::z.
Referenced by serial_update().
void matrix_2_pingpong | ( | float * | distancesMeters, |
uint16_t * | size_matrix_local, | ||
float * | distances_hor_local | ||
) |
Definition at line 237 of file obstacle_avoidance.c.
References AVOIDANCES_DISTANCES_HOR_COUNT.
Referenced by serial_update().
void pingpong_euler | ( | float * | distances_hor_local, |
float * | horizontalAnglesMeasurements, | ||
int | horizontalAmountOfMeasurements, | ||
float | attitude_reference_pitch, | ||
float | attitude_reference_roll, | ||
float | dist_treshold_local | ||
) |
Definition at line 357 of file obstacle_avoidance.c.
References ref_pitch, and ref_roll.
Referenced by serial_update().
void serial_init | ( | void | ) |
Definition at line 146 of file obstacle_avoidance.c.
References AVOIDANCE_AMOUNT_OF_BOARDS, AVOIDANCE_HEIGHT_IN_MEASUREMENT_VALUES, AVOIDANCE_WIDTH_IN_MEASUREMENT_VALUES, butter_old, Pest_new, and Xest_new.
void serial_start | ( | void | ) |
Definition at line 159 of file obstacle_avoidance.c.
void serial_update | ( | void | ) |
Definition at line 176 of file obstacle_avoidance.c.
References angle_hor_board, AVOIDANCE_AMOUNT_OF_BOARDS, CN_calculate_target(), CN_escape_velocity(), CN_potential_heading(), CN_potential_velocity(), CN_vector_escape_velocity(), CN_vector_velocity(), DefaultChannel, DefaultDevice, dist_treshold, distances_hor, LOGICBASED, matrix_2_pingpong(), OA_method_flag, PINGPONG, pingpong_euler(), POT_HEADING, POT_VEL, reference_pitch, reference_roll, SAFETYZONE, setAnglesMeasurements(), size_matrix, and stereo_fow.
void setAnglesMeasurements | ( | float * | anglesMeasurements, |
float * | centersensorRad, | ||
float * | fieldOfViewRad, | ||
uint16_t * | size_matrix_local | ||
) |
Definition at line 164 of file obstacle_avoidance.c.
Referenced by serial_update().
float A_kal = 1 |
Definition at line 83 of file obstacle_avoidance.c.
Referenced by CN_matrix_Kalman_filter().
float angle_hor_board[] = {0, 1.0472, 2.0944, 3.1416, -2.0944, -1.0472} |
Definition at line 59 of file obstacle_avoidance.c.
Referenced by CN_escape_velocity(), CN_potential_heading(), CN_potential_velocity(), CN_vector_escape_velocity(), CN_vector_velocity(), and serial_update().
struct FloatVect3 Attractforce_goal |
Definition at line 108 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and CN_vector_velocity().
struct FloatVect3 Attractforce_goal_send |
Definition at line 136 of file obstacle_avoidance.c.
float b_damp = 0 |
Definition at line 110 of file obstacle_avoidance.c.
Referenced by CN_potential_heading(), and CN_potential_velocity().
float B_kal = 0 |
Definition at line 84 of file obstacle_avoidance.c.
float baseline = 60 |
Definition at line 61 of file obstacle_avoidance.c.
Referenced by CN_escape_velocity(), CN_potential_heading(), CN_potential_velocity(), CN_vector_escape_velocity(), and CN_vector_velocity().
float butter_old[AVOIDANCE_AMOUNT_OF_BOARDS *AVOIDANCE_HEIGHT_IN_MEASUREMENT_VALUES *AVOIDANCE_WIDTH_IN_MEASUREMENT_VALUES] |
Definition at line 97 of file obstacle_avoidance.c.
Referenced by CN_matrix_butterworth(), and serial_init().
float c1_oa = 0.4 |
Definition at line 113 of file obstacle_avoidance.c.
Referenced by CN_potential_heading(), and CN_potential_velocity().
float c2_oa = 0.4 |
Definition at line 114 of file obstacle_avoidance.c.
Referenced by CN_potential_heading(), and CN_potential_velocity().
float c3_oa = 5.0 |
Definition at line 115 of file obstacle_avoidance.c.
Referenced by CN_potential_heading(), and CN_potential_velocity().
float c4_oa = 0.5 |
Definition at line 116 of file obstacle_avoidance.c.
Referenced by CN_potential_heading(), and CN_potential_velocity().
float c5_oa = 0.9 |
Definition at line 117 of file obstacle_avoidance.c.
float Cfreq = 1 |
Definition at line 101 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and CN_vector_velocity().
struct NedCoor_f current_pos |
Definition at line 77 of file obstacle_avoidance.c.
Referenced by CN_calculate_target().
uint8_t direction = 0 |
Definition at line 125 of file obstacle_avoidance.c.
Referenced by CN_escape_velocity(), CN_vector_escape_velocity(), and nav_get_speed_sp_from_line().
int8_t dis_treshold = 2 |
Definition at line 105 of file obstacle_avoidance.c.
float Dist_offset = 0 |
Definition at line 104 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and CN_vector_velocity().
float dist_treshold = 1.25 |
Definition at line 66 of file obstacle_avoidance.c.
Referenced by serial_update().
float distances_hor[AVOIDANCES_DISTANCES_HOR_COUNT] |
Definition at line 67 of file obstacle_avoidance.c.
Referenced by serial_update().
float dx_ref = 0 |
Definition at line 80 of file obstacle_avoidance.c.
Referenced by CN_calculate_target().
float dy_ref = 0 |
Definition at line 81 of file obstacle_avoidance.c.
Referenced by CN_calculate_target().
float epsilon = 0.0 |
Definition at line 119 of file obstacle_avoidance.c.
Referenced by CN_potential_heading(), CN_potential_velocity(), inverse_isometric_latitude_d(), and inverse_isometric_latitude_f().
uint8_t escape_flag = 0 |
Definition at line 128 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity().
float F1 = 0.1 |
Definition at line 99 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and CN_vector_velocity().
float F2 = 0.9 |
Definition at line 100 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and CN_vector_velocity().
struct FloatVect3 filter_repforce_old = {0.0, 0.0, 0.0} |
Definition at line 94 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and CN_vector_velocity().
int16_t focal = 118 * 6 |
Definition at line 60 of file obstacle_avoidance.c.
Referenced by CN_escape_velocity(), CN_potential_heading(), CN_potential_velocity(), CN_vector_escape_velocity(), and CN_vector_velocity().
float H_kal = 1 |
Definition at line 85 of file obstacle_avoidance.c.
Referenced by CN_matrix_Kalman_filter().
float heading_goal_f = 0 |
Definition at line 73 of file obstacle_avoidance.c.
Referenced by CN_calculate_target(), CN_escape_velocity(), CN_potential_heading(), CN_potential_velocity(), CN_vector_escape_velocity(), and CN_vector_velocity().
float heading_goal_ref |
Definition at line 74 of file obstacle_avoidance.c.
Referenced by CN_escape_velocity(), CN_potential_heading(), CN_potential_velocity(), CN_vector_escape_velocity(), and CN_vector_velocity().
uint8_t hysteris_flag |
Definition at line 134 of file obstacle_avoidance.c.
Referenced by CN_vector_velocity().
struct FloatVect2 init_target = {0, 0} |
Definition at line 79 of file obstacle_avoidance.c.
Referenced by CN_calculate_target().
float K_gain_send = 0 |
Definition at line 88 of file obstacle_avoidance.c.
float K_goal = 1 |
Definition at line 111 of file obstacle_avoidance.c.
Referenced by CN_potential_heading(), and CN_potential_velocity().
float K_obst = 40 |
Definition at line 112 of file obstacle_avoidance.c.
Referenced by CN_potential_heading(), and CN_potential_velocity().
float Kg = 100 |
Definition at line 103 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and CN_vector_velocity().
float Ko = 60 |
Definition at line 102 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and CN_vector_velocity().
float kv = 0.05 |
Definition at line 118 of file obstacle_avoidance.c.
Referenced by CN_potential_heading(), and CN_potential_velocity().
float new_heading_old |
Definition at line 127 of file obstacle_avoidance.c.
Referenced by CN_escape_velocity(), and CN_vector_escape_velocity().
uint8_t obstacle_flag = 0 |
Definition at line 124 of file obstacle_avoidance.c.
Referenced by CN_escape_velocity(), and CN_vector_escape_velocity().
float Pest_new[AVOIDANCE_AMOUNT_OF_BOARDS *AVOIDANCE_HEIGHT_IN_MEASUREMENT_VALUES *AVOIDANCE_WIDTH_IN_MEASUREMENT_VALUES] |
Definition at line 90 of file obstacle_avoidance.c.
Referenced by CN_matrix_Kalman_filter(), and serial_init().
uint8_t point_index = 0 |
Definition at line 121 of file obstacle_avoidance.c.
struct FloatVect2 pos_diff |
Definition at line 75 of file obstacle_avoidance.c.
Referenced by CN_calculate_target(), CN_escape_velocity(), CN_potential_heading(), CN_potential_velocity(), CN_vector_escape_velocity(), CN_vector_velocity(), get_dist2_to_point(), nav_circle(), nav_route(), nav_set_heading_towards(), and nav_spiral_run().
float Q_kal = 0.05 |
Definition at line 86 of file obstacle_avoidance.c.
Referenced by CN_matrix_Kalman_filter().
float R_kal = 2 |
Definition at line 87 of file obstacle_avoidance.c.
Referenced by CN_matrix_Kalman_filter().
uint8_t* READimageBuffer_old |
Definition at line 72 of file obstacle_avoidance.c.
Referenced by CN_matrix_butterworth().
float ref_yaw = 0.0 |
Definition at line 62 of file obstacle_avoidance.c.
float reference_pitch = 0.1 |
Definition at line 64 of file obstacle_avoidance.c.
Referenced by serial_update().
float reference_roll = 0.1 |
Definition at line 65 of file obstacle_avoidance.c.
Referenced by serial_update().
struct FloatVect3 Repulsionforce_Kan |
Definition at line 107 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and CN_vector_velocity().
struct FloatVect3 Repulsionforce_Kan_old = {0.0, 0.0, 0.0} |
Definition at line 95 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and CN_vector_velocity().
struct FloatVect3 Repulsionforce_Kan_send |
Definition at line 137 of file obstacle_avoidance.c.
struct FloatVect3 Repulsionforce_Used |
Definition at line 106 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and CN_vector_velocity().
uint8_t set_bias = 0 |
Definition at line 123 of file obstacle_avoidance.c.
Referenced by CN_escape_velocity(), and CN_vector_escape_velocity().
uint16_t size_matrix[] = {AVOIDANCE_AMOUNT_OF_BOARDS, AVOIDANCE_HEIGHT_IN_MEASUREMENT_VALUES, AVOIDANCE_WIDTH_IN_MEASUREMENT_VALUES} |
Definition at line 57 of file obstacle_avoidance.c.
Referenced by CN_escape_velocity(), CN_matrix_butterworth(), CN_matrix_Kalman_filter(), CN_potential_heading(), CN_potential_velocity(), CN_vector_escape_velocity(), CN_vector_velocity(), and serial_update().
float stereo_fow[2] = {1.0018, 0.7767} |
Definition at line 58 of file obstacle_avoidance.c.
Referenced by CN_escape_velocity(), CN_potential_heading(), CN_potential_velocity(), CN_vector_escape_velocity(), CN_vector_velocity(), and serial_update().
struct FloatVect2 target |
Definition at line 78 of file obstacle_avoidance.c.
Referenced by CN_calculate_target(), georeference_run(), lsm303d_spi_init(), mavlink_common_message_handler(), nav_eight(), nav_get_speed_sp_from_go(), nav_get_speed_sp_from_line(), nav_set_heading_towards(), and px4flash_event().
float V_hys_high = 10 |
Definition at line 133 of file obstacle_avoidance.c.
Referenced by CN_vector_velocity().
float V_hys_low = 5 |
Definition at line 132 of file obstacle_avoidance.c.
Referenced by CN_vector_velocity().
float v_max = 0.6 |
Definition at line 130 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and image_labeling().
float v_min = 0.3 |
Definition at line 129 of file obstacle_avoidance.c.
Referenced by CN_vector_escape_velocity(), and image_labeling().
float vmin = 0.2 |
Definition at line 120 of file obstacle_avoidance.c.
Referenced by CN_potential_velocity().
float waypoint_rot = 0 |
Definition at line 126 of file obstacle_avoidance.c.
Referenced by CN_calculate_target(), CN_escape_velocity(), and CN_vector_escape_velocity().
float Xest_new[AVOIDANCE_AMOUNT_OF_BOARDS *AVOIDANCE_HEIGHT_IN_MEASUREMENT_VALUES *AVOIDANCE_WIDTH_IN_MEASUREMENT_VALUES] |
Definition at line 92 of file obstacle_avoidance.c.
Referenced by CN_matrix_Kalman_filter(), and serial_init().