Skip to main content

Model

Struct Model 

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

Poses of the joints and dynamic properties of the robot.

Port of franka::Model. Obtain one from Robot::load_model, or build one directly from a URDF with Model::from_urdf.

Implementations§

Source§

impl Model

Source

pub unsafe fn from_model_library_bytes(bytes: &[u8]) -> FrankaResult<Model>

Builds a model from the bytes of a libfcimodels shared object.

The offline twin of load_from_robot: same temp-file lifecycle (a 0600 file under std::env::temp_dir, removed when the model is dropped), no network. Useful for a captured library and for tests.

§Safety

The bytes are written to a temporary file and dlopened, which executes the shared object’s initialisers and, afterwards, its exported entry points in this process. The caller asserts that bytes are a trusted libfcimodels build for the current platform — served by a Franka control unit, or captured from one and kept where only trusted principals can write. See SoModelBackend::from_bytes.

§Errors

FrankaError::Model when the file cannot be written, dlopened, or when any of the thirty libfcimodels symbols is missing.

Source

pub unsafe fn from_model_library_path(path: &Path) -> FrankaResult<Model>

Builds a model from a libfcimodels shared object already on disk.

Unlike Model::from_model_library_bytes the file is left alone when the model is dropped.

§Safety

The file is dlopened, which executes its code in this process. The caller asserts that path names a trusted libfcimodels build for the current platform and that it cannot be swapped before the load. See SoModelBackend::open.

§Errors

FrankaError::Model when the file cannot be dlopened or when any of the thirty libfcimodels symbols is missing.

Source§

impl Model

Source

pub fn from_urdf(urdf: &str) -> FrankaResult<Model>

Builds a model from a URDF string using the native backend.

Port of franka::Model::Model(const std::string&).

§Errors

crate::FrankaError::Model if the URDF cannot be parsed or does not describe a seven-axis arm ending in a link8 flange frame.

Source

pub fn native_fer() -> Model

Builds the Franka Emika Robot (FER)’s model, without asking a robot for it.

This is the FCI v5 counterpart of what Model::from_urdf does with an FR3’s GetRobotModel answer: it is the native backend over FER_URDF, whose parameters were identified from an FER’s own libfcimodels_x64.so. It needs no download, no dlopen, no model-library feature and no x86-64 Linux host, and it is what crate::Robot::load_model returns on an FER.

Agreement with the shared object, over 208 joint configurations (see docs/book/src/reference/model.md): poses and both Jacobians to 9e-16 at all ten frames, gravity to 5e-14 with any payload, and the mass matrix and Coriolis vector to 4e-14 with no payload. With a payload the mass matrix and Coriolis vector differ by up to 3e-3 and 5e-2, because the robot’s own M_NE is not affine in m_load and therefore is not a rigid-body model of the payload; see docs/book/src/reference/model.md. Use crate::Robot::load_model_from_robot when you need the library’s own answer to the last bit.

§Panics

Never: FER_URDF is compiled in and a unit test parses it.

Source

pub fn from_backend(backend: Box<dyn RobotModelBackend + Send + Sync>) -> Model

Builds a model around an explicit backend.

Port of franka::Model::Model(std::unique_ptr<RobotModelBase>), which libfranka provides for its own tests; the conformance suite uses it to run the evaluation backends through the same API.

Source

pub fn backend(&self) -> &(dyn RobotModelBackend + Send + Sync)

Borrows the underlying backend.

Source

pub fn pose(&self, frame: Frame, state: &RobotState) -> [f64; 16]

4x4 pose matrix of frame in the base frame, column-major.

Port of franka::Model::pose(Frame, const RobotState&).

Source

pub fn pose_q( &self, frame: Frame, q: &[f64; 7], F_T_EE: &[f64; 16], EE_T_K: &[f64; 16], ) -> [f64; 16]

4x4 pose matrix of frame in the base frame, column-major.

Port of franka::Model::pose(Frame, q, F_T_EE, EE_T_K).

Source

pub fn body_jacobian(&self, frame: Frame, state: &RobotState) -> [f64; 42]

6x7 body Jacobian of frame, column-major, relative to frame itself.

Port of franka::Model::bodyJacobian(Frame, const RobotState&).

Source

pub fn body_jacobian_q( &self, frame: Frame, q: &[f64; 7], F_T_EE: &[f64; 16], EE_T_K: &[f64; 16], ) -> [f64; 42]

6x7 body Jacobian of frame, column-major, relative to frame itself.

Port of franka::Model::bodyJacobian(Frame, q, F_T_EE, EE_T_K).

Source

pub fn zero_jacobian(&self, frame: Frame, state: &RobotState) -> [f64; 42]

6x7 zero Jacobian of frame, column-major, relative to the base frame.

Port of franka::Model::zeroJacobian(Frame, const RobotState&).

Source

pub fn zero_jacobian_q( &self, frame: Frame, q: &[f64; 7], F_T_EE: &[f64; 16], EE_T_K: &[f64; 16], ) -> [f64; 42]

6x7 zero Jacobian of frame, column-major, relative to the base frame.

Port of franka::Model::zeroJacobian(Frame, q, F_T_EE, EE_T_K).

Source

pub fn mass(&self, state: &RobotState) -> [f64; 49]

7x7 mass matrix, column-major, in kg * m^2.

Port of franka::Model::mass(const RobotState&).

Source

pub fn mass_q( &self, q: &[f64; 7], I_total: &[f64; 9], m_total: f64, F_x_Ctotal: &[f64; 3], ) -> [f64; 49]

7x7 mass matrix, column-major, in kg * m^2.

Port of franka::Model::mass(q, I_total, m_total, F_x_Ctotal).

Source

pub fn coriolis(&self, state: &RobotState) -> [f64; 7]

Coriolis force vector, in Nm, with Earth’s gravity {0, 0, -9.81}.

Port of franka::Model::coriolis(const RobotState&), which forwards to the deprecated RobotModel::coriolis overload that hard-codes that gravity vector.

Source

pub fn coriolis_q( &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]

Coriolis force vector, in Nm.

Port of franka::Model::coriolis(q, dq, I_total, m_total, F_x_Ctotal, gravity_earth).

Source

pub fn gravity(&self, state: &RobotState) -> [f64; 7]

Gravity torque vector, in Nm, using the state’s O_ddP_O as Earth’s gravity.

Port of franka::Model::gravity(const RobotState&).

Source

pub fn gravity_q( &self, q: &[f64; 7], m_total: f64, F_x_Ctotal: &[f64; 3], gravity_earth: &[f64; 3], ) -> [f64; 7]

Gravity torque vector, in Nm.

Port of franka::Model::gravity(q, m_total, F_x_Ctotal, gravity_earth).

Trait Implementations§

Source§

impl Debug for Model

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Model

§

impl !UnwindSafe for Model

§

impl Freeze for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

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.