rby1_sdk.dynamics#

Robot dynamics and kinematics module.

Provides robot dynamics calculations including inertia, joint dynamics, and link properties.

Functions

load_robot_from_urdf(path, base_link_name)

Load a robot model from a URDF file.

load_robot_from_urdf_data(model, base_link_name)

Load a robot model from URDF data string.

Classes

Collision

Collision detection object.

CollisionResult

Collision detection result.

Geom

Base geometry class.

GeomCapsule

Capsule geometry.

GeomType

Geometry type enumeration.

Joint

Joint in the robot dynamics model.

Link

Link in the robot dynamics model.

MobileBase

Base class for mobile bases.

MobileBaseDifferential

Differential drive mobile base.

MobileBaseType

Mobile base type enumeration.

Robot

Robot dynamics model.

RobotConfiguration

Robot configuration.

Robot_18

Robot (DOF=18) dynamics model.

Robot_24

Robot (DOF=24) dynamics model.

Robot_26

Robot (DOF=26) dynamics model.

State

Robot state for dynamics calculations.

State_18

Robot state (DOF=18) for dynamics calculations.

State_24

Robot state (DOF=24) for dynamics calculations.

State_26

Robot state (DOF=26) for dynamics calculations.

class Collision#

Bases: pybind11_object

Collision detection object.

Manages collision detection for a link with multiple geometric objects.

origin#

Origin transformation matrix.

Type:

numpy.ndarray

geoms#

List of geometric objects for collision detection.

Type:

list

add_geom(self: rby1_sdk.dynamics.Collision, geom: rby1_sdk.dynamics.Geom) None#

Add a geometric object for collision detection.

Parameters:

geom (Geom) – Geometric object to add.

get_geoms(*args, **kwargs)#

Overloaded function.

  1. get_geoms(self: rby1_sdk.dynamics.Collision) -> list[rby1_sdk.dynamics.Geom]

Get the list of geometric objects.

Returns:

List of geometric objects.

Return type:

list

  1. get_geoms(self: rby1_sdk.dynamics.Collision) -> list[rby1_sdk.dynamics.Geom]

Get the list of geometric objects (const version).

Returns:

List of geometric objects.

Return type:

list

get_origin(self: rby1_sdk.dynamics.Collision) numpy.ndarray[numpy.float64[4, 4]]#

Get the origin transformation.

Returns:

Origin transformation matrix.

Return type:

numpy.ndarray

set_origin(self: rby1_sdk.dynamics.Collision, T: numpy.ndarray[numpy.float64[4, 4]]) None#

Set the origin transformation.

Parameters:

T (numpy.ndarray) – Origin transformation matrix.

class CollisionResult#

Bases: pybind11_object

Collision detection result.

Provides information about collision detection between two geometric objects.

link1#

Name of the first link involved in collision.

Type:

str

link2#

Name of the second link involved in collision.

Type:

str

position1#

Position of collision point on first link [m].

Type:

numpy.ndarray

position2#

Position of collision point on second link [m].

Type:

numpy.ndarray

distance#

Signed distance [m]. Positive when separated, 0 when touching, negative when overlapping (penetration depth = -distance).

Type:

float

property distance#
property link1#
property link2#
property position1#
property position2#
class Geom#

Bases: pybind11_object

Base geometry class.

Abstract base class for geometric objects used in collision detection.

coltype#

Collision type identifier.

Type:

int

colaffinity#

Collision affinity identifier.

Type:

int

compute_minimum_distance(self: rby1_sdk.dynamics.Geom, T: numpy.ndarray[numpy.float64[4, 4]], other_geom: rby1_sdk.dynamics.Geom, other_T: numpy.ndarray[numpy.float64[4, 4]]) rby1_sdk.dynamics.CollisionResult | None#

Compute the minimum Euclidean distance between this geometry and another geometry.

Parameters:
  • T (numpy.ndarray, shape (4, 4)) – Homogeneous transformation of this geometry in the world (SE(3)).

  • other_geom (Geom) – The other geometry.

  • other_T (numpy.ndarray, shape (4, 4)) – Homogeneous transformation of the other geometry in the world (SE(3)).

Returns:

Signed-distance result with the two closest points on each geometry. Returns None if the pair is unsupported or filtered out.

Return type:

CollisionResult or None

Notes

The returned distance is signed:

  • distance > 0 : geometries are separated by that metric distance

  • distance = 0 : geometries are just touching

  • distance < 0 : geometries overlap; penetration depth = -distance

Examples

>>> # quick, copy-paste friendly
>>> import numpy as np
>>> import rby1_sdk.dynamics as dyn
>>>
>>> caps1 = dyn.GeomCapsule(height=0.4, radius=0.05, coltype=0, colaffinity=0)
>>> caps2 = dyn.GeomCapsule(height=0.4, radius=0.05, coltype=0, colaffinity=0)
>>> T1 = np.eye(4)
>>> T2 = np.eye(4); T2[0, 3] = 0.20  # shift 20 cm in x
>>>
>>> res = caps1.compute_minimum_distance(T1, caps2, T2)
>>> if res is not None:
...     print(res.distance)
filter(self: rby1_sdk.dynamics.Geom, other_geom: rby1_sdk.dynamics.Geom) bool#

Filter collision detection with another geometry.

Parameters:

other_geom (Geom) – Other geometry to filter with.

Returns:

True if collision should be checked, False otherwise.

Return type:

bool

get_colaffinity(self: rby1_sdk.dynamics.Geom) int#

Get the collision affinity.

Returns:

Collision affinity identifier.

Return type:

int

get_coltype(self: rby1_sdk.dynamics.Geom) int#

Get the collision type.

Returns:

Collision type identifier.

Return type:

int

get_type(self: rby1_sdk.dynamics.Geom) rby1_sdk.dynamics.GeomType#

Get the geometry type.

Returns:

Type of the geometry.

Return type:

GeomType

class GeomCapsule#

Bases: Geom

Capsule geometry.

Represents a capsule (cylinder with rounded ends) for collision detection.

start_point#

Start point of the capsule axis [m].

Type:

numpy.ndarray

end_point#

End point of the capsule axis [m].

Type:

numpy.ndarray

radius#

Radius of the capsule [m].

Type:

float

get_end_point(self: rby1_sdk.dynamics.GeomCapsule) numpy.ndarray[numpy.float64[3, 1]]#

Get the end point of the capsule axis.

Returns:

End point with respect to link frame.

Return type:

numpy.ndarray

get_radius(self: rby1_sdk.dynamics.GeomCapsule) float#

Get the radius of the capsule.

Returns:

Radius [m].

Return type:

float

get_start_point(self: rby1_sdk.dynamics.GeomCapsule) numpy.ndarray[numpy.float64[3, 1]]#

Get the start point of the capsule axis.

Returns:

Start point with respect to link frame.

Return type:

numpy.ndarray

class GeomType#

Bases: pybind11_object

Geometry type enumeration.

Defines the types of geometric objects supported.

Members#

Capsuleint

Capsule geometry type.

Members:

Capsule :

Capsule geometry type.

Capsule = <GeomType.Capsule: 0>#
property name#
property value#
class Joint#

Bases: pybind11_object

Joint in the robot dynamics model.

Represents a joint connecting two links in the robot.

name#

Name of the joint.

Type:

str

Parent link of the joint.

Type:

Link

Child link of the joint.

Type:

Link

Connect two links through this joint.

Parameters:
  • parent_link (Link) – Parent link.

  • child_link (Link) – Child link.

  • T_pj (numpy.ndarray, shape (4, 4), dtype=float64, optional) – Transformation from parent joint to joint. Default is identity.

  • T_jc (numpy.ndarray, shape (4, 4), dtype=float64, optional) – Transformation from joint to child joint. Default is identity.

disconnect(self: rby1_sdk.dynamics.Joint) None#

Disconnect the joint from its parent and child links.

Overloaded function.

  1. get_child_link(self: rby1_sdk.dynamics.Joint) -> rby1_sdk.dynamics.Link

Get the child link of the joint.

Returns:

Child link.

Return type:

Link

  1. get_child_link(self: rby1_sdk.dynamics.Joint) -> rby1_sdk.dynamics.Link

Get the child link of the joint (const version).

Returns:

Child link.

Return type:

Link

get_limit_q_lower(self: rby1_sdk.dynamics.Joint) float#

Get lower joint position limit.

Returns:

Lower limit for joint position [rad].

Return type:

float

get_limit_q_upper(self: rby1_sdk.dynamics.Joint) float#

Get upper joint position limit.

Returns:

Upper limit for joint position [rad].

Return type:

float

get_limit_qddot_lower(self: rby1_sdk.dynamics.Joint) float#

Get lower joint acceleration limit.

Returns:

Lower limit for joint acceleration [rad/s²].

Return type:

float

get_limit_qddot_upper(self: rby1_sdk.dynamics.Joint) float#

Get upper joint acceleration limit.

Returns:

Upper limit for joint acceleration [rad/s²].

Return type:

float

get_limit_qdot_lower(self: rby1_sdk.dynamics.Joint) float#

Get lower joint velocity limit.

Returns:

Lower limit for joint velocity [rad/s].

Return type:

float

get_limit_qdot_upper(self: rby1_sdk.dynamics.Joint) float#

Get upper joint velocity limit.

Returns:

Upper limit for joint velocity [rad/s].

Return type:

float

get_limit_torque(self: rby1_sdk.dynamics.Joint) float#

Get joint torque limits.

Returns:

Torque limits [Nm].

Return type:

float

get_name(self: rby1_sdk.dynamics.Joint) str#

Get the name of the joint.

Returns:

Name of the joint.

Return type:

str

Get the parent link of the joint.

Returns:

Parent link if it exists, None otherwise.

Return type:

Link, optional

is_fixed(self: rby1_sdk.dynamics.Joint) bool#

Check if the joint is fixed.

Returns:

True if fixed, False otherwise.

Return type:

bool

static make(name: str, S: numpy.ndarray[numpy.float64[6, 1]]) rby1_sdk.dynamics.Joint#

Create a joint with a specific screw axis.

Parameters:
static make_fixed(name: str) rby1_sdk.dynamics.Joint#

Create a fixed joint.

Parameters:

name (str) – Name of the joint.

static make_prismatic(name: str, T: numpy.ndarray[numpy.float64[4, 4]] = array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), axis: numpy.ndarray[numpy.float64[3, 1]] = array([0., 0., 1.])) rby1_sdk.dynamics.Joint#

Create a prismatic joint.

Parameters:
  • name (str) – Name of the joint.

  • T (numpy.ndarray, optional) – Transformation from the parent link’s frame to the joint’s frame. Defaults to identity.

  • axis (numpy.ndarray, optional) – Axis of translation. Defaults to [0, 0, 1].

static make_revolute(name: str, T: numpy.ndarray[numpy.float64[4, 4]] = array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), axis: numpy.ndarray[numpy.float64[3, 1]] = array([0., 0., 1.])) rby1_sdk.dynamics.Joint#

