Skip to main content

Controller Plugin Project

Directory Structure

The project is mainly divided into third-party libraries, configuration files, usage examples, main source code under src, and xcore_api.

example
├──3rdparty/
├──config/
├──examples/
├──src/
├──xcore_api/
├──CMakeLists.txt
└──README.md

Third-Party Libraries (3rdparty)

This mainly includes third-party libraries in use: g3log, jsoncpp, gtest, and others.

The plugin only needs the header files of these libraries. To make it easier for users to use third-party libraries independently, corresponding lib packages are provided so users can link the libraries and build standalone executables.

The following sections introduce common log and json library usage.

config Directory

All files under this directory are packaged into the plugin binary data. Files can be read directly through the cmrc interface.

    CMRC_DECLARE(cmrc_config);  
auto cmrc_fs = cmrc::cmrc_config::get_filesystem();
// All json files under the conf_data directory
auto file_path = "cmrc_config/conf_data/" + dir_in_conf_data;
for (auto&& entry : cmrc_fs.iterate_directory(file_path)) {
Json::Value root;
auto json_file = cmrc_fs.open(file_path + entry.filename());
auto json_str = std::string(json_file.begin(), json_file.end());
xcore_api::utils::LoadFromStringAPI(root,json_str);
ret[dir_in_conf_data + entry.filename()] = root;
}

examples Directory

Contains plugin usage examples. Users can refer to these examples to learn how to use the API.

example_launch is the entry point for these examples.

src Directory

The main plugin source code. Users can place their own code in this directory.

A built-in launch module currently serves as the plugin entry program.

Users can add their own implementation logic under this directory.

xcore_api Directory

Interfaces exported by the controller. Users can use controller functionality through these interfaces.