diff --git a/src/lib/ecl/attitude_fw/ecl_wheel_controller.cpp b/src/lib/ecl/attitude_fw/ecl_wheel_controller.cpp index 7f8a9ca6c7..7e34ff2a61 100644 --- a/src/lib/ecl/attitude_fw/ecl_wheel_controller.cpp +++ b/src/lib/ecl/attitude_fw/ecl_wheel_controller.cpp @@ -33,7 +33,7 @@ /** * @file ecl_wheel_controller.cpp - * Implementation of a simple orthogonal coordinated turn yaw PID controller. + * Implementation of a simple PID wheel controller for heading tracking. * * Authors and acknowledgements in header. */ diff --git a/src/lib/geo/geo.c b/src/lib/geo/geo.c index a8eee50435..af49bf1504 100644 --- a/src/lib/geo/geo.c +++ b/src/lib/geo/geo.c @@ -301,18 +301,16 @@ __EXPORT float get_distance_to_next_waypoint(double lat_now, double lon_now, dou __EXPORT void create_waypoint_from_line_and_dist(double lat_A, double lon_A, double lat_B, double lon_B, float dist, double *lat_target, double *lon_target) { - float heading; - if (fabsf(dist) < FLT_EPSILON) { *lat_target = lat_A; *lon_target = lon_A; } else if (dist >= FLT_EPSILON) { - heading = get_bearing_to_next_waypoint(lat_A, lon_A, lat_B, lon_B); + float heading = get_bearing_to_next_waypoint(lat_A, lon_A, lat_B, lon_B); waypoint_from_heading_and_distance(lat_A, lon_A, heading, dist, lat_target, lon_target); } else { - heading = get_bearing_to_next_waypoint(lat_A, lon_A, lat_B, lon_B); + float heading = get_bearing_to_next_waypoint(lat_A, lon_A, lat_B, lon_B); heading = _wrap_2pi(heading + M_PI_F); waypoint_from_heading_and_distance(lat_A, lon_A, heading, dist, lat_target, lon_target); } @@ -324,16 +322,16 @@ __EXPORT void waypoint_from_heading_and_distance(double lat_start, double lon_st bearing = _wrap_2pi(bearing); double radius_ratio = (double)(fabs(dist) / CONSTANTS_RADIUS_OF_EARTH); - double lat_start_rad = lat_start / (double)180.0 * M_PI; - double lon_start_rad = lon_start / (double)180.0 * M_PI; + double lat_start_rad = lat_start * M_DEG_TO_RAD; + double lon_start_rad = lon_start * M_DEG_TO_RAD; *lat_target = asin(sin(lat_start_rad) * cos(radius_ratio) + cos(lat_start_rad) * sin(radius_ratio) * cos(( double)bearing)); *lon_target = lon_start_rad + atan2(sin((double)bearing) * sin(radius_ratio) * cos(lat_start_rad), cos(radius_ratio) - sin(lat_start_rad) * sin(*lat_target)); - *lat_target *= (double)180.0 / M_PI; - *lon_target *= (double)180.0 / M_PI; + *lat_target *= M_RAD_TO_DEG; + *lon_target *= M_RAD_TO_DEG; } __EXPORT float get_bearing_to_next_waypoint(double lat_now, double lon_now, double lat_next, double lon_next) { diff --git a/src/lib/geo/geo.h b/src/lib/geo/geo.h index 0aa6cf03a8..11451fcf19 100644 --- a/src/lib/geo/geo.h +++ b/src/lib/geo/geo.h @@ -245,7 +245,7 @@ __EXPORT float get_distance_to_next_waypoint(double lat_now, double lon_now, dou * @param lon_A waypoint A longitude in degrees (8.1234567°, not 81234567°) * @param lat_B waypoint B latitude in degrees (47.1234567°, not 471234567°) * @param lon_B waypoint B longitude in degrees (8.1234567°, not 81234567°) - * @param dist distance of target waypoint from waypoint A (can be negative) + * @param dist distance of target waypoint from waypoint A in meters (can be negative) * @param lat_target latitude of target waypoint C in degrees (47.1234567°, not 471234567°) * @param lon_target longitude of target waypoint C in degrees (47.1234567°, not 471234567°) */ @@ -254,11 +254,12 @@ __EXPORT void create_waypoint_from_line_and_dist(double lat_A, double lon_A, dou /** * Creates a waypoint from given waypoint, distance and bearing + * see http://www.movable-type.co.uk/scripts/latlong.html * * @param lat_start latitude of starting waypoint in degrees (47.1234567°, not 471234567°) * @param lon_start longitude of starting waypoint in degrees (8.1234567°, not 81234567°) - * @param bearing - * @param distance + * @param bearing in rad + * @param distance in meters * @param lat_target latitude of target waypoint in degrees (47.1234567°, not 471234567°) * @param lon_target longitude of target waypoint in degrees (47.1234567°, not 471234567°) */ diff --git a/src/lib/runway_takeoff/runway_takeoff_params.c b/src/lib/runway_takeoff/runway_takeoff_params.c index 7c64889e76..f5a1017f96 100644 --- a/src/lib/runway_takeoff/runway_takeoff_params.c +++ b/src/lib/runway_takeoff/runway_takeoff_params.c @@ -71,6 +71,7 @@ PARAM_DEFINE_INT32(RWTO_HDG, 0); * rudder is used to keep the heading (see RWTO_HDG). This should be below * FW_CLMBOUT_DIFF if FW_CLMBOUT_DIFF > 0. * + * @unit m * @min 0.0 * @max 100.0 * @group Runway Takeoff @@ -93,6 +94,7 @@ PARAM_DEFINE_FLOAT(RWTO_MAX_THR, 1.0); * a little to keep it's wheel on the ground before airspeed * to takeoff is reached. * + * @unit deg * @min 0.0 * @max 20.0 * @group Runway Takeoff @@ -104,6 +106,7 @@ PARAM_DEFINE_FLOAT(RWTO_PSP, 0.0); * Fixed-wing settings are used if set to 0. Note that there is also a minimum * pitch of 10 degrees during takeoff, so this must be larger if set. * + * @unit deg * @min 0.0 * @max 60.0 * @group Runway Takeoff @@ -115,6 +118,7 @@ PARAM_DEFINE_FLOAT(RWTO_MAX_PITCH, 20.0); * Roll is limited during climbout to ensure enough lift and prevents aggressive * navigation before we're on a safe height. * + * @unit deg * @min 0.0 * @max 60.0 * @group Runway Takeoff diff --git a/src/lib/terrain_estimation/terrain_estimator.h b/src/lib/terrain_estimation/terrain_estimator.h index 25723f21d8..ed9e9741f3 100644 --- a/src/lib/terrain_estimation/terrain_estimator.h +++ b/src/lib/terrain_estimation/terrain_estimator.h @@ -51,14 +51,14 @@ * The measurement_update(...) function does a measurement update based on range finder and gps * velocity measurements. Both functions should always be called together when there is new * acceleration data available. -* The is_valid() function provides information wether the estimate is valid. +* The is_valid() function provides information whether the estimate is valid. */ class __EXPORT TerrainEstimator { public: TerrainEstimator(); - ~TerrainEstimator(); + ~TerrainEstimator() {}; bool is_valid() {return _terrain_valid;} float get_distance_to_ground() {return -_x(0);} @@ -85,6 +85,7 @@ private: uint64_t _time_last_distance; uint64_t _time_last_gps; + /* struct { float var_acc_z; float var_p_z; @@ -92,6 +93,7 @@ private: float var_lidar; float var_gps_vz; } _params; + */ bool is_distance_valid(float distance); diff --git a/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp b/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp index e4c8eeccde..49f08f3cab 100644 --- a/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp +++ b/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp @@ -270,7 +270,7 @@ AttitudePositionEstimatorEKF::~AttitudePositionEstimatorEKF() } } while (_estimator_task != -1); } - + delete _terrain_estimator; delete _ekf; estimator::g_estimator = nullptr;