2022-05-26 23:57:55 -03:00
|
|
|
/*
|
2022-06-14 01:11:27 -03:00
|
|
|
Gremsy mount backend class
|
2022-05-26 23:57:55 -03:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2024-11-08 19:29:06 -04:00
|
|
|
#include "AP_Mount_config.h"
|
2022-06-14 01:11:27 -03:00
|
|
|
|
|
|
|
#if HAL_MOUNT_GREMSY_ENABLED
|
|
|
|
|
2024-11-08 19:29:06 -04:00
|
|
|
#include "AP_Mount_Backend.h"
|
|
|
|
|
2022-05-26 23:57:55 -03:00
|
|
|
#include <AP_Math/AP_Math.h>
|
|
|
|
#include <AP_Common/AP_Common.h>
|
|
|
|
#include <GCS_MAVLink/GCS_MAVLink.h>
|
|
|
|
|
|
|
|
class AP_Mount_Gremsy : public AP_Mount_Backend
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Constructor
|
2023-03-05 18:09:30 -04:00
|
|
|
using AP_Mount_Backend::AP_Mount_Backend;
|
2022-05-26 23:57:55 -03:00
|
|
|
|
|
|
|
// update mount position
|
|
|
|
void update() override;
|
|
|
|
|
2022-06-16 05:13:27 -03:00
|
|
|
// return true if healthy
|
|
|
|
bool healthy() const override;
|
|
|
|
|
2022-05-26 23:57:55 -03:00
|
|
|
// has_pan_control
|
2022-08-26 00:42:17 -03:00
|
|
|
bool has_pan_control() const override { return yaw_range_valid(); }
|
2022-05-26 23:57:55 -03:00
|
|
|
|
|
|
|
// handle GIMBAL_DEVICE_INFORMATION message
|
|
|
|
void handle_gimbal_device_information(const mavlink_message_t &msg) override;
|
|
|
|
|
|
|
|
// handle GIMBAL_DEVICE_ATTITUDE_STATUS message
|
|
|
|
void handle_gimbal_device_attitude_status(const mavlink_message_t &msg) override;
|
|
|
|
|
2022-07-11 05:07:22 -03:00
|
|
|
protected:
|
|
|
|
|
|
|
|
// get attitude as a quaternion. returns true on success
|
|
|
|
bool get_attitude_quaternion(Quaternion& att_quat) override;
|
|
|
|
|
2022-05-26 23:57:55 -03:00
|
|
|
private:
|
|
|
|
|
|
|
|
// search for gimbal in GCS_MAVLink routing table
|
|
|
|
void find_gimbal();
|
|
|
|
|
|
|
|
// request GIMBAL_DEVICE_INFORMATION from gimbal (holds vendor and model name, max lean angles)
|
|
|
|
void request_gimbal_device_information() const;
|
|
|
|
|
|
|
|
// start sending ATTITUDE and AUTOPILOT_STATE_FOR_GIMBAL_DEVICE to gimbal
|
|
|
|
// returns true on success, false on failure to start sending
|
|
|
|
bool start_sending_attitude_to_gimbal();
|
|
|
|
|
2022-06-10 05:24:04 -03:00
|
|
|
// send GIMBAL_DEVICE_SET_ATTITUDE to gimbal to command gimbal to retract (aka relax)
|
|
|
|
void send_gimbal_device_retract() const;
|
|
|
|
|
2022-05-26 23:57:55 -03:00
|
|
|
// send GIMBAL_DEVICE_SET_ATTITUDE to gimbal to control rate
|
|
|
|
// earth_frame should be true if yaw_rads target is an earth frame rate, false if body_frame
|
|
|
|
void send_gimbal_device_set_rate(float roll_rads, float pitch_rads, float yaw_rads, bool earth_frame) const;
|
|
|
|
|
|
|
|
// send GIMBAL_DEVICE_SET_ATTITUDE to gimbal to control attitude
|
|
|
|
// earth_frame should be true if yaw_rad target is an earth frame angle, false if body_frame
|
|
|
|
void send_gimbal_device_set_attitude(float roll_rad, float pitch_rad, float yaw_rad, bool earth_frame) const;
|
|
|
|
|
|
|
|
// internal variables
|
|
|
|
bool _got_device_info; // true once gimbal has provided device info
|
|
|
|
bool _initialised; // true once the gimbal has provided a GIMBAL_DEVICE_INFORMATION
|
|
|
|
uint32_t _last_devinfo_req_ms; // system time that GIMBAL_DEVICE_INFORMATION was last requested (used to throttle requests)
|
2023-02-23 01:03:21 -04:00
|
|
|
class GCS_MAVLINK *_link; // link we have found gimbal on; nullptr if not seen yet
|
2022-05-26 23:57:55 -03:00
|
|
|
uint8_t _sysid; // sysid of gimbal
|
|
|
|
uint8_t _compid; // component id of gimbal
|
|
|
|
mavlink_gimbal_device_attitude_status_t _gimbal_device_attitude_status; // copy of most recently received gimbal status
|
2022-06-16 05:13:27 -03:00
|
|
|
uint32_t _last_attitude_status_ms; // system time last attitude status was received (used for health reporting)
|
2022-05-26 23:57:55 -03:00
|
|
|
};
|
2022-06-14 01:11:27 -03:00
|
|
|
#endif // HAL_MOUNT_GREMSY_ENABLED
|