mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-13 21:30:09 +00:00
fix pybullet gym environments: InvertedDoublePendulumBulletEnv-v0,
InvertedPendulumBulletEnv-v0, InvertedPendulumSwingupBulletEnv-v0 motors were not disabled, extra gains applied etc.
This commit is contained in:
parent
c220513757
commit
3d7ee317db
@ -53,6 +53,7 @@ class MJCFBasedRobot:
|
||||
part_name = part_name.decode("utf8")
|
||||
parts[part_name] = BodyPart(part_name, bodies, i, -1)
|
||||
for j in range(p.getNumJoints(bodies[i])):
|
||||
p.setJointMotorControl2(bodies[i],j,p.POSITION_CONTROL,positionGain=0.1,velocityGain=0.1,force=0)
|
||||
_,joint_name,_,_,_,_,_,_,_,_,_,_,part_name = p.getJointInfo(bodies[i], j)
|
||||
|
||||
joint_name = joint_name.decode("utf8")
|
||||
@ -209,4 +210,4 @@ class Joint:
|
||||
self.disable_motor()
|
||||
|
||||
def disable_motor(self):
|
||||
p.setJointMotorControl2(self.bodies[self.bodyIndex],self.jointIndex,controlMode=p.VELOCITY_CONTROL, force=0)
|
||||
p.setJointMotorControl2(self.bodies[self.bodyIndex],self.jointIndex,controlMode=p.POSITION_CONTROL, targetPosition=0, targetVelocity=0, positionGain=0.1, velocityGain=0.1, force=0)
|
||||
|
@ -3,7 +3,6 @@ import numpy as np
|
||||
|
||||
class InvertedPendulum(MJCFBasedRobot):
|
||||
swingup = False
|
||||
force_gain = 12 # TODO: Try to find out why we need to scale the force
|
||||
def __init__(self):
|
||||
MJCFBasedRobot.__init__(self, 'inverted_pendulum.xml', 'cart', action_dim=1, obs_dim=5)
|
||||
|
||||
@ -20,7 +19,7 @@ class InvertedPendulum(MJCFBasedRobot):
|
||||
if not np.isfinite(a).all():
|
||||
print("a is inf")
|
||||
a[0] = 0
|
||||
self.slider.set_motor_torque( self.force_gain * 100*float(np.clip(a[0], -1, +1)) )
|
||||
self.slider.set_motor_torque( 100*float(np.clip(a[0], -1, +1)) )
|
||||
|
||||
def calc_state(self):
|
||||
self.theta, theta_dot = self.j1.current_position()
|
||||
@ -50,7 +49,6 @@ class InvertedPendulum(MJCFBasedRobot):
|
||||
|
||||
class InvertedPendulumSwingup(InvertedPendulum):
|
||||
swingup = True
|
||||
force_gain = 2.2 # TODO: Try to find out why we need to scale the force
|
||||
|
||||
|
||||
class InvertedDoublePendulum(MJCFBasedRobot):
|
||||
@ -70,8 +68,7 @@ class InvertedDoublePendulum(MJCFBasedRobot):
|
||||
|
||||
def apply_action(self, a):
|
||||
assert( np.isfinite(a).all() )
|
||||
force_gain = 0.78 # TODO: Try to find out why we need to scale the force
|
||||
self.slider.set_motor_torque( force_gain *200*float(np.clip(a[0], -1, +1)) )
|
||||
self.slider.set_motor_torque( 200*float(np.clip(a[0], -1, +1)) )
|
||||
|
||||
def calc_state(self):
|
||||
theta, theta_dot = self.j1.current_position()
|
||||
@ -84,4 +81,4 @@ class InvertedDoublePendulum(MJCFBasedRobot):
|
||||
self.pos_x,
|
||||
np.cos(theta), np.sin(theta), theta_dot,
|
||||
np.cos(gamma), np.sin(gamma), gamma_dot,
|
||||
])
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user