Implement train_pybullet_racecar.py and enjoy_pybullet_racecar.py using OpenAI baselines DQN for the RacecarGymEnv.

This commit is contained in:
Erwin Coumans
2017-06-09 19:26:07 -07:00
parent 82e3c553b9
commit b361722500
4 changed files with 138 additions and 33 deletions

View File

@@ -22,7 +22,7 @@ class Racecar:
self.motorizedWheels = [2]
self.steeringLinks=[4,6]
self.speedMultiplier = 10.
def getActionDimension(self):
return self.nMotors
@@ -33,22 +33,25 @@ class Racecar:
def getObservation(self):
observation = []
pos,orn=p.getBasePositionAndOrientation(self.racecarUniqueId)
observation.extend(list(pos))
observation.extend(list(orn))
return observation
def applyAction(self, motorCommands):
targetVelocity=motorCommands[0]*self.speedMultiplier
print("targetVelocity")
print(targetVelocity)
#print("targetVelocity")
#print(targetVelocity)
steeringAngle = motorCommands[1]
print("steeringAngle")
print(steeringAngle)
print("maxForce")
print(self.maxForce)
#print("steeringAngle")
#print(steeringAngle)
#print("maxForce")
#print(self.maxForce)
for motor in self.motorizedwheels:
p.setJointMotorControl2(self.racecarUniqueId,motor,p.VELOCITY_CONTROL,targetVelocity=targetVelocity,force=self.maxForce)
p.setJointMotorControl2(self.racecarUniqueId,motor,p.VELOCITY_CONTROL,targetVelocity=targetVelocity,force=self.maxForce)
for steer in self.steeringLinks:
p.setJointMotorControl2(self.racecarUniqueId,steer,p.POSITION_CONTROL,targetPosition=steeringAngle)