PX4 Firmware
PX4 Autopilot Software http://px4.io
MulticopterRateControl Class Reference

#include <MulticopterRateControl.hpp>

Inheritance diagram for MulticopterRateControl:
Collaboration diagram for MulticopterRateControl:

Public Member Functions

 MulticopterRateControl ()
 
virtual ~MulticopterRateControl ()
 
int print_status () override
 
void Run () override
 
bool init ()
 

Static Public Member Functions

static int task_spawn (int argc, char *argv[])
 
static int custom_command (int argc, char *argv[])
 
static int print_usage (const char *reason=nullptr)
 

Private Member Functions

void parameters_updated ()
 initialize some vectors/matrices from parameters More...
 
void vehicle_status_poll ()
 
float get_landing_gear_state ()
 Get the landing gear state based on the manual control switch position. More...
 

Private Attributes

RateControl _rate_control
 class for rate control calculations More...
 
uORB::Subscription _v_rates_sp_sub {ORB_ID(vehicle_rates_setpoint)}
 vehicle rates setpoint subscription More...
 
uORB::Subscription _v_control_mode_sub {ORB_ID(vehicle_control_mode)}
 vehicle control mode subscription More...
 
uORB::Subscription _parameter_update_sub {ORB_ID(parameter_update)}
 parameter updates subscription More...
 
uORB::Subscription _manual_control_sp_sub {ORB_ID(manual_control_setpoint)}
 manual control setpoint subscription More...
 
uORB::Subscription _vehicle_status_sub {ORB_ID(vehicle_status)}
 vehicle status subscription More...
 
uORB::Subscription _motor_limits_sub {ORB_ID(multirotor_motor_limits)}
 motor limits subscription More...
 
uORB::Subscription _battery_status_sub {ORB_ID(battery_status)}
 battery status subscription More...
 
uORB::Subscription _vehicle_land_detected_sub {ORB_ID(vehicle_land_detected)}
 vehicle land detected subscription More...
 
uORB::Subscription _landing_gear_sub {ORB_ID(landing_gear)}
 
uORB::SubscriptionCallbackWorkItem _vehicle_angular_velocity_sub {this, ORB_ID(vehicle_angular_velocity)}
 
uORB::PublicationMulti< rate_ctrl_status_s_controller_status_pub {ORB_ID(rate_ctrl_status), ORB_PRIO_DEFAULT}
 controller status publication More...
 
uORB::Publication< landing_gear_s_landing_gear_pub {ORB_ID(landing_gear)}
 
uORB::Publication< vehicle_rates_setpoint_s_v_rates_sp_pub {ORB_ID(vehicle_rates_setpoint)}
 rate setpoint publication More...
 
orb_advert_t _actuators_0_pub {nullptr}
 attitude actuator controls publication More...
 
orb_id_t _actuators_id {nullptr}
 pointer to correct actuator controls0 uORB metadata structure More...
 
landing_gear_s _landing_gear {}
 
manual_control_setpoint_s _manual_control_sp {}
 
vehicle_control_mode_s _v_control_mode {}
 
vehicle_status_s _vehicle_status {}
 
bool _actuators_0_circuit_breaker_enabled {false}
 circuit breaker to suppress output More...
 
bool _landed {true}
 
bool _maybe_landed {true}
 
float _battery_status_scale {0.0f}
 
perf_counter_t _loop_perf
 loop duration performance counter More...
 
float _loop_update_rate_hz {initial_update_rate_hz}
 current rate-controller loop update rate in [Hz] More...
 
matrix::Vector3f _rates_sp
 angular rates setpoint More...
 
float _thrust_sp {0.0f}
 thrust setpoint More...
 
bool _gear_state_initialized {false}
 true if the gear state has been initialized More...
 
hrt_abstime _task_start {hrt_absolute_time()}
 
hrt_abstime _last_run {0}
 
float _dt_accumulator {0.0f}
 
int _loop_counter {0}
 

Static Private Attributes

static constexpr const float initial_update_rate_hz = 1000.f
 loop update rate used for initialization More...
 

Detailed Description

Definition at line 63 of file MulticopterRateControl.hpp.

Constructor & Destructor Documentation

◆ MulticopterRateControl()

MulticopterRateControl::MulticopterRateControl ( )

Definition at line 45 of file MulticopterRateControl.cpp.

