Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Navigation
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
Container 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
Skills
Navigation
Commits
cca9f99c
Commit
cca9f99c
authored
2 years ago
by
Tobias Gröger
Browse files
Options
Downloads
Patches
Plain Diff
Calculate target position for planning (wip)
parent
e416d8eb
No related branches found
No related tags found
2 merge requests
!28
Draft: Dev -> Main
,
!27
Add TEB to CMake config
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/armarx/navigation/local_planning/TimedElasticBands.cpp
+75
-7
75 additions, 7 deletions
...ce/armarx/navigation/local_planning/TimedElasticBands.cpp
source/armarx/navigation/local_planning/TimedElasticBands.h
+9
-0
9 additions, 0 deletions
source/armarx/navigation/local_planning/TimedElasticBands.h
with
84 additions
and
7 deletions
source/armarx/navigation/local_planning/TimedElasticBands.cpp
+
75
−
7
View file @
cca9f99c
#include
"TimedElasticBands.h"
#include
<VirtualRobot/MathTools.h>
#include
<VirtualRobot/Robot.h>
#include
<ArmarXCore/core/logging/Logging.h>
...
...
@@ -79,15 +80,16 @@ namespace armarx::navigation::loc_plan
std
::
optional
<
LocalPlannerResult
>
TimedElasticBands
::
plan
(
const
core
::
Trajectory
&
goal
)
{
teb_local_planner
::
TimedElasticBand
globalPath
=
conv
::
toRos
(
goal
);
const
teb_local_planner
::
TimedElasticBand
globalPath
=
conv
::
toRos
(
goal
);
teb_globalPath
=
globalPath
.
poses
();
hcp_
->
setGlobalPath
(
&
teb_globalPath
);
//TODO (SALt): calculate target pose
const
teb_local_planner
::
PoseSE2
start
=
conv
::
toRos
(
static_cast
<
core
::
Pose
>
(
scene
.
robot
->
getGlobalPose
()));
const
teb_local_planner
::
PoseSE2
end
=
conv
::
toRos
(
goal
.
points
().
end
()
->
waypoint
.
pose
);
bool
planToDestination
=
true
;
const
core
::
Pose
currentPose
{
scene
.
robot
->
getGlobalPose
()};
const
teb_local_planner
::
PoseSE2
start
=
conv
::
toRos
(
currentPose
);
const
FindTargetResult
target
=
findTarget
(
currentPose
,
goal
);
const
teb_local_planner
::
PoseSE2
end
=
conv
::
toRos
(
target
.
target
);
core
::
Twist
currentVelocity
=
core
::
Twist
::
Zero
();
if
(
scene
.
platformVelocity
.
has_value
())
...
...
@@ -100,7 +102,7 @@ namespace armarx::navigation::loc_plan
try
{
hcp_
->
plan
(
start
,
end
,
&
velocity_start
,
!
planToDest
ination
);
hcp_
->
plan
(
start
,
end
,
&
velocity_start
,
!
planToDest
);
}
catch
(
std
::
exception
&
e
)
{
...
...
@@ -116,4 +118,70 @@ namespace armarx::navigation::loc_plan
}
TimedElasticBands
::
FindTargetResult
TimedElasticBands
::
findTarget
(
const
core
::
Pose
&
currentPose
,
const
core
::
Trajectory
&
globalPath
)
{
float
distance
=
std
::
numeric_limits
<
float
>::
max
();
const
core
::
Position
point
=
currentPose
.
translation
();
core
::
Position
projection
;
size_t
closestSegment
=
-
1
;
for
(
size_t
i
=
0
;
i
<
globalPath
.
points
().
size
()
-
1
;
i
++
)
{
const
auto
&
wpBefore
=
globalPath
.
points
().
at
(
i
);
const
auto
&
wpAfter
=
globalPath
.
points
().
at
(
i
+
1
);
// FIXME remove after finding the bug
if
((
wpBefore
.
waypoint
.
pose
.
translation
()
-
wpAfter
.
waypoint
.
pose
.
translation
())
.
norm
()
<
1.
F
)
{
// ARMARX_WARNING << "Trajectory segment " << i << " too small ...";
continue
;
}
const
auto
closestPoint
=
VirtualRobot
::
MathTools
::
nearestPointOnSegment
<
core
::
Position
>
(
wpBefore
.
waypoint
.
pose
.
translation
(),
wpAfter
.
waypoint
.
pose
.
translation
(),
point
);
const
float
currentDistance
=
(
closestPoint
-
point
).
norm
();
// 'less equal' to accept following segment if the closest point is the waypoint
if
(
currentDistance
<=
distance
)
{
closestSegment
=
i
;
projection
=
closestPoint
;
distance
=
currentDistance
;
}
}
//TODO (SALt): parameter to set planning distance
float
remaining
=
5.
F
;
core
::
Position
closestPoint
=
projection
;
for
(
size_t
i
=
closestSegment
;
i
<
globalPath
.
points
().
size
()
-
1
;
i
++
)
{
const
core
::
Position
&
segEnd
=
globalPath
.
points
().
at
(
i
+
1
).
waypoint
.
pose
.
translation
();
const
float
segmentDistance
=
(
segEnd
-
closestPoint
).
norm
();
if
(
segmentDistance
<
remaining
)
{
closestPoint
=
segEnd
;
remaining
-=
segmentDistance
;
}
else
{
const
core
::
Position
dest
=
closestPoint
+
remaining
*
(
segEnd
-
closestPoint
).
normalized
();
return
{
projection
,
dest
,
false
};
}
}
return
{
projection
,
globalPath
.
points
().
end
()[
0
].
waypoint
.
pose
.
translation
(),
true
};
}
}
// namespace armarx::navigation::loc_plan
This diff is collapsed.
Click to expand it.
source/armarx/navigation/local_planning/TimedElasticBands.h
+
9
−
0
View file @
cca9f99c
...
...
@@ -52,7 +52,16 @@ namespace armarx::navigation::loc_plan
std
::
optional
<
LocalPlannerResult
>
plan
(
const
core
::
Trajectory
&
goal
)
override
;
private:
struct
FindTargetResult
{
core
::
Pose
projection
;
core
::
Pose
target
;
bool
planToDestination
;
};
void
initConfig
();
FindTargetResult
findTarget
(
const
core
::
Pose
&
currentPose
,
const
core
::
Trajectory
&
globalPath
);
protected
:
const
Params
params
;
...
...
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