class mola::MolaLauncherApp

Overview

Main launcher for a MOLA system. See mola-cli for a ready-to-use program.

#include <MolaLauncherApp.h>

class MolaLauncherApp: public mrpt::system::COutputLogger
{
public:
    // typedefs

    typedef std::string module_name_t;
    typedef std::string module_shared_path_t;

    // structs

    struct InfoPerRunningThread;
    struct Parameters;

    // fields

    mrpt::system::CTimeLogger profiler_ {true, "MolaLauncherApp"};
    std::optional<ProfilerSaverAtDtor> profiler_dtor_save_stats_;
    Parameters launcher_params_;

    // methods

    void setup(
        const mrpt::containers::yaml& cfg,
        const std::optional<std::string>& basePath = std::nullopt
        );

    void spin();
    void shutdown();
    void addPathModuleLibs(const std::string& path);
    void addPathModuleSources(const std::string& path);
    std::vector<std::string> getModuleLibPaths() const;
    std::vector<std::string> getModuleSourcePaths() const;
    std::vector<std::string> getLoadedModules();
    std::string findModuleSharedDir(const std::string& moduleName) const;
    void scanAndLoadLibraries();
    std::map<module_name_t, module_shared_path_t> scanForModuleSharedDirectories() const;
};

Fields

mrpt::system::CTimeLogger profiler_ {true, "MolaLauncherApp"}

Time profiler. It’s enabled/disabled status will be inherited (by default, unless set otherwise in their YAML config files) by all modules created upon the call to setup()

std::optional<ProfilerSaverAtDtor> profiler_dtor_save_stats_

Enabled from mola-cli with --profiler-whole to save full profile stats to .m files at program end.

Methods

void setup(
    const mrpt::containers::yaml& cfg,
    const std::optional<std::string>& basePath = std::nullopt
    )

Prepares the SLAM system based on a YAML configuration file. See [mola]/demos/ for example YAML files. At this point, MOLA module libraries are searched in a list of paths and loaded for their classes to be available in name-based class factories. Modules must be named “libmola*” to be loaded.

See also:

addPathModuleLibs, scanAndLoadLibraries

void spin()

(Blocking call) Launch sensor and worker threads and enters into an infinite loop executing the SLAM system, until shutdown() is called (e.g. from another thread or a signal handler).

void shutdown()

Attempts to do a clean shutdown of the system, giving all threads an opportunity to end and save any pending data, etc.

See also:

spin()

void addPathModuleLibs(const std::string& path)

Adds a directory to the list of paths to search for MOLA modules (.so/.dll) when setup() is called. The environment variable MOLA_MODULES_LIB_PATH (path1[:path2[:...]]) is automatically added at class construction. Default is CMAKE_LIBRARY_OUTPUT_DIRECTORY.

void addPathModuleSources(const std::string& path)

Adds a directory to the list of paths to search for MOLA module source and shared files. The environment variable MOLA_MODULES_SHARED_PATH (path1[:path2[:...]]) is automatically added at class construction.

Default is ${MOLA_SOURCE_DIR}/modules/

std::vector<std::string> getModuleLibPaths() const

Returns a copy of the current list of paths in which this object will try to look for MOLA modules compiled binaries.

See also:

addPathModuleLibs

std::vector<std::string> getModuleSourcePaths() const

Returns a copy of the current list of paths in which this object will try to look for MOLA modules shared files.

See also:

addPathModuleSources

std::vector<std::string> getLoadedModules()

Returns the current list of loaded module dynamic libraries.

std::string findModuleSharedDir(const std::string& moduleName) const

Returns the absolute path of the root directory where the given module shared files can be found. For BUILD_INTERFACE, this should be the root of each repository source. For INSTALL_INTERFACE, it should be <INSTALL_PREFIX>/share/<MODULE_NAME>/

Returns an empty string if module is not found.

See also:

scanForModuleSharedDirectories() to search for all module paths.

void scanAndLoadLibraries()

Scans and loads MOLA module libraries. This is automatically called within setup(), but it’s provided here in case a user want to only load modules for use the RTTI machinery on them without setting up a complete SLAM system.

See also:

addPathModuleLibs, setup

std::map<module_name_t, module_shared_path_t> scanForModuleSharedDirectories() const

Scans the shared directories and returns a list with found modules and their shared directory.