PyBullet R2D2 Environment works but not PyBulletGym for the same model

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
Manish
Posts: 4
Joined: Sat Aug 13, 2022 8:08 am

PyBullet R2D2 Environment works but not PyBulletGym for the same model

Post by Manish »

I am trying to build upon the RaceCar environment provided in the PyBullet Tutorials, by replacing the racecar with a R2D2 model and also replacing the control of wheels by a simple differential steering logic, where the wheels on the right have 1 velocity and the ones on left have another.

On trying to implement this simple scenario individually as a PyBullet script pybullet_r2d2.py, I get the desired scenario where the robot is turning with some radius. The only actuation is feasible on wheels and no other joint. However, when I try to create a Gym environment with the exact same URDF and step() logic r2d2GymEnvTest.py, I see a weird behaviour where the head is swivelling and the gripper pole enters in and out of the body. Basically the 2 joints seem to be active despite giving no force/velocity input. I have tried forcefully setting it to 0, but no help. I also increased solver steps and decreased time step but no help again.

I am not able to identify where this difference arises from. I am attaching all my scripts for reference (it's not nicely written though). I am completely stuck. Please do let me know if there's something which I am missing!

It will be clearly visible that there is bare minimum modification from the tutorial script.

P.S. I did try to see if there is some force provided to the joints using p.enableJointForceTorqueSensor(), and it indeed shows the force/torque to be 0 for head and gripper. This makes me even more confused as to how the bodies are moving without any force.
Attachments
r2d2_pybullet.zip
(143.23 KiB) Downloaded 828 times
Manish
Posts: 4
Joined: Sat Aug 13, 2022 8:08 am

Re: PyBullet R2D2 Environment works but not PyBulletGym for the same model

Post by Manish »

Ok, I just found out why one of them works while the other doesn't. As expected, I was the one who had made an error. It seems that the bodies which don't actually should have some joint force. No joint force is the reason they were moving freely in space. I had set the revolute and prismatic joints as VELOCITY_CONTROL mode with target velocity and force as 0, as suggested in the documentation. But I guess I interpreted it wrong.

Will add more here when I discover some more information.
Post Reply