From 6cb7851314d37f4d5a27d9ad2e4118b74d1715e5 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 28 Aug 2024 19:27:13 -0700 Subject: [PATCH] car: default now_nanos value --- opendbc/car/interfaces.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/opendbc/car/interfaces.py b/opendbc/car/interfaces.py index c19591f4a2..3d5252dcb8 100644 --- a/opendbc/car/interfaces.py +++ b/opendbc/car/interfaces.py @@ -1,10 +1,11 @@ import json import os import numpy as np +import time import tomllib from abc import abstractmethod, ABC from enum import StrEnum -from typing import Any, NamedTuple +from typing import Any, NamedTuple, Optional from collections.abc import Callable from functools import cache @@ -101,7 +102,9 @@ def __init__(self, CP: structs.CarParams, CarController, CarState): dbc_name = "" if self.cp is None else self.cp.dbc_name self.CC: CarControllerBase = CarController(dbc_name, CP) - def apply(self, c: structs.CarControl, now_nanos: int) -> tuple[structs.CarControl.Actuators, list[CanData]]: + def apply(self, c: structs.CarControl, now_nanos: Optional[int] = None) -> tuple[structs.CarControl.Actuators, list[CanData]]: + if now_nanos is None: + now_nanos = int(time.monotonic() * 1e9) return self.CC.update(c, self.CS, now_nanos) @staticmethod