pub struct MitController { /* private fields */ }Expand description
MIT 模式高层控制器
核心特性:
- ✅ Option 模式:允许安全提取 Piper
- ✅ 循环锚点:消除累积漂移,保证精确 200Hz
- ✅ 容错性:允许最多连续 5 帧丢帧
- ✅ 状态流转:
park()返还Piper<Standby>
Implementations§
Source§impl MitController
impl MitController
Sourcepub fn move_to_position(
&mut self,
target: [Rad; 6],
threshold: Rad,
timeout: Duration,
) -> Result<bool, ControlError>
pub fn move_to_position( &mut self, target: [Rad; 6], threshold: Rad, timeout: Duration, ) -> Result<bool, ControlError>
Sourcepub fn relax_joints(&mut self)
pub fn relax_joints(&mut self)
Sourcepub fn park(self, config: DisableConfig) -> Result<Piper<Standby>>
pub fn park(self, config: DisableConfig) -> Result<Piper<Standby>>
停车(失能并返还 Piper<Standby>)
资源管理:
- ✅ 返还
Piper<Standby>,支持继续使用 - ✅ 使用 Option 模式,安全提取 Piper
§安全保证
显式调用 park()(推荐):
- 提取 Piper,调用 disable(),等待完成
- 返回
Piper<Standby>可继续使用 - 不会触发 Piper 的 Drop
忘记调用 park()(安全网):
- MitController 被 drop 时,
Piper<Active>::drop()自动触发 - 发送 disable 命令(不等待确认)
- 电机被安全失能
§示例
// 方式 1:显式停车(推荐)
let piper_standby = controller.park(DisableConfig::default())?;
// 现在 piper_standby 可以重新使能或做其他操作
// 方式 2:直接丢弃(触发自动安全失能)
// drop(controller); // 自动调用 Piper::drop(),发送 disable 命令Auto Trait Implementations§
impl Freeze for MitController
impl !RefUnwindSafe for MitController
impl Send for MitController
impl Sync for MitController
impl Unpin for MitController
impl !UnwindSafe for MitController
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