RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
uResourceGenerator

UtiLite provides a utility application called uResourceGenerator to generate resources to include in an executable. For example:

$ rtabmap-res_tool DatabaseSchema.sql

This will generate a HEX file "DatabaseSchema_sql.h" which can be included in source files. Data of the file is global and can be accessed by the generated const char * DATABASESCHEMA_SQL.

#include "DatabaseSchema_sql.h"
...
std::string hex = DATABASESCHEMA_SQL;
// Assuming there are only ASCII characters, we can directly convert to a string:
std::string schema = uHex2Str(hex);
// For binary data:
std::vector<char> bytes = uHex2Bytes(hex);
std::string UTILITE_EXPORT uHex2Str(const std::string &hex)
std::vector< char > UTILITE_EXPORT uHex2Bytes(const std::string &hex)

The generator can be automated in a CMake build like:

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/DatabaseSchema_sql.h
COMMAND ${RTABMAP_RES_TOOL} -n my_namespace -p ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/DatabaseSchema.sql
COMMENT "[Creating database resource]"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/DatabaseSchema.sql
)
SET(RESOURCES
${CMAKE_CURRENT_BINARY_DIR}/DatabaseSchema_sql.h
)
ADD_LIBRARY(mylib ${SRC_FILES} ${RESOURCES})
ADD_EXECUTABLE(myexecutable ${SRC_FILES} ${RESOURCES})

The tool is installed as rtabmap-res_tool. It is not exported by FIND_PACKAGE(RTABMap), so locate it with FIND_PROGRAM(RTABMAP_RES_TOOL rtabmap-res_tool). Inside RTAB-Map's own build, the res_tool CMake target can be used directly as the COMMAND instead.