Create a revolute joint.

Parameters:
  • name (str) – Name of the joint.

  • T (numpy.ndarray, optional) – Transformation from the parent link’s frame to the joint’s frame. Defaults to identity.

  • axis (numpy.ndarray, optional) – Axis of rotation. Defaults to [0, 0, 1].

set_limit_q(self: rby1_sdk.dynamics.Joint, lower: float, upper: float) None#

Set joint position limits.

Parameters:
  • lower (float) – Lower limit for joint position [rad].

  • upper (float) – Upper limit for joint position [rad].

set_limit_q_lower(self: rby1_sdk.dynamics.Joint, val: float) None#

Set lower joint position limit.

Parameters:

val (float) – New lower limit for joint position [rad].

set_limit_q_upper(self: rby1_sdk.dynamics.Joint, val: float) None#

Set upper joint position limit.

Parameters:

val (float) – New upper limit for joint position [rad].

set_limit_qddot(self: rby1_sdk.dynamics.Joint, lower: float, upper: float) None#

Set joint acceleration limits.

Parameters:
  • lower (float) – Lower limit for joint acceleration [rad/s²].

  • upper (float) – Upper limit for joint acceleration [rad/s²].

set_limit_qddot_lower(self: rby1_sdk.dynamics.Joint, val: float) None#

Set lower joint acceleration limit.

Parameters:

val (float) – New lower limit for joint acceleration [rad/s²].

set_limit_qddot_upper(self: rby1_sdk.dynamics.Joint, val: float) None#

Set upper joint acceleration limit.

Parameters:

val (float) – New upper limit for joint acceleration [rad/s²].

set_limit_qdot(self: rby1_sdk.dynamics.Joint, lower: float, upper: float) None#

Set joint velocity limits.

Parameters:
  • lower (float) – Lower limit for joint velocity [rad/s].

  • upper (float) – Upper limit for joint velocity [rad/s].

set_limit_qdot_lower(self: rby1_sdk.dynamics.Joint, val: float) None#

Set lower joint velocity limit.

Parameters:

val (float) – New lower limit for joint velocity [rad/s].

set_limit_qdot_upper(self: rby1_sdk.dynamics.Joint, val: float) None#

Set upper joint velocity limit.

Parameters:

val (float) – New upper limit for joint velocity [rad/s].

set_limit_torque(self: rby1_sdk.dynamics.Joint, torque: float) None#

Set joint torque limits.

Parameters:

torque (float) – Torque limits.

Bases: pybind11_object

Link in the robot dynamics model.

Represents a rigid body link in the robot.

name#

Name of the link.

Type:

str

inertial#

Inertial properties of the link.

Type:

Inertial

parent_joint#

Parent joint of the link.

Type:

Joint

add_collision(self: rby1_sdk.dynamics.Link, collision: rby1_sdk.dynamics.Collision) None#

Add a collision object to the link.

Parameters:

collision (Collision) – Collision object to add.

get_child_joint_list(*args, **kwargs)#

Overloaded function.

  1. get_child_joint_list(self: rby1_sdk.dynamics.Link) -> list[rby1_sdk.dynamics.Joint]

Get the list of child joints.

Returns:

List of child joints.

Return type:

list

  1. get_child_joint_list(self: rby1_sdk.dynamics.Link) -> list[rby1_sdk.dynamics.Joint]

Get the list of child joints (const version).

Returns:

List of child joints.

Return type:

list

get_collisions(*args, **kwargs)#

Overloaded function.

  1. get_collisions(self: rby1_sdk.dynamics.Link) -> list[rby1_sdk.dynamics.Collision]

Get the list of collisions.

Returns:

List of collisions.

Return type:

list

  1. get_collisions(self: rby1_sdk.dynamics.Link) -> list[rby1_sdk.dynamics.Collision]

Get the list of collisions (const version).

Returns:

List of collisions.

Return type:

list

get_name(self: rby1_sdk.dynamics.Link) str#

Get the name of the link.

Returns:

Name of the link.

Return type:

str

get_parent_joint(self: rby1_sdk.dynamics.Link) rby1_sdk.dynamics.Joint#

Get the parent joint of the link.

Returns:

Parent joint if it exists, None otherwise.

Return type:

Joint, optional

class MobileBase#

Bases: pybind11_object

Base class for mobile bases.

Represents the base of the robot that can move.

type#

Type of the mobile base (e.g., differential, mecanum).

Type:

MobileBaseType

T#

Transformation matrix from the base to the world frame.

Type:

numpy.ndarray

joints#

List of joints that make up the mobile base.

Type:

list

params#

Parameters of the mobile base.

Type:

dict

property T#
property joints#
property params#
property type#
class MobileBaseDifferential#

Bases: MobileBase

Differential drive mobile base.

Represents a differential drive mobile base with two wheels.

right_wheel_idx#

Index of the right wheel joint.

Type:

int

left_wheel_idx#

Index of the left wheel joint.

Type:

int

wheel_base#

Distance between the two wheels [m].

Type:

float

wheel_radius#

Radius of the wheels [m].

Type:

float

property left_wheel_idx#
property right_wheel_idx#
property wheel_base#
property wheel_radius#
class MobileBaseType#

Bases: pybind11_object

Mobile base type enumeration.

Defines the types of mobile bases supported.

Members#

Noneint

No mobile base.

Differentialint

Differential drive mobile base.

Mecanumint

Mecanum drive mobile base.

Members:

Unspecified :

No mobile base.

Differential :

Differential drive mobile base.

Mecanum :

Mecanum drive mobile base.

Differential = <MobileBaseType.Differential: 1>#
Mecanum = <MobileBaseType.Mecanum: 2>#
Unspecified = <MobileBaseType.Unspecified: 0>#
property name#
property value#
class Robot#

Bases: pybind11_object

Robot dynamics model.

Represents the dynamics of a robot with a given number of degrees of freedom.

base#

Base link of the robot.

Type:

Link

List of names of all links.

Type:

list

joint_names#

List of names of all joints.

Type:

list

compute_2nd_diff_forward_kinematics(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) None#

Computes the second-order differential forward kinematics for each joint.

This method calculates the body acceleration for each joint frame based on the current joint accelerations (qddot) in the state. The results are cached within the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions, velocities, and accelerations. This object will be updated with the computed body accelerations.

Notes

compute_forward_kinematics and compute_diff_forward_kinematics must be called before this function.

Examples

>>> # Continuing from the previous example...
>>> dyn_state.set_qddot(np.zeros(dyn_robot.get_dof()))
>>> dyn_robot.compute_2nd_diff_forward_kinematics(dyn_state)
compute_body_jacobian(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, n]]#

Computes the body Jacobian for a target link relative to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6xDOF body Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_body_velocity(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 1]]#

Computes the relative body velocity (twist) of a target link with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6x1 body velocity vector (twist).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics and compute_diff_forward_kinematics must be called before this function.

compute_center_of_mass(*args, **kwargs)#

Overloaded function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, ref_link: int, target_link: int) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the center of mass of a single target link with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_link (int) – The index of the target link.

Returns:

The 3D position vector of the center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, ref_link: int, target_links: list[int]) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the combined center of mass of multiple target links with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_links (list[int]) – A list of indices of the target links.

Returns:

The 3D position vector of the combined center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, ref_link: int) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the center of mass of the entire robot with respect to a reference link.

Parameters:
Returns:

The 3D position vector of the total center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_center_of_mass_jacobian(*args, **kwargs)#

Overloaded function.

  1. compute_center_of_mass_jacobian(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, ref_link: int, target_link: int) -> numpy.ndarray[numpy.float64[3, n]]

Computes the Jacobian for the center of mass of a single target link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_link (int) – The index of the target link.

Returns:

The 3xDOF center of mass Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass_jacobian(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, ref_link: int) -> numpy.ndarray[numpy.float64[3, n]]

Computes the Jacobian for the center of mass of the entire robot.

Parameters:
Returns:

The 3xDOF center of mass Jacobian matrix for the whole robot.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_diff_forward_kinematics(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) None#

Computes the differential forward kinematics for each joint.

This method calculates the body velocity (twist) for each joint frame based on the current joint velocities (qdot) in the state. The results are cached within the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, which includes joint velocities. This object will be updated with the computed body velocities.

Notes

compute_forward_kinematics must be called before this function.

Examples

>>> # Continuing from the previous example...
>>> dyn_state.set_qdot(np.zeros(dyn_robot.get_dof()))
>>> dyn_robot.compute_diff_forward_kinematics(dyn_state)
compute_forward_kinematics(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) None#

Computes the forward kinematics for each joint.

This method calculates the transformation matrix from the base to each joint frame based on the current joint positions (q) in the state. The results are cached within the state object. This function must be called before other kinematics or dynamics calculations.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, which includes joint positions. This object will be updated with the computed transformation matrices.

Examples

>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>> # Assume dyn_robot is an initialized rby_dyn.Robot instance
>>> # and dyn_state is a corresponding state object.
>>> dyn_state.set_q(np.random.rand(dyn_robot.get_dof()))
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> # Now you can compute transformations, Jacobians, etc.
>>> transform = dyn_robot.compute_transformation(dyn_state, 0, 1)
>>> print(transform)
compute_gravity_term(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Computes the gravity compensation term for the robot.

This method calculates the joint torques required to counteract gravity at the current joint positions. The gravity vector must be set in the state object prior to calling this function.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions and the gravity vector.

Returns:

A vector of joint torques required to compensate for gravity.

Return type:

numpy.ndarray

Notes

  • compute_forward_kinematics must be called before this function.

  • The gravity vector (spatial acceleration) must be set on the state object using state.set_gravity() or state.set_Vdot0(). For standard gravity along the negative Z-axis, the vector is [0, 0, 0, 0, 0, -9.81].

Examples

>>> # Continuing from a previous example where dyn_robot and dyn_state are set up.
>>> dyn_state.set_gravity(np.array([0, 0, 0, 0, 0, -9.81]))
>>> # or dyn_state.set_Vdot0(np.array([0, 0, 0, 0, 0, 9.81]))  # Note that direction is reversed
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> gravity_torques = dyn_robot.compute_gravity_term(dyn_state)
>>> print(gravity_torques)
compute_inverse_dynamics(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) None#

Computes the inverse dynamics of the robot.

This method calculates the joint torques required to achieve the given joint accelerations (qddot), considering the current joint positions (q) and velocities (qdot). The results are stored back into the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions, velocities, and accelerations. This object will be updated with the computed joint torques. Hello. This is state.

Notes

compute_forward_kinematics, compute_diff_forward_kinematics, and compute_2nd_diff_forward_kinematics must be called in order before this function.

Examples

>>> # This example demonstrates the full sequence for inverse dynamics.
>>> import rby1_sdk as rby
>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>> robot = rby.create_robot_a("localhost:50051")
>>> robot.connect()
>>> dyn_robot = robot.get_dynamics()
>>> dyn_state = dyn_robot.make_state(
...     dyn_robot.get_link_names(), dyn_robot.get_joint_names()
... )
>>> q = (np.random.rand(dyn_robot.get_dof()) - 0.5) * np.pi / 2
>>> dyn_state.set_q(q)
>>> dyn_state.set_qdot(np.zeros(dyn_robot.get_dof()))
>>> dyn_state.set_qddot(np.zeros(dyn_robot.get_dof()))
>>>
>>> # Perform kinematics calculations in order
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> dyn_robot.compute_diff_forward_kinematics(dyn_state)
>>> dyn_robot.compute_2nd_diff_forward_kinematics(dyn_state)
>>>
>>> # Compute inverse dynamics
>>> dyn_robot.compute_inverse_dynamics(dyn_state)
>>>
>>> # Get the resulting torques
>>> torques = dyn_state.get_tau()
>>> with np.printoptions(precision=4, suppress=True):
...     print(f"Inverse dynamics torque (Nm): {torques}")
compute_mass(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, target_link_index: int) float#

Computes the mass of a specific link.

Parameters:
Returns:

The mass of the specified link.

Return type:

float

compute_mass_matrix(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, n]]#

