Skip to main content

ActiveTorqueControl

Struct ActiveTorqueControl 

Source
pub struct ActiveTorqueControl<'a> { /* private fields */ }
Expand description

An external torque controller driven by the caller (Robot::start_torque_control).

§FCI v5

An FER has no torque-only motion generator mode, so the motion is started with a joint velocity generator and every ActiveTorqueControl::write_once sends an all-zero dq_c alongside the torques, ending with motion_generation_finished instead of torque_command_finished. That is exactly what libfranka 0.9.2’s Robot::control(control_callback, ...) does (src/robot.cpp:41-57); the API is unchanged.

§Example

let robot = Robot::new("192.168.0.1", RealtimeConfig::Ignore)?;
let mut control = robot.start_torque_control()?;
for _ in 0..1000 {
    let (_state, _period) = control.read_once()?;
    control.write_once(&Torques::new([0.0; 7]))?;
}
control.write_once(&franka::motion_finished(Torques::new([0.0; 7])))?;

§Threading

Unlike crate::Robot, which is Send + Sync, this type is !Send: it holds the std::sync::MutexGuard for the robot’s control lock (franka::assertOwningLock) for as long as the motion runs, and a MutexGuard may not cross threads. Read and write the motion from the thread that started it; a crate::Robot::stop from another thread still works, because it goes through the Arc<Robot> and not through this handle.

Implementations§

Source§

impl<'a> ActiveTorqueControl<'a>

Source

pub fn read_once(&mut self) -> FrankaResult<(RobotState, Duration)>

Waits for the next robot state and returns it together with the time elapsed since the previous read_once (zero on the first call).

§Errors

FrankaError::Control if the motion was aborted, FrankaError::Network if the connection was lost.

Source

pub fn write_once(&mut self, control_input: &Torques) -> FrankaResult<()>

Sends the given torques.

Setting motion_finished on control_input ends the control process; the control lock is released and any further call fails.

§Errors

FrankaError::Control if the motion has already finished or was aborted, FrankaError::InvalidArgument if a torque is NaN or infinite, FrankaError::Network if the connection was lost.

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.