MCPcopy Create free account
hub / github.com/BoosterRobotics/booster_train / _load_motion

Method _load_motion

scripts/csv_to_npz.py:105–126  ·  view source on GitHub ↗

Loads the motion from the csv file.

(self)

Source from the content-addressed store, hash-verified

103 self._compute_velocities()
104
105 def _load_motion(self):
106 """Loads the motion from the csv file."""
107 if self.frame_range is None:
108 motion = torch.from_numpy(np.loadtxt(self.motion_file, delimiter=","))
109 else:
110 motion = torch.from_numpy(
111 np.loadtxt(
112 self.motion_file,
113 delimiter=",",
114 skiprows=self.frame_range[0] - 1,
115 max_rows=self.frame_range[1] - self.frame_range[0] + 1,
116 )
117 )
118 motion = motion.to(torch.float32).to(self.device)
119 self.motion_base_poss_input = motion[:, :3]
120 self.motion_base_rots_input = motion[:, 3:7]
121 self.motion_base_rots_input = self.motion_base_rots_input[:, [3, 0, 1, 2]] # convert to wxyz
122 self.motion_dof_poss_input = motion[:, 7:]
123
124 self.input_frames = motion.shape[0]
125 self.duration = (self.input_frames - 1) * self.input_dt
126 print(f"Motion loaded ({self.motion_file}), duration: {self.duration} sec, frames: {self.input_frames}")
127
128 def _interpolate_motion(self):
129 """Interpolates the motion to the output fps."""

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected