GKD.RoboCtrl
RoboMaster Linux 电控:异步 IO、设备驱动与机器人控制
载入中...
搜索中...
未找到
runtime.hpp 文件参考

外部 JSON/YAML 配置的读取与启动前校验。 更多...

详细描述

外部 JSON/YAML 配置的读取与启动前校验。

配置根对象直接组合各组件原有的 info_type;不维护平行的 Spec 类型。

在文件 runtime.hpp 中定义.

#include <algorithm>
#include <expected>
#include <filesystem>
#include <fstream>
#include <iterator>
#include <ostream>
#include <optional>
#include <span>
#include <string>
#include <vector>
#include <rfl/thirdparty/enchantum/enchantum.hpp>
#include "config/base.hpp"
#include "config/validate.hpp"
#include "ctrl/power_manager.h"
#include "device/aim_link.hpp"
#include "device/remote_logger.hpp"
#include "device/referee/referee.h"
#include "device/super_cap.h"
#include "device/motor/j6006.h"
#include "device/motor/m9025.h"
#include <rfl/NoExtraFields.hpp>
#include <rfl/Processors.hpp>
#include <rfl/json.hpp>
#include <rfl/yaml.hpp>
runtime.hpp 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

类

struct  enchantum::enum_traits< roboctrl::device::dji_motor::type >
 
struct  roboctrl::config::runtime_config
 运行时配置根对象。 更多...
 

类型定义

using roboctrl::config::configuration_result = std::expected< runtime_config, std::string >
 

函数

void roboctrl::config::validate_runtime_extensions (const runtime_config &config)
 
configuration_result roboctrl::config::validate_runtime_configuration (runtime_config config)
 校验已解析的运行时配置。
 
std::expected< std::string, std::string > roboctrl::config::read_text_file (const std::filesystem::path &path)
 读取整个文本文件。
 
configuration_result roboctrl::config::load_configuration (const std::filesystem::path &path)
 从 YAML 或 JSON 文件加载并校验运行时配置。
 
std::filesystem::path roboctrl::config::default_configuration_path ()
 获取未指定 --config 时使用的默认配置路径。
 
void roboctrl::config::print_available_configurations (std::ostream &output, const std::filesystem::path &directory)
 将指定目录下的 YAML/JSON 配置按名称排序后打印到输出流。
 

类型定义说明

◆ configuration_result

using roboctrl::config::configuration_result = typedef std::expected<runtime_config, std::string>

在文件 runtime.hpp 第 80 行定义.

函数说明

◆ default_configuration_path()

std::filesystem::path roboctrl::config::default_configuration_path ( )
inline

获取未指定 --config 时使用的默认配置路径。

返回
configs/infantry.yaml(默认配置;其他车型通过 --config 选择)。

在文件 runtime.hpp 第 270 行定义.

引用了 roboctrl::config::default_configuration_path() , 以及 roboctrl::config::default_profile.

被这些函数引用 roboctrl::config::default_configuration_path().

◆ load_configuration()

configuration_result roboctrl::config::load_configuration ( const std::filesystem::path &  path)
inline

从 YAML 或 JSON 文件加载并校验运行时配置。

参数
path配置文件路径;扩展名必须为 .yaml、<tt>.yml 或 .json。
返回
已解析且通过语义校验的配置,或包含解析/校验错误的 std::unexpected。

在文件 runtime.hpp 第 240 行定义.

引用了 roboctrl::config::load_configuration(), roboctrl::config::read_text_file() , 以及 roboctrl::config::validate_runtime_configuration().

被这些函数引用 roboctrl::config::load_configuration().

◆ print_available_configurations()

void roboctrl::config::print_available_configurations ( std::ostream &  output,
const std::filesystem::path &  directory 
)
inline

将指定目录下的 YAML/JSON 配置按名称排序后打印到输出流。

参数
output输出流。
directory要枚举的配置目录。

在文件 runtime.hpp 第 280 行定义.

引用了 roboctrl::config::print_available_configurations() , 以及 roboctrl::config::read_text_file().

被这些函数引用 roboctrl::config::print_available_configurations().

◆ read_text_file()

std::expected< std::string, std::string > roboctrl::config::read_text_file ( const std::filesystem::path &  path)
inline

读取整个文本文件。

参数
path文件路径。
返回
文件内容,或包含打开失败原因的 std::unexpected。

在文件 runtime.hpp 第 223 行定义.

引用了 roboctrl::config::read_text_file().

被这些函数引用 roboctrl::config::load_configuration(), roboctrl::config::print_available_configurations() , 以及 roboctrl::config::read_text_file().

◆ validate_runtime_configuration()

configuration_result roboctrl::config::validate_runtime_configuration ( runtime_config  config)
inline

校验已解析的运行时配置。

参数
config待校验的配置对象;成功时按值返回,便于继续移动到初始化阶段。
返回
通过校验的配置,或包含错误原因的 std::unexpected。

在文件 runtime.hpp 第 189 行定义.

引用了 roboctrl::ctrl::robot::info_type::chassis_type, roboctrl::ctrl::robot::info_type::gimbal_type, roboctrl::config::validate_runtime_configuration() , 以及 roboctrl::config::validate_runtime_extensions().

被这些函数引用 roboctrl::config::load_configuration() , 以及 roboctrl::config::validate_runtime_configuration().

◆ validate_runtime_extensions()

void roboctrl::config::validate_runtime_extensions ( const runtime_config &  config)
inline

Check optional application links and policies before opening any IO resource.

在文件 runtime.hpp 第 83 行定义.

引用了 roboctrl::io::can::info_type::name , 以及 roboctrl::config::validate_runtime_extensions().

被这些函数引用 roboctrl::config::validate_runtime_configuration() , 以及 roboctrl::config::validate_runtime_extensions().