References _vehicle_status, parameters_updated(), and vehicle_status_s::vehicle_type.

Referenced by task_spawn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~MulticopterRateControl()

MulticopterRateControl::~MulticopterRateControl ( )
virtual

Definition at line 55 of file MulticopterRateControl.cpp.

References _loop_perf, and perf_free().

Here is the call graph for this function:

Member Function Documentation

◆ custom_command()

int MulticopterRateControl::custom_command ( int  argc,
char *  argv[] 
)
static
See also
ModuleBase

Definition at line 376 of file MulticopterRateControl.cpp.

References print_usage().

Here is the call graph for this function:

◆ get_landing_gear_state()

float MulticopterRateControl::get_landing_gear_state ( )
private

Get the landing gear state based on the manual control switch position.

Returns
vehicle_attitude_setpoint_s::LANDING_GEAR_UP or vehicle_attitude_setpoint_s::LANDING_GEAR_DOWN

Definition at line 118 of file MulticopterRateControl.cpp.

References _gear_state_initialized, _landed, _manual_control_sp, and manual_control_setpoint_s::gear_switch.

Referenced by Run().

Here is the caller graph for this function:

◆ init()

bool MulticopterRateControl::init ( )

Definition at line 61 of file MulticopterRateControl.cpp.

References _vehicle_angular_velocity_sub, and uORB::SubscriptionCallback::registerCallback().

Referenced by task_spawn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parameters_updated()

void MulticopterRateControl::parameters_updated ( )
private

initialize some vectors/matrices from parameters

Definition at line 72 of file MulticopterRateControl.cpp.

References _actuators_0_circuit_breaker_enabled, _loop_update_rate_hz, _rate_control, CBRK_RATE_CTRL_KEY, circuit_breaker_enabled_by_val(), matrix::Matrix< Type, M, N >::emult(), math::radians(), RateControl::setDTermCutoff(), RateControl::setFeedForwardGain(), RateControl::setGains(), and RateControl::setIntegratorLimit().

Referenced by MulticopterRateControl(), and Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_status()

int MulticopterRateControl::print_status ( )
override
See also
ModuleBase::print_status()

Definition at line 367 of file MulticopterRateControl.cpp.

References _loop_perf, and perf_print_counter().

Here is the call graph for this function:

◆ print_usage()

int MulticopterRateControl::print_usage ( const char *  reason = nullptr)
static
See also
ModuleBase

Definition at line 381 of file MulticopterRateControl.cpp.

References mc_rate_control_main().

Referenced by custom_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Run()

void MulticopterRateControl::Run ( )
override

Definition at line 142 of file MulticopterRateControl.cpp.

References _actuators_0_circuit_breaker_enabled, _actuators_0_pub, _actuators_id, _battery_status_scale, _battery_status_sub, _controller_status_pub, _dt_accumulator, _landed, _landing_gear, _landing_gear_pub, _landing_gear_sub, _last_run, _loop_counter, _loop_perf, _loop_update_rate_hz, _manual_control_sp, _manual_control_sp_sub, _maybe_landed, _motor_limits_sub, _parameter_update_sub, _rate_control, _rates_sp, _task_start, _thrust_sp, _v_control_mode, _v_control_mode_sub, _v_rates_sp_pub, _v_rates_sp_sub, _vehicle_angular_velocity_sub, _vehicle_land_detected_sub, _vehicle_status, math::constrain(), actuator_controls_s::control, uORB::Subscription::copy(), dt, matrix::Matrix< Type, M, N >::emult(), f(), vehicle_control_mode_s::flag_armed, vehicle_control_mode_s::flag_control_altitude_enabled, vehicle_control_mode_s::flag_control_attitude_enabled, vehicle_control_mode_s::flag_control_manual_enabled, vehicle_control_mode_s::flag_control_position_enabled, vehicle_control_mode_s::flag_control_rates_enabled, vehicle_control_mode_s::flag_control_rattitude_enabled, vehicle_control_mode_s::flag_control_termination_enabled, vehicle_control_mode_s::flag_control_velocity_enabled, get_landing_gear_state(), RateControl::getRateControlStatus(), hrt_absolute_time(), hrt_abstime, hrt_elapsed_time(), vehicle_status_s::is_vtol, vehicle_land_detected_s::landed, landing_gear_s::landing_gear, vehicle_land_detected_s::maybe_landed, ORB_PRIO_DEFAULT, orb_publish_auto(), parameters_updated(), perf_begin(), perf_end(), vehicle_rates_setpoint_s::pitch, uORB::Publication< T >::publish(), uORB::PublicationMulti< T >::publish(), manual_control_setpoint_s::r, RateControl::resetIntegral(), vehicle_rates_setpoint_s::roll, multirotor_motor_limits_s::saturation_status, battery_status_s::scale, RateControl::setDTermCutoff(), RateControl::setSaturationStatus(), math::superexpo(), vehicle_rates_setpoint_s::thrust_body, landing_gear_s::timestamp, actuator_controls_s::timestamp, vehicle_angular_velocity_s::timestamp_sample, uORB::SubscriptionCallback::unregisterCallback(), uORB::SubscriptionInterval::update(), RateControl::update(), uORB::Subscription::update(), uORB::Subscription::updated(), MultirotorMixer::saturation_status::value, vehicle_status_poll(), vehicle_status_s::vehicle_type, manual_control_setpoint_s::x, vehicle_angular_velocity_s::xyz, manual_control_setpoint_s::y, vehicle_rates_setpoint_s::yaw, and manual_control_setpoint_s::z.

