How to reset position of all objects in scene in a Python script?

Hi there,

I have a python script running my simulation. I am trying to offer a reset button that will reset the positions of all objects in my scene. My scene is a warehouse scene with a Carter V2 running the ROS Bridge extension.

I’ve tried the following with no luck:

  1. Use ROS1 teleportation service to move the cart back to the starting place
    This one didn’t quite work out because it appears the positions are relative to the starting position. For example, if the cart starts at P1, and then through publishing of /cmd_vel messages, the cart moves to the other side of the room, if I publish a teleportation to P1, it won’t move. Inspecting the cart’s position in the tree viewer on the right, it still shows it’s in P1 when it has in fact moved. So I’d have to do something like figure out the current position, subtract that from P1, and then call the teleportation service on the difference. Don’t see a way to do this either.

  2. Using the timeline interface to stop and replay the simulator.
    This would work find, as it’s how I reset the simulator when using the Isaac Sim GUI. However, when I do it in a python script, it doesn’t reset the scene and instead spams:

[Warning] [omni.isaac.core.articulations.articulation_view] Physics Simulation View is not created yet in order to use apply_action
[Warning] [omni.isaac.core.articulations.articulation_view] Physics Simulation View is not created yet in order to use get_applied_actions

Oddly, if I telnet into the device and call omni.timeline.get_timeline_interface().stop() then omni.timeline.get_timeline_interface().play() on separate REPL instructions, it will work. But does not work when run from a script.

Is there any other way I can easily reset the position of all of my objects in the scene via the Python API?

Thanks

Another failed attempt.

Using a simulation context, I tried to call the reset function. However, the same issue appeared where the console got spammed about missing a Physics View :

from omni.isaac.core import SimulationContext

sc = SimulationContext()

sc.reset()
sc.play()

Even calling sc.initialize_physics() didn’t fix the issue. Any ideas?

Bump. This is still blocking our efforts here. Thanks

Hi @pweids

Have you tried the World.reset method from the omni.isaac.core extension

You can inspect the standalone examples to see its usage…

For example, the standalone_examples/api/omni.isaac.core/add_frankas.py script resets the world 5 times…

  1. You want to use the teleportation service on the “chassis” rigid body, not the prim that contains the articulation. The chassis is what moves if the robot is driving around and what you want to teleport. The parent xform remains static as it has no physics apis on it.

  2. Are you using a standalone python script (via python.sh) or isaac-sim.sh and running a script async?

World.reset is an option, but you have to set up the scene using the isaac.core interfaces so default positions etc are set and add all of the objects in the scene to the World object so it knows what to reset.

I did try that, yes. I still get a crash with the error print: Physics Simulation View is not created yet in order to use get_applied_actions. Maybe something here I’m doing wrong?

Can you provide the script you are using?

Hi Hammad_M,

Your suggestion to use chassis_link worked perfectly! Thanks for catching that one.

Great!
Usually for fixed robot arms this is not an issue because the parent xform to root link transform is fixed. But for mobile robots you have to use the root/chassis for any odometry, pose, teleportation operations

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.