PiperFrame

Struct PiperFrame 

Source
pub struct PiperFrame {
    pub id: u32,
    pub data: [u8; 8],
    pub len: u8,
    pub is_extended: bool,
    pub timestamp_us: u64,
}
Expand description

SDK 通用的 CAN 帧定义(只针对 CAN 2.0)

设计要点:

  • Copy trait:零成本复制,适合高频场景
  • 固定 8 字节数据:避免堆分配
  • 无生命周期:简化 API
  • 支持硬件时间戳:用于精确的时间测量(实时控制场景)

Fields§

§id: u32

CAN ID(标准帧或扩展帧)

§data: [u8; 8]

帧数据(固定 8 字节,未使用部分为 0)

§len: u8

有效数据长度 (0-8)

§is_extended: bool

是否为扩展帧(29-bit ID)

§timestamp_us: u64

硬件时间戳(微秒),0 表示不可用

当启用硬件时间戳模式(GS_CAN_MODE_HW_TIMESTAMP)时, 此字段包含设备硬件提供的时间戳,用于精确测量帧收发时间。 对于力控机械臂等实时控制系统,这是关键信息。

类型说明:使用 u64 而非 u32,原因:

  • 支持绝对时间戳(Unix 纪元开始),无需基准时间管理
  • 支持相对时间戳(从适配器启动开始),可覆盖更长的时间范围(584,000+ 年)
  • 与状态层设计一致(JointPositionState.hardware_timestamp_us: u64
  • 内存对齐后大小相同(24 字节),无额外开销

Implementations§

Source§

impl PiperFrame

Source

pub fn new_standard(id: u16, data: &[u8]) -> Self

创建标准帧

Source

pub fn new_extended(id: u32, data: &[u8]) -> Self

创建扩展帧

Source

pub fn data_slice(&self) -> &[u8]

获取数据切片(只包含有效数据)

Trait Implementations§

Source§

impl Clone for PiperFrame

Source§

fn clone(&self) -> PiperFrame

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PiperFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<PiperCommand> for PiperFrame

Source§

fn from(cmd: PiperCommand) -> Self

Converts to this type from the input type.
Source§

impl From<PiperFrame> for PiperCommand

Source§

fn from(frame: PiperFrame) -> Self

默认转换为可靠命令(向后兼容)

Source§

impl PartialEq for PiperFrame

Source§

fn eq(&self, other: &PiperFrame) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<PiperFrame> for CollisionProtectionLevelFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for ControlModeCommandFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for EndPoseFeedback1

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for EndPoseFeedback2

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for EndPoseFeedback3

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for EndVelocityAccelFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for FirmwareReadFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for GripperControlFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for GripperFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for GripperTeachParamsFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for JointControl12Feedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for JointControl34Feedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for JointControl56Feedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for JointDriverHighSpeedFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for JointDriverLowSpeedFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for JointEndVelocityAccelFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for JointFeedback12

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for JointFeedback34

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for JointFeedback56

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for MotorLimitFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for MotorMaxAccelFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for RobotStatusFeedback

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PiperFrame> for SettingResponse

Source§

type Error = ProtocolError

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

fn try_from(frame: PiperFrame) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for PiperFrame

Source§

impl Eq for PiperFrame

Source§

impl StructuralPartialEq for PiperFrame

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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