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.
ExponentialCable
¶
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.
MuscleModel
¶
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
¶
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 a TensionDrive cable's tension (N) >= 0. Takes effect on the next step; raises for any other actuator.
set_cable_length
¶
Set a LengthDrive cable's target length (m) > 0. Takes effect on the next step; raises for any other actuator.
cable_length
¶
A cable's polyline length at the last accepted step (m); the rest length before the first.
cable_tension
¶
A cable's tension at the last accepted step (N); 0 before the first.
cable_points
¶
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 a muscle's or fiber muscle's activation, in [0, 1]. Takes effect on the next step; raises for any other actuator.
muscle_activation
¶
A muscle's or fiber muscle's activation.
muscle_length
¶
A muscle's polyline length at the last accepted step (m); the rest length before the first.
muscle_tension
¶
A muscle's tension at the last accepted step (N); 0 before the first.
muscle_points
¶
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 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 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
¶
A revolute or prismatic joint drive's target (rad or m).
joint_effort
¶
A revolute or prismatic joint drive's effort (N*m or N).
joint_position
¶
A joint drive's coordinate at the last accepted step: hinge angle (rad) or slide (m).
set_project_positive_definite
¶
PSD-project this module's Hessians on every Newton iteration (default off). Call before the first step().