Skip to content

Commit

Permalink
use livePose
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Oct 18, 2024
1 parent 2f0385d commit 84953a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 5 additions & 1 deletion opendbc/car/toyota/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ def update(self, CC, CS, now_nanos):
# TODO: sometimes when switching from brake to gas quickly, CLUTCH->ACCEL_NET shows a slow unwind. make it go to 0 immediately
if self.CP.flags & ToyotaFlags.RAISED_ACCEL_LIMIT and CC.longActive and not CS.out.cruiseState.standstill:
# calculate amount of acceleration PCM should apply to reach target, given pitch
accel_due_to_pitch = math.sin(CS.slope_angle) * ACCELERATION_DUE_TO_GRAVITY
if len(CC.orientationNED) == 3:
accel_due_to_pitch = math.sin(CC.orientationNED[1]) * ACCELERATION_DUE_TO_GRAVITY
else:
accel_due_to_pitch = 0.0

net_acceleration_request = actuators.accel + accel_due_to_pitch

# let PCM handle stopping for now
Expand Down
2 changes: 0 additions & 2 deletions opendbc/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def __init__(self, CP):
self.acc_type = 1
self.lkas_hud = {}
self.pcm_accel_net = 0.0
self.slope_angle = 0.0
self.secoc_synchronization = None

def update(self, cp, cp_cam, *_) -> structs.CarState:
Expand Down Expand Up @@ -88,7 +87,6 @@ def update(self, cp, cp_cam, *_) -> structs.CarState:
can_gear = int(cp.vl["GEAR_PACKET_HYBRID"]["GEAR"])
else:
ret.gasPressed = cp.vl["PCM_CRUISE"]["GAS_RELEASED"] == 0 # TODO: these also have GAS_PEDAL, come back and unify
self.slope_angle = cp.vl["VSC1S07"]["ASLP"] * CV.DEG_TO_RAD # filtered pitch from the car, negative is downward
can_gear = int(cp.vl["GEAR_PACKET"]["GEAR"])
if not self.CP.enableDsu and not self.CP.flags & ToyotaFlags.DISABLE_RADAR.value:
ret.stockAeb = bool(cp_acc.vl["PRE_COLLISION"]["PRECOLLISION_ACTIVE"] and cp_acc.vl["PRE_COLLISION"]["FORCE"] < -1e-5)
Expand Down

0 comments on commit 84953a0

Please sign in to comment.