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
859843ff
Commit
859843ff
authored
5 years ago
by
Matthew Hansen
Committed by
Matt Hansen
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update for new LoadMap service
parent
011a8465
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nav2_map_server/src/occ_grid_loader.cpp
+2
-9
2 additions, 9 deletions
nav2_map_server/src/occ_grid_loader.cpp
nav2_map_server/test/component/test_occ_grid_node.cpp
+5
-26
5 additions, 26 deletions
nav2_map_server/test/component/test_occ_grid_node.cpp
with
7 additions
and
35 deletions
nav2_map_server/src/occ_grid_loader.cpp
+
2
−
9
View file @
859843ff
...
...
@@ -133,7 +133,7 @@ bool OccGridLoader::loadMapFromYaml(
{
if
(
yaml_file
.
empty
())
{
RCLCPP_ERROR
(
node_
->
get_logger
(),
"YAML file name is empty, can't load!"
);
response
->
result
=
nav2_msgs
::
srv
::
LoadMap
::
Response
::
RESULT_MAP_
ID_
DOES_NOT_EXIST
;
response
->
result
=
nav2_msgs
::
srv
::
LoadMap
::
Response
::
RESULT_MAP_DOES_NOT_EXIST
;
return
false
;
}
RCLCPP_INFO
(
node_
->
get_logger
(),
"Loading yaml file: %s"
,
yaml_file
.
c_str
());
...
...
@@ -206,15 +206,8 @@ nav2_util::CallbackReturn OccGridLoader::on_configure(const rclcpp_lifecycle::St
return
;
}
RCLCPP_INFO
(
node_
->
get_logger
(),
"OccGridLoader: Handling LoadMap request"
);
// Check if map_id is a file
if
(
request
->
type
!=
nav2_msgs
::
srv
::
LoadMap
::
Request
::
TYPE_FILE
)
{
RCLCPP_ERROR
(
node_
->
get_logger
(),
"OccGridLoader: unsupported FILE_TYPE in request, can't load map"
);
response
->
result
=
nav2_msgs
::
srv
::
LoadMap
::
Response
::
RESULT_INVALID_TYPE
;
return
;
}
// Load from file
if
(
loadMapFromYaml
(
request
->
map_
id
,
response
))
{
if
(
loadMapFromYaml
(
request
->
map_
url
,
response
))
{
response
->
map
=
*
msg_
;
response
->
result
=
nav2_msgs
::
srv
::
LoadMap
::
Response
::
RESULT_SUCCESS
;
occ_pub_
->
publish
(
*
msg_
);
// publish new map
...
...
This diff is collapsed.
Click to expand it.
nav2_map_server/test/component/test_occ_grid_node.cpp
+
5
−
26
View file @
859843ff
...
...
@@ -114,8 +114,7 @@ TEST_F(TestNode, LoadMap)
RCLCPP_INFO
(
node_
->
get_logger
(),
"Waiting for load_map service"
);
ASSERT_TRUE
(
client
->
wait_for_service
());
req
->
type
=
nav2_msgs
::
srv
::
LoadMap
::
Request
::
TYPE_FILE
;
req
->
map_id
=
path
(
TEST_DIR
)
/
path
(
g_valid_yaml_file
);
req
->
map_url
=
path
(
TEST_DIR
)
/
path
(
g_valid_yaml_file
);
auto
resp
=
send_request
<
nav2_msgs
::
srv
::
LoadMap
>
(
node_
,
client
,
req
);
ASSERT_EQ
(
resp
->
result
,
nav2_msgs
::
srv
::
LoadMap
::
Response
::
RESULT_SUCCESS
);
...
...
@@ -127,23 +126,6 @@ TEST_F(TestNode, LoadMap)
}
}
TEST_F
(
TestNode
,
LoadMapURL
)
{
RCLCPP_INFO
(
node_
->
get_logger
(),
"Testing LoadMap service"
);
auto
req
=
std
::
make_shared
<
nav2_msgs
::
srv
::
LoadMap
::
Request
>
();
auto
client
=
node_
->
create_client
<
nav2_msgs
::
srv
::
LoadMap
>
(
"load_map"
);
RCLCPP_INFO
(
node_
->
get_logger
(),
"Waiting for load_map service"
);
ASSERT_TRUE
(
client
->
wait_for_service
());
req
->
type
=
nav2_msgs
::
srv
::
LoadMap
::
Request
::
TYPE_URL
;
req
->
map_id
=
"dummy"
;
RCLCPP_INFO
(
node_
->
get_logger
(),
"Sending load_map request with invalid type"
);
auto
resp
=
send_request
<
nav2_msgs
::
srv
::
LoadMap
>
(
node_
,
client
,
req
);
ASSERT_EQ
(
resp
->
result
,
nav2_msgs
::
srv
::
LoadMap
::
Response
::
RESULT_INVALID_TYPE
);
}
TEST_F
(
TestNode
,
LoadMapNull
)
{
RCLCPP_INFO
(
node_
->
get_logger
(),
"Testing LoadMap service"
);
...
...
@@ -153,12 +135,11 @@ TEST_F(TestNode, LoadMapNull)
RCLCPP_INFO
(
node_
->
get_logger
(),
"Waiting for load_map service"
);
ASSERT_TRUE
(
client
->
wait_for_service
());
req
->
type
=
nav2_msgs
::
srv
::
LoadMap
::
Request
::
TYPE_FILE
;
req
->
map_id
=
""
;
req
->
map_url
=
""
;
RCLCPP_INFO
(
node_
->
get_logger
(),
"Sending load_map request with null file name"
);
auto
resp
=
send_request
<
nav2_msgs
::
srv
::
LoadMap
>
(
node_
,
client
,
req
);
ASSERT_EQ
(
resp
->
result
,
nav2_msgs
::
srv
::
LoadMap
::
Response
::
RESULT_MAP_
ID_
DOES_NOT_EXIST
);
ASSERT_EQ
(
resp
->
result
,
nav2_msgs
::
srv
::
LoadMap
::
Response
::
RESULT_MAP_DOES_NOT_EXIST
);
}
TEST_F
(
TestNode
,
LoadMapInvalidYaml
)
...
...
@@ -170,8 +151,7 @@ TEST_F(TestNode, LoadMapInvalidYaml)
RCLCPP_INFO
(
node_
->
get_logger
(),
"Waiting for load_map service"
);
ASSERT_TRUE
(
client
->
wait_for_service
());
req
->
type
=
nav2_msgs
::
srv
::
LoadMap
::
Request
::
TYPE_FILE
;
req
->
map_id
=
"invalid_file.yaml"
;
req
->
map_url
=
"invalid_file.yaml"
;
RCLCPP_INFO
(
node_
->
get_logger
(),
"Sending load_map request with invalid yaml file name"
);
auto
resp
=
send_request
<
nav2_msgs
::
srv
::
LoadMap
>
(
node_
,
client
,
req
);
...
...
@@ -187,8 +167,7 @@ TEST_F(TestNode, LoadMapInvalidImage)
RCLCPP_INFO
(
node_
->
get_logger
(),
"Waiting for load_map service"
);
ASSERT_TRUE
(
client
->
wait_for_service
());
req
->
type
=
nav2_msgs
::
srv
::
LoadMap
::
Request
::
TYPE_FILE
;
req
->
map_id
=
req
->
map_id
=
path
(
TEST_DIR
)
/
"invalid_image.yaml"
;
req
->
map_url
=
path
(
TEST_DIR
)
/
"invalid_image.yaml"
;
RCLCPP_INFO
(
node_
->
get_logger
(),
"Sending load_map request with invalid image file name"
);
auto
resp
=
send_request
<
nav2_msgs
::
srv
::
LoadMap
>
(
node_
,
client
,
req
);
...
...
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