Telemetry API
Aggregates multiple :class:~bulletlab.telemetry.channel.TelemetryChannel instances.
Register channels with :meth:watch, then call :meth:update every
simulation step. Retrieve the latest values via :meth:get or
:meth:snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
history_len
|
int
|
Default history buffer length for new channels. |
1000
|
Example::
telemetry = TelemetryManager()
telemetry.watch("Roll", lambda: robot.roll, unit="rad")
telemetry.watch("Speed", lambda: robot.speed, unit="m/s")
for _ in range(1000):
sim.step()
telemetry.update(t=sim.elapsed_time)
print(telemetry.snapshot())
Source code in bulletlab/telemetry/manager.py
32 33 34 35 36 37 38 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 | |
channel_names: list[str]
property
List of all registered channel names.
channels: dict[str, TelemetryChannel]
property
Dictionary of all registered channels.
clear_all() -> None
clear_history() -> None
get(name: str, default: Any = None) -> Any
Return the latest value for a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Channel name. |
required |
default
|
Any
|
Value to return if channel does not exist. |
None
|
Example::
speed = telemetry.get("Speed")
Source code in bulletlab/telemetry/manager.py
history(name: str) -> list[tuple[float, Any]]
Return the full history for a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Channel name. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[float, Any]]
|
List of |
Example::
times_and_vals = telemetry.history("Speed")
Source code in bulletlab/telemetry/manager.py
snapshot() -> dict[str, Any]
Return a dictionary of all channel names to their latest values.
Example::
data = telemetry.snapshot()
print(data["Speed"])
Source code in bulletlab/telemetry/manager.py
unwatch(name: str) -> None
Remove a channel by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Channel name to remove. |
required |
update(t: float | None = None) -> dict[str, Any]
Poll all channels and return a snapshot of current values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float | None
|
Timestamp for this update cycle. If |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary mapping channel names to their current values. |
Example::
values = telemetry.update(t=sim.elapsed_time)
Source code in bulletlab/telemetry/manager.py
values_array(name: str) -> list[Any]
Return only the values (no timestamps) for a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Channel name. |
required |
Returns:
| Type | Description |
|---|---|
list[Any]
|
List of values in chronological order. |
Source code in bulletlab/telemetry/manager.py
watch(name: str, source: Callable[[], Any], unit: str = '', history_len: int | None = None) -> TelemetryChannel
Register a new channel to monitor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Human-readable channel name. |
required |
source
|
Callable[[], Any]
|
A callable (lambda, function, or method) that returns the current value when called. |
required |
unit
|
str
|
Optional unit string (e.g. |
''
|
history_len
|
int | None
|
History buffer size. Defaults to manager's default. |
None
|
Returns:
| Type | Description |
|---|---|
TelemetryChannel
|
The created :class: |
Example::
telemetry.watch("Speed", lambda: robot.speed, unit="m/s")
telemetry.watch("Joint_1", robot.joints["iiwa_joint_1"].position)
Source code in bulletlab/telemetry/manager.py
A single named data stream with a rolling history buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Human-readable channel name. |
required |
source
|
Callable[[], Any]
|
Callable that returns the current value when called. |
required |
history_len
|
int
|
Maximum number of samples to retain in history. Defaults to 1000. |
1000
|
unit
|
str
|
Optional unit string (e.g. |
''
|
Example::
ch = TelemetryChannel("Roll", lambda: robot.roll, unit="rad")
ch.poll(0.0)
print(ch.latest)
print(ch.history[-1]) # (timestamp, value)
Source code in bulletlab/telemetry/channel.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 | |
history: deque[tuple[float, Any]]
property
Rolling history as a deque of (timestamp, value) pairs.
latest: Any
property
Most recently polled value, or None if never polled.
name: str
property
Channel name.
timestamps: list[float]
property
List of all stored timestamps.
unit: str
property
Measurement unit string (e.g. "m/s").
values: list[Any]
property
List of all stored values.
clear() -> None
poll(t: float | None = None) -> Any
Sample the source and store the result in history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float | None
|
Timestamp for this sample. If |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The sampled value. |
Example::
value = channel.poll(t=sim.elapsed_time)