pub struct Robot { /* private fields */ }Expand description
A configured robot: named buses + named groups + lifecycle state.
Implementations§
Source§impl Robot
impl Robot
Sourcepub fn from_config<P: AsRef<Path>>(
path: P,
registry: &CodecRegistry,
) -> Result<Self, Error>
pub fn from_config<P: AsRef<Path>>( path: P, registry: &CodecRegistry, ) -> Result<Self, Error>
Parse a TOML config file and build a Robot using the supplied codec
registry. Performs schema validation (including codec-supports-motor)
before opening any socket. A bus with fd = true opens in CAN-FD mode.
Sourcepub fn from_config_str(
toml_text: &str,
registry: &CodecRegistry,
) -> Result<Self, Error>
pub fn from_config_str( toml_text: &str, registry: &CodecRegistry, ) -> Result<Self, Error>
Parse a TOML config string. Same semantics as
Robot::from_config but skips the file read.
Source§impl Robot
impl Robot
Sourcepub fn builder() -> RobotBuilder
pub fn builder() -> RobotBuilder
Start a builder.
Sourcepub fn group_mut(&mut self, name: &str) -> Option<&mut GroupKind>
pub fn group_mut(&mut self, name: &str) -> Option<&mut GroupKind>
Mutable access to a named group.
Sourcepub fn group_names(&self) -> impl Iterator<Item = &str>
pub fn group_names(&self) -> impl Iterator<Item = &str>
Iterate group names in insertion order.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
True after a successful connect().
Sourcepub fn bus(&self, name: &str) -> Option<&Arc<Mutex<Bus>>>
pub fn bus(&self, name: &str) -> Option<&Arc<Mutex<Bus>>>
Borrow a bus by name (returns the Arc<Mutex<Bus>> for direct lock).
Sourcepub fn connect(&mut self) -> Result<(), Error>
pub fn connect(&mut self) -> Result<(), Error>
Open sockets, populate per-bus recv-id routing tables, register fds with the poller, lock topology.
Sourcepub fn enable(&mut self) -> Result<(), Error>
pub fn enable(&mut self) -> Result<(), Error>
Send the enable frame to every motor in every group, in insertion order.
Sourcepub fn disable(&mut self) -> Result<(), Error>
pub fn disable(&mut self) -> Result<(), Error>
Send the disable frame to every motor in every group, in reverse
insertion order. A no-op Ok(()) if never enabled.
Sourcepub fn refresh(&mut self) -> Result<(), Error>
pub fn refresh(&mut self) -> Result<(), Error>
Send a state-refresh query to every motor in every group (no motion).
Send-only — pair with Robot::tick to receive the replies. Errors with
Error::NotConnected if called before connect().
Sourcepub fn set_mode(&mut self, mode: CommandKind) -> Result<(), Error>
pub fn set_mode(&mut self, mode: CommandKind) -> Result<(), Error>
Set the persistent control mode (MIT / PosVel / Vel / PosForce) on every
motor in every group (no motion). Send-only. Call once after connect
and before commanding. Errors with Error::NotConnected if not
connected.