Skip to content

Commit

Permalink
Merge pull request #63 from Heavy02011/master
Browse files Browse the repository at this point in the history
feat: car roll, pitch yaw angle added
  • Loading branch information
tawnkramer authored Apr 15, 2021
2 parents 056afaa + f1fc80a commit 422505c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions gym_donkeycar/envs/donkey_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def __init__(self, conf):
self.vel_z = 0.0
self.lidar = []

# car in Unity lefthand coordinate system: roll is Z, pitch is X and yaw is Y
self.roll = 0.0
self.pitch = 0.0
self.yaw = 0.0

def on_connect(self, client):
logger.debug("socket connected")
self.client = client
Expand Down Expand Up @@ -260,6 +265,11 @@ def reset(self):
self.vel_z = 0.0
self.lidar = []

# car
self.roll = 0.0
self.pitch = 0.0
self.yaw = 0.0

def get_sensor_size(self):
return self.camera_img_size

Expand All @@ -285,6 +295,7 @@ def observe(self):
"accel": (self.accel_x, self.accel_y, self.accel_z),
"vel": (self.vel_x, self.vel_y, self.vel_z),
"lidar": (self.lidar),
"car": (self.roll, self.pitch, self.yaw),
}

# self.timer.on_frame()
Expand Down Expand Up @@ -344,6 +355,12 @@ def on_telemetry(self, data):
self.vel_y = data["vel_y"]
self.vel_z = data["vel_z"]

if "roll" in data:
self.roll = data["roll"]
self.pitch = data["pitch"]
self.yaw = data["yaw"]
print(self.roll, self.pitch, self.yaw)

# Cross track error not always present.
# Will be missing if path is not setup in the given scene.
# It should be setup in the 4 scenes available now.
Expand All @@ -358,9 +375,10 @@ def on_telemetry(self, data):

try:
self.lidar = data["lidar"]
logger.info("reading lidar in telemetry package DONE.")
# logger.info("reading lidar in telemetry package DONE.")
except:
logger.info("reading lidar in telemetry package FAILED.")
pass
# logger.info("reading lidar in telemetry package FAILED.")

self.determine_episode_over()

Expand Down

0 comments on commit 422505c

Please sign in to comment.