GKD.RoboCtrl
RoboMaster Linux 电控:异步 IO、设备驱动与机器人控制
载入中...
搜索中...
未找到
roboctrl::utils 命名空间参考

用于存放工具函数的命名空间。 更多...

详细描述

用于存放工具函数的命名空间。

封装了工具函数,如字节序列转换、角度处理等。

命名空间

namespace  byte_literals
 字节面向的用户字面量命名空间。
 

类

struct  ballistic_config
 
struct  ballistic_solution
 
struct  ballistic_target
 
struct  ballistic_vector
 
struct  control_chain
 控制链,将多个控制器串联组合。 更多...
 
class  control_stage
 
struct  function_arg
 
struct  function_arg< Ret(*)(Arg) noexcept >
 
struct  function_arg< Ret(*)(Arg)>
 
struct  function_arg< Ret(Arg) noexcept >
 
struct  function_arg< Ret(Arg)>
 
struct  function_arg< Ret(Class::*)(Arg) const >
 
struct  function_arg< Ret(Class::*)(Arg) const noexcept >
 
struct  function_arg< Ret(Class::*)(Arg) noexcept >
 
struct  function_arg< Ret(Class::*)(Arg)>
 
struct  immovable_base
 快速继承获得“不可移动”约束的基类。 更多...
 
class  Matrix
 
struct  not_copyable_base
 快速继承获得“不可复制”约束的基类。 更多...
 
struct  pair
 双值绑定结构,兼容 std::pair。 更多...
 
struct  pid_base
 PID 控制器基础模板。 更多...
 
class  ramp
 一阶斜坡控制器 (Ramp) 更多...
 
class  RLS
 
class  runtime_control_chain
 
class  singleton_base
 提供单例模式的单例基类 更多...
 

概念

concept  invocable_r
 约束可调用对象的返回值。
 
concept  instance_of
 判断类型是否为某模板的实例。
 
concept  immovable
 判断类型不可移动。
 
concept  not_copyable
 判断类型不可复制。
 
concept  package
 用于约束“可安全作为报文搬运”的平凡类型。
 
concept  controller
 控制器概念,约束 update/state/构造能力。
 
concept  singleton_info
 单例信息
 
concept  singleton
 
concept  byte_container
 描述具有 data() 与 size() 接口的字节容器。
 

类型定义

template<int r, int c>
using Matrixf = Matrix< r, c, float >
 
using linear_pid = pid_base< fp32, details::linear_error >
 线性 PID 控制器。
 
using rad_pid = pid_base< fp32, details::rad_error >
 角度 PID 控制器。
 
template<device::motor motor_type>
using linear_pid_motor = device::controlled_motor< motor_type, linear_pid >
 将线性 PID 附着于特定电机类型的别名。
 
template<device::motor motor_type>
using rad_pid_motor = device::controlled_motor< motor_type, rad_pid >
 将角度 PID 附着于特定电机类型的别名。
 
using ramp_f = ramp< float >
 float 精度的 Ramp 控制器别名。
 
using ramp_d = ramp< double >
 double 精度的 Ramp 控制器别名。
 
template<typename Fn >
using function_arg_t = typename function_arg< std::remove_cvref_t< Fn > >::type
 

枚举

enum class  ballistic_status {
  success , invalid_config , invalid_input , no_intercept ,
  not_converged
}
 

函数

std::optional< double > legacy_ballistic_drag (double bullet_speed)
 
std::optional< ballistic_vector > ballistic_position (const ballistic_config &config, double speed, double yaw, double pitch, double time)
 
ballistic_solution solve_ballistics (const ballistic_config &config, const ballistic_target &target, double bullet_speed)
 
template<controller controller_type>
controller_type make_controller (const typename controller_type::info_type &info)
 
constexpr fp32 rad_format (fp32 ang)
 将角度限制到[-Pi,Pi]范围内
 
template<package T, byte_container C>
T from_bytes (const C &bytes)
 将字节容器内容反序列化为平凡类型。
 
template<package T>
auto to_bytes (const T &t) -> std::array< std::byte, sizeof(T)>
 
template<package T, typename C >
requires requires(C& c) { { c.data() } -> std::convertible_to<std::byte*>; { c.size() } -> std::convertible_to<std::size_t>; }
void to_bytes (const T &t, C &container)
 将平凡类型序列化到指定容器。
 
auto now ()
 记录程序启动后的纳秒级时间戳。
 
constexpr uint16_t make_u16 (uint16_t high, uint16_t low) noexcept
 将高低字节组合成无符号 16 位整数。
 
constexpr int16_t make_i16 (int16_t high, int16_t low) noexcept
 将高低字节组合成有符号 16 位整数。
 
constexpr std::byte to_byte (std::integral auto v) noexcept
 辅助将整数转换为 std::byte。
 

类型定义说明

◆ function_arg_t

template<typename Fn >
using roboctrl::utils::function_arg_t = typedef typename function_arg<std::remove_cvref_t<Fn> >::type

在文件 utils.hpp 第 212 行定义.

◆ linear_pid

线性 PID 控制器。

在文件 pid.h 第 144 行定义.

◆ linear_pid_motor

