mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 06:33:33 +08:00
FlightTasks: private variables follow underscore name convention, member description comments doxygen style
This commit is contained in:
@@ -91,12 +91,12 @@ public:
|
||||
protected:
|
||||
static constexpr int _timeout = 500000; /*< maximal time in us before a loop or data times out */
|
||||
|
||||
float _time = 0; /*< passed time in seconds since the task was activated */
|
||||
float _deltatime = 0; /*< passed time in seconds since the task was last updated */
|
||||
float _time = 0; /**< passed time in seconds since the task was activated */
|
||||
float _deltatime = 0; /**< passed time in seconds since the task was last updated */
|
||||
|
||||
/* Current vehicle position for every task */
|
||||
matrix::Vector3f _position; /*< current vehicle position */
|
||||
matrix::Vector3f _velocity; /*< current vehicle velocity */
|
||||
matrix::Vector3f _position; /**< current vehicle position */
|
||||
matrix::Vector3f _velocity; /**< current vehicle velocity */
|
||||
float _yaw = 0.f;
|
||||
|
||||
/**
|
||||
@@ -122,11 +122,10 @@ protected:
|
||||
private:
|
||||
uORB::Subscription<vehicle_local_position_s> _sub_vehicle_local_position;
|
||||
|
||||
hrt_abstime _starting_time_stamp = 0; /*< time stamp when task was activated */
|
||||
hrt_abstime _last_time_stamp = 0; /*< time stamp when task was last updated */
|
||||
hrt_abstime _starting_time_stamp = 0; /**< time stamp when task was activated */
|
||||
hrt_abstime _last_time_stamp = 0; /**< time stamp when task was last updated */
|
||||
|
||||
/* Output position setpoint that every task has */
|
||||
vehicle_local_position_setpoint_s _vehicle_local_position_setpoint;
|
||||
vehicle_local_position_setpoint_s _vehicle_local_position_setpoint; /**< Output position setpoint that every task has */
|
||||
|
||||
void _evaluate_vehicle_position();
|
||||
};
|
||||
|
||||
@@ -105,7 +105,7 @@ private:
|
||||
|
||||
|
||||
/* --- Acceleration Smoothing --- */
|
||||
static constexpr uint64_t DIRECTION_CHANGE_TIME_US = 1e5; /** Time in us to switch into direction change state */
|
||||
static constexpr uint64_t DIRECTION_CHANGE_TIME_US = 1e5; /**< Time in us to switch into direction change state */
|
||||
|
||||
control::BlockParamFloat _jerk_hor_max; /**< maximum jerk only applied when braking to zero */
|
||||
control::BlockParamFloat _jerk_hor_min; /**< minimum jerk only applied when braking to zero */
|
||||
@@ -118,7 +118,7 @@ private:
|
||||
control::BlockParamFloat _rc_flt_cutoff; /**< cutoff frequency for stick lowpass filter */
|
||||
|
||||
matrix::Vector2f _stick_input_xy_prev;
|
||||
matrix::Vector3f _vel_sp_prev; /* velocity setpoint of last loop to calculate setpoint slewrate - acceleration */
|
||||
matrix::Vector3f _vel_sp_prev; /**< velocity setpoint of last loop to calculate setpoint slewrate - acceleration */
|
||||
enum stick_user_intention {
|
||||
brake,
|
||||
direction_change,
|
||||
|
||||
@@ -48,11 +48,11 @@ using namespace matrix;
|
||||
int FlightTaskOrbit::activate()
|
||||
{
|
||||
FlightTask::activate();
|
||||
r = 1.f;
|
||||
v = 0.5f;
|
||||
z = _position(2);
|
||||
_r = 1.f;
|
||||
_v = 0.5f;
|
||||
_z = _position(2);
|
||||
_center = Vector2f(_position.data());
|
||||
_center(0) -= r;
|
||||
_center(0) -= _r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -66,25 +66,25 @@ int FlightTaskOrbit::update()
|
||||
{
|
||||
int ret = FlightTaskManual::update();
|
||||
|
||||
r += _sticks(0) * _deltatime;
|
||||
r = math::constrain(r, 1.f, 20.f);
|
||||
v -= _sticks(1) * _deltatime;
|
||||
v = math::constrain(v, -7.f, 7.f);
|
||||
z += _sticks(2) * _deltatime;
|
||||
_r += _sticks(0) * _deltatime;
|
||||
_r = math::constrain(_r, 1.f, 20.f);
|
||||
_v -= _sticks(1) * _deltatime;
|
||||
_v = math::constrain(_v, -7.f, 7.f);
|
||||
_z += _sticks(2) * _deltatime;
|
||||
|
||||
Vector2f center_to_position = Vector2f(_position.data()) - _center;
|
||||
|
||||
/* xy velocity to go around in a circle */
|
||||
Vector2f velocity_xy = Vector2f(center_to_position(1), -center_to_position(0));
|
||||
velocity_xy = velocity_xy.unit_or_zero();
|
||||
velocity_xy *= v;
|
||||
velocity_xy *= _v;
|
||||
|
||||
/* xy velocity adjustment to stay on the radius distance */
|
||||
velocity_xy += (r - center_to_position.norm()) * center_to_position.unit_or_zero();
|
||||
velocity_xy += (_r - center_to_position.norm()) * center_to_position.unit_or_zero();
|
||||
|
||||
float yaw = atan2f(center_to_position(1), center_to_position(0)) + M_PI_F;
|
||||
|
||||
_set_position_setpoint(Vector3f(NAN, NAN, z));
|
||||
_set_position_setpoint(Vector3f(NAN, NAN, _z));
|
||||
_set_velocity_setpoint(Vector3f(velocity_xy(0), velocity_xy(1), 0.f));
|
||||
_set_yaw_setpoint(yaw);
|
||||
return ret;
|
||||
|
||||
@@ -57,9 +57,9 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
float r = 0.f; /* radius with which to orbit the target */
|
||||
float v = 0.f; /* linear velocity for orbiting in m/s */
|
||||
float z = 0.f; /* local z coordinate in meters */
|
||||
float _r = 0.f; /**< radius with which to orbit the target */
|
||||
float _v = 0.f; /**< linear velocity for orbiting in m/s */
|
||||
float _z = 0.f; /**< local z coordinate in meters */
|
||||
matrix::Vector2f _center;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user