Line data Source code
1 : /// @file AP_MotorsCoax.h 2 : /// @brief Motor and Servo control class for Co-axial helicopters with two motors and two flaps 3 : #pragma once 4 : 5 : #include <AP_Common/AP_Common.h> 6 : #include <AP_Math/AP_Math.h> // ArduPilot Mega Vector/Matrix math Library 7 : #include "AP_MotorsMulticopter.h" 8 : 9 : // feedback direction 10 : #define AP_MOTORS_COAX_POSITIVE 1 11 : #define AP_MOTORS_COAX_NEGATIVE -1 12 : 13 : #define NUM_ACTUATORS 4 14 : 15 : #define AP_MOTORS_SINGLE_SPEED_DIGITAL_SERVOS 250 // update rate for digital servos 16 : #define AP_MOTORS_SINGLE_SPEED_ANALOG_SERVOS 125 // update rate for analog servos 17 : 18 : #define AP_MOTORS_COAX_SERVO_INPUT_RANGE 4500 // roll or pitch input of -4500 will cause servos to their minimum (i.e. radio_min), +4500 will move them to their maximum (i.e. radio_max) 19 : 20 : /// @class AP_MotorsSingle 21 : class AP_MotorsCoax : public AP_MotorsMulticopter { 22 : public: 23 : 24 : /// Constructor 25 1 : AP_MotorsCoax(uint16_t speed_hz = AP_MOTORS_SPEED_DEFAULT) : 26 1 : AP_MotorsMulticopter(speed_hz) 27 : { 28 1 : }; 29 : 30 : // init 31 : void init(motor_frame_class frame_class, motor_frame_type frame_type) override; 32 : 33 : // set frame class (i.e. quad, hexa, heli) and type (i.e. x, plus) 34 : void set_frame_class_and_type(motor_frame_class frame_class, motor_frame_type frame_type) override; 35 : 36 : // set update rate to motors - a value in hertz 37 : void set_update_rate( uint16_t speed_hz ) override; 38 : 39 : // output_to_motors - sends minimum values out to the motors 40 : virtual void output_to_motors() override; 41 : 42 : // get_motor_mask - returns a bitmask of which outputs are being used for motors or servos (1 means being used) 43 : // this can be used to ensure other pwm outputs (i.e. for servos) do not conflict 44 : uint32_t get_motor_mask() override; 45 : 46 : // Run arming checks 47 42 : bool arming_checks(size_t buflen, char *buffer) const override { return AP_Motors::arming_checks(buflen, buffer); } 48 : 49 : protected: 50 : // output - sends commands to the motors 51 : void output_armed_stabilizing() override; 52 : 53 : float _actuator_out[NUM_ACTUATORS]; // combined roll, pitch, yaw and throttle outputs to motors in 0~1 range 54 : float _thrust_yt_ccw; 55 : float _thrust_yt_cw; 56 : 57 1 : const char* _get_frame_string() const override { return "COAX"; } 58 : 59 : // output_test_seq - spin a motor at the pwm value specified 60 : // motor_seq is the motor's sequence number from 1 to the number of motors on the frame 61 : // pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000 62 : virtual void _output_test_seq(uint8_t motor_seq, int16_t pwm) override; 63 : };