Line data Source code
1 : /// @file AP_MotorsHeli_Quad.h 2 : /// @brief Motor control class collective pitch quad helicopter (such as stingray) 3 : 4 : #pragma once 5 : 6 : #include <AP_Common/AP_Common.h> 7 : #include <AP_Math/AP_Math.h> 8 : #include <RC_Channel/RC_Channel.h> 9 : 10 : #include "AP_MotorsHeli.h" 11 : #include "AP_MotorsHeli_RSC.h" 12 : 13 : // default collective min, max and midpoints for the rear swashplate 14 : #define AP_MOTORS_HELI_QUAD_COLLECTIVE_MIN 1100 15 : #define AP_MOTORS_HELI_QUAD_COLLECTIVE_MAX 1900 16 : 17 : #define AP_MOTORS_HELI_QUAD_NUM_MOTORS 4 18 : 19 : class AP_MotorsHeli_Quad : public AP_MotorsHeli { 20 : public: 21 : // constructor 22 3 : AP_MotorsHeli_Quad(uint16_t speed_hz = AP_MOTORS_HELI_SPEED_DEFAULT) : 23 3 : AP_MotorsHeli(speed_hz) 24 : { 25 3 : AP_Param::setup_object_defaults(this, var_info); 26 3 : }; 27 : 28 : // set_update_rate - set update rate to motors 29 : void set_update_rate( uint16_t speed_hz ) override; 30 : 31 : // output_to_motors - sends values out to the motors 32 : void output_to_motors() override; 33 : 34 : // calculate_scalars - recalculates various scalars used 35 : void calculate_scalars() override; 36 : 37 : // servo_test - move servos through full range of movement 38 : void servo_test() override; 39 : 40 : #if HAL_LOGGING_ENABLED 41 : // heli motors logging - called at 10 Hz 42 : void Log_Write(void) override; 43 : #endif 44 : 45 : // var_info for holding Parameter information 46 : static const struct AP_Param::GroupInfo var_info[]; 47 : 48 : protected: 49 : 50 : // init_outputs 51 : void init_outputs () override; 52 : 53 : // update_motor_controls - sends commands to motor controllers 54 : void update_motor_control(AP_MotorsHeli_RSC::DesiredRSCSpoolState state) override; 55 : 56 : // update_spool_state - updates the spool state based on the desired state 57 : AP_Motors::SpoolState update_spool_state(AP_MotorsHeli_RSC::DesiredRSCSpoolState state) override; 58 : 59 : // calculate_roll_pitch_collective_factors - setup rate factors 60 : void calculate_roll_pitch_collective_factors (); 61 : 62 : // move_actuators - moves swash plate to attitude of parameters passed in 63 : void move_actuators(float roll_out, float pitch_out, float coll_in, float yaw_out) override; 64 : 65 3 : const char* _get_frame_string() const override { return "HELI_QUAD"; } 66 : 67 : // rate factors 68 : float _rollFactor[AP_MOTORS_HELI_QUAD_NUM_MOTORS]; 69 : float _pitchFactor[AP_MOTORS_HELI_QUAD_NUM_MOTORS]; 70 : float _collectiveFactor[AP_MOTORS_HELI_QUAD_NUM_MOTORS]; 71 : float _yawFactor[AP_MOTORS_HELI_QUAD_NUM_MOTORS]; 72 : float _out[AP_MOTORS_HELI_QUAD_NUM_MOTORS]; 73 : }; 74 : 75 :