template<device::motor motor_type>
using roboctrl::utils::linear_pid_motor = typedef device::controlled_motor<motor_type, linear_pid>

将线性 PID 附着于特定电机类型的别名。

在文件 pid.h 第 153 行定义.

◆ Matrixf

template<int r, int c>
using roboctrl::utils::Matrixf = typedef Matrix<r, c, float>

在文件 Matrix.hpp 第 508 行定义.

◆ rad_pid

角度 PID 控制器。

在文件 pid.h 第 146 行定义.

◆ rad_pid_motor

template<device::motor motor_type>
using roboctrl::utils::rad_pid_motor = typedef device::controlled_motor<motor_type, rad_pid>

将角度 PID 附着于特定电机类型的别名。

在文件 pid.h 第 157 行定义.

◆ ramp_d

using roboctrl::utils::ramp_d = typedef ramp<double>

double 精度的 Ramp 控制器别名。

在文件 ramp.hpp 第 133 行定义.

◆ ramp_f

using roboctrl::utils::ramp_f = typedef ramp<float>

float 精度的 Ramp 控制器别名。

在文件 ramp.hpp 第 128 行定义.

枚举类型说明

◆ ballistic_status

enum class roboctrl::utils::ballistic_status
strong

在文件 ballistics.hpp 第 37 行定义.

函数说明

◆ ballistic_position()

std::optional< ballistic_vector > roboctrl::utils::ballistic_position ( const ballistic_config &  config,
double  speed,
double  yaw,
double  pitch,
double  time 
)

Evaluate the same linear-drag trajectory used by solve_ballistics().

在文件 ballistics.cpp 第 98 行定义.

◆ from_bytes()

template<package T, byte_container C>
T roboctrl::utils::from_bytes ( const C &  bytes)

将字节容器内容反序列化为平凡类型。

模板参数
T目标类型,需满足 package
C字节容器类型
参数
bytes输入字节缓冲

在文件 utils.hpp 第 121 行定义.

◆ legacy_ballistic_drag()

std::optional< double > roboctrl::utils::legacy_ballistic_drag ( double  bullet_speed)

Legacy uncalibrated coefficient lookup, made opt-in instead of implicit.

在文件 ballistics.cpp 第 89 行定义.

◆ make_controller()

template<controller controller_type>
controller_type roboctrl::utils::make_controller ( const typename controller_type::info_type &  info)

在文件 controller.hpp 第 123 行定义.

◆ make_i16()

constexpr int16_t roboctrl::utils::make_i16 ( int16_t  high,
int16_t  low 
)
inlineconstexprnoexcept

将高低字节组合成有符号 16 位整数。

在文件 utils.hpp 第 173 行定义.

◆ make_u16()

constexpr uint16_t roboctrl::utils::make_u16 ( uint16_t  high,
uint16_t  low 
)
inlineconstexprnoexcept

将高低字节组合成无符号 16 位整数。

在文件 utils.hpp 第 166 行定义.

◆ now()

auto roboctrl::utils::now ( )
inline

记录程序启动后的纳秒级时间戳。

在文件 utils.hpp 第 158 行定义.

被这些函数引用 roboctrl::device::device_base::offline(), roboctrl::device::device_base::tick() , 以及 roboctrl::utils::ramp< T >::update().

◆ rad_format()

constexpr fp32 roboctrl::utils::rad_format ( fp32  ang)
inlineconstexpr

将角度限制到[-Pi,Pi]范围内

在文件 utils.hpp 第 99 行定义.

引用了 roboctrl::Pi_f.

被这些函数引用 roboctrl::device::convert_serial_imu(), roboctrl::device::gkd_sentry_gimbal::set_target_yaw() , 以及 roboctrl::device::gkd_sentry_gimbal::update().

◆ solve_ballistics()

ballistic_solution roboctrl::utils::solve_ballistics ( const ballistic_config &  config,
const ballistic_target &  target,
double  bullet_speed 
)

Bounded search for the first bracketed positive-time intercept in max_flight_time. Retains the old adjacent-armor selection and high-spin front-surface prediction. no_intercept means no root was bracketed in this horizon, not a reachability proof. Pure calculation: it neither commands hardware nor authorizes firing.

在文件 ballistics.cpp 第 111 行定义.

引用了 roboctrl::utils::ballistic_config::drag , 以及 roboctrl::utils::ballistic_solution::pitch.

◆ to_byte()

constexpr std::byte roboctrl::utils::to_byte ( std::integral auto  v)
inlineconstexprnoexcept

辅助将整数转换为 std::byte。

在文件 utils.hpp 第 180 行定义.

◆ to_bytes() [1/2]

template<package T>
auto roboctrl::utils::to_bytes ( const T &  t) -> std::array<std::byte, sizeof(T)>

在文件 utils.hpp 第 131 行定义.

◆ to_bytes() [2/2]

template<package T, typename C >
requires requires(C& c) { { c.data() } -> std::convertible_to<std::byte*>; { c.size() } -> std::convertible_to<std::size_t>; }
void roboctrl::utils::to_bytes ( const T &  t,
C &  container 
)

将平凡类型序列化到指定容器。

模板参数
T输入类型
C可写容器类型
参数
t待写入对象
container目标容器

在文件 utils.hpp 第 149 行定义.