Skip to main content

Gripper

Struct Gripper 

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

Maintains a network connection to the gripper, provides the current gripper state, and allows the execution of commands (port of franka::Gripper).

The underlying Network is Sync (see crate::network::TcpSession and crate::network::UdpChannel), so the members of this struct are threadsafe, matching libfranka’s documented guarantee for franka::Gripper – except that only one Gripper::read_once should be in flight at a time, since concurrent callers would race to claim the same UDP datagram.

Implementations§

Source§

impl Gripper

Source

pub fn new(franka_address: &str) -> FrankaResult<Gripper>

Establishes a connection with a gripper connected to a robot.

franka_address is the IP/hostname of the robot the gripper is connected to, as "host" or "host:port"; the gripper command port (1338) is used unless an explicit port is embedded in the address.

§Errors

Returns FrankaError::Network if the connection is unsuccessful and FrankaError::IncompatibleVersion if this crate’s gripper protocol version is not supported by the server.

Source

pub fn server_version(&self) -> u16

Returns the software version reported by the connected server.

Source

pub fn homing(&self) -> FrankaResult<bool>

Performs homing of the gripper.

After changing the gripper fingers, a homing needs to be done. This is needed to estimate the maximum grasping width.

§Errors

Returns FrankaError::Command if the command failed or was aborted, and FrankaError::Network if the connection is lost, e.g. after a timeout.

See GripperState::max_width for the maximum grasping width.

Source

pub fn grasp( &self, width: f64, speed: f64, force: f64, epsilon_inner: f64, epsilon_outer: f64, ) -> FrankaResult<bool>

Grasps an object.

An object is considered grasped if the distance d between the gripper fingers satisfies (width - epsilon_inner) < d < (width + epsilon_outer).

epsilon_inner and epsilon_outer default to 0.005 in libfranka’s C++ overload; this port takes both explicitly (there is no default-argument mechanism in a fn).

§Errors

Returns FrankaError::Command if the command failed or was aborted, and FrankaError::Network if the connection is lost, e.g. after a timeout.

Source

pub fn move_gripper(&self, width: f64, speed: f64) -> FrankaResult<bool>

Moves the gripper fingers to a specified width.

§Errors

Returns FrankaError::Command if the command failed or was aborted, and FrankaError::Network if the connection is lost, e.g. after a timeout.

Source

pub fn stop(&self) -> FrankaResult<bool>

Stops a currently running gripper move or grasp.

§Errors

Returns FrankaError::Command if the command failed or was aborted, and FrankaError::Network if the connection is lost, e.g. after a timeout.

Source

pub fn read_once(&self) -> FrankaResult<GripperState>

Waits for a gripper state update and returns it.

Port of Gripper::readOnce: first drains every datagram already queued on the UDP socket (stale data from before this call), then blocks for one fresh state.

§Errors

Returns FrankaError::Network if the connection is lost, e.g. after a timeout.

Trait Implementations§

Source§

impl Debug for Gripper

Source§

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

Formats the value using the given formatter. Read more

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.