Skip to main content

ParserState

Struct ParserState 

Source
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§

Source§

impl<'a> ParserState<'a>

Source

pub fn new() -> Self

创建新的解析器状态

§Example
let state = ParserState::new();

Trait Implementations§

Source§

impl<'a> Default for ParserState<'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more