Skip to content

Commit

Permalink
allocate once
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayankm96 committed Oct 7, 2024
1 parent 12d218d commit 7365662
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,16 @@ def __init__(self, cfg: EventTermCfg, env: ManagerBasedEnv):
num_buckets = int(cfg.params.get("num_buckets", 1))

# sample material properties from the given ranges
# note: we only sample the materials once during initialization
# afterwards these are randomly assigned to the geometries of the asset
range_list = [static_friction_range, dynamic_friction_range, restitution_range]
ranges = torch.tensor(range_list, device="cpu")
material_buckets = math_utils.sample_uniform(ranges[:, 0], ranges[:, 1], (num_buckets, 3), device="cpu")
self.material_buckets = math_utils.sample_uniform(ranges[:, 0], ranges[:, 1], (num_buckets, 3), device="cpu")

# ensure dynamic friction is always less than static friction
make_consistent = cfg.params.get("make_consistent", False)
if make_consistent:
material_buckets[:, 1] = torch.min(material_buckets[:, 0], material_buckets[:, 1])

# store the material buckets
# note: we only sample the materials once during initialization
# afterwards these are randomly assigned to the geometries of the asset
self.material_buckets = material_buckets
self.material_buckets[:, 1] = torch.min(self.material_buckets[:, 0], self.material_buckets[:, 1])

def __call__(
self,
Expand Down

0 comments on commit 7365662

Please sign in to comment.