Skip to main content

RobotError

Enum RobotError 

Source
pub enum RobotError {
Show 19 variants HardwareFailure(String), StatePoisoned { reason: String, }, EmergencyStop, CanBusFatal(String), Timeout { timeout_ms: u64, }, InvalidTransition { from: String, to: String, }, JointLimitExceeded { joint: Joint, value: f64, limit: f64, }, VelocityLimitExceeded { joint: Joint, value: f64, limit: f64, }, TorqueLimitExceeded { joint: Joint, value: f64, limit: f64, }, CanIoError(String), SerializationError(String), Protocol(ProtocolError), Infrastructure(DriverError), CanAdapter(CanError), InvalidFrameId { id: u32, }, InvalidDataLength { expected: usize, actual: usize, }, ConfigError(String), InvalidParameter { param: String, reason: String, }, Unknown(String),
}
Expand description

机器人错误类型

分层错误类型,支持致命错误和可恢复错误的区分。

Variants§

§

HardwareFailure(String)

硬件通信失败

§

StatePoisoned

状态机损坏

Fields

§reason: String

损坏原因

§

EmergencyStop

急停触发

§

CanBusFatal(String)

CAN 总线错误(致命)

§

Timeout

命令超时

Fields

§timeout_ms: u64

超时时间(毫秒)

§

InvalidTransition

无效的状态转换

Fields

§from: String

起始状态

§to: String

目标状态

§

JointLimitExceeded

关节限位超出

Fields

§joint: Joint

关节索引

§value: f64

实际值

§limit: f64

限位值

§

VelocityLimitExceeded

速度限制超出

Fields

§joint: Joint

关节索引

§value: f64

实际速度

§limit: f64

限速

§

TorqueLimitExceeded

力矩限制超出

Fields

§joint: Joint

关节索引

§value: f64

实际力矩

§limit: f64

限矩

§

CanIoError(String)

CAN 总线 I/O 错误(可恢复)

§

SerializationError(String)

序列化错误

§

Protocol(ProtocolError)

协议错误(自动转换自 protocol::ProtocolError)

§

Infrastructure(DriverError)

驱动层错误(自动转换自 driver::DriverError)

§

CanAdapter(CanError)

CAN 适配器错误(自动转换自 can::CanError)

§

InvalidFrameId

无效的帧ID

Fields

§id: u32

帧 ID

§

InvalidDataLength

无效的数据长度

Fields

§expected: usize

期望长度

§actual: usize

实际长度

§

ConfigError(String)

配置错误

§

InvalidParameter

参数无效

Fields

§param: String

参数名

§reason: String

原因

§

Unknown(String)

未知错误

Implementations§

Source§

impl RobotError

Source

pub fn is_fatal(&self) -> bool

是否为致命错误

致命错误表示系统处于不安全状态,必须立即停止。

Source

pub fn is_retryable(&self) -> bool

是否可重试

可重试错误表示重新执行操作可能会成功。

Source

pub fn is_config_error(&self) -> bool

是否为配置错误

Source

pub fn is_limit_error(&self) -> bool

是否为限位错误

Source

pub fn context(self, context: impl Into<String>) -> RobotError

添加上下文信息

Source

pub fn hardware_failure(msg: impl Into<String>) -> RobotError

创建硬件故障错误

Source

pub fn state_poisoned(reason: impl Into<String>) -> RobotError

创建状态损坏错误

Source

pub fn timeout(timeout_ms: u64) -> RobotError

创建超时错误

Source

pub fn invalid_transition( from: impl Into<String>, to: impl Into<String>, ) -> RobotError

创建无效状态转换错误

Source

pub fn joint_limit(joint: Joint, value: f64, limit: f64) -> RobotError

创建关节限位错误

Source

pub fn velocity_limit(joint: Joint, value: f64, limit: f64) -> RobotError

创建速度限制错误

Source

pub fn torque_limit(joint: Joint, value: f64, limit: f64) -> RobotError

创建力矩限制错误

Trait Implementations§

Source§

impl Debug for RobotError

Source§

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

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

impl Display for RobotError

Source§

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

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

impl Error for RobotError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<CanError> for RobotError

Source§

fn from(source: CanError) -> RobotError

Converts to this type from the input type.
Source§

impl From<DriverError> for RobotError

Source§

fn from(source: DriverError) -> RobotError

Converts to this type from the input type.
Source§

impl From<ProtocolError> for RobotError

Source§

fn from(source: ProtocolError) -> RobotError

Converts to this type from the input type.
Source§

impl From<RobotError> for ControlError

Source§

fn from(source: RobotError) -> ControlError

Converts to this type from the input type.

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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