Skip to main content

SoModelBackend

Struct SoModelBackend 

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

RobotModelBackend backed by the robot’s own libfcimodels shared object.

Obtain one from crate::model::model_library::load_from_robot (online) or from SoModelBackend::open / SoModelBackend::from_bytes (offline, e.g. from a captured library).

Implementations§

Source§

impl SoModelBackend

Source

pub unsafe fn open(path: &Path) -> FrankaResult<SoModelBackend>

Loads a libfcimodels shared object from an existing file.

The file is not removed when the backend is dropped; use SoModelBackend::from_bytes for a downloaded library.

Port of franka::LibraryLoader plus franka::ModelLibrary’s symbol binding (src/library_loader.cpp, src/model_library.cpp, 0.9.2).

§Safety

This dlopens path, which runs the shared object’s DT_INIT constructors and then calls function pointers resolved out of it — i.e. it executes the file’s code in this process, with no sandbox and no validation of its contents.

The caller asserts that path is a trusted libfcimodels build for the current platform: it came from a source the caller is willing to run arbitrary native code from (a Franka control unit over the FCI command socket, or a library captured from one and stored somewhere only trusted principals can write), the file cannot be swapped between this call and the load, and its thirty exported entry points have the signatures libfcimodels.h of libfranka 0.9.2 declares. Loading anything else is undefined behaviour.

§Errors

FrankaError::Model when the file cannot be dlopened (wrong architecture, missing dependency, not a shared object) or when any of the thirty expected symbols is absent — libfranka reports the same two conditions as ModelException("libfranka: Cannot load model library: ...") and ModelException("libfranka: Symbol cannot be found: ...").

Source

pub unsafe fn from_bytes(bytes: &[u8]) -> FrankaResult<SoModelBackend>

Writes bytes to a fresh, 0600, uniquely named file under std::env::temp_dir, loads it, and removes the file when the returned backend is dropped.

This is what libfranka does with the LoadModelLibrary response (LibraryDownloader::LibraryDownloader, which names the file with Poco::TemporaryFile::tempName() and unlinks it in its destructor).

§Safety

bytes are written to disk and dlopened, so this executes them in this process; see SoModelBackend::open for what that means. The caller asserts that bytes are a trusted libfcimodels build for the current platform — in the online path, that trust is the FCI peer itself, which already commands the arm.

§Errors

FrankaError::Model when the file cannot be created or written (libfranka: "libfranka: Cannot save model library."), or for the reasons listed on SoModelBackend::open.

Trait Implementations§

Source§

impl Debug for SoModelBackend

Source§

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

Formats the value using the given formatter. Read more
Source§

impl RobotModelBackend for SoModelBackend

Source§

fn coriolis( &self, q: &[f64; 7], dq: &[f64; 7], i_total: &[f64; 9], m_total: f64, f_x_ctotal: &[f64; 3], _gravity_earth: &[f64; 3], ) -> [f64; 7]

c_NE(q, dq, I_total, m_total, F_x_Ctotal).

gravity_earth is ignored: the FCI v5 model library’s Coriolis entry point takes no gravity vector and franka::Model::coriolis (0.9.2) has no such parameter either. See the module documentation.

Source§

fn gravity( &self, q: &[f64; 7], gravity_earth: &[f64; 3], m_total: f64, f_x_ctotal: &[f64; 3], ) -> [f64; 7]

g_NE(q, gravity_earth, m_total, F_x_Ctotal).

Source§

fn mass( &self, q: &[f64; 7], i_total: &[f64; 9], m_total: f64, f_x_ctotal: &[f64; 3], ) -> [f64; 49]

M_NE(q, I_total, m_total, F_x_Ctotal).

Source§

fn pose(&self, q: &[f64; 7], joint_index: usize) -> [f64; 16]

Pose of a joint frame in the base frame. Port of RobotModelBase::pose.
Source§

fn pose_flange(&self, q: &[f64; 7]) -> [f64; 16]

Pose of the flange frame. Port of RobotModelBase::poseFlange.
Source§

fn pose_ee(&self, q: &[f64; 7], f_t_ee: &[f64; 16]) -> [f64; 16]

Pose of the end-effector frame. Port of RobotModelBase::poseEe.
Source§

fn pose_stiffness( &self, q: &[f64; 7], f_t_ee: &[f64; 16], ee_t_k: &[f64; 16], ) -> [f64; 16]

Pose of the stiffness frame. Port of RobotModelBase::poseStiffness.
Source§

fn body_jacobian(&self, q: &[f64; 7], joint_index: usize) -> [f64; 42]

Body (LOCAL) Jacobian of a joint frame. Port of RobotModelBase::bodyJacobian.
Source§

fn body_jacobian_flange(&self, q: &[f64; 7]) -> [f64; 42]

Body Jacobian of the flange frame. Port of RobotModelBase::bodyJacobianFlange.
Source§

fn body_jacobian_ee(&self, q: &[f64; 7], f_t_ee: &[f64; 16]) -> [f64; 42]

Body Jacobian of the end-effector frame. Port of RobotModelBase::bodyJacobianEe.
Source§

fn body_jacobian_stiffness( &self, q: &[f64; 7], f_t_ee: &[f64; 16], ee_t_k: &[f64; 16], ) -> [f64; 42]

Body Jacobian of the stiffness frame. Port of RobotModelBase::bodyJacobianStiffness.
Source§

fn zero_jacobian(&self, q: &[f64; 7], joint_index: usize) -> [f64; 42]

Zero (LOCAL_WORLD_ALIGNED) Jacobian of a joint frame. Port of RobotModelBase::zeroJacobian.
Source§

fn zero_jacobian_flange(&self, q: &[f64; 7]) -> [f64; 42]

Zero Jacobian of the flange frame. Port of RobotModelBase::zeroJacobianFlange.
Source§

fn zero_jacobian_ee(&self, q: &[f64; 7], f_t_ee: &[f64; 16]) -> [f64; 42]

Zero Jacobian of the end-effector frame. Port of RobotModelBase::zeroJacobianEe.
Source§

fn zero_jacobian_stiffness( &self, q: &[f64; 7], f_t_ee: &[f64; 16], ee_t_k: &[f64; 16], ) -> [f64; 42]

Zero Jacobian of the stiffness frame. Port of RobotModelBase::zeroJacobianStiffness.

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.