123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #pragma once
- #include <AP_Math/AP_Math.h>
- #include <AP_Common/AP_Common.h>
- #include <AP_AHRS/AP_AHRS.h>
- #include <GCS_MAVLink/GCS_MAVLink.h>
- #include <SRV_Channel/SRV_Channel.h>
- #include "AP_Mount_Backend.h"
- class AP_Mount_Servo : public AP_Mount_Backend
- {
- public:
-
- AP_Mount_Servo(AP_Mount &frontend, AP_Mount::mount_state &state, uint8_t instance):
- AP_Mount_Backend(frontend, state, instance),
- _roll_idx(SRV_Channel::k_none),
- _tilt_idx(SRV_Channel::k_none),
- _pan_idx(SRV_Channel::k_none),
- _open_idx(SRV_Channel::k_none)
- {
- }
-
- void init() override;
-
- void update() override;
-
- bool has_pan_control() const override { return _flags.pan_control; }
-
- void set_mode(enum MAV_MOUNT_MODE mode) override;
-
- void send_mount_status(mavlink_channel_t chan) override;
- private:
-
- struct {
- bool roll_control :1;
- bool tilt_control :1;
- bool pan_control :1;
- } _flags;
-
-
- void check_servo_map();
-
- void stabilize();
-
- int16_t closest_limit(int16_t angle, int16_t angle_min, int16_t angle_max);
-
- void move_servo(uint8_t rc, int16_t angle, int16_t angle_min, int16_t angle_max);
-
- SRV_Channel::Aux_servo_function_t _roll_idx;
- SRV_Channel::Aux_servo_function_t _tilt_idx;
- SRV_Channel::Aux_servo_function_t _pan_idx;
- SRV_Channel::Aux_servo_function_t _open_idx;
- Vector3f _angle_bf_output_deg;
- uint32_t _last_check_servo_map_ms;
- };
|