Hi
I am trying to create a simulation environment with moving objects. In this case, I try to spawn a cylinder in the sim and give it some initial angular_velocity so that it moves a bit and slows down. I want these natural physics because I would like to add a robot to the scene as well so that it can interact with the object.
But when I run the simulation, the cylinder does not move at all. What could I do to get it moving in the standalone python script?
from omni.isaac.kit import SimulationApp
simulation_app = SimulationApp({"headless": False})
import argparse
import sys
import carb
import numpy as np
from omni.isaac.core import World
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.core.objects import DynamicCylinder
from omni.isaac.core.materials.physics_material import PhysicsMaterial
parser = argparse.ArgumentParser()
parser.add_argument("--test", default=False, action="store_true", help="Run in test mode")
args, unknown = parser.parse_known_args()
assets_root_path = get_assets_root_path()
if assets_root_path is None:
carb.log_error("Could not find Isaac Sim assets folder")
simulation_app.close()
sys.exit()
my_world = World(stage_units_in_meters=1.0)
my_world.scene.add_default_ground_plane()
prim = DynamicCylinder(
prim_path="/World/Xform/Cylinder",
name="dynamic_cylinder",
position=np.array([0.0, 0.0, 0.1]),
orientation=np.array([1 / np.sqrt(2), 1 / np.sqrt(2), 0.0, 0.0]),
radius=0.1,
height=1.0,
color=np.array([1.0, 0.0, 0.0]),
mass=1.0
)
material = PhysicsMaterial(
prim_path="/World/physics_material/aluminum", # path to the material prim to create
dynamic_friction=0.1,
static_friction=0.1,
restitution=0.1
)
i = 0
while simulation_app.is_running():
print("#########################################################")
my_world.step(render=True)
if my_world.is_playing():
print("ITERATION : ", i)
i += 1
if my_world.current_time_step_index == 0:
my_world.reset()
# position = cube.get_local_pose()[0]
# position[0] += 0.005
# cube.set_local_pose(position)
if i>=60:
prim.set_linear_velocity(angular_velocity=np.array([10.0, 0.0, 0.0]))
observations = my_world.get_observations()
print(prim.get_angular_velocity())
if args.test is True:
break
simulation_app.close()