robot_msgs

PoseTrajectory

positions (N, 3) in metres, orientations (N, 4) xyzw, optional twist per sample.

Full docstring
Orientations are slerped between samples and normalised at construction. Velocities are
expressed in the reference frame (`header.frame_id`).
Import
from robot_msgs.trajectory import PoseTrajectory
ROS 2nav_msgs/msg/Path

Preview

The figure robot_msgs.viz.plot(example) draws for the example below.

Plot of an example PoseTrajectory

Fields

NameTypeDefault
tArrayrequired
channelsMapping[str, Array]{}
headerHeaderHeader()
child_frame_idstr''
positions per sampleArrayrequired
orientations per sampleArrayrequired
linear_velocities per sampleArray | NoneNone
angular_velocities per sampleArray | NoneNone

Example

One instance from the package's own test catalog; the output is its real repr().

PoseTrajectory(N=3, t=[0 … 1] s, header=Header(stamp=0.0, frame_id='base_link'), child_frame_id='tool0', positions=float64[3×3], orientations=float64[3×4], linear_velocities=float64[3×3], angular_velocities=float64[3×3])
to_dict() as JSON
{
  "_type": "trajectory/PoseTrajectory",
  "t": {
    "dtype": "<f8",
    "shape": [3],
    "data": [0.0, 0.5, 1.0]
  },
  "channels": {},
  "header": {
    "_type": "std/Header",
    "stamp": 0.0,
    "frame_id": "base_link",
    "meta": {}
  },
  "child_frame_id": "tool0",
  "positions": {
    "dtype": "<f8",
    "shape": [3, 3],
    "data": [0.4, -0.1, 0.25, 0.4, -0.1, 0.14999999999999997, 0.4, -0.1, 0.25]
  },
  "orientations": {
    "dtype": "<f8",
    "shape": [3, 4],
    "data": [-0.10566871683993562, 0.6991667342497077, 0.10566871683993563, 0.6991667342497078, -0.035340609509366974, 0.7062230818371108, 0.17494101728127348, 0.6851245437674769, -0.10566871683993562, 0.6991667342497077, 0.10566871683993563, 0.6991667342497078]
  },
  "linear_velocities": {
    "dtype": "<f8",
    "shape": [3, 3],
    "data": [-1.1102230246251565e-16, 2.7755575615628914e-17, -0.40000000000000013, 0.0, 0.0, 0.0, 0.0, 0.0, 0.40000000000000013]
  },
  "angular_velocities": {
    "dtype": "<f8",
    "shape": [3, 3],
    "data": [0.3821345956502424, 0.11820808266453608, -5.560377786892211e-17, 2.7755575615628914e-17, 6.938893903907228e-17, 0.0, -0.3821345956502423, -0.11820808266453595, 5.560377786892211e-17]
  }
}

Long arrays are cut after 16 values and say so with “…”.

Functions

Constructors

Classmethods and staticmethods: ways to build one.

from_matrices(
    t: Sequence[float],
    matrices: np.ndarray,
    **static: object,
) -> PoseTrajectory

From (N, 4, 4) homogeneous transforms (what FK usually returns).

from_poses(
    t: Sequence[float],
    poses: Sequence[Pose],
    **static: object,
) -> PoseTrajectory

No docstring.

from_dict

from Msg
from_dict(data: Mapping[str, Any]) -> M

No docstring.

from_points(
    points: Sequence[TrajectoryPoint],
    **static: Any,
) -> TrajectoryT

Stack points back into one trajectory; static sets the per-trajectory fields.

from_samples(
    t: Any,
    duplicate_times: DuplicateTimes,
    **fields: Any,
) -> tuple[TrajectoryT, TimeRepair]

Build from recorded samples whose stamps may repeat or step back; say what changed.

Properties

Read-only views computed from the fields.

absolute_times: np.ndarray

t on the header's clock: header.stamp + t.

dt: float

The fixed sample step. Raises on a non-uniform trajectory rather than guess.

duration: float

No docstring.

end_time: float

No docstring.

sample_names: tuple[str, ...]

Names of every per-sample array that is set: typed fields, then channels.

start_time: float

No docstring.

Methods

Return new values; messages are never mutated.

matrices() -> np.ndarray

(N, 4, 4) homogeneous transforms, reference ← child.

path_length() -> float

Distance travelled by the origin of the child frame, in metres.

pose_at(time: float, *, extrapolate: Extrapolation = 'raise') -> Pose

No docstring.

poses() -> tuple[Pose, ...]

No docstring.

rotated(
    roll: float = 0.0,
    pitch: float = 0.0,
    yaw: float = 0.0,
    local: bool = False,
) -> PoseTrajectory

Every pose turned in place by ROS RPY, about the reference axes or its own.

shifted(
    dx: float = 0.0,
    dy: float = 0.0,
    dz: float = 0.0,
    local: bool = False,
) -> PoseTrajectory

Every pose moved by (dx, dy, dz): along the reference axes, or along each pose's

transformed(
    transform: Transform | Pose,
    frame_id: str | None = None,
) -> PoseTrajectory

Re-express in another frame: T_new_child = transform @ T_old_child.

with_derivatives(*, overwrite: bool = False) -> PoseTrajectory

Fill missing linear/angular velocity by finite differences on the real time grid.

at(
    time: float,
    extrapolate: Extrapolation = 'raise',
) -> TrajectoryPoint

The point at time, interpolated per field (sample(interp=...)).

is_uniform(rtol: float = 1e-06) -> bool

True when every sample step equals the mean step within rtol.

rebased() -> TrajectoryT

Same trajectory with t[0] == 0; the offset moves into header.stamp.

replace

from Msg
replace(**changes: Any) -> M

A copy with some fields changed. Validation runs again.

resample(
    times: Any = None,
    dt: float | None = None,
    extrapolate: Extrapolation = 'raise',
) -> TrajectoryT

The trajectory at new times, or on a fixed dt grid from start_time.

time_shifted(seconds: float) -> TrajectoryT

Every sample seconds later (earlier if negative).

to_dict

from Msg
to_dict() -> dict[str, Any]

JSON-safe dict with a "_type" key; arrays keep their dtype and shape.

to_points() -> tuple[TrajectoryPoint, ...]

Array-of-structs view (what ROS puts on the wire).

window(start: float, end: float) -> TrajectoryT

Samples with start <= t <= end, as a view.

with_channel(name: str, values: Any) -> TrajectoryT

No docstring.

without_channel(name: str) -> TrajectoryT

No docstring.

Operators

Python operators and protocols the type supports.

__getitem__(key: Any) -> Any

str → a field's array · int → a point · slice, mask, indices → a trajectory.

__iter__() -> Iterator[TrajectoryPoint]

No docstring.

__len__() -> int

No docstring.

Uses

Types its fields refer to.

Header

Extends

The base class it specialises.

Trajectory

Sample type

What traj[i] returns.

PoseTrajectoryPoint

robot_msgs 0.1.0 @ 2dc6666GitHub · MIT license · generated from the package, not written per type