sf45/collision-prevention: replace repeated code with ObstacleMath library functions.

This commit is contained in:
mahimayoga
2025-02-07 13:28:17 +01:00
committed by Silvan Fuhrer
parent e7e76e2e21
commit 093b379b6b
7 changed files with 78 additions and 118 deletions
+17 -1
View File
@@ -45,6 +45,7 @@ enum SensorOrientation {
ROTATION_YAW_225 = 5, // MAV_SENSOR_ROTATION_YAW_225
ROTATION_YAW_270 = 6, // MAV_SENSOR_ROTATION_YAW_270
ROTATION_YAW_315 = 7, // MAV_SENSOR_ROTATION_YAW_315
ROTATION_CUSTOM = 100, // MAV_SENSOR_ROTATION_CUSTOM
ROTATION_FORWARD_FACING = 0, // MAV_SENSOR_ROTATION_NONE
ROTATION_RIGHT_FACING = 2, // MAV_SENSOR_ROTATION_YAW_90
@@ -56,7 +57,7 @@ enum SensorOrientation {
* Converts a sensor orientation to a yaw offset
* @param orientation sensor orientation
*/
float sensor_orientation_to_yaw_offset(const SensorOrientation orientation);
float sensor_orientation_to_yaw_offset(const SensorOrientation orientation, const float q[4] = nullptr);
/**
* Scales a distance measurement taken in the vehicle body horizontal plane onto the world horizontal plane
@@ -73,6 +74,14 @@ void project_distance_on_horizontal_plane(float &distance, const float yaw, cons
*/
int get_bin_at_angle(float bin_width, float angle);
/**
* Returns lower bound angle of a bin
* @param bin bin index
* @param bin_width width of a bin in degrees
* @param angle_offset clockwise angle offset in degrees
*/
float get_lower_bound_angle(int bin, float bin_width, float angle_offset);
/**
* Returns bin index for the current bin after an angle offset
* @param bin current bin index
@@ -88,4 +97,11 @@ int get_offset_bin_index(int bin, float bin_width, float angle_offset);
*/
int wrap_bin(int bin, int bin_count);
/**
* Wraps an angle to the range [0, 360)
* @param angle angle in degrees
*/
float wrap_360(const float angle);
} // ObstacleMath