PX4 Firmware
PX4 Autopilot Software http://px4.io
|
#include <mc_att_control.hpp>
Classes | |
struct | _manual_control_sp |
manual control setpoint More... | |
struct | _v_att |
vehicle attitude More... | |
struct | _v_att_sp |
vehicle attitude setpoint More... | |
struct | _v_control_mode |
vehicle control mode More... | |
struct | _v_rates_sp |
vehicle rates setpoint More... | |
struct | _vehicle_land_detected |
struct | _vehicle_status |
vehicle status More... | |
Public Member Functions | |
MulticopterAttitudeControl () | |
virtual | ~MulticopterAttitudeControl () |
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 () |
void | publish_rates_setpoint () |
float | throttle_curve (float throttle_stick_input) |
void | generate_attitude_setpoint (float dt, bool reset_yaw_sp) |
Generate & publish an attitude setpoint from stick inputs. More... | |
void | control_attitude () |
Attitude controller. More... | |
DEFINE_PARAMETERS ((ParamFloat< px4::params::MC_ROLL_P >) _param_mc_roll_p,(ParamFloat< px4::params::MC_PITCH_P >) _param_mc_pitch_p,(ParamFloat< px4::params::MC_YAW_P >) _param_mc_yaw_p,(ParamFloat< px4::params::MC_ROLLRATE_MAX >) _param_mc_rollrate_max,(ParamFloat< px4::params::MC_PITCHRATE_MAX >) _param_mc_pitchrate_max,(ParamFloat< px4::params::MC_YAWRATE_MAX >) _param_mc_yawrate_max,(ParamFloat< px4::params::MPC_MAN_Y_MAX >) _param_mpc_man_y_max,(ParamFloat< px4::params::MC_RATT_TH >) _param_mc_ratt_th,(ParamFloat< px4::params::MPC_MAN_TILT_MAX >) _param_mpc_man_tilt_max,(ParamFloat< px4::params::MPC_MANTHR_MIN >) _param_mpc_manthr_min,(ParamFloat< px4::params::MPC_THR_MAX >) _param_mpc_thr_max,(ParamFloat< px4::params::MPC_THR_HOVER >) _param_mpc_thr_hover,(ParamInt< px4::params::MPC_THR_CURVE >) _param_mpc_thr_curve,(ParamInt< px4::params::MC_AIRMODE >) _param_mc_airmode) bool _is_tailsitter | |
Private Attributes | |
AttitudeControl | _attitude_control |
class for attitude control calculations More... | |
uORB::Subscription | _v_att_sp_sub {ORB_ID(vehicle_attitude_setpoint)} |
vehicle attitude setpoint subscription 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 | _params_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 | _vehicle_land_detected_sub {ORB_ID(vehicle_land_detected)} |
vehicle land detected subscription More... | |
uORB::SubscriptionCallbackWorkItem | _vehicle_attitude_sub {this, ORB_ID(vehicle_attitude)} |
uORB::Publication< vehicle_rates_setpoint_s > | _v_rates_sp_pub {ORB_ID(vehicle_rates_setpoint)} |
rate setpoint publication More... | |
orb_advert_t | _vehicle_attitude_setpoint_pub {nullptr} |
orb_id_t | _attitude_sp_id {nullptr} |
pointer to correct attitude setpoint uORB metadata structure More... | |
perf_counter_t | _loop_perf |
loop duration performance counter More... | |
matrix::Vector3f | _rates_sp |
angular rates setpoint More... | |
float | _man_yaw_sp {0.f} |
current yaw setpoint in manual mode More... | |
hrt_abstime | _last_run {0} |
bool | _reset_yaw_sp {true} |
float | _man_tilt_max |
maximum tilt allowed for manual flight [rad] More... | |
Definition at line 65 of file mc_att_control.hpp.
MulticopterAttitudeControl::MulticopterAttitudeControl | ( | ) |
Definition at line 54 of file mc_att_control_main.cpp.
References parameters_updated().
Referenced by task_spawn().
|
virtual |
Definition at line 68 of file mc_att_control_main.cpp.
References _loop_perf, and perf_free().
|
private |
Attitude controller.
Input: 'vehicle_attitude_setpoint' topics (depending on mode) Output: '_rates_sp' vector
Definition at line 247 of file mc_att_control_main.cpp.
References _attitude_control, _rates_sp, _v_att_sp_sub, AttitudeControl::update(), and uORB::Subscription::update().
Referenced by Run().
|
static |
Definition at line 398 of file mc_att_control_main.cpp.
References print_usage().
|
inlineprivate |
_param_mpc_man_y_max | scaling factor from stick to yaw rate |
_param_mpc_man_tilt_max | maximum tilt allowed for manual flight |
_param_mpc_manthr_min | minimum throttle for stabilized |
_param_mpc_thr_max | maximum throttle for stabilized |
_param_mpc_thr_hover | throttle at which vehicle is at hover equilibrium |
_param_mpc_thr_curve | throttle curve behavior |
Definition at line 148 of file mc_att_control.hpp.
|
private |
Generate & publish an attitude setpoint from stick inputs.
Definition at line 144 of file mc_att_control_main.cpp.
References _attitude_sp_id, _man_tilt_max, _man_yaw_sp, _vehicle_attitude_setpoint_pub, matrix::Matrix< Type, M, N >::copyTo(), f(), hrt_absolute_time(), matrix::Vector< Type, M >::norm(), ORB_PRIO_DEFAULT, orb_publish_auto(), math::radians(), Mixer::roll_pitch_yaw, throttle_curve(), and matrix::wrap_pi().
Referenced by Run().
bool MulticopterAttitudeControl::init | ( | ) |
Definition at line 74 of file mc_att_control_main.cpp.
References _vehicle_attitude_sub, and uORB::SubscriptionCallback::registerCallback().
Referenced by task_spawn().
|
private |
initialize some vectors/matrices from parameters
Definition at line 85 of file mc_att_control_main.cpp.
References _attitude_control, _man_tilt_max, math::radians(), AttitudeControl::setProportionalGain(), and AttitudeControl::setRateLimit().
Referenced by MulticopterAttitudeControl(), and Run().
|
override |
Definition at line 389 of file mc_att_control_main.cpp.
References _loop_perf, and perf_print_counter().
|
static |
Definition at line 403 of file mc_att_control_main.cpp.
Referenced by custom_command().
|
private |
Definition at line 254 of file mc_att_control_main.cpp.
References _rates_sp, _v_rates_sp_pub, hrt_absolute_time(), uORB::Publication< T >::publish(), and vehicle_rates_setpoint_s::roll.
Referenced by Run().
|
override |
Definition at line 270 of file mc_att_control_main.cpp.
References _last_run, _loop_perf, _man_yaw_sp, _manual_control_sp_sub, _params_sub, _rates_sp, _reset_yaw_sp, _v_control_mode_sub, _v_rates_sp_sub, _vehicle_attitude_sub, _vehicle_land_detected_sub, math::constrain(), control_attitude(), uORB::Subscription::copy(), dt, f(), generate_attitude_setpoint(), hrt_absolute_time(), hrt_abstime, parameters_updated(), perf_begin(), perf_end(), publish_rates_setpoint(), uORB::SubscriptionCallback::unregisterCallback(), uORB::SubscriptionInterval::update(), uORB::Subscription::update(), uORB::Subscription::updated(), and vehicle_status_poll().
|
static |
Definition at line 366 of file mc_att_control_main.cpp.
References init(), ll40ls::instance, and MulticopterAttitudeControl().
|
private |
Definition at line 122 of file mc_att_control_main.cpp.
References f().
Referenced by generate_attitude_setpoint().
|
private |
Definition at line 99 of file mc_att_control_main.cpp.
References _attitude_sp_id, _vehicle_status_sub, ORB_ID, param_find(), param_get(), TAILSITTER, and uORB::Subscription::update().
Referenced by Run().
|
private |
class for attitude control calculations
Definition at line 112 of file mc_att_control.hpp.
Referenced by control_attitude(), and parameters_updated().
|
private |
pointer to correct attitude setpoint uORB metadata structure
Definition at line 128 of file mc_att_control.hpp.
Referenced by generate_attitude_setpoint(), and vehicle_status_poll().
|
private |
Definition at line 144 of file mc_att_control.hpp.
Referenced by Run().
|
private |
loop duration performance counter
Definition at line 138 of file mc_att_control.hpp.
Referenced by print_status(), Run(), and ~MulticopterAttitudeControl().
|
private |
maximum tilt allowed for manual flight [rad]
Definition at line 172 of file mc_att_control.hpp.
Referenced by generate_attitude_setpoint(), and parameters_updated().
|
private |
current yaw setpoint in manual mode
Definition at line 142 of file mc_att_control.hpp.
Referenced by generate_attitude_setpoint(), and Run().
|
private |
manual control setpoint subscription
Definition at line 118 of file mc_att_control.hpp.
Referenced by Run().
|
private |
parameter updates subscription
Definition at line 117 of file mc_att_control.hpp.
Referenced by Run().
|
private |
angular rates setpoint
Definition at line 140 of file mc_att_control.hpp.
Referenced by control_attitude(), publish_rates_setpoint(), and Run().
|
private |
Definition at line 146 of file mc_att_control.hpp.
Referenced by Run().
|
private |
vehicle attitude setpoint subscription
Definition at line 114 of file mc_att_control.hpp.
Referenced by control_attitude().
|
private |
vehicle control mode subscription
Definition at line 116 of file mc_att_control.hpp.
Referenced by Run().
|
private |
rate setpoint publication
Definition at line 124 of file mc_att_control.hpp.
Referenced by publish_rates_setpoint().
|
private |
vehicle rates setpoint subscription
Definition at line 115 of file mc_att_control.hpp.
Referenced by Run().
|
private |
Definition at line 126 of file mc_att_control.hpp.
Referenced by generate_attitude_setpoint().
|
private |
Definition at line 122 of file mc_att_control.hpp.
|
private |
vehicle land detected subscription
Definition at line 120 of file mc_att_control.hpp.
Referenced by Run().
|
private |
vehicle status subscription
Definition at line 119 of file mc_att_control.hpp.
Referenced by vehicle_status_poll().