bullet3 icon indicating copy to clipboard operation
bullet3 copied to clipboard

High PD Gains

Open SidPad opened this issue 9 months ago • 0 comments

Hello @erwincoumans,

In the below thread, you mentioned that the PD gains for POSITION_CONTROL need to be in the range [0,..,1]. Currently I am working on a Sim2Real problem, and the actual gains that are used on the real robot are a lot higher:

Kp = [ 44000, 44000, 2000, 2000, 15000, 14000, 14000, 14000, 14000, 14000, 14000, 15000, 14000, 14000, 14000, 14000, 14000, 14000, 20000, 20000, 20000, 20000, 10000, 10000, 20000, 20000, 20000, 20000, 10000, 10000]

Kd = [
  440, 440, 
  50, 50, 
  240, 240, 240, 
  240, 240, 240, 240,
  240, 240, 240, 
  240, 240, 240, 240,
  400, 400, 400, 400,
  300, 300,
  400, 400, 400, 400,
  300, 300]

Does that mean that I would need to retune the PD gains to fall within [0-1]? These gains are meant to be used for a full-sized humanoid robot. Thanks in advance.

#################################################################

Hi Avik!

There are a few issues:

  1. You are using PD gains, but those are not suitable for POSITION_CONTROL mode, but you can use PD gains for the PD_CONTROL control method. For POSITION_CONTROL use Kp=1 and Kd=0.1, gains need to be in range [0..1].

  2. In addition, your velocity exceed 100 rad/sec, and this hits a safety clamp. I just exposed a method to increase this maxJointVelocity setting.

p.changeDynamics(bid,	-1,	maxJointVelocity=1000)
	usePD	=	False
	if usePD:
		p.setJointMotorControlArray(bid, [1],	p.PD_CONTROL,	targetPositions=[qdes],	targetVelocities=[dqdes],	positionGains=[100000],	velocityGains=[100], forces=[1000000000])
	else:
		p.setJointMotorControlArray(bid, [1],	p.POSITION_CONTROL,	targetPositions=[qdes],	targetVelocities=[dqdes],	positionGains=[1], velocityGains=[0.1],	forces=[1000000000])

image

Just in case, even though this doesn't affect your test noticeably, but you can disable default damping like this:

p.changeDynamics(bid,-1,linearDamping=0, angularDamping=0)

See attached avik.zip for a fix. You will need PyBullet 2.4.8 or newer for the changeDynamics(maxJointVelocity). https://github.com/bulletphysics/bullet3/pull/2153

avik.zip

Originally posted by @erwincoumans in https://github.com/bulletphysics/bullet3/issues/2152#issuecomment-471203162

SidPad avatar Oct 03 '23 01:10 SidPad