pub struct Observer { /* private fields */ }Expand description
状态观察器(只读接口,View 模式)
直接持有 driver::Piper 引用,零拷贝、零延迟地读取底层状态。
不再使用缓存层,避免数据延迟和锁竞争。
Implementations§
Source§impl Observer
impl Observer
Sourcepub fn new(driver: Arc<Piper>) -> Observer
pub fn new(driver: Arc<Piper>) -> Observer
创建新的 Observer
注意: 此方法通常不直接调用,Observer 应该通过 Piper 状态机的 observer() 方法获取。
此方法为 pub 以支持内部测试和性能基准测试。
基准测试: 为了支持性能基准测试,此方法在 benches 中也可访问。
Sourcepub fn snapshot(&self) -> MotionSnapshot
pub fn snapshot(&self) -> MotionSnapshot
Sourcepub fn joint_positions(&self) -> JointArray<Rad>
pub fn joint_positions(&self) -> JointArray<Rad>
Sourcepub fn joint_velocities(&self) -> JointArray<RadPerSecond>
pub fn joint_velocities(&self) -> JointArray<RadPerSecond>
Sourcepub fn joint_torques(&self) -> JointArray<NewtonMeter>
pub fn joint_torques(&self) -> JointArray<NewtonMeter>
Sourcepub fn gripper_state(&self) -> GripperState
pub fn gripper_state(&self) -> GripperState
获取夹爪状态
Sourcepub fn gripper_position(&self) -> f64
pub fn gripper_position(&self) -> f64
获取夹爪位置 (0.0-1.0)
Sourcepub fn gripper_effort(&self) -> f64
pub fn gripper_effort(&self) -> f64
获取夹爪力度 (0.0-1.0)
Sourcepub fn is_gripper_enabled(&self) -> bool
pub fn is_gripper_enabled(&self) -> bool
检查夹爪是否使能
Sourcepub fn joint_enabled_mask(&self) -> u8
pub fn joint_enabled_mask(&self) -> u8
获取使能掩码(Bit 0-5 对应 J1-J6)
Sourcepub fn is_joint_enabled(&self, joint_index: usize) -> bool
pub fn is_joint_enabled(&self, joint_index: usize) -> bool
检查指定关节是否使能
Sourcepub fn end_pose(&self) -> EndPoseState
pub fn end_pose(&self) -> EndPoseState
Sourcepub fn is_all_enabled(&self) -> bool
pub fn is_all_enabled(&self) -> bool
检查是否全部使能
Sourcepub fn is_all_disabled(&self) -> bool
pub fn is_all_disabled(&self) -> bool
检查是否全部失能
Sourcepub fn is_partially_enabled(&self) -> bool
pub fn is_partially_enabled(&self) -> bool
检查是否部分使能
Sourcepub fn is_arm_enabled(&self) -> bool
pub fn is_arm_enabled(&self) -> bool
检查机械臂是否使能(兼容旧 API)
如果所有关节都使能,返回 true。
Sourcepub fn joint_state(&self, joint: Joint) -> (Rad, RadPerSecond, NewtonMeter)
pub fn joint_state(&self, joint: Joint) -> (Rad, RadPerSecond, NewtonMeter)
获取单个关节的状态
返回 (position, velocity, torque) 元组。
注意:此方法独立读取,可能与其他状态有时间偏斜。
如需时间一致性,请使用 snapshot() 方法。
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Sourcepub fn connection_age(&self) -> Duration
pub fn connection_age(&self) -> Duration
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Observer
impl !RefUnwindSafe for Observer
impl Unpin for Observer
impl !UnwindSafe for Observer
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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