Summary
resample_trajectory builds its output time grid with
np.arange(t_start, t_end, target_dt), which excludes the endpoint. As a
result every resampled trajectory loses its final timestep, including the
terminal robot configuration.
Location
smooth_resampled_traj.py, in resample_trajectory (grid built around line 338):
t_start, t_end = float(times[0]), float(times[-1])
new_times = np.arange(t_start, t_end, target_dt)
Reproduction
import numpy as np
t_start, t_end, target_dt = 0.0, 1.0, 0.1
new_times = np.arange(t_start, t_end, target_dt)
print(new_times[-1]) # 0.9, expected to reach ~1.0
A trajectory spanning 0.0 to 1.0 s resampled at dt=0.1 ends at 0.9 s. The
frame at 1.0 s is dropped.
Impact
- The terminal frame is usually the most meaningful one in teleoperation data
(final arm pose, gripper closed on the object), and it is silently discarded.
- The truncation propagates through
process_single_trajectory into the saved
joints and the interpolated extra state, so the whole output is one step short.
- When
target_dt does not evenly divide the span, floating point accumulation
can further shift the final grid point.
Suggested fix
Construct the grid so it reaches the endpoint while keeping uniform spacing,
by computing the step count and landing on (or just past) t_end instead of
stopping short.
One design question before implementing: do you want strict uniform dt, where
the final point may not equal t_end exactly when the span is not a multiple of
dt, or an exact landing on t_end, where the final interval is slightly
shorter than dt? Both are reasonable and I did not want to assume.
Offer
I'm happy to open a PR with the fix and a small regression test covering the
grid endpoint, once you confirm which of the two behaviors you prefer.
Summary
resample_trajectorybuilds its output time grid withnp.arange(t_start, t_end, target_dt), which excludes the endpoint. As aresult every resampled trajectory loses its final timestep, including the
terminal robot configuration.
Location
smooth_resampled_traj.py, inresample_trajectory(grid built around line 338):Reproduction
A trajectory spanning 0.0 to 1.0 s resampled at dt=0.1 ends at 0.9 s. The
frame at 1.0 s is dropped.
Impact
(final arm pose, gripper closed on the object), and it is silently discarded.
process_single_trajectoryinto the savedjoints and the interpolated extra state, so the whole output is one step short.
target_dtdoes not evenly divide the span, floating point accumulationcan further shift the final grid point.
Suggested fix
Construct the grid so it reaches the endpoint while keeping uniform spacing,
by computing the step count and landing on (or just past)
t_endinstead ofstopping short.
One design question before implementing: do you want strict uniform
dt, wherethe final point may not equal
t_endexactly when the span is not a multiple ofdt, or an exact landing ont_end, where the final interval is slightlyshorter than
dt? Both are reasonable and I did not want to assume.Offer
I'm happy to open a PR with the fix and a small regression test covering the
grid endpoint, once you confirm which of the two behaviors you prefer.