47 #include <matrix/math.hpp> 50 #include <uORB/topics/follow_target.h> 65 static constexpr
int TARGET_TIMEOUT_MS = 2500;
66 static constexpr
int TARGET_ACCEPTANCE_RADIUS_M = 5;
67 static constexpr
int INTERPOLATION_PNTS = 20;
68 static constexpr
float FF_K = .25F;
69 static constexpr
float OFFSET_M = 8;
71 enum FollowTargetState {
74 SET_WAIT_FOR_TARGET_POSITION,
75 WAIT_FOR_TARGET_POSITION
85 static constexpr
float _follow_position_matricies[4][9] = {
86 { 1.0F, -1.0F, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F, 1.0F},
87 {-1.0F, 0.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F, 0.0F, 1.0F},
88 { 1.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 1.0F},
89 { 1.0F, 1.0F, 0.0F, -1.0F, 1.0F, 0.0F, 0.0F, 0.0F, 1.0F}
99 FollowTargetState _follow_target_state{SET_WAIT_FOR_TARGET_POSITION};
100 int _follow_target_position{FOLLOW_FROM_BEHIND};
102 int _follow_target_sub{-1};
103 float _step_time_in_ms{0.0f};
104 float _follow_offset{OFFSET_M};
106 uint64_t _target_updates{0};
107 uint64_t _last_update_time{0};
109 matrix::Vector3f _current_vel;
110 matrix::Vector3f _step_vel;
111 matrix::Vector3f _est_target_vel;
112 matrix::Vector3f _target_distance;
113 matrix::Vector3f _target_position_offset;
114 matrix::Vector3f _target_position_delta;
115 matrix::Vector3f _filtered_target_position_delta;
117 follow_target_s _current_target_motion{};
118 follow_target_s _previous_target_motion{};
120 float _yaw_rate{0.0f};
121 float _responsiveness{0.0f};
122 float _yaw_angle{0.0f};
132 matrix::Dcmf _rot_matrix;
134 void track_target_position();
135 void track_target_velocity();
136 bool target_velocity_valid();
137 bool target_position_valid();
138 void reset_target_validity();
139 void update_position_sp(
bool velocity_valid,
bool position_valid,
float yaw_rate);
140 void update_target_motion();
141 void update_target_velocity();
146 void set_follow_target_item(
struct mission_item_s *item,
float min_clearance, follow_target_s &target,
float yaw);
Global position setpoint in WGS84 coordinates.
Definition: navigation.h:145
Definition: px4_param.h:313
Helper class to use mission items.
Definition: mission_block.h:56
Definition: navigator_main.cpp:80
Definition: px4_param.h:318
void on_active() override
This function is called while the mode is active.
Definition: follow_target.cpp:99
C++ base class for modules/classes using configuration parameters.
Definition: px4_module_params.h:46
void on_inactive() override
This function is called while the mode is inactive.
Definition: follow_target.cpp:75
Common header for mathlib exports.
Definition: navigator.h:83
Base class for different modes in navigator.
void on_activation() override
This function is called one time when mode becomes active, pos_sp_triplet must be initialized here...
Definition: follow_target.cpp:80
Definition: follow_target.h:52