Expand description
The public Robot API.
Port of franka::Robot (libfranka 0.21.2 include/franka/robot.h, src/robot.cpp). The
doc comments are libfranka’s, adapted to Rust’s error type.
§Threading
Robot is Send + Sync and every method takes &self, so a control loop and a
Robot::stop call can run on two threads at the same time; share the robot as an
Arc<Robot>. Only one control or read operation may run at a time: a second one returns
FrankaError::InvalidOperation.
§Example
use franka::{JointPositions, RealtimeConfig, Robot};
let robot = Robot::new("192.168.0.1", RealtimeConfig::Enforce)?;
let initial = robot.read_once()?.q;
let mut time = 0.0;
robot.control_joint_positions(
|_state, period| {
time += period.as_secs_f64();
let delta = std::f64::consts::PI / 8.0 * (1.0 - (std::f64::consts::PI / 2.5 * time).cos());
let mut q = initial;
q[3] += delta;
let output = JointPositions::new(q);
if time >= 5.0 {
franka::motion_finished(output)
} else {
output
}
},
franka::ControllerMode::JointImpedance,
true,
franka::DEFAULT_CUTOFF_FREQUENCY,
)?;Re-exports§
pub use active_control::ActiveMotionGenerator;pub use active_control::ActiveMotionInput;pub use active_control::ActiveTorqueControl;pub use options::RobotOptions;pub use options::VersionPolicy;pub use options::VirtualWallCuboid;pub use target_control::impedance_torques;pub use target_control::Backend;pub use target_control::CartesianSent;pub use target_control::CartesianTargetControl;pub use target_control::IkOptions;pub use target_control::ImpedanceGains;pub use target_control::ImpedanceOptions;pub use target_control::JointSent;pub use target_control::JointTargetControl;pub use target_control::JointTargetControlOptions;pub use target_control::Leash;pub use target_control::Settle;pub use target_control::TargetControlOptions;
Modules§
- active_
control - Externally driven control:
read_once/write_onceinstead of a callback loop. - commands
- The TCP commands of the robot server and libfranka’s response handling.
- control_
loop - The 1 kHz control loop.
- logger
- Ring buffer of the last robot states and commands of a motion.
- options
- Connect-time options and the value types the FCI v5 getters return.
- robot_
impl - Connection, state stream and motion lifecycle.
- target_
control - Target control: a 1 kHz loop on its own thread that follows targets a low-rate commander sets whenever it likes.
Structs§
- Robot
- Maintains a network connection to the robot, provides the current robot state, gives access to the robot model and allows to control the robot.
Constants§
- CONTROL_
LOCK_ MESSAGE - Text of the exception libfranka raises when a second control or read operation is started
(
franka::assertOwningLock). - DEFAULT_
LOG_ SIZE - Default size of the control log attached to a
crate::error::ControlException(franka::Robot’slog_sizedefault).