Skip to content

piece_pose

Python reference for nagasim.appearance.piece_pose. Provisional: it may change between minor versions, see Appearance.

The pose on a conveyor piece's centreline at a distance along its path.

distance is in metres from the piece's start and is clamped to the piece, so 0 gives piece_start and piece_length_m gives its end. The heading is the direction of travel there, in degrees clockwise on screen; it is not folded into [0, 360), so a left arc from a heading of 0 ends at -90. The reference drawing places each leg, roller, drive and guide post at such a pose.

Parameters:

Name Type Description Default
document ModelDocument

The model, ModelDocument.load(path).

required
name str

The CONVEYOR block's name.

required
distance float

Metres along the path from the piece's start.

required

Returns:

Type Description
Pose or None

Pose(x, y, heading) in plan coordinates; None in the cases piece_start returns None.

See Also

nagasim.appearance.piece_start : The pose at distance 0. nagasim.appearance.piece_length_m : The distance of the piece's end.

Examples:

>>> from nagasim.appearance import ModelDocument, piece_pose
>>> doc = ModelDocument({"blocks": [{"name": "Belt", "type": "CONVEYOR",
...     "params": {"type": "roller",
...                "path": [{"straight": 4}, {"arc": {"radius": 1, "angle": 90, "turn": "right"}}]}}]})
>>> piece_pose(doc, "Belt", 2)
Pose(x=2.0, y=0.0, heading=0.0)
>>> end = piece_pose(doc, "Belt", 100)
>>> round(end.x, 3), round(end.y, 3), round(end.heading, 3)
(5.0, 1.0, 90.0)