2012-04-02 05:26:37 -03:00
|
|
|
/// @file AP_MotorsTri.h
|
|
|
|
/// @brief Motor control class for Tricopters
|
2016-02-17 21:25:38 -04:00
|
|
|
#pragma once
|
2012-04-02 05:26:37 -03:00
|
|
|
|
2015-08-11 03:28:44 -03:00
|
|
|
#include <AP_Common/AP_Common.h>
|
|
|
|
#include <AP_Math/AP_Math.h> // ArduPilot Mega Vector/Matrix math Library
|
2017-01-09 00:01:30 -04:00
|
|
|
#include <SRV_Channel/SRV_Channel.h>
|
2015-07-15 04:58:43 -03:00
|
|
|
#include "AP_MotorsMulticopter.h"
|
2012-04-02 05:26:37 -03:00
|
|
|
|
|
|
|
// tail servo uses channel 7
|
2015-05-25 10:26:48 -03:00
|
|
|
#define AP_MOTORS_CH_TRI_YAW CH_7
|
2012-04-02 05:26:37 -03:00
|
|
|
|
2016-03-25 05:56:58 -03:00
|
|
|
#define AP_MOTORS_TRI_SERVO_RANGE_DEG_MIN 5 // minimum angle movement of tail servo in degrees
|
|
|
|
#define AP_MOTORS_TRI_SERVO_RANGE_DEG_MAX 80 // maximum angle movement of tail servo in degrees
|
|
|
|
|
2012-08-17 03:20:27 -03:00
|
|
|
/// @class AP_MotorsTri
|
2015-07-15 04:58:43 -03:00
|
|
|
class AP_MotorsTri : public AP_MotorsMulticopter {
|
2012-08-17 03:20:27 -03:00
|
|
|
public:
|
2012-04-02 05:26:37 -03:00
|
|
|
|
2012-08-17 03:20:27 -03:00
|
|
|
/// Constructor
|
2015-05-14 22:00:46 -03:00
|
|
|
AP_MotorsTri(uint16_t loop_rate, uint16_t speed_hz = AP_MOTORS_SPEED_DEFAULT) :
|
2015-07-15 04:58:43 -03:00
|
|
|
AP_MotorsMulticopter(loop_rate, speed_hz)
|
2015-05-14 22:00:46 -03:00
|
|
|
{
|
2012-08-17 03:20:27 -03:00
|
|
|
};
|
2012-04-02 05:26:37 -03:00
|
|
|
|
2012-08-17 03:20:27 -03:00
|
|
|
// init
|
2018-11-07 07:00:51 -04:00
|
|
|
void init(motor_frame_class frame_class, motor_frame_type frame_type) override;
|
2016-12-14 01:46:42 -04:00
|
|
|
|
|
|
|
// set frame class (i.e. quad, hexa, heli) and type (i.e. x, plus)
|
2018-11-07 07:00:51 -04:00
|
|
|
void set_frame_class_and_type(motor_frame_class frame_class, motor_frame_type frame_type) override;
|
2012-04-02 05:26:37 -03:00
|
|
|
|
2012-09-13 09:31:13 -03:00
|
|
|
// set update rate to motors - a value in hertz
|
2018-11-07 07:00:51 -04:00
|
|
|
void set_update_rate( uint16_t speed_hz ) override;
|
2012-04-02 05:26:37 -03:00
|
|
|
|
2018-04-27 13:22:07 -03:00
|
|
|
// output_test_seq - spin a motor at the pwm value specified
|
2014-04-28 04:30:26 -03:00
|
|
|
// motor_seq is the motor's sequence number from 1 to the number of motors on the frame
|
|
|
|
// pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000
|
2018-04-27 13:22:07 -03:00
|
|
|
virtual void output_test_seq(uint8_t motor_seq, int16_t pwm) override;
|
2012-08-17 03:20:27 -03:00
|
|
|
|
2016-01-19 23:15:10 -04:00
|
|
|
// output_to_motors - sends minimum values out to the motors
|
2018-11-07 07:00:51 -04:00
|
|
|
virtual void output_to_motors() override;
|
2016-01-19 23:15:10 -04:00
|
|
|
|
2014-07-26 04:27:39 -03:00
|
|
|
// get_motor_mask - returns a bitmask of which outputs are being used for motors or servos (1 means being used)
|
|
|
|
// this can be used to ensure other pwm outputs (i.e. for servos) do not conflict
|
2018-08-24 02:38:28 -03:00
|
|
|
uint16_t get_motor_mask() override;
|
2014-07-26 04:27:39 -03:00
|
|
|
|
2017-05-08 20:05:30 -03:00
|
|
|
// output a thrust to all motors that match a given motor
|
|
|
|
// mask. This is used to control tiltrotor motors in forward
|
|
|
|
// flight. Thrust is in the range 0 to 1
|
2018-12-29 11:44:44 -04:00
|
|
|
// rudder_dt applys diffential thrust for yaw in the range 0 to 1
|
|
|
|
void output_motor_mask(float thrust, uint8_t mask, float rudder_dt) override;
|
|
|
|
|
|
|
|
// return the roll factor of any motor, this is used for tilt rotors and tail sitters
|
|
|
|
// using copter motors for forward flight
|
|
|
|
float get_roll_factor(uint8_t i) override;
|
|
|
|
|
2012-04-02 05:26:37 -03:00
|
|
|
protected:
|
2012-08-17 03:20:27 -03:00
|
|
|
// output - sends commands to the motors
|
2018-11-07 07:00:51 -04:00
|
|
|
void output_armed_stabilizing() override;
|
2012-04-02 05:26:37 -03:00
|
|
|
|
2016-05-01 19:00:45 -03:00
|
|
|
// call vehicle supplied thrust compensation if set
|
|
|
|
void thrust_compensation(void) override;
|
|
|
|
|
2015-05-14 22:00:46 -03:00
|
|
|
// calc_yaw_radio_output - calculate final radio output for yaw channel
|
2016-01-19 23:14:20 -04:00
|
|
|
int16_t calc_yaw_radio_output(float yaw_input, float yaw_input_max); // calculate radio output for yaw servo, typically in range of 1100-1900
|
2015-05-14 22:00:46 -03:00
|
|
|
|
|
|
|
// parameters
|
2017-01-09 00:01:30 -04:00
|
|
|
|
|
|
|
SRV_Channel *_yaw_servo; // yaw output channel
|
2016-01-19 23:14:20 -04:00
|
|
|
float _pivot_angle; // Angle of yaw pivot
|
|
|
|
float _thrust_right;
|
|
|
|
float _thrust_rear;
|
|
|
|
float _thrust_left;
|
2012-08-17 03:20:27 -03:00
|
|
|
};
|