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
impl SoModelBackend
Sourcepub unsafe fn open(path: &Path) -> FrankaResult<SoModelBackend>
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: ...").
Sourcepub unsafe fn from_bytes(bytes: &[u8]) -> FrankaResult<SoModelBackend>
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
impl Debug for SoModelBackend
Source§impl RobotModelBackend for SoModelBackend
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]
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]
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]
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]
fn pose(&self, q: &[f64; 7], joint_index: usize) -> [f64; 16]
RobotModelBase::pose.Source§fn pose_flange(&self, q: &[f64; 7]) -> [f64; 16]
fn pose_flange(&self, q: &[f64; 7]) -> [f64; 16]
RobotModelBase::poseFlange.Source§fn pose_ee(&self, q: &[f64; 7], f_t_ee: &[f64; 16]) -> [f64; 16]
fn pose_ee(&self, q: &[f64; 7], f_t_ee: &[f64; 16]) -> [f64; 16]
RobotModelBase::poseEe.Source§fn pose_stiffness(
&self,
q: &[f64; 7],
f_t_ee: &[f64; 16],
ee_t_k: &[f64; 16],
) -> [f64; 16]
fn pose_stiffness( &self, q: &[f64; 7], f_t_ee: &[f64; 16], ee_t_k: &[f64; 16], ) -> [f64; 16]
RobotModelBase::poseStiffness.Source§fn body_jacobian(&self, q: &[f64; 7], joint_index: usize) -> [f64; 42]
fn body_jacobian(&self, q: &[f64; 7], joint_index: usize) -> [f64; 42]
LOCAL) Jacobian of a joint frame. Port of RobotModelBase::bodyJacobian.Source§fn body_jacobian_flange(&self, q: &[f64; 7]) -> [f64; 42]
fn body_jacobian_flange(&self, q: &[f64; 7]) -> [f64; 42]
RobotModelBase::bodyJacobianFlange.Source§fn body_jacobian_ee(&self, q: &[f64; 7], f_t_ee: &[f64; 16]) -> [f64; 42]
fn body_jacobian_ee(&self, q: &[f64; 7], f_t_ee: &[f64; 16]) -> [f64; 42]
RobotModelBase::bodyJacobianEe.Source§fn body_jacobian_stiffness(
&self,
q: &[f64; 7],
f_t_ee: &[f64; 16],
ee_t_k: &[f64; 16],
) -> [f64; 42]
fn body_jacobian_stiffness( &self, q: &[f64; 7], f_t_ee: &[f64; 16], ee_t_k: &[f64; 16], ) -> [f64; 42]
RobotModelBase::bodyJacobianStiffness.Source§fn zero_jacobian(&self, q: &[f64; 7], joint_index: usize) -> [f64; 42]
fn zero_jacobian(&self, q: &[f64; 7], joint_index: usize) -> [f64; 42]
LOCAL_WORLD_ALIGNED) Jacobian of a joint frame. Port of
RobotModelBase::zeroJacobian.Source§fn zero_jacobian_flange(&self, q: &[f64; 7]) -> [f64; 42]
fn zero_jacobian_flange(&self, q: &[f64; 7]) -> [f64; 42]
RobotModelBase::zeroJacobianFlange.Auto Trait Implementations§
impl Freeze for SoModelBackend
impl RefUnwindSafe for SoModelBackend
impl Send for SoModelBackend
impl Sync for SoModelBackend
impl Unpin for SoModelBackend
impl UnsafeUnpin for SoModelBackend
impl UnwindSafe for SoModelBackend
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.