cartographer_utils.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Fabian Reister ( fabian dot reister at kit dot edu )
17 * @date 2021
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <filesystem>
25#include <memory>
26
27#include <cartographer/common/lua_parameter_dictionary.h>
28#include <cartographer/common/time.h>
29#include <cartographer/mapping/map_builder_interface.h>
30
32{
33 /**
34 * @brief Helper function to create Lua parameter object from string.
35 *
36 * Example:
37 *
38 * const std::string mapBuilderLuaCode = R"text(
39 * include "map_builder.lua"
40 * return MAP_BUILDER)text";
41 *
42 * auto paramsDict = resolveLuaParameters(mapBuilderLuaCode, ...);
43 *
44 *
45 * @param luaCode The lua code that will be evaluated.
46 * @param configPath The path where the lua config files reside.
47 * @return std::unique_ptr<::cartographer::common::LuaParameterDictionary>
48 */
49 std::unique_ptr<::cartographer::common::LuaParameterDictionary>
50 resolveLuaParameters(const std::string& luaCode, const std::filesystem::path& configPath);
51
52 /**
53 * @brief Convert cartographer time to unix time in [µs]
54 *
55 * @param time cartographer time
56 * @return int64_t time in [µs]
57 */
58 int64_t fromCarto(::cartographer::common::Time time);
59
60
61 /**
62 * @brief Convert unix time in [µs] to cartographer time
63 *
64 * @param time in [µs]
65 * @return ::cartographer::common::Time
66 */
67 ::cartographer::common::Time toCarto(const int64_t& time);
68
69 /**
70 * @brief Creates a map builder object from a stored map.
71 *
72 * @param mapPath The path to the map (e.g. /path/to/map.carto)
73 * @param configPath The path where the lua config files reside.
74 * @return std::unique_ptr<cartographer::mapping::MapBuilderInterface>
75 */
76 std::unique_ptr<::cartographer::mapping::MapBuilderInterface>
77 loadMap(const std::filesystem::path& mapPath, const std::filesystem::path& configPath);
78
79
80} // namespace armarx::localization_and_mapping::cartographer_adapter::util
int64_t fromCarto(::cartographer::common::Time time)
Convert cartographer time to unix time in [µs].
std::unique_ptr<::cartographer::mapping::MapBuilderInterface > loadMap(const std::filesystem::path &mapPath, const std::filesystem::path &configPath)
Creates a map builder object from a stored map.
::cartographer::common::Time toCarto(const int64_t &time)
Convert unix time in [µs] to cartographer time.
std::unique_ptr<::cartographer::common::LuaParameterDictionary > resolveLuaParameters(const std::string &luaCode, const std::filesystem::path &configPath)
Helper function to create Lua parameter object from string.