Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
210910794
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2021
210910794
Commits
fa8892ce
Commit
fa8892ce
authored
5 years ago
by
Matthew Hansen
Committed by
Matt Hansen
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove navigate_to_pose from updown test
parent
29f97126
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nav2_system_tests/src/updown/test_updown.cpp
+4
-73
4 additions, 73 deletions
nav2_system_tests/src/updown/test_updown.cpp
with
4 additions
and
73 deletions
nav2_system_tests/src/updown/test_updown.cpp
+
4
−
73
View file @
fa8892ce
...
...
@@ -22,72 +22,6 @@
using
namespace
std
::
chrono_literals
;
struct
xytheta
{
double
x
;
double
y
;
double
theta
;
};
void
nav_to_poses
(
const
char
*
nav_type_arg
,
nav2_lifecycle_manager
::
LifecycleManagerClient
&
client
)
{
if
(
nav_type_arg
!=
nullptr
)
{
std
::
string
nav_type
(
nav_type_arg
);
// Create a set of target poses across the map
std
::
vector
<
xytheta
>
target_poses
;
target_poses
.
push_back
({
-
2.0
,
-
0.5
,
0
});
target_poses
.
push_back
({
0.94
,
-
0.55
,
0
});
target_poses
.
push_back
({
1.7
,
0.5
,
1.4
});
target_poses
.
push_back
({
0.97
,
1.68
,
2.94
});
target_poses
.
push_back
({
0.02
,
1.74
,
-
2.9
});
xytheta
&
initial_pose
=
target_poses
[
0
];
// Set the robot's starting pose (approximately where it comes up in gazebo)
client
.
set_initial_pose
(
initial_pose
.
x
,
initial_pose
.
y
,
initial_pose
.
theta
);
if
(
nav_type
==
"iterative"
)
{
// In the iterative case, navigate through all of the poses (but skip the
// first one, which is the initial pose)
for
(
std
::
vector
<
xytheta
>::
size_type
i
=
1
;
i
<
target_poses
.
size
();
i
++
)
{
auto
pose
=
target_poses
[
i
];
if
(
!
client
.
navigate_to_pose
(
pose
.
x
,
pose
.
y
,
pose
.
theta
))
{
RCLCPP_ERROR
(
rclcpp
::
get_logger
(
"test_updown"
),
"Navigation failed!"
);
break
;
}
}
}
else
if
(
nav_type
==
"random"
)
{
// In the random case, navigate to randomly-selected poses from the target_poses
// collection
// Get set up to generate random indices
std
::
random_device
r
;
std
::
default_random_engine
e1
(
r
());
std
::
uniform_int_distribution
<
int
>
uniform_dist
(
0
,
target_poses
.
size
()
-
1
);
for
(
int
i
=
0
,
cur_index
=
0
;
i
<
10
;
i
++
)
{
// Get a random index that is not the current one (so we can navigate
// to a pose different than our current location)
int
next_index
=
0
;
do
{
next_index
=
uniform_dist
(
r
);
}
while
(
next_index
==
cur_index
);
// Grab the pose for that index and start the navigation
auto
pose
=
target_poses
[
next_index
];
if
(
!
client
.
navigate_to_pose
(
pose
.
x
,
pose
.
y
,
pose
.
theta
))
{
RCLCPP_ERROR
(
rclcpp
::
get_logger
(
"test_updown"
),
"Navigation failed!"
);
break
;
}
}
}
else
{
RCLCPP_ERROR
(
rclcpp
::
get_logger
(
"test_updown"
),
"Unrecognized navigation type: %s, no navigation performed"
,
nav_type
);
}
}
}
int
main
(
int
argc
,
char
**
argv
)
{
rclcpp
::
init
(
argc
,
argv
);
...
...
@@ -120,20 +54,17 @@ int main(int argc, char ** argv)
RCLCPP_ERROR
(
rclcpp
::
get_logger
(
"test_updown"
),
"System startup failed"
);
test_passed
=
false
;
}
else
{
// Parse the command line options
char
*
nav_type_arg
=
rcutils_cli_get_option
(
argv
,
argv
+
argc
,
"-t"
);
nav_to_poses
(
nav_type_arg
,
client
);
}
// Shut down the nav2 system, bringing it to the FINALIZED state
client
.
shutdown
();
if
(
test_passed
)
{
RCLCPP_INFO
(
rclcpp
::
get_logger
(
"test_updown"
),
"TEST PASSED!"
);
RCLCPP_INFO
(
rclcpp
::
get_logger
(
"test_updown"
),
"**************************************************** TEST PASSED!"
);
}
else
{
RCLCPP_INFO
(
rclcpp
::
get_logger
(
"test_updown"
),
"TEST FAILED!"
);
RCLCPP_INFO
(
rclcpp
::
get_logger
(
"test_updown"
),
"**************************************************** TEST FAILED!"
);
}
rclcpp
::
shutdown
();
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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