robot_msgs

Trajectory

Samples at strictly increasing times t (seconds after header.stamp).

Full docstring
A bare `Trajectory` is just `t` plus `channels` — enough for any time series. Domain
trajectories (`JointTrajectory`, `PoseTrajectory`, your own) subclass it and declare typed
per-sample fields with `sample()`; they inherit everything below.
Import
from robot_msgs.trajectory import Trajectory
ROS 2no ROS equivalent

Preview

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

Plot of an example Trajectory

Fields

NameTypeDefault
tArrayrequired
channelsMapping[str, Array]{}
headerHeaderHeader()

Example

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

Trajectory(N=3, t=[0 … 0.2] s, channels={'temperature': [20. , 20.5, 21. ]})
to_dict() as JSON
{
  "_type": "trajectory/Trajectory",
  "t": {
    "dtype": "<f8",
    "shape": [3],
    "data": [0.0, 0.1, 0.2]
  },
  "channels": {
    "temperature": {
      "dtype": "<f8",
      "shape": [3],
      "data": [20.0, 20.5, 21.0]
    }
  },
  "header": {
    "_type": "std/Header",
    "stamp": 0.0,
    "frame_id": "",
    "meta": {}
  }
}

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

Functions

Constructors

Classmethods and staticmethods: ways to build one.

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.

from_dict

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

No docstring.

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.

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.

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_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.

replace

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

A copy with some fields changed. Validation runs again.

to_dict

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

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

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

Extended by

Types that specialise it.

JointTrajectory PoseTrajectory

Sample type

What traj[i] returns.

TrajectoryPoint

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