123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- #pragma once
- #include <AP_Math/AP_Math.h>
- #include <AP_Common/AP_Common.h>
- #include <AP_Common/Location.h>
- #include <GCS_MAVLink/GCS_MAVLink.h>
- #define AP_MOUNT_MAX_INSTANCES 1
- class AP_Mount_Backend;
- class AP_Mount_Servo;
- class AP_Mount_SoloGimbal;
- class AP_Mount_Alexmos;
- class AP_Mount_SToRM32;
- class AP_Mount_SToRM32_serial;
- class AP_Mount
- {
-
- friend class AP_Mount_Backend;
- friend class AP_Mount_Servo;
- friend class AP_Mount_SoloGimbal;
- friend class AP_Mount_Alexmos;
- friend class AP_Mount_SToRM32;
- friend class AP_Mount_SToRM32_serial;
- public:
- AP_Mount(const struct Location ¤t_loc);
-
- AP_Mount(const AP_Mount &other) = delete;
- AP_Mount &operator=(const AP_Mount&) = delete;
-
- static AP_Mount *get_singleton() {
- return _singleton;
- }
-
- enum MountType {
- Mount_Type_None = 0,
- Mount_Type_Servo = 1,
- Mount_Type_SoloGimbal = 2,
- Mount_Type_Alexmos = 3,
- Mount_Type_SToRM32 = 4,
- Mount_Type_SToRM32_serial = 5
- };
-
- void init();
-
- void update();
-
- void update_fast();
-
- AP_Mount::MountType get_mount_type() const { return get_mount_type(_primary); }
- AP_Mount::MountType get_mount_type(uint8_t instance) const;
-
- bool has_pan_control() const { return has_pan_control(_primary); }
- bool has_pan_control(uint8_t instance) const;
-
- enum MAV_MOUNT_MODE get_mode() const { return get_mode(_primary); }
- enum MAV_MOUNT_MODE get_mode(uint8_t instance) const;
-
-
- void set_mode(enum MAV_MOUNT_MODE mode) { return set_mode(_primary, mode); }
- void set_mode(uint8_t instance, enum MAV_MOUNT_MODE mode);
-
-
- void set_mode_to_default() { set_mode_to_default(_primary); }
- void set_mode_to_default(uint8_t instance);
-
- void set_angle_targets(float roll, float tilt, float pan) { set_angle_targets(_primary, roll, tilt, pan); }
- void set_angle_targets(uint8_t instance, float roll, float tilt, float pan);
-
- void set_roi_target(const struct Location &target_loc) { set_roi_target(_primary,target_loc); }
- void set_roi_target(uint8_t instance, const struct Location &target_loc);
-
- MAV_RESULT handle_command_long(const mavlink_command_long_t &packet);
- void handle_param_value(const mavlink_message_t &msg);
- void handle_message(mavlink_channel_t chan, const mavlink_message_t &msg);
-
- void send_gimbal_report(mavlink_channel_t chan);
-
- void send_mount_status(mavlink_channel_t chan);
-
- static const struct AP_Param::GroupInfo var_info[];
- protected:
- static AP_Mount *_singleton;
-
- const struct Location &_current_loc;
-
- AP_Int8 _joystick_speed;
-
- uint8_t _num_instances;
- uint8_t _primary;
- AP_Mount_Backend *_backends[AP_MOUNT_MAX_INSTANCES];
-
- struct mount_state {
-
- AP_Int8 _type;
- AP_Int8 _default_mode;
- AP_Int8 _stab_roll;
- AP_Int8 _stab_tilt;
- AP_Int8 _stab_pan;
-
- AP_Int8 _roll_rc_in;
- AP_Int8 _tilt_rc_in;
- AP_Int8 _pan_rc_in;
-
- AP_Int16 _roll_angle_min;
- AP_Int16 _roll_angle_max;
- AP_Int16 _tilt_angle_min;
- AP_Int16 _tilt_angle_max;
- AP_Int16 _pan_angle_min;
- AP_Int16 _pan_angle_max;
- AP_Vector3f _retract_angles;
- AP_Vector3f _neutral_angles;
- AP_Float _roll_stb_lead;
- AP_Float _pitch_stb_lead;
- MAV_MOUNT_MODE _mode;
- struct Location _roi_target;
- } state[AP_MOUNT_MAX_INSTANCES];
- private:
- void handle_gimbal_report(mavlink_channel_t chan, const mavlink_message_t &msg);
- void handle_mount_configure(const mavlink_message_t &msg);
- void handle_mount_control(const mavlink_message_t &msg);
- MAV_RESULT handle_command_do_mount_configure(const mavlink_command_long_t &packet);
- MAV_RESULT handle_command_do_mount_control(const mavlink_command_long_t &packet);
- };
- namespace AP {
- AP_Mount *mount();
- };
|