Computes the joint space mass matrix (inertia matrix) of the robot.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions.

Returns:

The mass matrix (a square matrix of size DOF x DOF).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_mobility_diff_kinematics(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[3, 1]]#

Computes the forward differential kinematics for the mobile base.

Calculates the linear and angular velocity of the mobile base from the current wheel velocities (qdot).

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including wheel velocities.

Returns:

The resulting body velocity vector [w, vx, vy].

Return type:

numpy.ndarray

compute_mobility_inverse_diff_kinematics(*args, **kwargs)#

Overloaded function.

  1. compute_mobility_inverse_diff_kinematics(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, linear_velocity: numpy.ndarray[numpy.float64[2, 1]], angular_velocity: float) -> None

Computes the inverse differential kinematics for the mobile base.

Calculates the required wheel velocities to achieve a desired linear and angular velocity of the mobile base. Updates the qdot values in the state object.

Parameters:
  • state (rby1_sdk.dynamics.State) – The robot state object to be updated.

  • linear_velocity (numpy.ndarray) – The desired linear velocity (x, y) [m/s].

  • angular_velocity (float) – The desired angular velocity (yaw) [rad/s].

  1. compute_mobility_inverse_diff_kinematics(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, body_velocity: numpy.ndarray[numpy.float64[3, 1]]) -> None

Computes the inverse differential kinematics for the mobile base from a body velocity vector.

Calculates the required wheel velocities from a desired body velocity (twist). Updates the qdot values in the state object.

Parameters:
compute_reflective_inertia(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 6]]#

Computes the reflective inertia (task space inertia) of the target link with respect to the reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6x6 reflective inertia matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_space_jacobian(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, n]]#

Computes the space Jacobian for a target link relative to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6xDOF space Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_total_inertial(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, ref_link: int) numpy.ndarray[numpy.float64[6, 6]]#

Computes the total spatial inertia of the entire robot with respect to a reference link.

Parameters:
Returns:

The 6x6 total spatial inertia matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_transformation(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[4, 4]]#

Computes the transformation matrix from a reference link to a target link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link (the ‘from’ frame).

  • target_link_index (int) – The index of the target link (the ‘to’ frame).

Returns:

The 4x4 transformation matrix (SE(3)).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

static count_joints(base_link: rby1_sdk.dynamics.Link, include_fixed: bool = False) int#

count_joints(base_link, include_fixed=False)

Counts the number of joints in a kinematic chain starting from a base link.

Parameters:
  • base_link (rby1_sdk.dynamics.Link) – The starting link of the kinematic chain.

  • include_fixed (bool, optional) – Whether to include fixed joints in the count. Default is False.

Returns:

The total number of joints.

Return type:

int

Detects collisions or finds the nearest links in the robot model.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • collision_threshold (int, optional) – The minimum number of link pairs to return. The function first finds all colliding pairs. If the number of colliding pairs is less than this threshold, it will supplement the result with the nearest non-colliding link pairs until the total count reaches the threshold. The returned list is always sorted by distance. If set to 0, only actual collisions are returned. Default is 0.

Returns:

A list of collision results, sorted by distance.

Return type:

list[rby1_sdk.dynamics.CollisionResult]

Notes

compute_forward_kinematics must be called before this function.

get_base(self: rby1_sdk.dynamics.Robot) rby1_sdk.dynamics.Link#

Get the base link of the robot.

Returns:

Base link.

Return type:

Link

get_dof(self: rby1_sdk.dynamics.Robot) int#

Get the number of degrees of freedom.

Returns:

Number of degrees of freedom.

Return type:

int

get_joint_names(self: rby1_sdk.dynamics.Robot) list[str]#

Get the list of names of all joints.

Returns:

List of joint names.

Return type:

list

get_joint_property(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, getter: Callable[[rby1_sdk.dynamics.Joint], float]) numpy.ndarray[numpy.float64[m, 1]]#

Gets a specific property for all joints using a provided getter function.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • getter (callable) – A function that takes a joint object and returns a double value.

Returns:

A vector containing the specified property for each joint.

Return type:

numpy.ndarray

get_limit_q_lower(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Gets the lower position limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower position limits (q) for each joint.

Return type:

numpy.ndarray

get_limit_q_upper(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Gets the upper position limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper position limits (q) for each joint.

Return type:

numpy.ndarray

get_limit_qddot_lower(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Gets the lower acceleration limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower acceleration limits (q_ddot) for each joint.

Return type:

numpy.ndarray

get_limit_qddot_upper(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Gets the upper acceleration limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper acceleration limits (q_ddot) for each joint.

Return type:

numpy.ndarray

get_limit_qdot_lower(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Gets the lower velocity limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower velocity limits (q_dot) for each joint.

Return type:

numpy.ndarray

get_limit_qdot_upper(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Gets the upper velocity limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper velocity limits (q_dot) for each joint.

Return type:

numpy.ndarray

get_limit_torque(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Gets the torque limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of torque limits for each joint.

Return type:

numpy.ndarray

Overloaded function.

  1. get_link(self: rby1_sdk.dynamics.Robot, name: str) -> rby1_sdk.dynamics.Link

Get a link by name.

Parameters:

name (str) – Name of the link.

Returns:

Link if found, None otherwise.

Return type:

Link, optional

  1. get_link(self: rby1_sdk.dynamics.Robot, state: rby1_sdk.dynamics.State, index: int) -> rby1_sdk.dynamics.Link

Get a link by state and index.

Parameters:
  • state (State) – Current state of the robot.

  • index (int) – Index of the link.

Returns:

Link if found, None otherwise.

Return type:

Link, optional

Get the list of names of all links.

Returns:

List of link names.

Return type:

list

get_number_of_joints(self: rby1_sdk.dynamics.Robot) int#

Get the number of joints.

Returns:

Number of joints.

Return type:

int

make_state(self: rby1_sdk.dynamics.Robot, link_names: list[str], joint_names: list[str]) rby1_sdk.dynamics.State#

Create a state from link and joint names.

The state object is essential for using the robot dynamics functions. It stores the robot’s state, its state vector (e.g., indices of joints and links), and also serves as a cache for intermediate results in dynamics and kinematics calculations to optimize for speed.

Parameters:
  • link_names (list[str]) – List of link names.

  • joint_names (list[str]) – List of joint names.

Returns:

A new state object.

Return type:

State

Examples

>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>>
>>> link_0 = rby_dyn.Link("link_0")
>>> link_1 = rby_dyn.Link("link_1")
>>>
>>> joint_0 = rby_dyn.Joint.make_revolute("joint_0", np.identity(4), np.array([0, 0, 1]))
>>> joint_0.connect_links(link_0, link_1, np.identity(4), np.identity(4))
>>>
>>> dyn_robot = rby_dyn.Robot(
...     rby_dyn.RobotConfiguration(name="sample_robot", base_link=link_0)
... )
>>>
>>> dyn_state = dyn_robot.make_state(["link_0", "link_1"], ["joint_0"])
>>> dyn_state.set_q(np.array([np.pi / 2]))  # Angle of joint_0 is 90 degrees
>>>
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> # Calculate transformation from link_0 to link_1
>>> transform = dyn_robot.compute_transformation(dyn_state, 0, 1)  # 0: link_0, 1: link_1
>>> print(transform)
class RobotConfiguration#

Bases: pybind11_object

Robot configuration.

Defines the base link and mobile base of the robot.

name#

Name of the robot configuration.

Type:

str

Base link of the robot.

Type:

Link

mobile_base#

Mobile base of the robot.

Type:

MobileBase

property base_link#
property mobile_base#
property name#
class Robot_18#

Bases: pybind11_object

Robot (DOF=18) dynamics model.

Represents the dynamics of a robot with a given number of degrees of freedom.

base#

Base link of the robot.

Type:

Link

List of names of all links.

Type:

list

joint_names#

List of names of all joints.

Type:

list

compute_2nd_diff_forward_kinematics(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) None#

Computes the second-order differential forward kinematics for each joint.

This method calculates the body acceleration for each joint frame based on the current joint accelerations (qddot) in the state. The results are cached within the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions, velocities, and accelerations. This object will be updated with the computed body accelerations.

Notes

compute_forward_kinematics and compute_diff_forward_kinematics must be called before this function.

Examples

>>> # Continuing from the previous example...
>>> dyn_state.set_qddot(np.zeros(dyn_robot.get_dof()))
>>> dyn_robot.compute_2nd_diff_forward_kinematics(dyn_state)
compute_body_jacobian(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 18]]#

Computes the body Jacobian for a target link relative to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6xDOF body Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_body_velocity(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 1]]#

Computes the relative body velocity (twist) of a target link with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6x1 body velocity vector (twist).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics and compute_diff_forward_kinematics must be called before this function.

compute_center_of_mass(*args, **kwargs)#

Overloaded function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, ref_link: int, target_link: int) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the center of mass of a single target link with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_link (int) – The index of the target link.

Returns:

The 3D position vector of the center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, ref_link: int, target_links: list[int]) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the combined center of mass of multiple target links with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_links (list[int]) – A list of indices of the target links.

Returns:

The 3D position vector of the combined center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, ref_link: int) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the center of mass of the entire robot with respect to a reference link.

Parameters:
Returns:

The 3D position vector of the total center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_center_of_mass_jacobian(*args, **kwargs)#

Overloaded function.

  1. compute_center_of_mass_jacobian(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, ref_link: int, target_link: int) -> numpy.ndarray[numpy.float64[3, 18]]

Computes the Jacobian for the center of mass of a single target link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_link (int) – The index of the target link.

Returns:

The 3xDOF center of mass Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass_jacobian(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, ref_link: int) -> numpy.ndarray[numpy.float64[3, 18]]

Computes the Jacobian for the center of mass of the entire robot.

Parameters:
Returns:

The 3xDOF center of mass Jacobian matrix for the whole robot.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_diff_forward_kinematics(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) None#

Computes the differential forward kinematics for each joint.

This method calculates the body velocity (twist) for each joint frame based on the current joint velocities (qdot) in the state. The results are cached within the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, which includes joint velocities. This object will be updated with the computed body velocities.

Notes

compute_forward_kinematics must be called before this function.

Examples

>>> # Continuing from the previous example...
>>> dyn_state.set_qdot(np.zeros(dyn_robot.get_dof()))
>>> dyn_robot.compute_diff_forward_kinematics(dyn_state)
compute_forward_kinematics(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) None#

Computes the forward kinematics for each joint.

This method calculates the transformation matrix from the base to each joint frame based on the current joint positions (q) in the state. The results are cached within the state object. This function must be called before other kinematics or dynamics calculations.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, which includes joint positions. This object will be updated with the computed transformation matrices.

Examples

>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>> # Assume dyn_robot is an initialized rby_dyn.Robot instance
>>> # and dyn_state is a corresponding state object.
>>> dyn_state.set_q(np.random.rand(dyn_robot.get_dof()))
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> # Now you can compute transformations, Jacobians, etc.
>>> transform = dyn_robot.compute_transformation(dyn_state, 0, 1)
>>> print(transform)
compute_gravity_term(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Computes the gravity compensation term for the robot.

This method calculates the joint torques required to counteract gravity at the current joint positions. The gravity vector must be set in the state object prior to calling this function.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions and the gravity vector.

Returns:

A vector of joint torques required to compensate for gravity.

Return type:

numpy.ndarray

Notes

  • compute_forward_kinematics must be called before this function.

  • The gravity vector (spatial acceleration) must be set on the state object using state.set_gravity() or state.set_Vdot0(). For standard gravity along the negative Z-axis, the vector is [0, 0, 0, 0, 0, -9.81].

Examples

>>> # Continuing from a previous example where dyn_robot and dyn_state are set up.
>>> dyn_state.set_gravity(np.array([0, 0, 0, 0, 0, -9.81]))
>>> # or dyn_state.set_Vdot0(np.array([0, 0, 0, 0, 0, 9.81]))  # Note that direction is reversed
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> gravity_torques = dyn_robot.compute_gravity_term(dyn_state)
>>> print(gravity_torques)
compute_inverse_dynamics(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) None#

Computes the inverse dynamics of the robot.

This method calculates the joint torques required to achieve the given joint accelerations (qddot), considering the current joint positions (q) and velocities (qdot). The results are stored back into the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions, velocities, and accelerations. This object will be updated with the computed joint torques. Hello. This is state.

Notes

compute_forward_kinematics, compute_diff_forward_kinematics, and compute_2nd_diff_forward_kinematics must be called in order before this function.

Examples

>>> # This example demonstrates the full sequence for inverse dynamics.
>>> import rby1_sdk as rby
>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>> robot = rby.create_robot_a("localhost:50051")
>>> robot.connect()
>>> dyn_robot = robot.get_dynamics()
>>> dyn_state = dyn_robot.make_state(
...     dyn_robot.get_link_names(), dyn_robot.get_joint_names()
... )
>>> q = (np.random.rand(dyn_robot.get_dof()) - 0.5) * np.pi / 2
>>> dyn_state.set_q(q)
>>> dyn_state.set_qdot(np.zeros(dyn_robot.get_dof()))
>>> dyn_state.set_qddot(np.zeros(dyn_robot.get_dof()))
>>>
>>> # Perform kinematics calculations in order
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> dyn_robot.compute_diff_forward_kinematics(dyn_state)
>>> dyn_robot.compute_2nd_diff_forward_kinematics(dyn_state)
>>>
>>> # Compute inverse dynamics
>>> dyn_robot.compute_inverse_dynamics(dyn_state)
>>>
>>> # Get the resulting torques
>>> torques = dyn_state.get_tau()
>>> with np.printoptions(precision=4, suppress=True):
...     print(f"Inverse dynamics torque (Nm): {torques}")
compute_mass(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, target_link_index: int) float#

Computes the mass of a specific link.

Parameters:
Returns:

The mass of the specified link.

Return type:

float

compute_mass_matrix(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 18]]#

Computes the joint space mass matrix (inertia matrix) of the robot.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions.

Returns:

The mass matrix (a square matrix of size DOF x DOF).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_mobility_diff_kinematics(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[3, 1]]#

Computes the forward differential kinematics for the mobile base.

Calculates the linear and angular velocity of the mobile base from the current wheel velocities (qdot).

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including wheel velocities.

Returns:

The resulting body velocity vector [w, vx, vy].

Return type:

numpy.ndarray

compute_mobility_inverse_diff_kinematics(*args, **kwargs)#

Overloaded function.

  1. compute_mobility_inverse_diff_kinematics(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, linear_velocity: numpy.ndarray[numpy.float64[2, 1]], angular_velocity: float) -> None

Computes the inverse differential kinematics for the mobile base.

Calculates the required wheel velocities to achieve a desired linear and angular velocity of the mobile base. Updates the qdot values in the state object.

Parameters:
  • state (rby1_sdk.dynamics.State) – The robot state object to be updated.

  • linear_velocity (numpy.ndarray) – The desired linear velocity (x, y) [m/s].

  • angular_velocity (float) – The desired angular velocity (yaw) [rad/s].

  1. compute_mobility_inverse_diff_kinematics(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, body_velocity: numpy.ndarray[numpy.float64[3, 1]]) -> None

Computes the inverse differential kinematics for the mobile base from a body velocity vector.

Calculates the required wheel velocities from a desired body velocity (twist). Updates the qdot values in the state object.

Parameters:
compute_reflective_inertia(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 6]]#

Computes the reflective inertia (task space inertia) of the target link with respect to the reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6x6 reflective inertia matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_space_jacobian(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 18]]#

