123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #pragma once
- #include <AP_Common/AP_Common.h>
- #include <AP_Math/AP_Math.h>
- #include <AP_Param/AP_Param.h>
- #include <AC_PID/AC_PID.h>
- #include <AP_WheelEncoder/AP_WheelEncoder.h>
- #define AP_WINCH_POS_P 1.00f
- #define AP_WINCH_RATE_P 1.00f
- #define AP_WINCH_RATE_I 0.50f
- #define AP_WINCH_RATE_IMAX 1.00f
- #define AP_WINCH_RATE_D 0.00f
- #define AP_WINCH_RATE_FILT 5.00f
- #define AP_WINCH_RATE_DT 0.10f
- class AP_Winch_Backend;
- class AP_Winch {
- friend class AP_Winch_Backend;
- friend class AP_Winch_Servo;
- public:
- AP_Winch();
-
- bool enabled() const;
-
- void init(const AP_WheelEncoder *wheel_encoder = nullptr);
-
- void update();
-
- void relax() { config.state = STATE_RELAXED; }
-
- float get_line_length() const { return config.length_curr; }
-
-
- void release_length(float length, float rate = 0.0f);
-
- void set_desired_rate(float rate);
-
- float get_rate_max() const { return MAX(config.rate_max, 0.0f); }
- static const struct AP_Param::GroupInfo var_info[];
- private:
-
- AP_Int8 _enabled;
-
- typedef enum {
- STATE_RELAXED = 0,
- STATE_POSITION,
- STATE_RATE,
- } winch_state;
- struct Backend_Config {
- AP_Int8 type;
- AP_Float rate_max;
- AP_Float pos_p;
- AC_PID rate_pid = AC_PID(AP_WINCH_RATE_P, AP_WINCH_RATE_I, AP_WINCH_RATE_D, 0.0f, AP_WINCH_RATE_IMAX, 0.0f, AP_WINCH_RATE_FILT, 0.0f, AP_WINCH_RATE_DT);
- winch_state state;
- float length_curr;
- float length_desired;
- float rate_desired;
- } config;
- AP_Winch_Backend *backend;
- };
|