pub struct ParserState<'a> {
pub pending_joint_pos: [f64; 6],
pub joint_pos_frame_mask: u8,
pub pending_end_pose: [f64; 6],
pub end_pose_frame_mask: u8,
pub pending_joint_dynamic: JointDynamicState,
pub vel_update_mask: u8,
pub last_vel_commit_time_us: u64,
pub last_vel_packet_time_us: u64,
pub last_vel_packet_instant: Option<Instant>,
pub pending_joint_target_deg: [i32; 6],
pub joint_control_frame_mask: u8,
/* private fields */
}Expand description
帧解析器状态
封装 CAN 帧解析过程中的所有临时状态,包括:
- 关节位置帧组同步状态
- 末端位姿帧组同步状态
- 关节动态状态缓冲提交状态
- 主从模式关节控制帧组同步状态
设计目的:
- 避免函数参数列表过长(从 14 个参数减少到 2 个)
- 提高代码可读性和可维护性
- 方便未来扩展新的解析状态
§Example
let mut state = ParserState::new();
// 使用 state.pending_joint_pos 等Fields§
§pending_joint_pos: [f64; 6]待提交的关节位置数据(6个关节,单位:弧度)
joint_pos_frame_mask: u8关节位置帧组掩码(Bit 0-2 对应 0x2A5, 0x2A6, 0x2A7)
pending_end_pose: [f64; 6]待提交的末端位姿数据(6个自由度:x, y, z, rx, ry, rz)
end_pose_frame_mask: u8末端位姿帧组掩码(Bit 0-2 对应 0x2A2, 0x2A3, 0x2A4)
pending_joint_dynamic: JointDynamicState待提交的关节动态状态
vel_update_mask: u8速度帧更新掩码(Bit 0-5 对应 Joint 1-6)
last_vel_commit_time_us: u64上次速度帧提交时间(硬件时间戳,微秒)
last_vel_packet_time_us: u64上次速度帧到达时间(硬件时间戳,微秒)
last_vel_packet_instant: Option<Instant>上次速度帧到达时间(系统时间,用于超时检查)
pending_joint_target_deg: [i32; 6]待提交的主从模式关节目标角度(度)
joint_control_frame_mask: u8主从模式关节控制帧组掩码(Bit 0-2 对应 0x155, 0x156, 0x157)
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for ParserState<'a>
impl<'a> RefUnwindSafe for ParserState<'a>
impl<'a> Send for ParserState<'a>
impl<'a> Sync for ParserState<'a>
impl<'a> Unpin for ParserState<'a>
impl<'a> UnwindSafe for ParserState<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more