processing_utils
ExponentialAverageFilter
Bases: Filter
This class uses an exponential average of the form y_n = alpha * x_n + (1 - alpha) * y_{n - 1}. This is an IIR filter.
Source code in OmniGibson/omnigibson/utils/processing_utils.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
__init__(obs_dim, alpha=0.9)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs_dim
|
int
|
The dimension of the points to filter. |
required |
alpha
|
float
|
The relative weighting of new samples relative to older samples |
0.9
|
Source code in OmniGibson/omnigibson/utils/processing_utils.py
estimate(observation)
Do an online hold for state estimation given a recent observation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observation
|
New observation, cb.arr_type. |
required |
Returns:
| Type | Description |
|---|---|
arr_type
|
New estimate of state. |
Source code in OmniGibson/omnigibson/utils/processing_utils.py
Filter
Bases: Serializable
A base class for filtering a noisy data stream in an online fashion.
Implementations store state as compute-backend arrays (cb.arr_type) and accept observations
as cb arrays, torch tensors, or Python sequences (converted at the call boundary).
Source code in OmniGibson/omnigibson/utils/processing_utils.py
state_size
property
Size of the serialized state of this filter
estimate(observation)
Takes an observation and returns a de-noised estimate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observation
|
Current observation, cb.arr_type. |
required |
Returns:
| Type | Description |
|---|---|
arr_type
|
De-noised estimate. |
Source code in OmniGibson/omnigibson/utils/processing_utils.py
MovingAverageFilter
Bases: Filter
This class uses a moving average to de-noise a noisy data stream in an online fashion. This is a FIR filter.
Supports a batch of n_members independent filter rows. Each member has its own circular buffer row; estimate() targets one member, estimate_batch() processes all rows at once using matrix operations and broadcasting with no intermediate large allocations.
Internal buffers are compute-backend arrays (cb). The per-member fully_filled row uses
cb.bool_zeros / cb.logical_or. Serialized / dumped state uses torch tensors (cb.to_torch);
loads convert incoming torch tensors back to cb.
Source code in OmniGibson/omnigibson/utils/processing_utils.py
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 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
__init__(obs_dim, filter_width, n_members=1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs_dim
|
int
|
The dimension of the points to filter. |
required |
filter_width
|
int
|
The number of past samples to take the moving average over. |
required |
n_members
|
int
|
Number of independent filter rows (one per controller member). Defaults to 1. |
1
|
Source code in OmniGibson/omnigibson/utils/processing_utils.py
add_member(slot)
Register a member at the given slot index.
If slot < n_members the slot is being reused (tombstone reuse): its buffer is cleared in-place and n_members is unchanged. If slot == n_members a new row is appended.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot
|
int
|
Slot index as determined by the controller's add_member (either a previously tombstoned index or the next new index == current n_members). |
required |
Source code in OmniGibson/omnigibson/utils/processing_utils.py
estimate(member_idx, observation)
Do an online hold for state estimation given a recent observation for one member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
member_idx
|
int
|
Index of the controller member whose row to update. |
required |
observation
|
New observation of shape (obs_dim,) as |
required |
Returns:
| Type | Description |
|---|---|
arr_type
|
New estimate of state. |
Source code in OmniGibson/omnigibson/utils/processing_utils.py
estimate_batch(observations)
Process all N member rows at once using batched matrix operations.
Unfilled slots in past_samples are zero, so sum(dim=1) / fill_count gives the correct per-member mean without any masking matrix. Broadcasting is used throughout to avoid allocating intermediate large tensors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observations
|
(N, obs_dim) new observations for all members, cb.arr_type. |
required |
Returns:
| Type | Description |
|---|---|
arr_type
|
(N, obs_dim) smoothed estimates. |
Source code in OmniGibson/omnigibson/utils/processing_utils.py
reset(member_idx=None)
Reset one member's filter row, or all rows if member_idx is None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
member_idx
|
int or None
|
Member to reset. Resets all members if None. |
None
|
Source code in OmniGibson/omnigibson/utils/processing_utils.py
unregister_member(member_idx)
Zero a member's buffer when it is unregistered (tombstoned at the controller level).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
member_idx
|
int
|
Index of the member to unregister. |
required |
Source code in OmniGibson/omnigibson/utils/processing_utils.py
Subsampler
A base class for subsampling a data stream in an online fashion.
Source code in OmniGibson/omnigibson/utils/processing_utils.py
subsample(observation)
Takes an observation and returns the observation, or None, which corresponds to deleting the observation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observation
|
n - array
|
A current observation. |
required |
Returns:
| Type | Description |
|---|---|
None or n - array
|
No observation if subsampled, otherwise the observation |
Source code in OmniGibson/omnigibson/utils/processing_utils.py
UniformSubsampler
Bases: Subsampler
A class for subsampling a data stream uniformly in time in an online fashion.
Source code in OmniGibson/omnigibson/utils/processing_utils.py
__init__(T)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T
|
int
|
Pick one every T observations. |
required |
subsample(observation)
Returns an observation once every T observations, None otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observation
|
n - array
|
A current observation. |
required |
Returns:
| Type | Description |
|---|---|
None or n - array
|
The observation, or None. |