2013-10-02 06:59:04 -03:00
/// @file AP_MotorsSingle.h
/// @brief Motor and Servo control class for Singlecopters
2016-02-17 21:25:38 -04:00
# pragma once
2013-10-02 06:59:04 -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-03 05:56:57 -04:00
# include <SRV_Channel/SRV_Channel.h>
2015-07-15 04:58:14 -03:00
# include "AP_MotorsMulticopter.h"
2013-10-02 06:59:04 -03:00
// feedback direction
2013-11-12 10:02:05 -04:00
# define AP_MOTORS_SING_POSITIVE 1
# define AP_MOTORS_SING_NEGATIVE -1
2013-10-02 06:59:04 -03:00
2016-01-20 00:25:35 -04:00
# define NUM_ACTUATORS 4
2013-10-02 06:59:04 -03:00
# define AP_MOTORS_SINGLE_SPEED_DIGITAL_SERVOS 250 // update rate for digital servos
# define AP_MOTORS_SINGLE_SPEED_ANALOG_SERVOS 125 // update rate for analog servos
2014-02-07 09:03:22 -04:00
# define AP_MOTORS_SINGLE_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)
2013-11-12 10:02:05 -04:00
/// @class AP_MotorsSingle
2015-07-15 04:58:14 -03:00
class AP_MotorsSingle : public AP_MotorsMulticopter {
2013-10-02 06:59:04 -03:00
public :
/// Constructor
2022-12-06 21:03:36 -04:00
AP_MotorsSingle ( uint16_t speed_hz = AP_MOTORS_SPEED_DEFAULT ) :
AP_MotorsMulticopter ( speed_hz )
2013-11-12 10:02:05 -04:00
{
2013-10-02 06:59:04 -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 ;
2013-10-02 06:59:04 -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 ;
2013-10-02 06:59:04 -03:00
2016-01-20 00:48:49 -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-20 00:48:49 -04:00
2014-07-26 04:28:10 -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:28:10 -03:00
2022-09-03 22:58:37 -03:00
// Run arming checks
bool arming_checks ( size_t buflen , char * buffer ) const override { return AP_Motors : : arming_checks ( buflen , buffer ) ; }
2013-10-02 06:59:04 -03:00
protected :
// output - sends commands to the motors
2018-11-07 07:00:51 -04:00
void output_armed_stabilizing ( ) override ;
2013-10-02 06:59:04 -03:00
2022-01-01 11:55:34 -04:00
const char * _get_frame_string ( ) const override { return " SINGLE " ; }
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 ;
2016-01-20 21:51:12 -04:00
int16_t _throttle_radio_output ; // total throttle pwm value, summed onto throttle channel minimum, typically ~1100-1900
2016-01-20 00:25:35 -04:00
float _actuator_out [ NUM_ACTUATORS ] ; // combined roll, pitch, yaw and throttle outputs to motors in 0~1 range
float _thrust_out ;
2013-10-02 06:59:04 -03:00
} ;