Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python/mujoco/sysid/_src/signal_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ def apply_delay(
)
ts_sensor_delayed = ts_sensor.resample(ts.times - delay.value)

ts_delayed = timeseries.TimeSeries(ts.times, ts.data, ts.signal_mapping)
ts_delayed = timeseries.TimeSeries(
ts.times, ts.data.copy(), ts.signal_mapping
)
ts_delayed.data[:, indices] = ts_sensor_delayed.data

return ts_delayed
Expand Down
18 changes: 18 additions & 0 deletions python/mujoco/sysid/tests/test_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,24 @@ def test_apply_bias(arm_model):
np.testing.assert_array_equal(result.data[:, other], ts.data[:, other])


# ===========================================================================
# signal_modifier: apply_delay
# ===========================================================================


def test_apply_delay_does_not_modify_input(arm_model):
"""Delaying a sensor leaves the input timeseries unchanged."""
ts = _make_arm_sensor_ts(arm_model)
data = ts.data.copy()
delay = parameter.Parameter("delay", 0.1, 0.0, 0.2)

result = signal_modifier.apply_delay(ts, "joint1_pos", delay)

np.testing.assert_array_equal(ts.data, data)
idx = ts.get_indices("joint1_pos")[1]
assert not np.array_equal(result.data[:, idx], data[:, idx])


# ===========================================================================
# signal_modifier: apply_delayed_ts_window
# ===========================================================================
Expand Down