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
aa1b46f8
Commit
aa1b46f8
authored
6 years ago
by
Martina Rivizzigno
Committed by
bresch
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ObstacleAvoidance library: save current waypoint in global variable
to check progress
parent
94f73117
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/Utility/ObstacleAvoidance.cpp
+6
-7
6 additions, 7 deletions
src/lib/FlightTasks/tasks/Utility/ObstacleAvoidance.cpp
src/lib/FlightTasks/tasks/Utility/ObstacleAvoidance.hpp
+2
-0
2 additions, 0 deletions
src/lib/FlightTasks/tasks/Utility/ObstacleAvoidance.hpp
with
8 additions
and
7 deletions
src/lib/FlightTasks/tasks/Utility/ObstacleAvoidance.cpp
+
6
−
7
View file @
aa1b46f8
...
...
@@ -119,6 +119,7 @@ void ObstacleAvoidance::updateAvoidanceWaypoints(const Vector3f &curr_wp, const
{
_desired_waypoint
.
timestamp
=
hrt_absolute_time
();
_desired_waypoint
.
type
=
vehicle_trajectory_waypoint_s
::
MAV_TRAJECTORY_REPRESENTATION_WAYPOINTS
;
_curr_wp
=
curr_wp
;
curr_wp
.
copyTo
(
_desired_waypoint
.
waypoints
[
vehicle_trajectory_waypoint_s
::
POINT_1
].
position
);
Vector3f
(
NAN
,
NAN
,
NAN
).
copyTo
(
_desired_waypoint
.
waypoints
[
vehicle_trajectory_waypoint_s
::
POINT_1
].
velocity
);
...
...
@@ -149,21 +150,19 @@ void ObstacleAvoidance::updateAvoidanceSetpoints(const Vector3f &pos_sp, const V
}
void
ObstacleAvoidance
::
checkAvoidanceProgress
(
const
Vector3f
&
pos
,
const
Vector3f
&
prev_wp
,
float
target_acceptance_radius
,
const
Vector2f
&
closest_pt
)
float
target_acceptance_radius
,
const
Vector2f
&
closest_pt
)
{
position_controller_status_s
pos_control_status
=
{};
pos_control_status
.
timestamp
=
hrt_absolute_time
();
Vector3f
curr_wp
=
_desired_waypoint
.
waypoints
[
vehicle_trajectory_waypoint_s
::
POINT_1
].
position
;
// vector from previous triplet to current target
Vector2f
prev_to_target
=
Vector2f
(
curr_wp
-
prev_wp
);
Vector2f
prev_to_target
=
Vector2f
(
_
curr_wp
-
prev_wp
);
// vector from previous triplet to the vehicle projected position on the line previous-target triplet
Vector2f
prev_to_closest_pt
=
closest_pt
-
Vector2f
(
prev_wp
);
Vector2f
prev_to_closest_pt
=
closest_pt
-
Vector2f
(
prev_wp
);
prev_to_closest_pt
.
print
();
// fraction of the previous-tagerget line that has been flown
const
float
prev_curr_travelled
=
prev_to_closest_pt
.
length
()
/
prev_to_target
.
length
();
Vector2f
pos_to_target
=
Vector2f
(
curr_wp
-
pos
);
Vector2f
pos_to_target
=
Vector2f
(
_
curr_wp
-
pos
);
if
(
prev_curr_travelled
>
1.0
f
)
{
// if the vehicle projected position on the line previous-target is past the target waypoint,
...
...
@@ -171,7 +170,7 @@ void ObstacleAvoidance::checkAvoidanceProgress(const Vector3f &pos, const Vector
pos_control_status
.
acceptance_radius
=
pos_to_target
.
length
()
+
0.5
f
;
}
const
float
pos_to_target_z
=
fabsf
(
curr_wp
(
2
)
-
pos
(
2
));
const
float
pos_to_target_z
=
fabsf
(
_
curr_wp
(
2
)
-
pos
(
2
));
if
(
pos_to_target
.
length
()
<
target_acceptance_radius
&&
pos_to_target_z
>
NAV_MC_ALT_RAD
.
get
())
{
// vehicle above or below the target waypoint
...
...
This diff is collapsed.
Click to expand it.
src/lib/FlightTasks/tasks/Utility/ObstacleAvoidance.hpp
+
2
−
0
View file @
aa1b46f8
...
...
@@ -82,6 +82,8 @@ private:
orb_advert_t
_pub_pos_control_status
{
nullptr
};
orb_advert_t
_pub_vehicle_command
{
nullptr
};
matrix
::
Vector3f
_curr_wp
=
{};
void
_publish_avoidance_desired_waypoint
();
void
_publish_vehicle_cmd_do_loiter
();
...
...
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