Skip to main content

FeetechBridge

Struct FeetechBridge 

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

Bidirectional bridge for Feetech STS/SCS serial bus servos.

Created by the Copper runtime from configuration. Each cycle it:

  1. Receives (receive): reads present positions from all servos and publishes them on the positions Rx channel.
  2. Sends (send): if a goal_positions Tx message is available, writes goal positions to all servos via a single sync-write packet.

Positions are converted to the unit specified by the "units" config key ("raw", "deg", "rad", or "normalize"). When using "deg", "rad", or "normalize", a calibration file ("calibration_file" key) must be provided.

Implementations§

Source§

impl FeetechBridge

Source

pub fn ping(&mut self, id: u8) -> CuResult<()>

Ping a servo by ID. Returns Ok(()) if it responds without error.

Source

pub fn set_torque(&mut self, id: u8, enable: bool) -> Result<()>

Enable or disable torque on a single servo.

When torque is enabled the servo actively holds its position. When disabled the servo can be moved freely by hand.

Trait Implementations§

Source§

impl CuBridge for FeetechBridge

Source§

fn new( config: Option<&ComponentConfig>, tx_channels: &[BridgeChannelConfig<<Self::Tx as BridgeChannelSet>::Id>], _rx_channels: &[BridgeChannelConfig<<Self::Rx as BridgeChannelSet>::Id>], resources: Self::Resources<'_>, ) -> CuResult<Self>
where Self: Sized,

Construct the bridge from configuration.

Expected copperconfig.ron keys under the bridge’s config block:

KeyTypeDescription
servo0u8Bus ID of the first servo
servo1u8Bus ID of the second servo
Up to servo7
unitsstring"raw" (default), "deg", "rad", or "normalize"
calibration_filestringPath to calibration JSON (required for deg/rad/normalize)
ticks_per_revintegerRaw units per 360° (model-dependent; default 4096)

At least servo0 must be present.

Source§

fn start(&mut self, _ctx: &CuContext) -> CuResult<()>

Called once before the first processing cycle.

Enables torque only when writers are connected (commander mode). In follower mode torque stays off so the arm moves freely.

Source§

fn send<'a, Payload>( &mut self, _ctx: &CuContext, channel: &'static BridgeChannel<<Self::Tx as BridgeChannelSet>::Id, Payload>, msg: &CuMsg<Payload>, ) -> CuResult<()>
where Payload: CuMsgPayload + 'a,

Handle an outgoing message on a Tx channel.

For goal_positions: sync-writes the raw positions to the servo bus.

Source§

fn receive<'a, Payload>( &mut self, ctx: &CuContext, channel: &'static BridgeChannel<<Self::Rx as BridgeChannelSet>::Id, Payload>, msg: &mut CuMsg<Payload>, ) -> CuResult<()>
where Payload: CuMsgPayload + 'a,

Produce an incoming message on an Rx channel.

For positions: reads every servo’s present position and publishes them as a JointPositions.

Source§

fn stop(&mut self, _ctx: &CuContext) -> CuResult<()>

Called once after the last processing cycle.

Disables torque on every servo for safety (prevents the arm from holding position with power applied after the application exits).

Source§

type Tx = TxChannels

Outgoing channels (Copper -> external world).
Source§

type Rx = RxChannels

Incoming channels (external world -> Copper).
Source§

type Resources<'r> = Resources

Resources required by the bridge.
Source§

fn preprocess(&mut self, _ctx: &CuContext) -> Result<(), CuError>

Gives the bridge a chance to prepare buffers before I/O.
Source§

fn postprocess(&mut self, _ctx: &CuContext) -> Result<(), CuError>

Called once the send/receive pair completed.
Source§

impl Freezable for FeetechBridge

Source§

fn freeze<E>(&self, encoder: &mut E) -> Result<(), EncodeError>
where E: Encoder,

This method is called by the framework when it wants to save the task state. The default implementation is to encode nothing (stateless). If you have a state, you need to implement this method.
Source§

fn thaw<D>(&mut self, _decoder: &mut D) -> Result<(), DecodeError>
where D: Decoder,

This method is called by the framework when it wants to restore the task to a specific state. Here it is similar to Decode but the framework will give you a new instance of the task (the new method will be called)

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, 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> GetTypeRegistration for T

Source§

impl<T> Reflect for T
where T: 'static,

Source§

impl<T> ReflectTypePath for T