Recording API
skelarm.recording
Time-series logging of robot states with TOML-described .sklog.npz files.
A :class:StateLog records a sequence of frames, each a timestamp plus a set of
named channels (q, dq, tau and any extra signals a producer wants to
keep, e.g. a controller's target or tracking error). The container is
schema-agnostic: it stores whatever channels it is given, so new signals need no
format change.
The canonical on-disk format is a numpy .npz archive holding one array per
channel plus a __meta__ member with TOML metadata (schema version, producer,
the embedded robot geometry, per-channel units/labels, and any free-form extra
metadata such as the scenario config that produced the run). A standalone
human-readable .toml export is also available for small logs.
StateLog
A time series of robot states, savable to and loadable from a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skeleton
|
Skeleton
|
The robot whose geometry is embedded in the log so it can be replayed or
analyzed without the original config. Required for :meth: |
None
|
producer
|
str
|
A free-form name of whatever generated the log (e.g. |
''
|
channel_meta
|
Mapping[str, Mapping[str, Any]]
|
Optional per-channel descriptors ( |
None
|
extra
|
Mapping[str, Any]
|
Optional extra metadata stored under an |
None
|
Source code in src/skelarm/recording.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
channel_meta
property
Per-channel descriptors (unit / label / columns).
channel_names
property
The recorded channel names (excluding time), in record order.
created_at
property
ISO-8601 timestamp of when the log was created.
extra
property
Free-form extra metadata stored under the [extra] table.
producer
property
The name of whatever produced the log.
times
property
The frame timestamps as a 1-D array.
__init__(skeleton=None, *, producer='', channel_meta=None, extra=None)
Initialize an empty log.
Source code in src/skelarm/recording.py
__len__()
build_skeleton()
Reconstruct the robot embedded in the log.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the log carries no embedded robot geometry. |
Source code in src/skelarm/recording.py
channel(name)
Return channel name stacked over frames (shape (N,) or (N, k)).
Source code in src/skelarm/recording.py
export_toml(path)
Write a standalone, human-readable TOML file (metadata + data arrays).
Practical for small logs; for long runs prefer :meth:save (.npz).
Source code in src/skelarm/recording.py
load(path)
classmethod
Load a log previously written by :meth:save.
Source code in src/skelarm/recording.py
record(time, **channels)
Append one frame at time with the given named channels.
The set of channel names and each channel's width are fixed by the first call; later calls must match.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
float
|
The frame timestamp. |
required |
**channels
|
ArrayLike
|
Named channel values for this frame (scalars or 1-D arrays). |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the channel names or a channel's shape differ from the first frame. |
Source code in src/skelarm/recording.py
record_skeleton(skeleton, time, **extra)
Record the canonical robot state (q, dq, tau) plus extra channels.
save(path)
Save the log as a .sklog.npz archive (channel arrays + TOML metadata).
Source code in src/skelarm/recording.py
to_arrays()
Return every channel (including time) as a mapping of stacked arrays.
Source code in src/skelarm/recording.py
dump_toml(data)
Serialize a constrained nested mapping to TOML text.
Supports scalars (bool, int, float, str), (possibly nested)
lists of scalars, sub-tables (dict), and arrays of tables (list of
dict). This is enough for :class:StateLog metadata and exports; stdlib
tomllib reads the result back.