I am verifying the use of apply_body_force for simulations and have two questions.
Question 1:
I placed a cube and applied a force to it. Below is the test code. Even if I start the simulation with all materials’ Dynamic and Static Friction set to zero, the motion of the cube stops quickly.
It can’t be due to air resistance. Why does it stop despite there being no friction?
Question 2:
I placed a sphere and applied the same force in the same direction. The only difference is the coordinate system used for application (world coordinates vs. local coordinates).
Why does the rolling speed differ in this case?
from omni.isaac.examples.base_sample import BaseSample
from omni.isaac.core.objects import DynamicSphere, DynamicCuboid
from omni.isaac.dynamic_control import _dynamic_control
import numpy as np
class HelloWorld(BaseSample):
def __init__(self) -> None:
super().__init__()
self.force_applied = False # 力が適用されたかどうかを追跡するフラグ
def setup_scene(self):
world = self.get_world()
world.scene.add_default_ground_plane()
# 歩行者1のロード
self.pedestrian1 = world.scene.add(
DynamicCuboid(prim_path="/World/Pedestrian1",
name="pedestrian1",
position=np.array([0, -0.5, 0]),
scale=np.array([0.05, 0.05, 0.05]),
color=np.array([0, 0, 1.0]),
mass=0.1))
# 歩行者2のロード
self.pedestrian2 = world.scene.add(
DynamicCuboid(prim_path="/World/Pedestrian2",
name="pedestrian2",
position=np.array([0, 0.5, 0]),
scale=np.array([0.05, 0.05, 0.05]),
color=np.array([1.0, 0, 0]),
mass=0.1))
async def setup_post_load(self):
self._world = self.get_world()
self._dc = _dynamic_control.acquire_dynamic_control_interface()
self.pedestrian1_handle = self._dc.get_rigid_body("/World/Pedestrian1")
self.pedestrian2_handle = self._dc.get_rigid_body("/World/Pedestrian2")
self._world.add_physics_callback("send_actions", self.send_actions)
def send_actions(self, step_size):
if not self.force_applied:
# Pedestrian1に力を加える
self._dc.apply_body_force(self.pedestrian1_handle, np.array([20.0, 0.0, 0.0]), np.array([0, 0, 0]), True)
# Pedestrian2に力を加える
self._dc.apply_body_force(self.pedestrian2_handle, np.array([20.0, 0.0, 0.0]), np.array([0, 0, 0]), False)
self.force_applied = True # 力を加えたフラグをTrueにする