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>
impl<'a> ActiveTorqueControl<'a>
Sourcepub fn read_once(&mut self) -> FrankaResult<(RobotState, Duration)>
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.
Sourcepub fn write_once(&mut self, control_input: &Torques) -> FrankaResult<()>
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§
impl<'a> !Send for ActiveTorqueControl<'a>
impl<'a> Freeze for ActiveTorqueControl<'a>
impl<'a> RefUnwindSafe for ActiveTorqueControl<'a>
impl<'a> Sync for ActiveTorqueControl<'a>
impl<'a> Unpin for ActiveTorqueControl<'a>
impl<'a> UnsafeUnpin for ActiveTorqueControl<'a>
impl<'a> UnwindSafe for ActiveTorqueControl<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.