Computes the space Jacobian for a target link relative to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6xDOF space Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_total_inertial(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, ref_link: int) numpy.ndarray[numpy.float64[6, 6]]#

Computes the total spatial inertia of the entire robot with respect to a reference link.

Parameters:
Returns:

The 6x6 total spatial inertia matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_transformation(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[4, 4]]#

Computes the transformation matrix from a reference link to a target link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link (the ‘from’ frame).

  • target_link_index (int) – The index of the target link (the ‘to’ frame).

Returns:

The 4x4 transformation matrix (SE(3)).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

static count_joints(base_link: rby1_sdk.dynamics.Link, include_fixed: bool = False) int#

count_joints(base_link, include_fixed=False)

Counts the number of joints in a kinematic chain starting from a base link.

Parameters:
  • base_link (rby1_sdk.dynamics.Link) – The starting link of the kinematic chain.

  • include_fixed (bool, optional) – Whether to include fixed joints in the count. Default is False.

Returns:

The total number of joints.

Return type:

int

Detects collisions or finds the nearest links in the robot model.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • collision_threshold (int, optional) – The minimum number of link pairs to return. The function first finds all colliding pairs. If the number of colliding pairs is less than this threshold, it will supplement the result with the nearest non-colliding link pairs until the total count reaches the threshold. The returned list is always sorted by distance. If set to 0, only actual collisions are returned. Default is 0.

Returns:

A list of collision results, sorted by distance.

Return type:

list[rby1_sdk.dynamics.CollisionResult]

Notes

compute_forward_kinematics must be called before this function.

get_base(self: rby1_sdk.dynamics.Robot_18) rby1_sdk.dynamics.Link#

Get the base link of the robot.

Returns:

Base link.

Return type:

Link

get_dof(self: rby1_sdk.dynamics.Robot_18) int#

Get the number of degrees of freedom.

Returns:

Number of degrees of freedom.

Return type:

int

get_joint_names(self: rby1_sdk.dynamics.Robot_18) list[str]#

Get the list of names of all joints.

Returns:

List of joint names.

Return type:

list

get_joint_property(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, getter: Callable[[rby1_sdk.dynamics.Joint], float]) numpy.ndarray[numpy.float64[18, 1]]#

Gets a specific property for all joints using a provided getter function.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • getter (callable) – A function that takes a joint object and returns a double value.

Returns:

A vector containing the specified property for each joint.

Return type:

numpy.ndarray

