Browse Source

AC_PID: convert AC_P_2D to double

zr-v5.1
Andrew Tridgell 4 years ago
parent
commit
c8079a318c
  1. 4
      libraries/AC_PID/AC_P_2D.cpp
  2. 4
      libraries/AC_PID/AC_P_2D.h

4
libraries/AC_PID/AC_P_2D.cpp

@ -24,12 +24,12 @@ AC_P_2D::AC_P_2D(float initial_p, float dt) : @@ -24,12 +24,12 @@ AC_P_2D::AC_P_2D(float initial_p, float dt) :
// update_all - set target and measured inputs to P controller and calculate outputs
// limit is set true if the target has been moved to limit the maximum position error
Vector2f AC_P_2D::update_all(float &target_x, float &target_y, const Vector2f &measurement, bool &limit)
Vector2f AC_P_2D::update_all(postype_t &target_x, postype_t &target_y, const Vector2f &measurement, bool &limit)
{
limit = false;
// calculate distance _error
_error = Vector2f{target_x, target_y} - measurement;
_error = (Vector2p{target_x, target_y} - measurement.topostype()).tofloat();
// Constrain _error and target position
// Constrain the maximum length of _vel_target to the maximum position correction velocity

4
libraries/AC_PID/AC_P_2D.h

@ -20,11 +20,11 @@ public: @@ -20,11 +20,11 @@ public:
void set_dt(float dt) { _dt = dt; }
// set target and measured inputs to P controller and calculate outputs
Vector2f update_all(float &target_x, float &target_y, const Vector2f &measurement, bool &limit) WARN_IF_UNUSED;
Vector2f update_all(postype_t &target_x, postype_t &target_y, const Vector2f &measurement, bool &limit) WARN_IF_UNUSED;
// set target and measured inputs to P controller and calculate outputs
// measurement is provided as 3-axis vector but only x and y are used
Vector2f update_all(float &target_x, float &target_y, const Vector3f &measurement, bool &limit) WARN_IF_UNUSED {
Vector2f update_all(postype_t &target_x, postype_t &target_y, const Vector3f &measurement, bool &limit) WARN_IF_UNUSED {
return update_all(target_x, target_y, Vector2f{measurement.x, measurement.y}, limit);
}

Loading…
Cancel
Save