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
状态机损坏
EmergencyStop
急停触发
CanBusFatal(String)
CAN 总线错误(致命)
Timeout
命令超时
InvalidTransition
无效的状态转换
JointLimitExceeded
关节限位超出
VelocityLimitExceeded
速度限制超出
TorqueLimitExceeded
力矩限制超出
CanIoError(String)
CAN 总线 I/O 错误(可恢复)
SerializationError(String)
序列化错误
Protocol(ProtocolError)
协议错误(自动转换自 protocol::ProtocolError)
Infrastructure(DriverError)
驱动层错误(自动转换自 driver::DriverError)
CanAdapter(CanError)
CAN 适配器错误(自动转换自 can::CanError)
InvalidFrameId
无效的帧ID
InvalidDataLength
无效的数据长度
ConfigError(String)
配置错误
InvalidParameter
参数无效
Unknown(String)
未知错误
Implementations§
Source§impl RobotError
impl RobotError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
是否可重试
可重试错误表示重新执行操作可能会成功。
Sourcepub fn is_config_error(&self) -> bool
pub fn is_config_error(&self) -> bool
是否为配置错误
Sourcepub fn is_limit_error(&self) -> bool
pub fn is_limit_error(&self) -> bool
是否为限位错误
Sourcepub fn context(self, context: impl Into<String>) -> RobotError
pub fn context(self, context: impl Into<String>) -> RobotError
添加上下文信息
Sourcepub fn hardware_failure(msg: impl Into<String>) -> RobotError
pub fn hardware_failure(msg: impl Into<String>) -> RobotError
创建硬件故障错误
Sourcepub fn state_poisoned(reason: impl Into<String>) -> RobotError
pub fn state_poisoned(reason: impl Into<String>) -> RobotError
创建状态损坏错误
Sourcepub fn timeout(timeout_ms: u64) -> RobotError
pub fn timeout(timeout_ms: u64) -> RobotError
创建超时错误
Sourcepub fn invalid_transition(
from: impl Into<String>,
to: impl Into<String>,
) -> RobotError
pub fn invalid_transition( from: impl Into<String>, to: impl Into<String>, ) -> RobotError
创建无效状态转换错误
Sourcepub fn joint_limit(joint: Joint, value: f64, limit: f64) -> RobotError
pub fn joint_limit(joint: Joint, value: f64, limit: f64) -> RobotError
创建关节限位错误
Sourcepub fn velocity_limit(joint: Joint, value: f64, limit: f64) -> RobotError
pub fn velocity_limit(joint: Joint, value: f64, limit: f64) -> RobotError
创建速度限制错误
Sourcepub fn torque_limit(joint: Joint, value: f64, limit: f64) -> RobotError
pub fn torque_limit(joint: Joint, value: f64, limit: f64) -> RobotError
创建力矩限制错误
Trait Implementations§
Source§impl Debug for RobotError
impl Debug for RobotError
Source§impl Display for RobotError
impl Display for RobotError
Source§impl Error for RobotError
impl Error for RobotError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<CanError> for RobotError
impl From<CanError> for RobotError
Source§fn from(source: CanError) -> RobotError
fn from(source: CanError) -> RobotError
Converts to this type from the input type.
Source§impl From<DriverError> for RobotError
impl From<DriverError> for RobotError
Source§fn from(source: DriverError) -> RobotError
fn from(source: DriverError) -> RobotError
Converts to this type from the input type.
Source§impl From<ProtocolError> for RobotError
impl From<ProtocolError> for RobotError
Source§fn from(source: ProtocolError) -> RobotError
fn from(source: ProtocolError) -> RobotError
Converts to this type from the input type.
Source§impl From<RobotError> for ControlError
impl From<RobotError> for ControlError
Source§fn from(source: RobotError) -> ControlError
fn from(source: RobotError) -> ControlError
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for RobotError
impl !RefUnwindSafe for RobotError
impl Send for RobotError
impl Sync for RobotError
impl Unpin for RobotError
impl !UnwindSafe for RobotError
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