Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
694f49c8
Commit
694f49c8
authored
6 years ago
by
Dennis Mannhart
Browse files
Options
Downloads
Patches
Plain Diff
FlightTaskAuto: method for computing heading from 2D vector
parent
6cd16f34
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/FlightTasks/tasks/FlightTaskAuto.cpp
+17
-0
17 additions, 0 deletions
src/lib/FlightTasks/tasks/FlightTaskAuto.cpp
src/lib/FlightTasks/tasks/FlightTaskAuto.hpp
+1
-0
1 addition, 0 deletions
src/lib/FlightTasks/tasks/FlightTaskAuto.hpp
with
18 additions
and
0 deletions
src/lib/FlightTasks/tasks/FlightTaskAuto.cpp
+
17
−
0
View file @
694f49c8
...
...
@@ -450,6 +450,23 @@ void FlightTaskAuto::_updateInternalWaypoints()
}
}
bool
FlightTaskAuto
::
_compute_heading_from_2D_vector
(
float
&
heading
,
matrix
::
Vector2f
v
)
{
if
(
PX4_ISFINITE
(
v
.
length
())
&&
v
.
length
()
>
SIGMA_NORM
)
{
v
.
normalize
();
// To find yaw: take dot product of x = (1,0) and v
// and multiply by the sign given of cross product of x and v.
// Dot product: (x(0)*v(0)+(x(1)*v(1)) = v(0)
// Cross product: x(0)*v(1) - v(0)*x(1) = v(1)
heading
=
math
::
sign
(
v
(
1
))
*
wrap_pi
(
acosf
(
v
(
0
)));
return
true
;
}
// heading unknown and therefore do not change heading
return
false
;
}
float
FlightTaskAuto
::
_getVelocityFromAngle
(
const
float
angle
)
{
// minimum cruise speed when passing waypoint
...
...
This diff is collapsed.
Click to expand it.
src/lib/FlightTasks/tasks/FlightTaskAuto.hpp
+
1
−
0
View file @
694f49c8
...
...
@@ -83,6 +83,7 @@ protected:
float
_getMaxCruiseSpeed
()
{
return
MPC_XY_CRUISE
.
get
();}
/**< getter for default cruise speed */
matrix
::
Vector2f
_getTargetVelocityXY
();
/**< only used for follow-me and only here because of legacy reason.*/
void
_updateInternalWaypoints
();
/**< Depending on state of vehicle, the internal waypoints might differ from target (for instance if offtrack). */
bool
_compute_heading_from_2D_vector
(
float
&
heading
,
matrix
::
Vector2f
v
);
matrix
::
Vector3f
_prev_prev_wp
{};
/**< Pre-previous waypoint (local frame). This will be used for smoothing trajectories -> not used yet. */
matrix
::
Vector3f
_prev_wp
{};
/**< Previous waypoint (local frame). If no previous triplet is available, the prev_wp is set to current position. */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment