Created
August 21, 2020 19:12
-
-
Save Heavy02011/d96967e31e68a89d0829f0077aa1bc09 to your computer and use it in GitHub Desktop.
gym_donkeycar: version necessary for telemetry part
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Scripts for reading telemtry data of a DonkeySimObject | |
author: Rainer Bareiß, 2020 | |
many thanks to the Parking Lot Nerds team & | |
especially Tawn for so much support and lots of valuable hints | |
""" | |
import os | |
import time | |
import donkeycar as dk | |
import json | |
class TelemetryController(object): | |
''' | |
store actual simulator data into influxdb | |
''' | |
def __init__(self, DonkeySimObject, path, inputs=None, types=None, user_meta=[]): | |
# standard variables | |
print("setting up part: influx...") | |
self.inputs = inputs | |
self.types = types | |
self.user_meta = user_meta | |
self.donkeyenv = DonkeySimObject | |
def update(self): | |
pass | |
def run(self, *args): | |
self.poll() | |
return self.run_threaded() | |
def run_threaded(self, *args): | |
# prepare record | |
assert len(self.inputs) == len(args) | |
record = dict(zip(self.inputs, args)) | |
# get rid of non-numeric fields | |
del record["cam/image_array"] | |
del record["user/mode"] | |
#print(record) | |
print(self.donkeyenv.info) | |
def shutdown(self): | |
self.on = False | |
if __name__ == '__main__': | |
pass | |
""" | |
donkey_sim: {'msg_type': 'telemetry', 'steering_angle': 0, 'throttle': 0, | |
'speed': 0.0002537463, 'hit': 'none', | |
'time': 9714.574, | |
'accel_x': 6.653834e-05, 'accel_y': 8.470644e-05, 'accel_z': -0.0002268534, | |
'gyro_x': -3.883583e-06, 'gyro_y': -1.188326e-07, 'gyro_z': -3.279242e-06, | |
'gyro_w': 1, | |
'pos_x': 51.31769, 'pos_y': 5.26018, 'pos_z': 50.21447, | |
'vel_x': 6.07326e-05, 'vel_y': 6.816578e-05, 'vel_z': -0.0002367534, | |
'cte': 2.883248, 'activeNode': 0, 'totalNodes': 251, | |
'disqualified': 0, 'bestLapTimeMS': 1000000, | |
'currentLapTimeMS': 0, 'numLapsCompleted': 0, | |
'on_road': 1, 'progress_on_shortest_path': 1.907349e-05} | |
manage_max1.py | |
imput after tub handler | |
# RBX: create influxdb client | |
mytelemetry = TelemetryController(path=cfg.DATA_PATH, inputs=inputs, types=types, user_meta=meta) | |
V.add(mytelemetry, inputs=inputs, outputs=[""], threaded=True) | |
# RBX | |
call command | |
(sds) rainer@neuron:~/mysim_robohat$ python manage_max1.py drive | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment