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
|
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
|
2022-12-06 21:03:36 -04:00
|
|
|
AP_MotorsTri(uint16_t speed_hz = AP_MOTORS_SPEED_DEFAULT) :
|
|
|
|
AP_MotorsMulticopter(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
|
|
|
|
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
|
2021-12-10 12:45:20 -04:00
|
|
|
uint32_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
|
2022-11-25 14:40:22 -04:00
|
|
|
void output_motor_mask(float thrust, uint16_t mask, float rudder_dt) override;
|
2018-12-29 11:44:44 -04:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2023-03-28 01:12:49 -03:00
|
|
|
// Run arming checks
|
|
|
|
bool arming_checks(size_t buflen, char *buffer) const 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;
|
2022-01-01 11:55:34 -04:00
|
|
|
|
|
|
|
const char* _get_frame_string() const override { return "TRI"; }
|
|
|
|
|
2022-01-27 11:37:06 -04:00
|
|
|
// output_test_seq - spin a motor at the pwm value specified
|
|
|
|
// 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
|
|
|
|
virtual void _output_test_seq(uint8_t motor_seq, int16_t pwm) override;
|
|
|
|
|
2015-05-14 22:00:46 -03:00
|
|
|
// parameters
|
2017-01-09 00:01:30 -04:00
|
|
|
|
2016-01-19 23:14:20 -04:00
|
|
|
float _pivot_angle; // Angle of yaw pivot
|
|
|
|
float _thrust_right;
|
|
|
|
float _thrust_rear;
|
|
|
|
float _thrust_left;
|
2019-03-19 17:19:38 -03:00
|
|
|
|
|
|
|
// reverse pitch
|
|
|
|
bool _pitch_reversed;
|
2023-03-28 01:12:49 -03:00
|
|
|
bool _have_tail_servo;
|
2012-08-17 03:20:27 -03:00
|
|
|
};
|