Here is the call graph for this function:

◆ task_spawn()

int MulticopterRateControl::task_spawn ( int  argc,
char *  argv[] 
)
static
See also
ModuleBase

Definition at line 344 of file MulticopterRateControl.cpp.

References init(), ll40ls::instance, and MulticopterRateControl().

Here is the call graph for this function:

◆ vehicle_status_poll()

void MulticopterRateControl::vehicle_status_poll ( )
private

Definition at line 101 of file MulticopterRateControl.cpp.

References _actuators_id, _vehicle_status, _vehicle_status_sub, vehicle_status_s::is_vtol, ORB_ID, and uORB::Subscription::update().

Referenced by Run().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _actuators_0_circuit_breaker_enabled

bool MulticopterRateControl::_actuators_0_circuit_breaker_enabled {false}
private

circuit breaker to suppress output

Definition at line 127 of file MulticopterRateControl.hpp.

Referenced by parameters_updated(), and Run().

◆ _actuators_0_pub

orb_advert_t MulticopterRateControl::_actuators_0_pub {nullptr}
private

attitude actuator controls publication

Definition at line 119 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _actuators_id

orb_id_t MulticopterRateControl::_actuators_id {nullptr}
private

pointer to correct actuator controls0 uORB metadata structure

Definition at line 120 of file MulticopterRateControl.hpp.

Referenced by Run(), and vehicle_status_poll().

◆ _battery_status_scale

float MulticopterRateControl::_battery_status_scale {0.0f}
private

Definition at line 131 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _battery_status_sub

uORB::Subscription MulticopterRateControl::_battery_status_sub {ORB_ID(battery_status)}
private

battery status subscription

Definition at line 109 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _controller_status_pub

uORB::PublicationMulti<rate_ctrl_status_s> MulticopterRateControl::_controller_status_pub {ORB_ID(rate_ctrl_status), ORB_PRIO_DEFAULT}
private

controller status publication

Definition at line 115 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _dt_accumulator

float MulticopterRateControl::_dt_accumulator {0.0f}
private

Definition at line 146 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _gear_state_initialized

bool MulticopterRateControl::_gear_state_initialized {false}
private

true if the gear state has been initialized

Definition at line 142 of file MulticopterRateControl.hpp.

Referenced by get_landing_gear_state().

◆ _landed

bool MulticopterRateControl::_landed {true}
private

Definition at line 128 of file MulticopterRateControl.hpp.

Referenced by get_landing_gear_state(), and Run().

◆ _landing_gear

landing_gear_s MulticopterRateControl::_landing_gear {}
private

Definition at line 122 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _landing_gear_pub

uORB::Publication<landing_gear_s> MulticopterRateControl::_landing_gear_pub {ORB_ID(landing_gear)}
private

Definition at line 116 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _landing_gear_sub

uORB::Subscription MulticopterRateControl::_landing_gear_sub {ORB_ID(landing_gear)}
private

Definition at line 111 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _last_run

hrt_abstime MulticopterRateControl::_last_run {0}
private

Definition at line 145 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _loop_counter

