@@ -52,10 +52,17 @@ def _lta_msg(self, req, req2, angle_cmd, torque_wind_down=100):
5252 values = {"STEER_REQUEST" : req , "STEER_REQUEST_2" : req2 , "STEER_ANGLE_CMD" : angle_cmd , "TORQUE_WIND_DOWN" : torque_wind_down }
5353 return self .packer .make_can_msg_panda ("STEERING_LTA" , 0 , values )
5454
55- def _accel_msg (self , accel , cancel_req = 0 ):
55+ def _accel_msg_343 (self , accel , cancel_req = 0 ):
5656 values = {"ACCEL_CMD" : accel , "CANCEL_REQ" : cancel_req }
5757 return self .packer .make_can_msg_panda ("ACC_CONTROL" , 0 , values )
5858
59+ def _accel_msg_183 (self , accel ):
60+ values = {"ACCEL_CMD" : accel }
61+ return self .packer .make_can_msg_panda ("ACC_CONTROL_2" , 0 , values )
62+
63+ def _accel_msg (self , accel , cancel_req = 0 ):
64+ return self ._accel_msg_343 (accel , cancel_req )
65+
5966 def _speed_msg (self , speed ):
6067 values = {("WHEEL_SPEED_%s" % n ): speed * 3.6 for n in ["FR" , "FL" , "RR" , "RL" ]}
6168 return self .packer .make_can_msg_panda ("WHEEL_SPEEDS" , 0 , values )
@@ -285,9 +292,9 @@ def test_acc_cancel(self):
285292 for controls_allowed in [True , False ]:
286293 self .safety .set_controls_allowed (controls_allowed )
287294 for accel in np .arange (self .MIN_ACCEL - 1 , self .MAX_ACCEL + 1 , 0.1 ):
288- self .assertFalse (self ._tx (self ._accel_msg (accel )))
289- should_tx = np .isclose (accel , 0 , atol = 0.0001 )
290- self .assertEqual (should_tx , self ._tx (self ._accel_msg (accel , cancel_req = 1 )))
295+ self .assertFalse (self ._tx (self ._accel_msg_343 (accel )))
296+ should_tx = np .isclose (accel , self . INACTIVE_ACCEL , atol = 0.0001 )
297+ self .assertEqual (should_tx , self ._tx (self ._accel_msg_343 (accel , cancel_req = 1 )))
291298
292299
293300class TestToyotaStockLongitudinalTorque (TestToyotaStockLongitudinalBase , TestToyotaSafetyTorque ):
@@ -345,6 +352,9 @@ def test_lta_2_steer_cmd(self):
345352 should_tx = not req and not req2 and angle == 0
346353 self .assertEqual (should_tx , self ._tx (self ._lta_2_msg (req , req2 , angle )), f"{ req = } { req2 = } { angle = } " )
347354
355+ def _accel_msg (self , accel , cancel_req = 0 ):
356+ return self ._accel_msg_183 (accel )
357+
348358
349359class TestToyotaSecOcSafetyStockLongitudinal (TestToyotaSecOcSafetyBase , TestToyotaStockLongitudinalBase ):
350360
@@ -371,17 +381,17 @@ def setUp(self):
371381 def test_block_aeb (self , stock_longitudinal : bool = False ):
372382 pass
373383
374- def _accel_msg_2 (self , accel ):
375- values = { "ACCEL_CMD" : accel }
376- return self . packer . make_can_msg_panda ( "ACC_CONTROL_2" , 0 , values )
377-
378- # On a SecOC vehicle, we still transmit ACC_CONTROL but the accel value moves to ACC_CONTROL_2
379- # Verify that all non-idle accel values in ACC_CONTROL are rejected, verify ACC_CONTROL_2 accel normally
380- def _should_tx_1 ( self , controls_allowed : bool , accel : float , min_accel : float , max_accel : float ):
381- return accel == self .INACTIVE_ACCEL
382-
383- def _should_tx_2 ( self , controls_allowed : bool , accel : float , min_accel : float , max_accel : float ):
384- return ( controls_allowed and min_accel <= accel <= max_accel ) or accel == self . INACTIVE_ACCEL
384+ def test_343_actuation_blocked (self ):
385+ """
386+ For SecOC cars, longitudinal acceleration must be sent in ACC_CONTROL_2, but all other ACC
387+ data remains in ACC_CONTROL. Verify no actuation is sent via ACC_CONTROL.
388+ """
389+ for controls_allowed in [ True , False ]:
390+ self . safety . set_controls_allowed ( controls_allowed )
391+ for accel in np . arange ( self .MIN_ACCEL - 1 , self . MAX_ACCEL + 1 , 0.1 ):
392+ should_tx = np . isclose ( accel , self . INACTIVE_ACCEL , atol = 0.0001 )
393+ self . assertEqual ( should_tx , self . _tx ( self . _accel_msg_343 ( accel )), f" accel: { accel = } , { controls_allowed = } , { should_tx = } " )
394+ self . assertEqual ( should_tx , self . _tx ( self . _accel_msg_343 ( accel , cancel_req = 1 )))
385395
386396
387397if __name__ == "__main__" :
0 commit comments