Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into parser_remove_que…
Browse files Browse the repository at this point in the history
…ry_latest
  • Loading branch information
sshane committed Nov 2, 2024
2 parents 1fa97ff + a84fe18 commit eef22f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions opendbc/can/parser_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from libcpp.vector cimport vector
from libc.stdint cimport uint32_t

from .common cimport CANParser as cpp_CANParser
from .common cimport dbc_lookup, Msg, DBC, CanData, CanFrame
from .common cimport dbc_lookup, Msg, DBC, CanData

import numbers
from collections import defaultdict
Expand All @@ -17,23 +17,26 @@ cdef class CANParser:
cdef:
cpp_CANParser *can
const DBC *dbc
vector[uint32_t] addresses
set addresses

cdef readonly:
dict vl
dict vl_all
dict ts_nanos
string dbc_name
uint32_t bus

def __init__(self, dbc_name, messages, bus=0):
self.dbc_name = dbc_name
self.bus = bus
self.dbc = dbc_lookup(dbc_name)
if not self.dbc:
raise RuntimeError(f"Can't find DBC: {dbc_name}")

self.vl = {}
self.vl_all = {}
self.ts_nanos = {}
self.addresses = set()

# Convert message names into addresses and check existence in DBC
cdef vector[pair[uint32_t, int]] message_v
Expand All @@ -46,7 +49,7 @@ cdef class CANParser:

address = m.address
message_v.push_back((address, c[1]))
self.addresses.push_back(address)
self.addresses.add(address)

name = m.name.decode("utf8")
signal_names = [sig.name.decode("utf-8") for sig in (<Msg*>m).sigs]
Expand Down Expand Up @@ -84,11 +87,13 @@ cdef class CANParser:
can_data = &(can_data_array.emplace_back())
can_data.nanos = s[0]
can_data.frames.reserve(len(s[1]))
for f in s[1]:
frame = &(can_data.frames.emplace_back())
frame.address = f[0]
frame.dat = f[1]
frame.src = f[2]
for address, dat, src in s[1]:
source_bus = <uint32_t>src
if source_bus == self.bus and address in self.addresses:
frame = &(can_data.frames.emplace_back())
frame.address = address
frame.dat = dat
frame.src = source_bus
except TypeError:
raise RuntimeError("invalid parameter")

Expand Down
4 changes: 2 additions & 2 deletions opendbc/car/ford/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def apply_ford_curvature_limits(apply_curvature, apply_curvature_last, current_c

def apply_creep_compensation(accel: float, v_ego: float) -> float:
creep_accel = interp(v_ego, [1., 3.], [0.6, 0.])
if accel < 0.:
accel -= creep_accel
creep_accel = interp(accel, [0., 0.2], [creep_accel, 0.])
accel -= creep_accel
return accel


Expand Down

0 comments on commit eef22f6

Please sign in to comment.