int MulticopterRateControl::_loop_counter {0}
private

Definition at line 147 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _loop_perf

perf_counter_t MulticopterRateControl::_loop_perf
private

loop duration performance counter

Definition at line 133 of file MulticopterRateControl.hpp.

Referenced by print_status(), Run(), and ~MulticopterRateControl().

◆ _loop_update_rate_hz

float MulticopterRateControl::_loop_update_rate_hz {initial_update_rate_hz}
private

current rate-controller loop update rate in [Hz]

Definition at line 136 of file MulticopterRateControl.hpp.

Referenced by parameters_updated(), and Run().

◆ _manual_control_sp

manual_control_setpoint_s MulticopterRateControl::_manual_control_sp {}
private

Definition at line 123 of file MulticopterRateControl.hpp.

Referenced by get_landing_gear_state(), and Run().

◆ _manual_control_sp_sub

uORB::Subscription MulticopterRateControl::_manual_control_sp_sub {ORB_ID(manual_control_setpoint)}
private

manual control setpoint subscription

Definition at line 106 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _maybe_landed

bool MulticopterRateControl::_maybe_landed {true}
private

Definition at line 129 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _motor_limits_sub

uORB::Subscription MulticopterRateControl::_motor_limits_sub {ORB_ID(multirotor_motor_limits)}
private

motor limits subscription

Definition at line 108 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _parameter_update_sub

uORB::Subscription MulticopterRateControl::_parameter_update_sub {ORB_ID(parameter_update)}
private

parameter updates subscription

Definition at line 105 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _rate_control

RateControl MulticopterRateControl::_rate_control
private

class for rate control calculations

Definition at line 101 of file MulticopterRateControl.hpp.

Referenced by parameters_updated(), and Run().

◆ _rates_sp

matrix::Vector3f MulticopterRateControl::_rates_sp
private

angular rates setpoint

Definition at line 138 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _task_start

hrt_abstime MulticopterRateControl::_task_start {hrt_absolute_time()}
private

Definition at line 144 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _thrust_sp

float MulticopterRateControl::_thrust_sp {0.0f}
private

thrust setpoint

Definition at line 140 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _v_control_mode

vehicle_control_mode_s MulticopterRateControl::_v_control_mode {}
private

Definition at line 124 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _v_control_mode_sub

uORB::Subscription MulticopterRateControl::_v_control_mode_sub {ORB_ID(vehicle_control_mode)}
private

vehicle control mode subscription

Definition at line 104 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _v_rates_sp_pub

uORB::Publication<vehicle_rates_setpoint_s> MulticopterRateControl::_v_rates_sp_pub {ORB_ID(vehicle_rates_setpoint)}
private

rate setpoint publication

Definition at line 117 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _v_rates_sp_sub

uORB::Subscription MulticopterRateControl::_v_rates_sp_sub {ORB_ID(vehicle_rates_setpoint)}
private

vehicle rates setpoint subscription

Definition at line 103 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _vehicle_angular_velocity_sub

uORB::SubscriptionCallbackWorkItem MulticopterRateControl::_vehicle_angular_velocity_sub {this, ORB_ID(vehicle_angular_velocity)}
private

Definition at line 113 of file MulticopterRateControl.hpp.

Referenced by init(), and Run().

◆ _vehicle_land_detected_sub

uORB::Subscription MulticopterRateControl::_vehicle_land_detected_sub {ORB_ID(vehicle_land_detected)}
private

vehicle land detected subscription

Definition at line 110 of file MulticopterRateControl.hpp.

Referenced by Run().

◆ _vehicle_status

vehicle_status_s MulticopterRateControl::_vehicle_status {}
private

Definition at line 125 of file MulticopterRateControl.hpp.

Referenced by MulticopterRateControl(), Run(), and vehicle_status_poll().

◆ _vehicle_status_sub

uORB::Subscription MulticopterRateControl::_vehicle_status_sub {ORB_ID(vehicle_status)}
private

vehicle status subscription

Definition at line 107 of file MulticopterRateControl.hpp.

Referenced by vehicle_status_poll().

◆ initial_update_rate_hz

constexpr const float MulticopterRateControl::initial_update_rate_hz = 1000.f
staticprivate

loop update rate used for initialization

Definition at line 135 of file MulticopterRateControl.hpp.


The documentation for this class was generated from the following files: