Non-zero velocity for new object in a new World instance

Isaac Sim Version

[√ ] 4.5.0

Operating System

[ √ ] Windows 10

GPU Information

  • Model: RTX 3060
  • Driver Version: 31.0.15.4612

Detailed Description

the DynamicCuboid object, which is newly added to a new world, has a non-zero linear velocity (-0.16350001).

Steps to Reproduce

import numpy as np
from isaacsim import SimulationApp

simulation_app = SimulationApp({"headless": True})

from isaacsim.core.api.objects import DynamicSphere
from isaacsim.core.api.objects import DynamicCuboid
from isaacsim.core.api import World
import isaacsim.core.utils.bounds as bounds_utils
world = World()

cube = world.scene.add(
    DynamicCuboid(
        prim_path="/World/cube",
        name="cube",
        position=np.array([-2, -6, 9]),
        scale=np.array([0, 1, 4]),
    )
)
print(f'cube.get_linear_velocity():{cube.get_linear_velocity()}')
print(f'cube.get_world_pose():{cube.get_world_pose()}')
print(f'cube.get_local_pose():{cube.get_local_pose()}')

world.clear_instance()
world = World()
world.reset()

cube = world.scene.add(DynamicCuboid(prim_path="/World/cube",
 name="cube", 
 position=np.array([5, 3, -6]),
 scale=np.array([2, 4, 2]),

 )
)
print(f'cube.get_linear_velocity():{cube.get_linear_velocity()}')
print(f'cube.get_world_pose():{cube.get_world_pose()}')
print(f'cube.get_local_pose():{cube.get_local_pose()}')


simulation_app.close()

The output is :

[20.997s] Simulation App Startup Complete
cube.get_linear_velocity():[0. 0. 0.] 
cube.get_world_pose():(array([-2., -6.,  9.], dtype=float32), array([1., 0., 0., 0.], dtype=float32))
cube.get_local_pose():(array([-2., -6.,  9.], dtype=float32), array([0.8660254, 0.       , 0.       , 0.       ], dtype=float32))

cube.get_linear_velocity():[ 0.          0.         -0.16350001] # here
cube.get_world_pose():(array([ 5.,  3., -6.], dtype=float32), array([1., 0., 0., 0.], dtype=float32))
cube.get_local_pose():(array([ 5.,  3., -6.], dtype=float32), array([1., 0., 0., 0.], dtype=float32))
[23.393s] Simulation App Shutting Down

@Tommmmm thanks for posting the issue. What is happening when you recreate the world object and creating the cube at the same path is that you are just re-referencing the data that was created on the first pass. If you want to clear the prim data on the cube you will want to delete the prim. You can do this like this:

world.scene.remove_object("cube")
world.clear_instance()
world = World()
world.reset()

@michalin Thank you very much for your reply! There are still a few questions I’m confused about:

  1. If it’s just re-referencing the data that was created before, the object in the previous run didn’t have any linear velocity either, so why does it have a velocity in the second run?
  2. As I understand it, clear_instance() only destroys the original World instance, but the objects (e.g., cubes) inside it still remain, is that correct?
  3. If I simply want to clear all objects in the world and continue with other things, is it correct to use the combination of world.stop(), world.clear(), and then world.play()? I read in some other issues that the simulation should be stopped to remove objects, but I didn’t find a recommended way for this in the documentation.

Thanks again for your help!