Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Aug 19, 2024
1 parent 49105ad commit 9f5ee1a
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions selfdrive/car/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import os
import time
from typing import Any
from dataclasses import asdict
import copy

import cereal.messaging as messaging

Expand Down Expand Up @@ -36,7 +34,6 @@

def obd_callback(params: Params) -> ObdCallback:
def set_obd_multiplexing(obd_multiplexing: bool):
return
if params.get_bool("ObdMultiplexingEnabled") != obd_multiplexing:
cloudlog.warning(f"Setting OBD multiplexing to {obd_multiplexing}")
params.remove("ObdMultiplexingChanged")
Expand Down Expand Up @@ -135,7 +132,7 @@ class Car:
CP_capnp: car.CarParams

def __init__(self, CI=None) -> None:
self.can_sock = messaging.sub_sock('can', timeout=5)
self.can_sock = messaging.sub_sock('can', timeout=20)
self.sm = messaging.SubMaster(['pandaStates', 'carControl', 'onroadEvents'])
self.pm = messaging.PubMaster(['sendcan', 'carState', 'carParams', 'carOutput'])

Expand Down Expand Up @@ -197,8 +194,6 @@ def __init__(self, CI=None) -> None:
if prev_cp is not None:
self.params.put("CarParamsPrevRoute", prev_cp)

self.can_strs = []

# Write CarParams for controls and radard
# convert to pycapnp representation for caching and logging
self.CP_capnp = convert_to_capnp(self.CP)
Expand All @@ -213,17 +208,13 @@ def __init__(self, CI=None) -> None:
self.mock_carstate = MockCarState()

# card is driven by can recv, expected at 100Hz
self.rk = Ratekeeper(10000, print_delay_threshold=None)
self.rk = Ratekeeper(100, print_delay_threshold=None)

def state_update(self) -> car.CarState:
"""carState update loop, driven by can"""

# Update carState from CAN
if len(self.can_strs) < 100:
can_strs = messaging.drain_sock_raw(self.can_sock, wait_for_one=True)
self.can_strs.append(can_strs)
else:
can_strs = self.can_strs[50]
can_strs = messaging.drain_sock_raw(self.can_sock, wait_for_one=True)
CS = convert_to_capnp(self.CI.update(can_capnp_to_list(can_strs)))

if self.CP.carName == 'mock':
Expand Down Expand Up @@ -323,8 +314,7 @@ def step(self):
def card_thread(self):
while True:
self.step()
# self.rk.monitor_time()
self.rk.keep_time()
self.rk.monitor_time()


def main():
Expand Down

0 comments on commit 9f5ee1a

Please sign in to comment.