get_limit_q_lower(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Gets the lower position limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower position limits (q) for each joint.

Return type:

numpy.ndarray

get_limit_q_upper(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Gets the upper position limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper position limits (q) for each joint.

Return type:

numpy.ndarray

get_limit_qddot_lower(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Gets the lower acceleration limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower acceleration limits (q_ddot) for each joint.

Return type:

numpy.ndarray

get_limit_qddot_upper(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Gets the upper acceleration limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper acceleration limits (q_ddot) for each joint.

Return type:

numpy.ndarray

get_limit_qdot_lower(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Gets the lower velocity limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower velocity limits (q_dot) for each joint.

Return type:

numpy.ndarray

get_limit_qdot_upper(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Gets the upper velocity limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper velocity limits (q_dot) for each joint.

Return type:

numpy.ndarray

get_limit_torque(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Gets the torque limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of torque limits for each joint.

Return type:

numpy.ndarray

Overloaded function.

  1. get_link(self: rby1_sdk.dynamics.Robot_18, name: str) -> rby1_sdk.dynamics.Link

Get a link by name.

Parameters:

name (str) – Name of the link.

Returns:

Link if found, None otherwise.

Return type:

Link, optional

  1. get_link(self: rby1_sdk.dynamics.Robot_18, state: rby1_sdk.dynamics.State_18, index: int) -> rby1_sdk.dynamics.Link

Get a link by state and index.

Parameters:
  • state (State) – Current state of the robot.

  • index (int) – Index of the link.

Returns:

Link if found, None otherwise.

Return type:

Link, optional

Get the list of names of all links.

Returns:

List of link names.

Return type:

list

get_number_of_joints(self: rby1_sdk.dynamics.Robot_18) int#

Get the number of joints.

Returns:

Number of joints.

Return type:

int

make_state(self: rby1_sdk.dynamics.Robot_18, link_names: list[str], joint_names: list[str]) rby1_sdk.dynamics.State_18#

Create a state from link and joint names.

The state object is essential for using the robot dynamics functions. It stores the robot’s state, its state vector (e.g., indices of joints and links), and also serves as a cache for intermediate results in dynamics and kinematics calculations to optimize for speed.

Parameters:
  • link_names (list[str]) – List of link names.

  • joint_names (list[str]) – List of joint names.

Returns:

A new state object.

Return type:

State

Examples

>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>>
>>> link_0 = rby_dyn.Link("link_0")
>>> link_1 = rby_dyn.Link("link_1")
>>>
>>> joint_0 = rby_dyn.Joint.make_revolute("joint_0", np.identity(4), np.array([0, 0, 1]))
>>> joint_0.connect_links(link_0, link_1, np.identity(4), np.identity(4))
>>>
>>> dyn_robot = rby_dyn.Robot(
...     rby_dyn.RobotConfiguration(name="sample_robot", base_link=link_0)
... )
>>>
>>> dyn_state = dyn_robot.make_state(["link_0", "link_1"], ["joint_0"])
>>> dyn_state.set_q(np.array([np.pi / 2]))  # Angle of joint_0 is 90 degrees
>>>
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> # Calculate transformation from link_0 to link_1
>>> transform = dyn_robot.compute_transformation(dyn_state, 0, 1)  # 0: link_0, 1: link_1
>>> print(transform)
class Robot_24#

Bases: pybind11_object

Robot (DOF=24) dynamics model.

Represents the dynamics of a robot with a given number of degrees of freedom.

base#

Base link of the robot.

Type:

Link

List of names of all links.

Type:

list

joint_names#

List of names of all joints.

Type:

list

compute_2nd_diff_forward_kinematics(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) None#

Computes the second-order differential forward kinematics for each joint.

This method calculates the body acceleration for each joint frame based on the current joint accelerations (qddot) in the state. The results are cached within the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions, velocities, and accelerations. This object will be updated with the computed body accelerations.

Notes

compute_forward_kinematics and compute_diff_forward_kinematics must be called before this function.

Examples

>>> # Continuing from the previous example...
>>> dyn_state.set_qddot(np.zeros(dyn_robot.get_dof()))
>>> dyn_robot.compute_2nd_diff_forward_kinematics(dyn_state)
compute_body_jacobian(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 24]]#

Computes the body Jacobian for a target link relative to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6xDOF body Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_body_velocity(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 1]]#

Computes the relative body velocity (twist) of a target link with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6x1 body velocity vector (twist).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics and compute_diff_forward_kinematics must be called before this function.

compute_center_of_mass(*args, **kwargs)#

Overloaded function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, ref_link: int, target_link: int) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the center of mass of a single target link with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_link (int) – The index of the target link.

Returns:

The 3D position vector of the center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, ref_link: int, target_links: list[int]) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the combined center of mass of multiple target links with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_links (list[int]) – A list of indices of the target links.

Returns:

The 3D position vector of the combined center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, ref_link: int) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the center of mass of the entire robot with respect to a reference link.

Parameters:
Returns:

The 3D position vector of the total center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_center_of_mass_jacobian(*args, **kwargs)#

Overloaded function.

  1. compute_center_of_mass_jacobian(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, ref_link: int, target_link: int) -> numpy.ndarray[numpy.float64[3, 24]]

Computes the Jacobian for the center of mass of a single target link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_link (int) – The index of the target link.

Returns:

The 3xDOF center of mass Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass_jacobian(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, ref_link: int) -> numpy.ndarray[numpy.float64[3, 24]]

Computes the Jacobian for the center of mass of the entire robot.

Parameters:
Returns:

The 3xDOF center of mass Jacobian matrix for the whole robot.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_diff_forward_kinematics(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) None#

Computes the differential forward kinematics for each joint.

This method calculates the body velocity (twist) for each joint frame based on the current joint velocities (qdot) in the state. The results are cached within the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, which includes joint velocities. This object will be updated with the computed body velocities.

Notes

compute_forward_kinematics must be called before this function.

Examples

>>> # Continuing from the previous example...
>>> dyn_state.set_qdot(np.zeros(dyn_robot.get_dof()))
>>> dyn_robot.compute_diff_forward_kinematics(dyn_state)
compute_forward_kinematics(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) None#

Computes the forward kinematics for each joint.

This method calculates the transformation matrix from the base to each joint frame based on the current joint positions (q) in the state. The results are cached within the state object. This function must be called before other kinematics or dynamics calculations.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, which includes joint positions. This object will be updated with the computed transformation matrices.

Examples

>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>> # Assume dyn_robot is an initialized rby_dyn.Robot instance
>>> # and dyn_state is a corresponding state object.
>>> dyn_state.set_q(np.random.rand(dyn_robot.get_dof()))
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> # Now you can compute transformations, Jacobians, etc.
>>> transform = dyn_robot.compute_transformation(dyn_state, 0, 1)
>>> print(transform)
compute_gravity_term(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Computes the gravity compensation term for the robot.

This method calculates the joint torques required to counteract gravity at the current joint positions. The gravity vector must be set in the state object prior to calling this function.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions and the gravity vector.

Returns:

A vector of joint torques required to compensate for gravity.

Return type:

numpy.ndarray

Notes

  • compute_forward_kinematics must be called before this function.

  • The gravity vector (spatial acceleration) must be set on the state object using state.set_gravity() or state.set_Vdot0(). For standard gravity along the negative Z-axis, the vector is [0, 0, 0, 0, 0, -9.81].

Examples

>>> # Continuing from a previous example where dyn_robot and dyn_state are set up.
>>> dyn_state.set_gravity(np.array([0, 0, 0, 0, 0, -9.81]))
>>> # or dyn_state.set_Vdot0(np.array([0, 0, 0, 0, 0, 9.81]))  # Note that direction is reversed
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> gravity_torques = dyn_robot.compute_gravity_term(dyn_state)
>>> print(gravity_torques)
compute_inverse_dynamics(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) None#

Computes the inverse dynamics of the robot.

This method calculates the joint torques required to achieve the given joint accelerations (qddot), considering the current joint positions (q) and velocities (qdot). The results are stored back into the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions, velocities, and accelerations. This object will be updated with the computed joint torques. Hello. This is state.

Notes

compute_forward_kinematics, compute_diff_forward_kinematics, and compute_2nd_diff_forward_kinematics must be called in order before this function.

Examples

>>> # This example demonstrates the full sequence for inverse dynamics.
>>> import rby1_sdk as rby
>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>> robot = rby.create_robot_a("localhost:50051")
>>> robot.connect()
>>> dyn_robot = robot.get_dynamics()
>>> dyn_state = dyn_robot.make_state(
...     dyn_robot.get_link_names(), dyn_robot.get_joint_names()
... )
>>> q = (np.random.rand(dyn_robot.get_dof()) - 0.5) * np.pi / 2
>>> dyn_state.set_q(q)
>>> dyn_state.set_qdot(np.zeros(dyn_robot.get_dof()))
>>> dyn_state.set_qddot(np.zeros(dyn_robot.get_dof()))
>>>
>>> # Perform kinematics calculations in order
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> dyn_robot.compute_diff_forward_kinematics(dyn_state)
>>> dyn_robot.compute_2nd_diff_forward_kinematics(dyn_state)
>>>
>>> # Compute inverse dynamics
>>> dyn_robot.compute_inverse_dynamics(dyn_state)
>>>
>>> # Get the resulting torques
>>> torques = dyn_state.get_tau()
>>> with np.printoptions(precision=4, suppress=True):
...     print(f"Inverse dynamics torque (Nm): {torques}")
compute_mass(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, target_link_index: int) float#

Computes the mass of a specific link.

Parameters:
Returns:

The mass of the specified link.

Return type:

float

compute_mass_matrix(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 24]]#

Computes the joint space mass matrix (inertia matrix) of the robot.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions.

Returns:

The mass matrix (a square matrix of size DOF x DOF).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_mobility_diff_kinematics(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[3, 1]]#

Computes the forward differential kinematics for the mobile base.

Calculates the linear and angular velocity of the mobile base from the current wheel velocities (qdot).

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including wheel velocities.

Returns:

The resulting body velocity vector [w, vx, vy].

Return type:

numpy.ndarray

compute_mobility_inverse_diff_kinematics(*args, **kwargs)#

Overloaded function.

  1. compute_mobility_inverse_diff_kinematics(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, linear_velocity: numpy.ndarray[numpy.float64[2, 1]], angular_velocity: float) -> None

Computes the inverse differential kinematics for the mobile base.

Calculates the required wheel velocities to achieve a desired linear and angular velocity of the mobile base. Updates the qdot values in the state object.

Parameters:
  • state (rby1_sdk.dynamics.State) – The robot state object to be updated.

  • linear_velocity (numpy.ndarray) – The desired linear velocity (x, y) [m/s].

  • angular_velocity (float) – The desired angular velocity (yaw) [rad/s].

  1. compute_mobility_inverse_diff_kinematics(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, body_velocity: numpy.ndarray[numpy.float64[3, 1]]) -> None

Computes the inverse differential kinematics for the mobile base from a body velocity vector.

Calculates the required wheel velocities from a desired body velocity (twist). Updates the qdot values in the state object.

Parameters:
compute_reflective_inertia(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 6]]#

Computes the reflective inertia (task space inertia) of the target link with respect to the reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6x6 reflective inertia matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_space_jacobian(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 24]]#

Computes the space Jacobian for a target link relative to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6xDOF space Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_total_inertial(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, ref_link: int) numpy.ndarray[numpy.float64[6, 6]]#

Computes the total spatial inertia of the entire robot with respect to a reference link.

Parameters:
Returns:

The 6x6 total spatial inertia matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_transformation(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[4, 4]]#

Computes the transformation matrix from a reference link to a target link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link (the ‘from’ frame).

  • target_link_index (int) – The index of the target link (the ‘to’ frame).

Returns:

The 4x4 transformation matrix (SE(3)).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

static count_joints(base_link: rby1_sdk.dynamics.Link, include_fixed: bool = False) int#

count_joints(base_link, include_fixed=False)

Counts the number of joints in a kinematic chain starting from a base link.

Parameters:
  • base_link (rby1_sdk.dynamics.Link) – The starting link of the kinematic chain.

  • include_fixed (bool, optional) – Whether to include fixed joints in the count. Default is False.

Returns:

The total number of joints.

Return type:

int

Detects collisions or finds the nearest links in the robot model.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • collision_threshold (int, optional) – The minimum number of link pairs to return. The function first finds all colliding pairs. If the number of colliding pairs is less than this threshold, it will supplement the result with the nearest non-colliding link pairs until the total count reaches the threshold. The returned list is always sorted by distance. If set to 0, only actual collisions are returned. Default is 0.

Returns:

A list of collision results, sorted by distance.

Return type:

list[rby1_sdk.dynamics.CollisionResult]

Notes

compute_forward_kinematics must be called before this function.

get_base(self: rby1_sdk.dynamics.Robot_24) rby1_sdk.dynamics.Link#

Get the base link of the robot.

Returns:

Base link.

Return type:

Link

get_dof(self: rby1_sdk.dynamics.Robot_24) int#

Get the number of degrees of freedom.

Returns:

Number of degrees of freedom.

Return type:

int

get_joint_names(self: rby1_sdk.dynamics.Robot_24) list[str]#

Get the list of names of all joints.

Returns:

List of joint names.

Return type:

list

get_joint_property(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, getter: Callable[[rby1_sdk.dynamics.Joint], float]) numpy.ndarray[numpy.float64[24, 1]]#

Gets a specific property for all joints using a provided getter function.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • getter (callable) – A function that takes a joint object and returns a double value.

Returns:

A vector containing the specified property for each joint.

Return type:

numpy.ndarray

