benelot / pybullet-gym

Open-source implementations of OpenAI Gym MuJoCo environments for use with the OpenAI Gym Reinforcement Learning Research Platform.
https://pybullet.org/
Other
814 stars 124 forks source link

Any suggestions on how to lock certain joints? #73

Open gunnxx opened 2 years ago

gunnxx commented 2 years ago

I am trying to implement meta-learning for RL that needs environment that can be applied with certain damages. I am trying to implement locked joint on the agent e.g. ant environment. I tried two options

self.robot.ordered_joints[idx].disable_motor()   # first way
self.robot.ordered_joints[idx].power_coef = 0.0  # second way

Turns out, disable_motor() only makes the motor dead by applying no torque to the motor i.e. setJointMotorControl2(self.bodies[self.bodyIndex], self.jointIndex, controlMode=pybullet.POSITION_CONTROL, targetPosition=0, targetVelocity=0, positionGain=0.1, velocityGain=0.1, force=0). The joint is still moving due to other forces e.g. gravity. What I need is the joint to be locked at a certain degree.

For the power_coef, seems like that property is not being used by any of the methods in Joint class. Additionally, I found a typo(?). Joint has property power_coeff, but this line tries to change power_coef instead of power_coeff.

Back to the original question? Any suggestions on how to lock certain joints?