forked from jyoung8607/openpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lane filtering in model_parser is not tested
- Loading branch information
Showing
9 changed files
with
510 additions
and
780 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env python | ||
import csv | ||
import zmq | ||
import time | ||
import numpy as np | ||
import selfdrive.messaging as messaging | ||
from selfdrive.services import service_list | ||
from common.realtime import set_realtime_priority, Ratekeeper | ||
import os, os.path | ||
|
||
# Polling rate should be twice the data rate to prevent aliasing | ||
def main(rate=200): | ||
set_realtime_priority(5) | ||
context = zmq.Context() | ||
poller = zmq.Poller() | ||
|
||
live100 = messaging.sub_sock(context, service_list['live100'].port, conflate=True, poller=poller) | ||
carState = messaging.sub_sock(context, service_list['carState'].port, conflate=True, poller=poller) | ||
can = None #messaging.sub_sock(context, service_list['can'].port, conflate=True, poller=poller) | ||
|
||
vEgo = 0.0 | ||
_live100 = None | ||
_can = None | ||
|
||
frame_count = 0 | ||
skipped_count = 0 | ||
|
||
rk = Ratekeeper(rate, print_delay_threshold=np.inf) | ||
|
||
# simple version for working with CWD | ||
#print len([name for name in os.listdir('.') if os.path.isfile(name)]) | ||
|
||
# path joining version for other paths | ||
DIR = '/sdcard/tuning' | ||
filenumber = len([name for name in os.listdir(DIR) if os.path.isfile(os.path.join(DIR, name))]) | ||
|
||
kegman_counter = 0 | ||
monoTimeOffset = 0 | ||
receiveTime = 0 | ||
angle_rate = 0.0 | ||
|
||
print("start") | ||
with open(DIR + '/dashboard_file_%d.csv' % filenumber, mode='w') as dash_file: | ||
print("opened") | ||
dash_writer = csv.writer(dash_file, delimiter=',', quotechar='', quoting=csv.QUOTE_NONE) | ||
print("initialized") | ||
dash_writer.writerow(['angle_steers_des','angle_steers','angle_rate','dampened_angle_steers_des','dampened_angle_rate_des','dampened_angle_steers','v_ego','steer_override','p','i','f','time']) | ||
print("first row") | ||
|
||
while 1: | ||
for socket, event in poller.poll(0): | ||
if socket is can: | ||
_can = messaging.recv_one(socket) | ||
print(_can) | ||
|
||
if socket is carState: | ||
_carState = messaging.drain_sock(socket) | ||
for cs in _carState: | ||
angle_rate = cs.carState.steeringRate | ||
|
||
if socket is live100: | ||
_live100 = messaging.drain_sock(socket) | ||
for l100 in _live100: | ||
vEgo = l100.live100.vEgo | ||
if vEgo > 0: # and l100.live100.active: | ||
receiveTime = int(monoTimeOffset + l100.logMonoTime) | ||
if (abs(receiveTime - int(time.time() * 1000000000)) > 10000000000): | ||
monoTimeOffset = (time.time() * 1000000000) - l100.logMonoTime | ||
receiveTime = int(monoTimeOffset + l100.logMonoTime) | ||
|
||
frame_count += 1 | ||
dash_writer.writerow([str(round(l100.live100.angleSteersDes, 2)), | ||
str(round(l100.live100.angleSteers, 2)), | ||
str(round(angle_rate,1)), | ||
str(round(l100.live100.dampAngleSteersDes, 2)), | ||
str(round(l100.live100.dampAngleRateDes, 2)), | ||
str(round(l100.live100.dampAngleSteers, 2)), | ||
str(round(l100.live100.vEgo, 1)), | ||
1 if l100.live100.steerOverride else 0, | ||
str(round(l100.live100.upSteer, 4)), | ||
str(round(l100.live100.uiSteer, 4)), | ||
str(round(l100.live100.ufSteer, 4)), | ||
str(receiveTime)]) | ||
else: | ||
skipped_count += 1 | ||
else: | ||
skipped_count += 1 | ||
if frame_count % 200 == 0: | ||
print("captured = %d" % frame_count) | ||
frame_count += 1 | ||
if skipped_count % 200 == 0: | ||
print("skipped = %d" % skipped_count) | ||
skipped_count += 1 | ||
|
||
rk.keep_time() | ||
|
||
if __name__ == "__main__": | ||
main() |
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
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
Oops, something went wrong.