get_limit_q_lower(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Gets the lower position limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower position limits (q) for each joint.

Return type:

numpy.ndarray

get_limit_q_upper(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Gets the upper position limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper position limits (q) for each joint.

Return type:

numpy.ndarray

get_limit_qddot_lower(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Gets the lower acceleration limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower acceleration limits (q_ddot) for each joint.

Return type:

numpy.ndarray

get_limit_qddot_upper(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Gets the upper acceleration limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper acceleration limits (q_ddot) for each joint.

Return type:

numpy.ndarray

get_limit_qdot_lower(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Gets the lower velocity limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower velocity limits (q_dot) for each joint.

Return type:

numpy.ndarray

get_limit_qdot_upper(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Gets the upper velocity limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper velocity limits (q_dot) for each joint.

Return type:

numpy.ndarray

get_limit_torque(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Gets the torque limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of torque limits for each joint.

Return type:

numpy.ndarray

Overloaded function.

  1. get_link(self: rby1_sdk.dynamics.Robot_24, name: str) -> rby1_sdk.dynamics.Link

Get a link by name.

Parameters:

name (str) – Name of the link.

Returns:

Link if found, None otherwise.

Return type:

Link, optional

  1. get_link(self: rby1_sdk.dynamics.Robot_24, state: rby1_sdk.dynamics.State_24, index: int) -> rby1_sdk.dynamics.Link

Get a link by state and index.

Parameters:
  • state (State) – Current state of the robot.

  • index (int) – Index of the link.

Returns:

Link if found, None otherwise.

Return type:

Link, optional

Get the list of names of all links.

Returns:

List of link names.

Return type:

list

get_number_of_joints(self: rby1_sdk.dynamics.Robot_24) int#

Get the number of joints.

Returns:

Number of joints.

Return type:

int

make_state(self: rby1_sdk.dynamics.Robot_24, link_names: list[str], joint_names: list[str]) rby1_sdk.dynamics.State_24#

Create a state from link and joint names.

The state object is essential for using the robot dynamics functions. It stores the robot’s state, its state vector (e.g., indices of joints and links), and also serves as a cache for intermediate results in dynamics and kinematics calculations to optimize for speed.

Parameters:
  • link_names (list[str]) – List of link names.

  • joint_names (list[str]) – List of joint names.

Returns:

A new state object.

Return type:

State

Examples

>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>>
>>> link_0 = rby_dyn.Link("link_0")
>>> link_1 = rby_dyn.Link("link_1")
>>>
>>> joint_0 = rby_dyn.Joint.make_revolute("joint_0", np.identity(4), np.array([0, 0, 1]))
>>> joint_0.connect_links(link_0, link_1, np.identity(4), np.identity(4))
>>>
>>> dyn_robot = rby_dyn.Robot(
...     rby_dyn.RobotConfiguration(name="sample_robot", base_link=link_0)
... )
>>>
>>> dyn_state = dyn_robot.make_state(["link_0", "link_1"], ["joint_0"])
>>> dyn_state.set_q(np.array([np.pi / 2]))  # Angle of joint_0 is 90 degrees
>>>
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> # Calculate transformation from link_0 to link_1
>>> transform = dyn_robot.compute_transformation(dyn_state, 0, 1)  # 0: link_0, 1: link_1
>>> print(transform)
class Robot_26#

Bases: pybind11_object

Robot (DOF=26) dynamics model.

Represents the dynamics of a robot with a given number of degrees of freedom.

base#

Base link of the robot.

Type:

Link

List of names of all links.

Type:

list

joint_names#

List of names of all joints.

Type:

list

compute_2nd_diff_forward_kinematics(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) None#

Computes the second-order differential forward kinematics for each joint.

This method calculates the body acceleration for each joint frame based on the current joint accelerations (qddot) in the state. The results are cached within the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions, velocities, and accelerations. This object will be updated with the computed body accelerations.

Notes

compute_forward_kinematics and compute_diff_forward_kinematics must be called before this function.

Examples

>>> # Continuing from the previous example...
>>> dyn_state.set_qddot(np.zeros(dyn_robot.get_dof()))
>>> dyn_robot.compute_2nd_diff_forward_kinematics(dyn_state)
compute_body_jacobian(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 26]]#

Computes the body Jacobian for a target link relative to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6xDOF body Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_body_velocity(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 1]]#

Computes the relative body velocity (twist) of a target link with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6x1 body velocity vector (twist).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics and compute_diff_forward_kinematics must be called before this function.

compute_center_of_mass(*args, **kwargs)#

Overloaded function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, ref_link: int, target_link: int) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the center of mass of a single target link with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_link (int) – The index of the target link.

Returns:

The 3D position vector of the center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, ref_link: int, target_links: list[int]) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the combined center of mass of multiple target links with respect to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_links (list[int]) – A list of indices of the target links.

Returns:

The 3D position vector of the combined center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, ref_link: int) -> numpy.ndarray[numpy.float64[3, 1]]

Computes the center of mass of the entire robot with respect to a reference link.

Parameters:
Returns:

The 3D position vector of the total center of mass.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_center_of_mass_jacobian(*args, **kwargs)#

Overloaded function.

  1. compute_center_of_mass_jacobian(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, ref_link: int, target_link: int) -> numpy.ndarray[numpy.float64[3, 26]]

Computes the Jacobian for the center of mass of a single target link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • ref_link (int) – The index of the reference link frame.

  • target_link (int) – The index of the target link.

Returns:

The 3xDOF center of mass Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

  1. compute_center_of_mass_jacobian(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, ref_link: int) -> numpy.ndarray[numpy.float64[3, 26]]

Computes the Jacobian for the center of mass of the entire robot.

Parameters:
Returns:

The 3xDOF center of mass Jacobian matrix for the whole robot.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_diff_forward_kinematics(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) None#

Computes the differential forward kinematics for each joint.

This method calculates the body velocity (twist) for each joint frame based on the current joint velocities (qdot) in the state. The results are cached within the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, which includes joint velocities. This object will be updated with the computed body velocities.

Notes

compute_forward_kinematics must be called before this function.

Examples

>>> # Continuing from the previous example...
>>> dyn_state.set_qdot(np.zeros(dyn_robot.get_dof()))
>>> dyn_robot.compute_diff_forward_kinematics(dyn_state)
compute_forward_kinematics(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) None#

Computes the forward kinematics for each joint.

This method calculates the transformation matrix from the base to each joint frame based on the current joint positions (q) in the state. The results are cached within the state object. This function must be called before other kinematics or dynamics calculations.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, which includes joint positions. This object will be updated with the computed transformation matrices.

Examples

>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>> # Assume dyn_robot is an initialized rby_dyn.Robot instance
>>> # and dyn_state is a corresponding state object.
>>> dyn_state.set_q(np.random.rand(dyn_robot.get_dof()))
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> # Now you can compute transformations, Jacobians, etc.
>>> transform = dyn_robot.compute_transformation(dyn_state, 0, 1)
>>> print(transform)
compute_gravity_term(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Computes the gravity compensation term for the robot.

This method calculates the joint torques required to counteract gravity at the current joint positions. The gravity vector must be set in the state object prior to calling this function.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions and the gravity vector.

Returns:

A vector of joint torques required to compensate for gravity.

Return type:

numpy.ndarray

Notes

  • compute_forward_kinematics must be called before this function.

  • The gravity vector (spatial acceleration) must be set on the state object using state.set_gravity() or state.set_Vdot0(). For standard gravity along the negative Z-axis, the vector is [0, 0, 0, 0, 0, -9.81].

Examples

>>> # Continuing from a previous example where dyn_robot and dyn_state are set up.
>>> dyn_state.set_gravity(np.array([0, 0, 0, 0, 0, -9.81]))
>>> # or dyn_state.set_Vdot0(np.array([0, 0, 0, 0, 0, 9.81]))  # Note that direction is reversed
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> gravity_torques = dyn_robot.compute_gravity_term(dyn_state)
>>> print(gravity_torques)
compute_inverse_dynamics(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) None#

Computes the inverse dynamics of the robot.

This method calculates the joint torques required to achieve the given joint accelerations (qddot), considering the current joint positions (q) and velocities (qdot). The results are stored back into the state object.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions, velocities, and accelerations. This object will be updated with the computed joint torques. Hello. This is state.

Notes

compute_forward_kinematics, compute_diff_forward_kinematics, and compute_2nd_diff_forward_kinematics must be called in order before this function.

Examples

>>> # This example demonstrates the full sequence for inverse dynamics.
>>> import rby1_sdk as rby
>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>> robot = rby.create_robot_a("localhost:50051")
>>> robot.connect()
>>> dyn_robot = robot.get_dynamics()
>>> dyn_state = dyn_robot.make_state(
...     dyn_robot.get_link_names(), dyn_robot.get_joint_names()
... )
>>> q = (np.random.rand(dyn_robot.get_dof()) - 0.5) * np.pi / 2
>>> dyn_state.set_q(q)
>>> dyn_state.set_qdot(np.zeros(dyn_robot.get_dof()))
>>> dyn_state.set_qddot(np.zeros(dyn_robot.get_dof()))
>>>
>>> # Perform kinematics calculations in order
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> dyn_robot.compute_diff_forward_kinematics(dyn_state)
>>> dyn_robot.compute_2nd_diff_forward_kinematics(dyn_state)
>>>
>>> # Compute inverse dynamics
>>> dyn_robot.compute_inverse_dynamics(dyn_state)
>>>
>>> # Get the resulting torques
>>> torques = dyn_state.get_tau()
>>> with np.printoptions(precision=4, suppress=True):
...     print(f"Inverse dynamics torque (Nm): {torques}")
compute_mass(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, target_link_index: int) float#

Computes the mass of a specific link.

Parameters:
Returns:

The mass of the specified link.

Return type:

float

compute_mass_matrix(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 26]]#

Computes the joint space mass matrix (inertia matrix) of the robot.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including joint positions.

Returns:

The mass matrix (a square matrix of size DOF x DOF).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_mobility_diff_kinematics(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[3, 1]]#

Computes the forward differential kinematics for the mobile base.

Calculates the linear and angular velocity of the mobile base from the current wheel velocities (qdot).

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot, including wheel velocities.

Returns:

The resulting body velocity vector [w, vx, vy].

Return type:

numpy.ndarray

compute_mobility_inverse_diff_kinematics(*args, **kwargs)#

Overloaded function.

  1. compute_mobility_inverse_diff_kinematics(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, linear_velocity: numpy.ndarray[numpy.float64[2, 1]], angular_velocity: float) -> None

Computes the inverse differential kinematics for the mobile base.

Calculates the required wheel velocities to achieve a desired linear and angular velocity of the mobile base. Updates the qdot values in the state object.

Parameters:
  • state (rby1_sdk.dynamics.State) – The robot state object to be updated.

  • linear_velocity (numpy.ndarray) – The desired linear velocity (x, y) [m/s].

  • angular_velocity (float) – The desired angular velocity (yaw) [rad/s].

  1. compute_mobility_inverse_diff_kinematics(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, body_velocity: numpy.ndarray[numpy.float64[3, 1]]) -> None

Computes the inverse differential kinematics for the mobile base from a body velocity vector.

Calculates the required wheel velocities from a desired body velocity (twist). Updates the qdot values in the state object.

Parameters:
compute_reflective_inertia(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 6]]#

Computes the reflective inertia (task space inertia) of the target link with respect to the reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6x6 reflective inertia matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_space_jacobian(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[6, 26]]#

Computes the space Jacobian for a target link relative to a reference link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link.

  • target_link_index (int) – The index of the target link.

Returns:

The 6xDOF space Jacobian matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_total_inertial(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, ref_link: int) numpy.ndarray[numpy.float64[6, 6]]#

Computes the total spatial inertia of the entire robot with respect to a reference link.

Parameters:
Returns:

The 6x6 total spatial inertia matrix.

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

compute_transformation(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, reference_link_index: int, target_link_index: int) numpy.ndarray[numpy.float64[4, 4]]#

Computes the transformation matrix from a reference link to a target link.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • reference_link_index (int) – The index of the reference link (the ‘from’ frame).

  • target_link_index (int) – The index of the target link (the ‘to’ frame).

Returns:

The 4x4 transformation matrix (SE(3)).

Return type:

numpy.ndarray

Notes

compute_forward_kinematics must be called before this function.

static count_joints(base_link: rby1_sdk.dynamics.Link, include_fixed: bool = False) int#

count_joints(base_link, include_fixed=False)

Counts the number of joints in a kinematic chain starting from a base link.

Parameters:
  • base_link (rby1_sdk.dynamics.Link) – The starting link of the kinematic chain.

  • include_fixed (bool, optional) – Whether to include fixed joints in the count. Default is False.

Returns:

The total number of joints.

Return type:

int

Detects collisions or finds the nearest links in the robot model.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • collision_threshold (int, optional) – The minimum number of link pairs to return. The function first finds all colliding pairs. If the number of colliding pairs is less than this threshold, it will supplement the result with the nearest non-colliding link pairs until the total count reaches the threshold. The returned list is always sorted by distance. If set to 0, only actual collisions are returned. Default is 0.

Returns:

A list of collision results, sorted by distance.

Return type:

list[rby1_sdk.dynamics.CollisionResult]

Notes

compute_forward_kinematics must be called before this function.

get_base(self: rby1_sdk.dynamics.Robot_26) rby1_sdk.dynamics.Link#

Get the base link of the robot.

Returns:

Base link.

Return type:

Link

get_dof(self: rby1_sdk.dynamics.Robot_26) int#

Get the number of degrees of freedom.

Returns:

Number of degrees of freedom.

Return type:

int

get_joint_names(self: rby1_sdk.dynamics.Robot_26) list[str]#

Get the list of names of all joints.

Returns:

List of joint names.

Return type:

list

get_joint_property(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, getter: Callable[[rby1_sdk.dynamics.Joint], float]) numpy.ndarray[numpy.float64[26, 1]]#

Gets a specific property for all joints using a provided getter function.

Parameters:
  • state (rby1_sdk.dynamics.State) – The current state of the robot.

  • getter (callable) – A function that takes a joint object and returns a double value.

Returns:

A vector containing the specified property for each joint.

Return type:

numpy.ndarray

get_limit_q_lower(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Gets the lower position limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower position limits (q) for each joint.

Return type:

numpy.ndarray

get_limit_q_upper(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Gets the upper position limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper position limits (q) for each joint.

Return type:

numpy.ndarray

get_limit_qddot_lower(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Gets the lower acceleration limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower acceleration limits (q_ddot) for each joint.

Return type:

numpy.ndarray

get_limit_qddot_upper(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Gets the upper acceleration limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper acceleration limits (q_ddot) for each joint.

Return type:

numpy.ndarray

get_limit_qdot_lower(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Gets the lower velocity limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of lower velocity limits (q_dot) for each joint.

Return type:

numpy.ndarray

get_limit_qdot_upper(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Gets the upper velocity limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of upper velocity limits (q_dot) for each joint.

Return type:

numpy.ndarray

get_limit_torque(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Gets the torque limits for all joints.

Parameters:

state (rby1_sdk.dynamics.State) – The current state of the robot.

Returns:

A vector of torque limits for each joint.

Return type:

numpy.ndarray

Overloaded function.

  1. get_link(self: rby1_sdk.dynamics.Robot_26, name: str) -> rby1_sdk.dynamics.Link

Get a link by name.

Parameters:

name (str) – Name of the link.

Returns:

Link if found, None otherwise.

Return type:

Link, optional

  1. get_link(self: rby1_sdk.dynamics.Robot_26, state: rby1_sdk.dynamics.State_26, index: int) -> rby1_sdk.dynamics.Link

Get a link by state and index.

Parameters:
  • state (State) – Current state of the robot.

  • index (int) – Index of the link.

Returns:

Link if found, None otherwise.

Return type:

Link, optional

Get the list of names of all links.

Returns:

List of link names.

Return type:

list

get_number_of_joints(self: rby1_sdk.dynamics.Robot_26) int#

Get the number of joints.

Returns:

Number of joints.

Return type:

int

make_state(self: rby1_sdk.dynamics.Robot_26, link_names: list[str], joint_names: list[str]) rby1_sdk.dynamics.State_26#

Create a state from link and joint names.

The state object is essential for using the robot dynamics functions. It stores the robot’s state, its state vector (e.g., indices of joints and links), and also serves as a cache for intermediate results in dynamics and kinematics calculations to optimize for speed.

Parameters:
  • link_names (list[str]) – List of link names.

  • joint_names (list[str]) – List of joint names.

Returns:

A new state object.

Return type:

State

Examples

>>> import rby1_sdk.dynamics as rby_dyn
>>> import numpy as np
>>>
>>> link_0 = rby_dyn.Link("link_0")
>>> link_1 = rby_dyn.Link("link_1")
>>>
>>> joint_0 = rby_dyn.Joint.make_revolute("joint_0", np.identity(4), np.array([0, 0, 1]))
>>> joint_0.connect_links(link_0, link_1, np.identity(4), np.identity(4))
>>>
>>> dyn_robot = rby_dyn.Robot(
...     rby_dyn.RobotConfiguration(name="sample_robot", base_link=link_0)
... )
>>>
>>> dyn_state = dyn_robot.make_state(["link_0", "link_1"], ["joint_0"])
>>> dyn_state.set_q(np.array([np.pi / 2]))  # Angle of joint_0 is 90 degrees
>>>
>>> dyn_robot.compute_forward_kinematics(dyn_state)
>>> # Calculate transformation from link_0 to link_1
>>> transform = dyn_robot.compute_transformation(dyn_state, 0, 1)  # 0: link_0, 1: link_1
>>> print(transform)
class State#

Bases: pybind11_object

Robot state for dynamics calculations.

This class stores the state of the robot, including joint positions, velocities, accelerations, and torques. It also serves as a cache for intermediate results in dynamics and kinematics calculations to optimize performance.

Index of the base link.

Type:

int

q#

Joint positions vector.

Type:

numpy.ndarray, shape (DOF,)

qdot#

Joint velocities vector.

Type:

numpy.ndarray, shape (DOF,)

qddot#

Joint accelerations vector.

Type:

numpy.ndarray, shape (DOF,)

tau#

Joint torques vector (output of inverse dynamics).

Type:

numpy.ndarray, shape (DOF,)

V0#

Spatial velocity (twist) of the base link.

Type:

numpy.ndarray, shape (6,)

Vdot0#

Spatial acceleration of the base link (used to specify gravity). Note that gravity = -Vdot0.

Type:

numpy.ndarray, shape (6,)

joint_names#

List of joint names.

Type:

list[str]

List of link names.

Type:

list[str]

Get the index of the base link.

Returns:

Index of the base link.

Return type:

int

get_joint_names(self: rby1_sdk.dynamics.State) list[str]#

Get the list of joint names associated with this state.

Returns:

List of joint names.

Return type:

list[str]

Get the list of link names associated with this state.

Returns:

List of link names.

Return type:

list[str]

get_q(self: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Get the joint positions.

Returns:

Joint positions vector.

Return type:

numpy.ndarray

get_qddot(self: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Get the joint accelerations.

Returns:

Joint accelerations vector.

Return type:

numpy.ndarray

get_qdot(self: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Get the joint velocities.

Returns:

Joint velocities vector.

Return type:

numpy.ndarray

get_tau(self: rby1_sdk.dynamics.State) numpy.ndarray[numpy.float64[m, 1]]#

Get the joint torques.

Returns:

Joint torques vector.

Return type:

numpy.ndarray

set_V0(self: rby1_sdk.dynamics.State, V0: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the spatial velocity of the base link.

Parameters:

V0 (numpy.ndarray) – 6D spatial velocity vector (twist).

set_Vdot0(self: rby1_sdk.dynamics.State, Vdot0: numpy.ndarray[numpy.float64[6, 1]]) None#

Set the spatial acceleration of the base link.

Parameters:

Vdot0 (numpy.ndarray) – 6D spatial acceleration vector.

set_gravity(self: rby1_sdk.dynamics.State, gravity: numpy.ndarray[numpy.float64[6, 1]]) None#

Set the gravity vector. This is a convenience function that sets Vdot0 = -gravity.

Parameters:

gravity (numpy.ndarray) – 6D gravity vector (e.g., [0, 0, 0, 0, 0, -9.81]).

set_q(self: rby1_sdk.dynamics.State, q: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint positions.

Parameters:

q (numpy.ndarray) – Joint positions vector.

set_qddot(self: rby1_sdk.dynamics.State, qddot: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint accelerations.

Parameters:

qddot (numpy.ndarray) – Joint accelerations vector.

set_qdot(self: rby1_sdk.dynamics.State, qdot: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint velocities.

Parameters:

qdot (numpy.ndarray) – Joint velocities vector.

set_tau(self: rby1_sdk.dynamics.State, tau: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint torques.

Parameters:

tau (numpy.ndarray) – Joint torques vector.

property V0#
property Vdot0#
property base_link_idx#
property joint_names#
property link_names#
property q#
property qddot#
property qdot#
property tau#
class State_18#

Bases: pybind11_object

Robot state (DOF=18) for dynamics calculations.

This class stores the state of the robot, including joint positions, velocities, accelerations, and torques. It also serves as a cache for intermediate results in dynamics and kinematics calculations to optimize performance.

Index of the base link.

Type:

int

q#

Joint positions vector.

Type:

numpy.ndarray, shape (DOF,)

qdot#

Joint velocities vector.

Type:

numpy.ndarray, shape (DOF,)

qddot#

Joint accelerations vector.

Type:

numpy.ndarray, shape (DOF,)

tau#

Joint torques vector (output of inverse dynamics).

Type:

numpy.ndarray, shape (DOF,)

V0#

Spatial velocity (twist) of the base link.

Type:

numpy.ndarray, shape (6,)

Vdot0#

Spatial acceleration of the base link (used to specify gravity). Note that gravity = -Vdot0.

Type:

numpy.ndarray, shape (6,)

joint_names#

List of joint names.

Type:

list[str]

List of link names.

Type:

list[str]

Get the index of the base link.

Returns:

Index of the base link.

Return type:

int

get_joint_names(self: rby1_sdk.dynamics.State_18) Annotated[list[str], FixedSize(18)]#

Get the list of joint names associated with this state.

Returns:

List of joint names.

Return type:

list[str]

Get the list of link names associated with this state.

Returns:

List of link names.

Return type:

list[str]

get_q(self: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Get the joint positions.

Returns:

Joint positions vector.

Return type:

numpy.ndarray

get_qddot(self: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Get the joint accelerations.

Returns:

Joint accelerations vector.

Return type:

numpy.ndarray

get_qdot(self: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Get the joint velocities.

Returns:

Joint velocities vector.

Return type:

numpy.ndarray

get_tau(self: rby1_sdk.dynamics.State_18) numpy.ndarray[numpy.float64[18, 1]]#

Get the joint torques.

Returns:

Joint torques vector.

Return type:

numpy.ndarray

set_V0(self: rby1_sdk.dynamics.State_18, V0: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the spatial velocity of the base link.

Parameters:

V0 (numpy.ndarray) – 6D spatial velocity vector (twist).

set_Vdot0(self: rby1_sdk.dynamics.State_18, Vdot0: numpy.ndarray[numpy.float64[6, 1]]) None#

Set the spatial acceleration of the base link.

Parameters:

Vdot0 (numpy.ndarray) – 6D spatial acceleration vector.

set_gravity(self: rby1_sdk.dynamics.State_18, gravity: numpy.ndarray[numpy.float64[6, 1]]) None#

Set the gravity vector. This is a convenience function that sets Vdot0 = -gravity.

Parameters:

gravity (numpy.ndarray) – 6D gravity vector (e.g., [0, 0, 0, 0, 0, -9.81]).

set_q(self: rby1_sdk.dynamics.State_18, q: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint positions.

Parameters:

q (numpy.ndarray) – Joint positions vector.

set_qddot(self: rby1_sdk.dynamics.State_18, qddot: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint accelerations.

Parameters:

qddot (numpy.ndarray) – Joint accelerations vector.

set_qdot(self: rby1_sdk.dynamics.State_18, qdot: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint velocities.

Parameters:

qdot (numpy.ndarray) – Joint velocities vector.

set_tau(self: rby1_sdk.dynamics.State_18, tau: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint torques.

Parameters:

tau (numpy.ndarray) – Joint torques vector.

property V0#
property Vdot0#
property base_link_idx#
property joint_names#
property link_names#
property q#
property qddot#
property qdot#
property tau#
class State_24#

Bases: pybind11_object

Robot state (DOF=24) for dynamics calculations.

This class stores the state of the robot, including joint positions, velocities, accelerations, and torques. It also serves as a cache for intermediate results in dynamics and kinematics calculations to optimize performance.

Index of the base link.

Type:

int

q#

Joint positions vector.

Type:

numpy.ndarray, shape (DOF,)

qdot#

Joint velocities vector.

Type:

numpy.ndarray, shape (DOF,)

qddot#

Joint accelerations vector.

Type:

numpy.ndarray, shape (DOF,)

tau#

Joint torques vector (output of inverse dynamics).

Type:

numpy.ndarray, shape (DOF,)

V0#

Spatial velocity (twist) of the base link.

Type:

numpy.ndarray, shape (6,)

Vdot0#

Spatial acceleration of the base link (used to specify gravity). Note that gravity = -Vdot0.

Type:

numpy.ndarray, shape (6,)

joint_names#

List of joint names.

Type:

list[str]

List of link names.

Type:

list[str]

Get the index of the base link.

Returns:

Index of the base link.

Return type:

int

get_joint_names(self: rby1_sdk.dynamics.State_24) Annotated[list[str], FixedSize(24)]#

Get the list of joint names associated with this state.

Returns:

List of joint names.

Return type:

list[str]

Get the list of link names associated with this state.

Returns:

List of link names.

Return type:

list[str]

get_q(self: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Get the joint positions.

Returns:

Joint positions vector.

Return type:

numpy.ndarray

get_qddot(self: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Get the joint accelerations.

Returns:

Joint accelerations vector.

Return type:

numpy.ndarray

get_qdot(self: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Get the joint velocities.

Returns:

Joint velocities vector.

Return type:

numpy.ndarray

get_tau(self: rby1_sdk.dynamics.State_24) numpy.ndarray[numpy.float64[24, 1]]#

Get the joint torques.

Returns:

Joint torques vector.

Return type:

numpy.ndarray

set_V0(self: rby1_sdk.dynamics.State_24, V0: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the spatial velocity of the base link.

Parameters:

V0 (numpy.ndarray) – 6D spatial velocity vector (twist).

set_Vdot0(self: rby1_sdk.dynamics.State_24, Vdot0: numpy.ndarray[numpy.float64[6, 1]]) None#

Set the spatial acceleration of the base link.

Parameters:

Vdot0 (numpy.ndarray) – 6D spatial acceleration vector.

set_gravity(self: rby1_sdk.dynamics.State_24, gravity: numpy.ndarray[numpy.float64[6, 1]]) None#

Set the gravity vector. This is a convenience function that sets Vdot0 = -gravity.

Parameters:

gravity (numpy.ndarray) – 6D gravity vector (e.g., [0, 0, 0, 0, 0, -9.81]).

set_q(self: rby1_sdk.dynamics.State_24, q: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint positions.

Parameters:

q (numpy.ndarray) – Joint positions vector.

set_qddot(self: rby1_sdk.dynamics.State_24, qddot: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint accelerations.

Parameters:

qddot (numpy.ndarray) – Joint accelerations vector.

set_qdot(self: rby1_sdk.dynamics.State_24, qdot: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint velocities.

Parameters:

qdot (numpy.ndarray) – Joint velocities vector.

set_tau(self: rby1_sdk.dynamics.State_24, tau: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint torques.

Parameters:

tau (numpy.ndarray) – Joint torques vector.

property V0#
property Vdot0#
property base_link_idx#
property joint_names#
property link_names#
property q#
property qddot#
property qdot#
property tau#
class State_26#

Bases: pybind11_object

Robot state (DOF=26) for dynamics calculations.

This class stores the state of the robot, including joint positions, velocities, accelerations, and torques. It also serves as a cache for intermediate results in dynamics and kinematics calculations to optimize performance.

Index of the base link.

Type:

int

q#

Joint positions vector.

Type:

numpy.ndarray, shape (DOF,)

qdot#

Joint velocities vector.

Type:

numpy.ndarray, shape (DOF,)

qddot#

Joint accelerations vector.

Type:

numpy.ndarray, shape (DOF,)

tau#

Joint torques vector (output of inverse dynamics).

Type:

numpy.ndarray, shape (DOF,)

V0#

Spatial velocity (twist) of the base link.

Type:

numpy.ndarray, shape (6,)

Vdot0#

Spatial acceleration of the base link (used to specify gravity). Note that gravity = -Vdot0.

Type:

numpy.ndarray, shape (6,)

joint_names#

List of joint names.

Type:

list[str]

List of link names.

Type:

list[str]

Get the index of the base link.

Returns:

Index of the base link.

Return type:

int

get_joint_names(self: rby1_sdk.dynamics.State_26) Annotated[list[str], FixedSize(26)]#

Get the list of joint names associated with this state.

Returns:

List of joint names.

Return type:

list[str]

Get the list of link names associated with this state.

Returns:

List of link names.

Return type:

list[str]

get_q(self: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Get the joint positions.

Returns:

Joint positions vector.

Return type:

numpy.ndarray

get_qddot(self: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Get the joint accelerations.

Returns:

Joint accelerations vector.

Return type:

numpy.ndarray

get_qdot(self: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Get the joint velocities.

Returns:

Joint velocities vector.

Return type:

numpy.ndarray

get_tau(self: rby1_sdk.dynamics.State_26) numpy.ndarray[numpy.float64[26, 1]]#

Get the joint torques.

Returns:

Joint torques vector.

Return type:

numpy.ndarray

set_V0(self: rby1_sdk.dynamics.State_26, V0: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the spatial velocity of the base link.

Parameters:

V0 (numpy.ndarray) – 6D spatial velocity vector (twist).

set_Vdot0(self: rby1_sdk.dynamics.State_26, Vdot0: numpy.ndarray[numpy.float64[6, 1]]) None#

Set the spatial acceleration of the base link.

Parameters:

Vdot0 (numpy.ndarray) – 6D spatial acceleration vector.

set_gravity(self: rby1_sdk.dynamics.State_26, gravity: numpy.ndarray[numpy.float64[6, 1]]) None#

Set the gravity vector. This is a convenience function that sets Vdot0 = -gravity.

Parameters:

gravity (numpy.ndarray) – 6D gravity vector (e.g., [0, 0, 0, 0, 0, -9.81]).

set_q(self: rby1_sdk.dynamics.State_26, q: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint positions.

Parameters:

q (numpy.ndarray) – Joint positions vector.

set_qddot(self: rby1_sdk.dynamics.State_26, qddot: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint accelerations.

Parameters:

qddot (numpy.ndarray) – Joint accelerations vector.

set_qdot(self: rby1_sdk.dynamics.State_26, qdot: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint velocities.

Parameters:

qdot (numpy.ndarray) – Joint velocities vector.

set_tau(self: rby1_sdk.dynamics.State_26, tau: numpy.ndarray[numpy.float64[m, 1]]) None#

Set the joint torques.

Parameters:

tau (numpy.ndarray) – Joint torques vector.

property V0#
property Vdot0#
property base_link_idx#
property joint_names#
property link_names#
property q#
property qddot#
property qdot#
property tau#
load_robot_from_urdf(path: str, base_link_name: str) rby1_sdk.dynamics.RobotConfiguration#

Load a robot model from a URDF file.

This function reads a URDF file from the given path and constructs a robot model based on its description.

Parameters:
  • path (str) – File system path to the URDF file.

  • base_link_name (str) – Name of the base link in the URDF. This will be used as the reference link of the robot.

Returns:

The loaded robot model instance.

Return type:

Robot

Examples

>>> robot = load_robot_from_urdf("path/to/robot.urdf", "base_link")
load_robot_from_urdf_data(model: str, base_link_name: str) rby1_sdk.dynamics.RobotConfiguration#

Load a robot model from URDF data string.

This function parses URDF XML content directly from a string and constructs a robot model. It is useful when URDF data is already loaded in memory and does not need to be read from a file.

Parameters:
  • model (str) – URDF XML data as a string.

  • base_link_name (str) – Name of the base link in the URDF. This will be used as the reference link of the robot.

Returns:

The loaded robot model instance.

Return type:

Robot

Examples

>>> with open("robot.urdf") as f:
...     urdf_data = f.read()
>>> robot = load_robot_from_urdf_data(urdf_data, "base_link")