robot_msgs

Comparison

What robot_msgs.compare.compare(reference, measured) returns.

Full docstring
- `error` is a trajectory of the *same type* as the inputs, on the measured run's own
  samples, holding ``reference - measured`` (the ROS 2 controller-state convention): joint
  error is a `JointTrajectory`, pose error a `PoseTrajectory`. Derived error forms (rotation
  vector, lag, cross-track, …) ride along as `channels`. WHY one type, not a parallel
  "error" schema: plots, resampling, slicing and serialisation already work on it.
- `metrics` maps a stable name (``"positions/j2"``, ``"position"``, ``"lag"``,
  ``"channels/closure_gap"``) to its `ErrorStats`.
- `time_offset_s`, `dropped` and `coverage` record how the two were lined up, so a number is
  never separated from the decision that produced it: the offset applied to the measured
  clock, how many measured samples fell outside the reference (never extrapolated), and the
  fraction of the reference's duration the measured run covers.
Import
from robot_msgs.compare import Comparison
ROS 2no ROS equivalent

Fields

NameTypeDefault
errorTrajectoryrequired
metricsMapping[str, ErrorStats]{}
time_offset_sfloat0.0
droppedint0
coveragefloat1.0

Example

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

Comparison(error=JointTrajectory(N=11, t=[0 … 1] s, channels={'kp': float64[11×3]}, header=Header(stamp=12.0, frame_id='base_link'), joint_names=('j1', 'j2', 'j3'), positions=float64[11×3], velocities=float64[11×3]), metrics={'positions/j1': ErrorStats(n=11, rms=0.1478360001370795, mean=-0.02971577105855816, median=0.026962032734189345, std=0.14481870005950864, min=-0.3322999516645124, max=0.20199861291473598, max_abs=0.3322999516645124, p95_abs=0.26819593190151547, final=0.0886459943160588, iae=0.11002572035691702, ise=0.02156545018475165, itae=0.04254478760804756), 'positions/j2': ErrorStats(n=11, rms=0.08682948021772133, mean=0.025909194832599715, median=0.023193237764417368, std=0.08287383337342401, min=-0.05451055226877033, max=0.25556650313141827, max_abs=0.25556650313141827, p95_abs=0.16118556887115854, final=0.029172023243986434, iae=0.050130441120635964, ise=0.004985032275219179, itae=0.019665167975216218), 'positions/j3': ErrorStats(n=11, rms=0.08553786679615684, mean=-0.009362955341224121, median=0.021559716308978877, std=0.0850238891330861, min=-0.19350880340989174, max=0.10551505512051484, max_abs=0.19350880340989174, p95_abs=0.1495119292652033, final=-0.08825389674564843, iae=0.06844354034641323, ise=0.007571558484284488, itae=0.041013665997665344), 'velocities/j1': ErrorStats(n=11, rms=5.88567703535677e-15, mean=1.838176075998697e-15, median=8.187894806610529e-16, std=5.591270238340487e-15, min=-8.43769498715119e-15, max=1.2434497875801753e-14, max_abs=1.2434497875801753e-14, p95_abs=1.0436096431476471e-14, final=0.0, iae=4.8142045905308355e-15, ise=3.810531358097866e-29, itae=2.2362667273512214e-15), 'velocities/j2': ErrorStats(n=11, rms=6.7109168834422075e-15, mean=1.7732027967166562e-15, median=0.0, std=6.472415102431696e-15, min=-6.9735883734267645e-15, max=1.6431300764452317e-14, max_abs=1.6431300764452317e-14, p95_abs=1.354472090042691e-14, final=0.0, iae=5.01057528801141e-15, ise=4.954004595811664e-29, itae=2.5116714263972993e-15), 'velocities/j3': ErrorStats(n=11, rms=5.424424051738637e-15, mean=-1.3369986935755792e-15, median=0.0, std=5.257072453985944e-15, min=-1.199040866595169e-14, max=5.773159728050814e-15, max_abs=1.199040866595169e-14, p95_abs=1.0852430065710905e-14, final=0.0, iae=4.18033663240891e-15, ise=3.236681392238867e-29, itae=1.762028023488682e-15), 'channels/kp/j1': ErrorStats(n=11, rms=0.0, mean=0.0, median=0.0, std=0.0, min=0.0, max=0.0, max_abs=0.0, p95_abs=0.0, final=0.0, iae=0.0, ise=0.0, itae=0.0), 'channels/kp/j2': ErrorStats(n=11, rms=0.0, mean=0.0, median=0.0, std=0.0, min=0.0, max=0.0, max_abs=0.0, p95_abs=0.0, final=0.0, iae=0.0, ise=0.0, itae=0.0), 'channels/kp/j3': ErrorStats(n=11, rms=0.0, mean=0.0, median=0.0, std=0.0, min=0.0, max=0.0, max_abs=0.0, p95_abs=0.0, final=0.0, iae=0.0, ise=0.0, itae=0.0)}, time_offset_s=0.0, dropped=0, coverage=1.0)
to_dict() as JSON
{
  "_type": "compare/Comparison",
  "error": {
    "_type": "trajectory/JointTrajectory",
    "t": {
      "dtype": "<f8",
      "shape": [11],
      "data": [0.0, 0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6000000000000001, 0.7000000000000001, 0.8, 0.9, 1.0]
    },
    "channels": {
      "kp": {
        "dtype": "<f8",
        "shape": [11, 3],
        "data": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, "… 17 more values"]
      }
    },
    "header": {
      "_type": "std/Header",
      "stamp": 12.0,
      "frame_id": "base_link",
      "meta": {}
    },
    "joint_names": ["j1", "j2", "j3"],
    "positions": {
      "dtype": "<f8",
      "shape": [11, 3],
      "data": [-0.20409191213851852, 0.25556650313141827, -0.0418098846725779, 0.05677696061280224, 0.04526492921103714, 0.021559716308978877, 0.20199861291473598, 0.023193237764417368, 0.08652130762749888, -0.3322999516645124, -0.02257866132279815, 0.035263079434154854, 0.02812874181513475, 0.0668046346108988, 0.10551505512051484, 0.03908009772346549, "… 17 more values"]
    },
    "velocities": {
      "dtype": "<f8",
      "shape": [11, 3],
      "data": [0.0, 0.0, 0.0, 1.2434497875801753e-14, -3.3306690738754696e-15, 5.773159728050814e-15, -8.43769498715119e-15, 5.384581669432009e-15, -1.199040866595169e-14, 2.609024107869118e-15, 1.6431300764452317e-14, 4.805184028455756e-15, 8.187894806610529e-16, -8.881784197001252e-16, -3.1086244689504383e-15, 0.0, "… 17 more values"]
    },
    "accelerations": null,
    "effort": null,
    "limits": null
  },
  "metrics": {
    "positions/j1": {
      "_type": "compare/ErrorStats",
      "n": 11,
      "rms": 0.1478360001370795,
      "mean": -0.02971577105855816,
      "median": 0.026962032734189345,
      "std": 0.14481870005950864,
      "min": -0.3322999516645124,
      "max": 0.20199861291473598,
      "max_abs": 0.3322999516645124,
      "p95_abs": 0.26819593190151547,
      "final": 0.0886459943160588,
      "iae": 0.11002572035691702,
      "ise": 0.02156545018475165,
      "itae": 0.04254478760804756
    },
    "positions/j2": {
      "_type": "compare/ErrorStats",
      "n": 11,
      "rms": 0.08682948021772133,
      "mean": 0.025909194832599715,
      "median": 0.023193237764417368,
      "std": 0.08287383337342401,
      "min": -0.05451055226877033,
      "max": 0.25556650313141827,
      "max_abs": 0.25556650313141827,
      "p95_abs": 0.16118556887115854,
      "final": 0.029172023243986434,
      "iae": 0.050130441120635964,
      "ise": 0.004985032275219179,
      "itae": 0.019665167975216218
    },
    "positions/j3": {
      "_type": "compare/ErrorStats",
      "n": 11,
      "rms": 0.08553786679615684,
      "mean": -0.009362955341224121,
      "median": 0.021559716308978877,
      "std": 0.0850238891330861,
      "min": -0.19350880340989174,
      "max": 0.10551505512051484,
      "max_abs": 0.19350880340989174,
      "p95_abs": 0.1495119292652033,
      "final": -0.08825389674564843,
      "iae": 0.06844354034641323,
      "ise": 0.007571558484284488,
      "itae": 0.041013665997665344
    },
    "velocities/j1": {
      "_type": "compare/ErrorStats",
      "n": 11,
      "rms": 5.88567703535677e-15,
      "mean": 1.838176075998697e-15,
      "median": 8.187894806610529e-16,
      "std": 5.591270238340487e-15,
      "min": -8.43769498715119e-15,
      "max": 1.2434497875801753e-14,
      "max_abs": 1.2434497875801753e-14,
      "p95_abs": 1.0436096431476471e-14,
      "final": 0.0,
      "iae": 4.8142045905308355e-15,
      "ise": 3.810531358097866e-29,
      "itae": 2.2362667273512214e-15
    },
    "velocities/j2": {
      "_type": "compare/ErrorStats",
      "n": 11,
      "rms": 6.7109168834422075e-15,
      "mean": 1.7732027967166562e-15,
      "median": 0.0,
      "std": 6.472415102431696e-15,
      "min": -6.9735883734267645e-15,
      "max": 1.6431300764452317e-14,
      "max_abs": 1.6431300764452317e-14,
      "p95_abs": 1.354472090042691e-14,
      "final": 0.0,
      "iae": 5.01057528801141e-15,
      "ise": 4.954004595811664e-29,
      "itae": 2.5116714263972993e-15
    },
    "velocities/j3": {
      "_type": "compare/ErrorStats",
      "n": 11,
      "rms": 5.424424051738637e-15,
      "mean": -1.3369986935755792e-15,
      "median": 0.0,
      "std": 5.257072453985944e-15,
      "min": -1.199040866595169e-14,
      "max": 5.773159728050814e-15,
      "max_abs": 1.199040866595169e-14,
      "p95_abs": 1.0852430065710905e-14,
      "final": 0.0,
      "iae": 4.18033663240891e-15,
      "ise": 3.236681392238867e-29,
      "itae": 1.762028023488682e-15
    },
    "channels/kp/j1": {
      "_type": "compare/ErrorStats",
      "n": 11,
      "rms": 0.0,
      "mean": 0.0,
      "median": 0.0,
      "std": 0.0,
      "min": 0.0,
      "max": 0.0,
      "max_abs": 0.0,
      "p95_abs": 0.0,
      "final": 0.0,
      "iae": 0.0,
      "ise": 0.0,
      "itae": 0.0
    },
    "channels/kp/j2": {
      "_type": "compare/ErrorStats",
      "n": 11,
      "rms": 0.0,
      "mean": 0.0,
      "median": 0.0,
      "std": 0.0,
      "min": 0.0,
      "max": 0.0,
      "max_abs": 0.0,
      "p95_abs": 0.0,
      "final": 0.0,
      "iae": 0.0,
      "ise": 0.0,
      "itae": 0.0
    },
    "channels/kp/j3": {
      "_type": "compare/ErrorStats",
      "n": 11,
      "rms": 0.0,
      "mean": 0.0,
      "median": 0.0,
      "std": 0.0,
      "min": 0.0,
      "max": 0.0,
      "max_abs": 0.0,
      "p95_abs": 0.0,
      "final": 0.0,
      "iae": 0.0,
      "ise": 0.0,
      "itae": 0.0
    }
  },
  "time_offset_s": 0.0,
  "dropped": 0,
  "coverage": 1.0
}

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

Functions

Constructors

Classmethods and staticmethods: ways to build one.

from_dict

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

No docstring.

Methods

Return new values; messages are never mutated.

rows() -> list[dict[str, Any]]

The metrics as tidy rows — one dict per metric — for tables and data-ui.

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.

Uses

Types its fields refer to.

ErrorStats Trajectory

Used by

Types whose fields refer to it.

Aggregate

robot_msgs 0.2.0 @ 22ec67fGitHub · MIT license · generated from the package, not written per type