haosulab / SAPIEN

SAPIEN Embodied AI Platform
https://sapien.ucsd.edu/
MIT License
430 stars 41 forks source link

set_velocity not working #148

Closed chisarie closed 10 months ago

chisarie commented 10 months ago

System:

Describe the bug I create a kinematic actor and set its linear velocity using the function set_velocity, but the block is not moving

To Reproduce

import numpy as np
import sapien.core as sapien
from sapien.utils.viewer import Viewer

engine = sapien.Engine()
renderer = sapien.SapienRenderer()
engine.set_renderer(renderer)
scene = engine.create_scene()
scene.set_timestep(1 / 240)
scene.set_ambient_light([0.5, 0.5, 0.5])
scene.add_directional_light([0, 1, -1], [0.5, 0.5, 0.5])
viewer = Viewer(renderer)
viewer.set_scene(scene)
viewer.set_camera_xyz(x=-2, y=0, z=2.5)
viewer.set_camera_rpy(r=0, p=-np.arctan2(2, 2), y=0)
viewer.window.set_camera_parameters(near=0.05, far=100, fovy=1)

half_size = [0.1, 0.1, 0.1]
builder = scene.create_actor_builder()
builder.add_box_collision(half_size=half_size)
builder.add_box_visual(half_size=half_size, color=[0.2, 0.2, 0.2])
block = builder.build_kinematic()
block.set_velocity([1.0, 1.0, 1.0])

while not viewer.closed:
    scene.step()
    scene.update_render()
    viewer.render()

Expected behavior I expect the block to move at constant velocity

fbxiang commented 10 months ago

Kinematic object does not support velocity. If you do not require the kinematic actor to push other dynamic actors, you just need to set its pose every step. If you do need interactions between a moving kinematic actors and dynamic actors, unfortunately this interface was not properly exposed in SAPIEN 2. SAPIEN 3 (currently in alpha) does expose this functionality set_kinematic_target. The function is used in the same way as set_pose but the kinematic object will be moved instead of teleported to the target location.

chisarie commented 10 months ago

Thank you very much for your response. I indeed need the interaction between the kinematic actor and a dynamic one, so I will try to make it work with sapien 3. By the way, what is the expected timeline for the release of version 3?

Thank you again!

fbxiang commented 10 months ago

It is a bit hard to estimate an exact release date. However, we do not plan to have major API changes at this point so you could even start using the nightly builds if you need to make something right now. And I can provide support if something is not functioning as you expect. The major thing currently missing is full documentation, which will be worked on and posted to https://sapien-sim.github.io/docs/

chisarie commented 10 months ago

Thank you! I'll close this issue.