Nav2 Navigation Stack - jazzy
jazzy
ROS 2 Navigation Stack
nav2_map_server
src
map_mode.cpp
1
// Copyright 2019 Rover Robotics
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include "nav2_map_server/map_mode.hpp"
16
17
#include <stdexcept>
18
#include <string>
19
20
namespace
nav2_map_server
21
{
22
const
char
* map_mode_to_string(MapMode map_mode)
23
{
24
switch
(map_mode) {
25
case
MapMode::Trinary:
26
return
"trinary"
;
27
case
MapMode::Scale:
28
return
"scale"
;
29
case
MapMode::Raw:
30
return
"raw"
;
31
default
:
32
throw
std::invalid_argument(
"map_mode"
);
33
}
34
}
35
36
MapMode map_mode_from_string(std::string map_mode_name)
37
{
38
for
(
auto
& c : map_mode_name) {
39
c = tolower(c);
40
}
41
42
if
(map_mode_name ==
"scale"
) {
43
return
MapMode::Scale;
44
}
else
if
(map_mode_name ==
"raw"
) {
45
return
MapMode::Raw;
46
}
else
if
(map_mode_name ==
"trinary"
) {
47
return
MapMode::Trinary;
48
}
else
{
49
throw
std::invalid_argument(
"map_mode_name"
);
50
}
51
}
52
}
// namespace nav2_map_server
Generated by
1.9.1