MCPcopy Create free account
hub / github.com/RoboVerseOrg/RoboVerse / initialize

Method initialize

roboverse_pack/randomization/humanoid.py:364–393  ·  view source on GitHub ↗

Validate configuration and cache default masses.

(self)

Source from the content-addressed store, hash-verified

362 self.initialize()
363
364 def initialize(self):
365 """Validate configuration and cache default masses."""
366 # check for valid operation
367 if self.operation == "scale":
368 _validate_scale_range(
369 self.mass_distribution_params,
370 "mass_distribution_params",
371 allow_zero=False,
372 )
373 elif self.operation not in ("abs", "add"):
374 raise ValueError(
375 f"Randomization term 'randomize_rigid_body_mass' does not support operation: '{self.operation}'."
376 )
377
378 self.all_robot_names = [robot.name for robot in self.handler.robots]
379 self.all_object_names = [obj.name for obj in self.handler.objects]
380 self.body_names = self.handler.get_body_names(self.obj_name, sort=False)
381 self.set_body_ids = (
382 torch.tensor(
383 [self.body_names.index(_name) for _name in self.set_body_names],
384 dtype=torch.int,
385 device="cpu",
386 )
387 if self.set_body_names is not None
388 else torch.arange(len(self.body_names), dtype=torch.int, device="cpu")
389 )
390 if self.simulator_name == "newton":
391 self._newton_body_ids = self._build_newton_body_id_map()
392 self.default_inertias = self._get_inertias_newton()
393 self.default_masses = deepcopy(self._get_masses())
394
395 def __call__(self, env_ids: torch.Tensor | None = None):
396 """Apply mass randomization for selected environments."""

Callers 1

bind_handlerMethod · 0.95

Calls 4

_get_inertias_newtonMethod · 0.95
_get_massesMethod · 0.95
_validate_scale_rangeFunction · 0.70

Tested by

no test coverage detected