maxspahn / gym_envs_urdf

URDF environments for gym
https://maxspahn.github.io/gym_envs_urdf/
GNU General Public License v3.0
43 stars 14 forks source link

Weird & Unwanted Behavior to Singular Input Action #237

Open behradkhadem opened 9 months ago

behradkhadem commented 9 months ago

Hello @maxspahn, I've come across some hurdles in my project and this is a weird one. We know that joints can get actuated and actuated joints move links (dah!) but we expect that whenever a single joint is actuated, only links connected to that joint move, right? This is the issue I've come across while I was testing stuff. We have an issue on this matter. Given these samples:

from urdfenvs.robots.generic_urdf import GenericUrdfReacher
from urdfenvs.urdf_common import UrdfEnv
import numpy as np

robots = [
    GenericUrdfReacher(urdf='mobilePandaWithGripper.urdf', mode="vel"),
]

render: bool = True

roboticEnv = UrdfEnv(render=render, robots=robots)

roboticEnv.set_spaces()

ob, *_ = roboticEnv.reset()

roboticEnv.reset()
while True:
    action = np.array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0])
    obs, reward, done, truncated, info = roboticEnv.step(action)

and

from urdfenvs.robots.generic_urdf import GenericUrdfReacher
from urdfenvs.urdf_common import UrdfEnv
import numpy as np

robots = [
    GenericUrdfReacher(urdf='panda_with_gripper.urdf', mode="vel"),
]

render: bool = True

roboticEnv = UrdfEnv(render=render, robots=robots)

roboticEnv.set_spaces()

ob, *_ = roboticEnv.reset()

roboticEnv.reset()
while True:
    action = np.array([1, 0, 0, 0, 0, 0, 0, 0, 0])
    obs, reward, done, truncated, info = roboticEnv.step(action)

we clearly see that the input action is intended to move one joint. But after a while, some other joints start moving. And I think this can cause some issues. Is this us or pyBullet? Because code is solid and I don't see any case that our input violate something in pyBullet's documentation. Or have I gone mad? 😅Can you check this one? I can't find a logical explanation for this.

maxspahn commented 9 months ago

The moment you are trying to exceed the joint limits, the behavior become weird in pybullet. The PID controller for velocities is probably saturating the torques too much. You should stop your while loop as soon as done becomes true, in your cases around step 300.

If you do so, you can plot the velocities, see below and you observe nothing weird about it.

MobilePandaWithGripper mobilePandaWithGripper_velocities

PandaWithGripper pandaWithGripper_velocities