Skip to main content

Robot

Struct Robot 

Source
pub struct Robot { /* private fields */ }
Expand description

A configured robot: named buses + named groups + lifecycle state.

Implementations§

Source§

impl Robot

Source

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.

Source

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

Source

pub fn builder() -> RobotBuilder

Start a builder.

Source

pub fn group(&self, name: &str) -> Option<&GroupKind>

Read-only access to a named group.

Source

pub fn group_mut(&mut self, name: &str) -> Option<&mut GroupKind>

Mutable access to a named group.

Source

pub fn group_names(&self) -> impl Iterator<Item = &str>

Iterate group names in insertion order.

Source

pub fn bus_names(&self) -> impl Iterator<Item = &str>

Iterate bus names in insertion order.

Source

pub fn is_connected(&self) -> bool

True after a successful connect().

Source

pub fn bus(&self, name: &str) -> Option<&Arc<Mutex<Bus>>>

Borrow a bus by name (returns the Arc<Mutex<Bus>> for direct lock).

Source

pub fn connect(&mut self) -> Result<(), Error>

Open sockets, populate per-bus recv-id routing tables, register fds with the poller, lock topology.

Source

pub fn enable(&mut self) -> Result<(), Error>

Send the enable frame to every motor in every group, in insertion order.

Source

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.

Source

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().

Source

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.

Source

pub fn tick(&mut self, deadline: Duration) -> Result<(), Error>

One tick of the control loop: poll all buses, drain readable ones, decode each frame exactly once, dispatch the resulting events to the owning groups via per-bus routing tables.

Trait Implementations§

Source§

impl Drop for Robot

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl Freeze for Robot

§

impl RefUnwindSafe for Robot

§

impl Send for Robot

§

impl Sync for Robot

§

impl Unpin for Robot

§

impl UnsafeUnpin for Robot

§

impl UnwindSafe for Robot

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, 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, 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.