Skip to content

trusty.rods

Discrete elastic rods.

RodDiscretization

Bases: Enum

DiscreteElasticRods class-attribute instance-attribute

DiscreteElasticRods = 0

RodMaterial

youngs_modulus property writable

youngs_modulus: float

poisson_ratio property writable

poisson_ratio: float

radius property writable

radius: float

density property writable

density: float

discretization property writable

discretization: RodDiscretization

add_rod

add_rod(
    world: World,
    X: ndarray[float64, (N, M)],
    material: RodMaterial,
    *,
    friction_mu: float = 0.0,
) -> int

Add a polyline rod body (X is (num_verts, 3) in order). Multiple add_rod calls create multiple rods in one simulation. friction_mu is the body's surface Coulomb coefficient (>= 0); 0 is frictionless.

pin_vertices

pin_vertices(
    world: World, body: int, indices: Sequence[int]
) -> None

pin_twist

pin_twist(
    world: World, body: int, edge_indices: Sequence[int]
) -> None

read_positions

read_positions(
    world: World, body: int
) -> ndarray[float64, (N, 3)]

add_rod_muscle

add_rod_muscle(
    world: World,
    body: int,
    path_vertices: Sequence[int],
    f_max: float,
    l_opt: float,
    l_tendon_slack: float,
    pennation: float = 0.0,
    activation: float = 0.0,
) -> int

Add a Hill-type muscle on the arc length of a rod's path_vertices (ordered local indices). Returns the muscle entity for rods.set_muscle_activation / rods.muscle_{length,force}.

num_muscles

num_muscles(world: World, body: int) -> int

Number of rod muscles attached to body.

set_muscle_activation

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

Set a rod muscle's activation in [0, 1]. Held until changed; takes effect on the next step.

muscle_activation

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

Current activation of a rod muscle.

muscle_length

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

Muscle path length (m) from the accepted state; its rest path length before the first step.

muscle_force

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

Hill tension (N) along the muscle at its published length; zero before the first step.