I wonder how I can add multiple robots to a scene programmatically. Given the adding must be performed by coding, not adding the robot through GUI.
Something like the spawn function.
The problem setting is actually similar to this post. But I could not get the answer.
If you want to make your own class for your robot, e.g. look into how the classes: UR10 and WheeledRobot are made.
from omni.isaac.universal_robots import UR10
from omni.isaac.wheeled_robots.robots import WheeledRobot
No you don’t need three robots in the same USD file. “path_to_robot” is the path to your USD file containing your single robot.
Here is an example of how to spawn 3 robots of the same type with one USD file of a single robot.
from omni.isaac.kit import SimulationApp
simulation_app = SimulationApp({"headless": False})
from omni.isaac.core import World
from omni.isaac.core.utils.stage import add_reference_to_stage
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.core.prims import XFormPrim
import carb
my_world = World(stage_units_in_meters=1.0)
my_world.scene.add_default_ground_plane()
assets_root_path = get_assets_root_path()
if assets_root_path is None:
carb.log_error("Could not find Isaac Sim assets folder")
usd_path = assets_root_path + "/Isaac/Robots/UR10/ur10.usd"
add_reference_to_stage(usd_path=usd_path,prim_path="/World/robot1")
add_reference_to_stage(usd_path=usd_path,prim_path="/World/robot2")
add_reference_to_stage(usd_path=usd_path,prim_path="/World/robot3")
my_world.scene.add(XFormPrim(prim_path="/World/robot1", name="robot1", position=[0,0,0],orientation=[0.7071068,0, 0,0.7071068]))
my_world.scene.add(XFormPrim(prim_path="/World/robot2", name="robot2", position=[-1,0,0],orientation=[0.7071068,0, 0,0.7071068]))
my_world.scene.add(XFormPrim(prim_path="/World/robot3", name="robot3", position=[1,0,0],orientation=[0.7071068,0, 0,0.7071068]))
my_world.reset()
while simulation_app.is_running():
my_world.step(render=True)
if my_world.is_playing():
if my_world.current_time_step_index == 0:
my_world.reset()
simulation_app.close()