diff --git a/source/extensions/omni.isaac.lab/omni/isaac/lab/envs/mdp/events.py b/source/extensions/omni.isaac.lab/omni/isaac/lab/envs/mdp/events.py index aa41a1cc44..cb55b7a779 100644 --- a/source/extensions/omni.isaac.lab/omni/isaac/lab/envs/mdp/events.py +++ b/source/extensions/omni.isaac.lab/omni/isaac/lab/envs/mdp/events.py @@ -573,9 +573,6 @@ def apply_external_force_torque_duration( asset_cfg: SceneEntityCfg = SceneEntityCfg("robot"), ): """ - force/torque维持一段时间 然后取消 - 和原有的apply_external_force_torque在reset以后整个episode一直保持不同 - apply the force/torque for a time, then cancel it changes the above function apply_external_force_torque that apply the force/torque in the whole episode """ @@ -595,9 +592,8 @@ def apply_external_force_torque_duration( torques = math_utils.sample_uniform(*torque_range, size, asset.device).clone() else: size = (len(env_ids), num_bodies, 3) - forces = torch.zeros(size, asset.device) - torques = torch.zeros(size, asset.device) - + forces = torch.zeros(size=size, device=asset.device) + torques = torch.zeros(size=size, device=asset.device) # set the forces and torques into the buffers # note: these are only applied when you call: `asset.write_data_to_sim()` diff --git a/source/extensions/omni.isaac.lab/omni/isaac/lab/managers/event_manager.py b/source/extensions/omni.isaac.lab/omni/isaac/lab/managers/event_manager.py index c072b589db..ed49189d6a 100644 --- a/source/extensions/omni.isaac.lab/omni/isaac/lab/managers/event_manager.py +++ b/source/extensions/omni.isaac.lab/omni/isaac/lab/managers/event_manager.py @@ -222,7 +222,7 @@ def apply( if time_left < 1e-6: lower, upper = term_cfg.interval_range_s sampled_interval = torch.rand(1) * (upper - lower) + lower - self._interval_term_time_left[index][:] = sampled_interval + self._duration_term_interval_time_left[index][:] = sampled_interval # call the event term (with None for env_ids) term_cfg.params["open"]=True @@ -244,7 +244,7 @@ def apply( if len(valid_env_ids) > 0: lower, upper = term_cfg.interval_range_s sampled_time = torch.rand(len(valid_env_ids), device=self.device) * (upper - lower) + lower - self._interval_term_time_left[index][valid_env_ids] = sampled_time + self._duration_term_interval_time_left[index][valid_env_ids] = sampled_time # call the event term term_cfg.params["open"]=True @@ -255,8 +255,8 @@ def apply( valid_env_ids_duration = (duration_left < 1e-6).nonzero().flatten() if len(valid_env_ids_duration) > 0: term_cfg.params["open"]=False - term_cfg.func(self._env, valid_env_ids, **term_cfg.params) - self._duration_term_started[index][valid_env_ids] = False + term_cfg.func(self._env, valid_env_ids_duration, **term_cfg.params) + self._duration_term_started[index][valid_env_ids_duration] = False lower, upper = term_cfg.duration_range_s duration_left = torch.rand(len(valid_env_ids_duration), device=self.device) * (upper - lower) + lower