Skip to content

Commit 50588d3

Browse files
committed
Set a synthetic walking trajectory by default.
1 parent fbf3f1e commit 50588d3

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

flybody/tasks/trajectory_loaders.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import h5py
77
import numpy as np
88

9+
from flybody.tasks.synthetic_trajectories import constant_speed_trajectory
10+
from flybody.tasks.constants import _WALK_CONTROL_TIMESTEP
11+
912

1013
class HDF5TrajectoryLoader(ABC):
1114
"""Base class for loading and serving trajectories from hdf5 datasets."""
@@ -216,14 +219,21 @@ class InferenceWalkingTrajectoryLoader():
216219
This trajectory loader can be used for bypassing loading actual walking
217220
datasets and loading custom trajectories instead, e.g. at inference time.
218221
219-
To use this class, create qpos and qvel for your custom trajectory and then
220-
set this trajectory for loading in the walking task by calling:
221-
env.task._traj_generator.set_next_trajectory(qpos, qvel)
222+
A simple synthetic walking trajectory is automatically set upon this class
223+
initialization.
224+
225+
To use this class with other custom trajectories, create qpos and qvel for
226+
your custom trajectory and then set this trajectory for loading in the
227+
walking task by calling:
228+
env.task._traj_generator.set_next_trajectory(qpos, qvel)
222229
"""
223230

224231
def __init__(self):
225-
# Nothing here!
226-
pass
232+
# Initially, set a simple synthetic trajectory, e.g. for quick testing.
233+
qpos, qvel = constant_speed_trajectory(
234+
n_steps=300, speed=2, init_pos=(0, 0, 0.1278),
235+
control_timestep=_WALK_CONTROL_TIMESTEP)
236+
self.set_next_trajectory(qpos, qvel)
227237

228238
def set_next_trajectory(self, qpos: np.ndarray, qvel: np.ndarray):
229239
"""Set new trajectory to be returned by get_trajectory.

0 commit comments

Comments
 (0)