Skip to main content

JointDriverHighSpeedFeedback

Struct JointDriverHighSpeedFeedback 

Source
pub struct JointDriverHighSpeedFeedback {
    pub joint_index: u8,
    pub speed_rad_s: i16,
    pub current_a: i16,
    pub position_rad: i32,
}
Expand description

关节驱动器高速反馈 (0x251~0x256)

包含关节速度、电流和位置反馈。

  • 速度单位:0.001rad/s(原始值)
  • 电流单位:0.001A(原始值)
  • 位置单位:rad(原始值)

注意:关节索引从 CAN ID 推导(0x251 -> 1, 0x252 -> 2, …, 0x256 -> 6)

Fields§

§joint_index: u8§speed_rad_s: i16§current_a: i16§position_rad: i32

Implementations§

Source§

impl JointDriverHighSpeedFeedback

Source

pub const COEFFICIENT_1_3: f64 = 1.18125

关节 1-3 的力矩系数(CAN ID: 0x251~0x253)

根据官方参考实现,关节 1、2、3 使用此系数计算力矩。 公式:torque = current * COEFFICIENT_1_3

Source

pub const COEFFICIENT_4_6: f64 = 0.95844

关节 4-6 的力矩系数(CAN ID: 0x254~0x256)

根据官方参考实现,关节 4、5、6 使用此系数计算力矩。 公式:torque = current * COEFFICIENT_4_6

Source

pub fn speed_raw(&self) -> i16

获取速度原始值(0.001rad/s 单位)

Source

pub fn current_raw(&self) -> i16

获取电流原始值(0.001A 单位)

Source

pub fn position_raw(&self) -> i32

获取位置原始值(rad 单位)

Source

pub fn speed(&self) -> f64

获取速度(rad/s)

Source

pub fn current(&self) -> f64

获取电流(A)

注意:电流可以为负值(反向电流)

Source

pub fn position(&self) -> f64

👎Deprecated since 0.1.0: Field unit unverified (rad vs mrad). Prefer Observer::get_joint_position() for verified position data, or use position_raw() for raw access.

获取位置(rad)

§⚠️ 弃用警告 (Deprecated)

此方法的返回值单位未确认,可能导致不正确的位置值。

已知问题:

  • 字段标注为 rad,但测试数据存在矛盾(3141592 对应 π?)
  • 可能的单位:rad、mrad(0.001rad)、0.01°、编码器 ticks
  • 当前没有生产代码使用此方法

替代方案:

  • 高层 API: piper.observer().get_joint_position(joint) - 推荐,单位已确认为弧度
  • 协议层: JointFeedback12::j1_rad(), j2_rad() 等 - 单位明确 (从 0.001° 转换)
  • 原始值: self.position_raw() - 获取未转换的 i32 原始值

背景: 详见 docs/v0/position_unit_analysis_report.md

Source

pub fn torque(&self, current_opt: Option<f64>) -> f64

计算力矩(N·m)

根据关节索引和电流值计算力矩。

  • 关节 1-3 (CAN ID: 0x251~0x253) 使用系数 COEFFICIENT_1_3 = 1.18125
  • 关节 4-6 (CAN ID: 0x254~0x256) 使用系数 COEFFICIENT_4_6 = 0.95844

公式:torque = current * coefficient

§参数
  • current_opt: 可选的电流值(A)。如果为 None,则使用当前反馈的电流值。
§返回值

计算得到的力矩值(N·m)

§示例
// 使用反馈中的电流值计算力矩
let torque = feedback.torque(None);

// 使用指定的电流值计算力矩
let torque = feedback.torque(Some(2.5)); // 2.5A
Source

pub fn torque_raw(&self) -> i32

获取力矩原始值(0.001N·m 单位)

返回以 0.001N·m 为单位的力矩原始值(整数形式)。 这对应于官方参考实现中 effort 字段的单位。

§返回值

力矩原始值(0.001N·m 单位,即毫牛·米)

§示例
let torque_raw = feedback.torque_raw(); // 例如:1181 (表示 1.181 N·m)

Trait Implementations§

Source§

impl Clone for JointDriverHighSpeedFeedback

Source§

fn clone(&self) -> JointDriverHighSpeedFeedback

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 JointDriverHighSpeedFeedback

Source§

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

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

impl Default for JointDriverHighSpeedFeedback

Source§

fn default() -> JointDriverHighSpeedFeedback

Returns the “default value” for a type. Read more
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<JointDriverHighSpeedFeedback, <JointDriverHighSpeedFeedback as TryFrom<PiperFrame>>::Error>

Performs the conversion.
Source§

impl Copy for JointDriverHighSpeedFeedback

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