Skip to content

trusty.actuators

Actuators: cables, muscles, fiber muscles and joint drives.

TensionDrive

A cable driven by its tension (N): energy T * L.

LinearCable

A cable force law linear in the strain e = (L - L_t) / L_t from the target length: tension EA * e, with axial_stiffness EA (N) > 0; the default is about a 1 mm steel cable.

axial_stiffness property

axial_stiffness: float

ExponentialCable

A cable force law that stiffens with the strain e = (L - L_t) / L_t from the target length: tension (EA / c) * (exp(c * e) - 1), with axial_stiffness EA (N) > 0, the slope at zero strain, and exponent c > 0.

axial_stiffness property

axial_stiffness: float

exponent property

exponent: float

LengthDrive

A cable driven by a winch setting its target length L_t (m): tension follows law (LinearCable or ExponentialCable, default LinearCable()) in the strain (L - L_t) / L_t, and is zero below L_t.

law property

law: LinearCable | ExponentialCable

MuscleModel

Bases: Enum

Hill class-attribute instance-attribute

Hill = 0

Polynomial class-attribute instance-attribute

Polynomial = 1

add_cable

add_cable(
    world: World,
    bodies: int | Sequence[int],
    positions: ndarray[float64, (N, 3)],
    drive: TensionDrive | LengthDrive = ...,
) -> int

Attach a cable (tendon) along a polyline. bodies is one body (every point on it) or one body per point; positions (n >= 2, 3) are rest-world points (m), each moving as its body interpolates it: FEM, embedded, affine and subspace bodies take points inside or outside their rest volume, shells points on their rest midsurface, rods points on their rest centerline. The polyline length sums the segments joining consecutive points; close a loop by repeating the first point at the end. drive (TensionDrive() or LengthDrive(law=...)) is fixed for the cable's life. The cable starts slack: zero tension, or a target length equal to the polyline's. Returns the cable entity.

add_muscle

add_muscle(
    world: World,
    bodies: int | Sequence[int],
    positions: ndarray[float64, (N, 3)],
    f_max: float,
    l_opt: float,
    l_tendon_slack: float,
    pennation: float = 0.0,
    model: MuscleModel = MuscleModel.Hill,
) -> int

Attach a Hill-type muscle along a polyline. bodies is one body (every point on it) or one body per point; positions (n >= 2, 3) are rest-world points (m), each moving as its body interpolates it: FEM, embedded, affine and subspace bodies take points inside or outside their rest volume, shells points on their rest midsurface, rods points on their rest centerline. The polyline length sums the segments joining consecutive points; close a loop by repeating the first point at the end. f_max (N), l_opt (optimal fiber length, m), l_tendon_slack (m), pennation (rad); model (MuscleModel.Hill or MuscleModel.Polynomial) is the force-length law. Starts at activation 0. Returns the muscle entity.

add_fiber_muscle

add_fiber_muscle(
    world: World,
    body: int,
    directions: ndarray[float64, (N, 3)],
    stiffness: float | ndarray[float64, (N,)],
) -> int

Attach a fiber muscle to a fem or subspace solid: energy 0.5 * activation * sum_e stiffness_e wJ |F u_e|^2, contracting the body along the fiber. directions is the rest-frame fiber, (1, 3) to broadcast one direction or (num_elements, 3); stiffness in Pa, a number or a (num_elements,) array, each >= 0 and at least one > 0; a zero-stiffness element (a tendon) does not contract. Starts at activation 0. For a subspace body, declare it on the precompute world too, before building the basis. The first step raises for one on any other body, or for a directions or stiffness whose length is neither 1 nor the body's element count. Returns the fiber muscle entity.

add_joint_drive

add_joint_drive(
    world: World,
    joint: int,
    stiffness: float,
    damping: float = 0.0,
) -> int

Drive an affine joint's free coordinate (revolute angle, prismatic slide, spherical relative rotation) to a target with an implicit position servo of gain stiffness >= 0: energy 0.5 k (theta - target)^2 revolute (Nm/rad), 0.5 k (s - target)^2 prismatic (N/m), 0.5 k ||A_i - A_j R||_F^2 spherical (Nm). damping >= 0 adds the torque (force) -damping * v on the end-of-step joint rate v (Nms/rad revolute and spherical, Ns/m prismatic). The target starts at the joint's rest configuration and the effort (set_joint_effort) at 0, so a drive of stiffness 0 is a pure torque source. Raises for a non-joint. Returns the drive entity.

set_cable_tension

set_cable_tension(
    world: World, cable: int, tension: float
) -> None

Set a TensionDrive cable's tension (N) >= 0. Takes effect on the next step; raises for any other actuator.

set_cable_length

set_cable_length(
    world: World, cable: int, length: float
) -> None

Set a LengthDrive cable's target length (m) > 0. Takes effect on the next step; raises for any other actuator.

cable_length

cable_length(world: World, cable: int) -> float

A cable's polyline length at the last accepted step (m); the rest length before the first.

cable_tension

cable_tension(world: World, cable: int) -> float

A cable's tension at the last accepted step (N); 0 before the first.

cable_points

cable_points(
    world: World, cable: int
) -> ndarray[float64, (N, 3)]

A cable's polyline points at the last accepted step, (n, 3) world positions (m); the rest positions before the first.

set_muscle_activation

set_muscle_activation(
    world: World, muscle: int, activation: float
) -> None

Set a muscle's or fiber muscle's activation, in [0, 1]. Takes effect on the next step; raises for any other actuator.

muscle_activation

muscle_activation(world: World, muscle: int) -> float

A muscle's or fiber muscle's activation.

muscle_length

muscle_length(world: World, muscle: int) -> float

A muscle's polyline length at the last accepted step (m); the rest length before the first.

muscle_tension

muscle_tension(world: World, muscle: int) -> float

A muscle's tension at the last accepted step (N); 0 before the first.

muscle_points

muscle_points(
    world: World, muscle: int
) -> ndarray[float64, (N, 3)]

A muscle's polyline points at the last accepted step, (n, 3) world positions (m); the rest positions before the first.

set_joint_target

set_joint_target(
    world: World,
    drive: int,
    target: float | ndarray[float64, (3, 3)],
) -> None

Set a joint drive's target: revolute angle (rad), prismatic slide (m), or a 3x3 rotation for a spherical joint. Takes effect on the next step; raises for any other actuator.

set_joint_effort

set_joint_effort(
    world: World, drive: int, effort: float
) -> None

Set a revolute or prismatic joint drive's effort: a torque (N*m) about the hinge or a force (N) along the slide, positive toward increasing angle or slide (energy -effort * theta). Takes effect on the next step; the first step raises for a spherical joint.

joint_target

joint_target(world: World, drive: int) -> float

A revolute or prismatic joint drive's target (rad or m).

joint_effort

joint_effort(world: World, drive: int) -> float

A revolute or prismatic joint drive's effort (N*m or N).

joint_position

joint_position(world: World, drive: int) -> float

A joint drive's coordinate at the last accepted step: hinge angle (rad) or slide (m).

num_actuators

num_actuators(world: World) -> int

Number of actuators of every kind in the world.

set_project_positive_definite

set_project_positive_definite(
    world: World, project: bool
) -> None

PSD-project this module's Hessians on every Newton iteration (default off). Call before the first step().

project_positive_definite

project_positive_definite(world: World) -> bool