robot_msgs

Python · numpy only · MIT

robot_msgs — the standard vocabulary for robot data

ROS's geometry_msgs, sensor_msgs, trajectory_msgs and vision_msgs as frozen Python dataclasses, with the functions that move between them: offset a pose, interpolate a trajectory, project a point, turn a depth image into a cloud.

pip install robot-msgs

PyPI release coming.

ROS's shape, not ROS

Same packages and field names, so the ROS docs are our docs. No ROS install, no codegen. ROS 2 messages and bags are an export, not the programming model.

One entity, many views

A trajectory is one value with batch arrays, single points, slices and interpolation, not 500 point messages. Views are free; messages are immutable.

numpy only

One runtime dependency. Plots and ROS export are optional extras that the core never imports.

A tour in one screen

This is examples/tour.py, run for real; the output below is what it printed.

import numpy as np

from robot_msgs.geometry import Pose
from robot_msgs.trajectory import JointTrajectory

t = np.linspace(0.0, 2.0, 201)
traj = JointTrajectory(
    t=t,
    joint_names=("shoulder", "elbow"),
    positions=np.stack([np.sin(t), np.cos(t)], axis=1),
).with_derivatives()

print(traj)  # a summary, never 400 numbers
print(traj.positions.shape)  # batch view, no copy
print(traj[100])  # one point
print(traj.at(0.123).positions)  # interpolated at any time
for point in traj[:2]:  # slices are views too
    print(point.t, point.positions)
print(traj.joint("elbow").joint_names)  # one joint, still a JointTrajectory
print(traj.resample(dt=0.5).t)  # onto a fixed grid

grasp = Pose.from_xyz_rpy(0.5, 0.0, 0.2, np.pi, 0.0, 0.0)  # tool pointing down
pregrasp = grasp.shifted(dz=-0.10, local=True)  # back off along the tool
print(pregrasp.position)

Output

JointTrajectory(N=201, t=[0 … 2] s, joint_names=('shoulder', 'elbow'), positions=float64[201×2], velocities=float64[201×2], accelerations=float64[201×2])
(201, 2)
JointTrajectoryPoint(t=1.0, positions=[0.8415, 0.5403], velocities=[ 0.5403, -0.8415], accelerations=[-0.8414, -0.5403])
[0.12268879 0.99243461]
0.0 [0. 1.]
0.01 [0.00999983 0.99995   ]
('elbow',)
[0.  0.5 1.  1.5 2. ]
Point(x=0.5, y=1.2246467991473533e-17, z=0.30000000000000004)

Packages

Every message has == and hash by value, a short repr, replace(...), to_dict() / from_dict(), save_npz / load_npz and pickling. See all types.