From 83bdd278c6bcdc09397d7a78bfaa42d9d54ab1b4 Mon Sep 17 00:00:00 2001 From: xx979xx <40252818+xx979xx@users.noreply.github.com> Date: Tue, 21 Aug 2018 04:56:04 +0300 Subject: [PATCH 1/8] fix forwarding for giraffe --- panda/board/drivers/can.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/board/drivers/can.h b/panda/board/drivers/can.h index 233b99027b231c..db9f41ee715a29 100644 --- a/panda/board/drivers/can.h +++ b/panda/board/drivers/can.h @@ -84,7 +84,7 @@ int can_err_cnt = 0; CAN_TypeDef *cans[] = {CAN1, CAN2, CAN3}; uint8_t bus_lookup[] = {0,1,2}; uint8_t can_num_lookup[] = {0,1,2,-1}; - int8_t can_forwarding[] = {1,-1,-1,-1}; + int8_t can_forwarding[] = {2,-1,-1,-1}; uint32_t can_speed[] = {5000, 5000, 5000, 333}; bool can_autobaud_enabled[] = {false, false, false, false}; #define CAN_MAX 3 From 6da4a9a804944a2306055a79a78a95507b5c5fbf Mon Sep 17 00:00:00 2001 From: xx979xx <40252818+xx979xx@users.noreply.github.com> Date: Tue, 21 Aug 2018 04:57:08 +0300 Subject: [PATCH 2/8] fix forwarding for giraffe --- selfdrive/car/hyundai/camstate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/car/hyundai/camstate.py b/selfdrive/car/hyundai/camstate.py index 8d9e56b5d3333b..babda7cf5c35d8 100644 --- a/selfdrive/car/hyundai/camstate.py +++ b/selfdrive/car/hyundai/camstate.py @@ -27,7 +27,7 @@ def get_can_parser2(CP): ("LKAS12", 10) # LKAS12 = 10Hz ] - return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 1) + return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2) class CamState(object): From 115520670d2fe3ebdac1a2c8ed762b8c1989157d Mon Sep 17 00:00:00 2001 From: xx979xx <40252818+xx979xx@users.noreply.github.com> Date: Tue, 21 Aug 2018 05:01:15 +0300 Subject: [PATCH 3/8] Update carcontroller.py as cabana shows --- selfdrive/car/hyundai/carcontroller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index a0580e25f9d939..747d5a87880b46 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -136,13 +136,13 @@ def update(self, sendcan, enabled, CS, frame, actuators, CamS): lkas11_byte3 = CamS.lkas11_b3 # When LKAS Forward is disabled, we generate the entire LKAS message else: - lkas11_byte0 = self.lanes + 0x2 + lkas11_byte0 = self.lanes + 0x06 lkas11_byte1 = 0x00 lkas11_byte2 = apply_steer_a lkas11_byte3 = apply_steer_b lkas11_byte4 = (self.idx * 16) + 0x04 lkas11_byte5 = 0x00 - lkas11_byte7 = 0x18 + lkas11_byte7 = 0x02 From d1511a0c30f66fdf8bee644be9183ed68e31fecd Mon Sep 17 00:00:00 2001 From: xx979xx <40252818+xx979xx@users.noreply.github.com> Date: Tue, 21 Aug 2018 05:13:57 +0300 Subject: [PATCH 4/8] Update interface.py as car specs --- selfdrive/car/hyundai/interface.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 308e6c8d6284ed..d8913de8aee4a1 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -77,9 +77,9 @@ def get_params(candidate, fingerprint): ret.steerKf = 0.00008 # full torque for 20 deg at 80mph means 0.00007818594 ret.steerRateCost = 1. stop_and_go = True - ret.mass = 1985 + std_cargo - ret.wheelbase = 2.78 - ret.steerRatio = 15.0 + ret.mass = 2060 + std_cargo + ret.wheelbase = 3.01 + ret.steerRatio = 16.5 ret.steerKpV, ret.steerKiV = [[0.20], [0.007]] ret.centerToFront = ret.wheelbase * 0.4 @@ -88,7 +88,7 @@ def get_params(candidate, fingerprint): # min speed to enable ACC. if car can do stop and go, then set enabling speed # to a negative value, so it won't matter. - ret.minEnableSpeed = -1. + ret.minEnableSpeed = 56. centerToRear = ret.wheelbase - ret.centerToFront # TODO: get actual value, for now starting with reasonable value for From d05c5c1c5c0a8d89eccdeb1552364c9f9b21ed42 Mon Sep 17 00:00:00 2001 From: xx979xx <40252818+xx979xx@users.noreply.github.com> Date: Tue, 21 Aug 2018 05:15:54 +0300 Subject: [PATCH 5/8] fix speed error --- selfdrive/car/hyundai/carstate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 88619ea68ff5c5..cd9eaf8d73ffee 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -132,8 +132,8 @@ def update(self, cp): # There is a 2% error on Sorento GT due to slightly larger wheel diameter compared to poverty packs. # Dash assumes about 4% which is excessive. Using 3% to be safe - if self.car_fingerprint == CAR.SORENTO: - self.v_wheel = self.v_wheel * 1.03 + if self.car_fingerprint == CAR.GENESIS: + self.v_wheel = self.v_wheel * 1.075 self.low_speed_lockout = self.v_wheel < 1.0 # Kalman filter From 70cde9110d86c2dd2deaa708404ee333b97f6978 Mon Sep 17 00:00:00 2001 From: xx979xx <40252818+xx979xx@users.noreply.github.com> Date: Tue, 21 Aug 2018 06:47:32 +0300 Subject: [PATCH 6/8] Fix min speed unit --- selfdrive/car/hyundai/interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index d8913de8aee4a1..f6dd6fee64f9fe 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -88,7 +88,7 @@ def get_params(candidate, fingerprint): # min speed to enable ACC. if car can do stop and go, then set enabling speed # to a negative value, so it won't matter. - ret.minEnableSpeed = 56. + ret.minEnableSpeed = 56 * CV.KPH_TO_MS centerToRear = ret.wheelbase - ret.centerToFront # TODO: get actual value, for now starting with reasonable value for From c5b7e46dd827e58a316602d6bd45088e94142e5e Mon Sep 17 00:00:00 2001 From: xx979xx <40252818+xx979xx@users.noreply.github.com> Date: Tue, 21 Aug 2018 18:05:31 +0300 Subject: [PATCH 7/8] Improve tuning Not finished yet --- selfdrive/car/hyundai/interface.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index f6dd6fee64f9fe..63d23a081098f7 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -74,13 +74,13 @@ def get_params(candidate, fingerprint): ret.steerActuatorDelay = 0.1 # Default delay, Prius has larger delay #borrowing a lot from corolla, given similar car size - ret.steerKf = 0.00008 # full torque for 20 deg at 80mph means 0.00007818594 + ret.steerKf = 0.000078 # full torque for 20 deg at 80mph means 0.00007818594 ret.steerRateCost = 1. stop_and_go = True ret.mass = 2060 + std_cargo ret.wheelbase = 3.01 ret.steerRatio = 16.5 - ret.steerKpV, ret.steerKiV = [[0.20], [0.007]] + ret.steerKpV, ret.steerKiV = [[0.14], [0.005]] ret.centerToFront = ret.wheelbase * 0.4 ret.longPidDeadzoneBP = [0., 9.] From b4206dea8e4bdfe79adff8cc1f5ecca80308eb4a Mon Sep 17 00:00:00 2001 From: xx979xx <40252818+xx979xx@users.noreply.github.com> Date: Fri, 31 Aug 2018 17:23:15 +0300 Subject: [PATCH 8/8] tuning --- selfdrive/car/hyundai/interface.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 63d23a081098f7..101693fa568876 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -63,6 +63,16 @@ def get_params(candidate, fingerprint): ret.safetyModel = car.CarParams.SafetyModels.hyundai # pedal + # FIXME: hardcoding honda civic 2016 touring params so they can be used to + # scale unknown params for other cars + mass_civic = 2923 * CV.LB_TO_KG + std_cargo + wheelbase_civic = 2.70 + centerToFront_civic = wheelbase_civic * 0.4 + centerToRear_civic = wheelbase_civic - centerToFront_civic + rotationalInertia_civic = 2500 + tireStiffnessFront_civic = 192150 + tireStiffnessRear_civic = 202500 + ret.enableCruise = False rotationalInertia = 2500 @@ -74,14 +84,15 @@ def get_params(candidate, fingerprint): ret.steerActuatorDelay = 0.1 # Default delay, Prius has larger delay #borrowing a lot from corolla, given similar car size - ret.steerKf = 0.000078 # full torque for 20 deg at 80mph means 0.00007818594 - ret.steerRateCost = 1. + ret.steerKf = 0.00004 # full torque for 20 deg at 80mph means 0.00007818594 + ret.steerRateCost = 0.5 stop_and_go = True ret.mass = 2060 + std_cargo ret.wheelbase = 3.01 ret.steerRatio = 16.5 - ret.steerKpV, ret.steerKiV = [[0.14], [0.005]] + ret.steerKpV, ret.steerKiV = [[0.16], [0.007]] ret.centerToFront = ret.wheelbase * 0.4 + tire_stiffness_factor = 1. ret.longPidDeadzoneBP = [0., 9.] ret.longPidDeadzoneV = [0., .15] @@ -97,8 +108,12 @@ def get_params(candidate, fingerprint): # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors - ret.tireStiffnessFront = tireStiffnessFront * ret.mass * (centerToRear / ret.wheelbase) - ret.tireStiffnessRear = tireStiffnessRear * ret.mass * (ret.centerToFront / ret.wheelbase) + ret.tireStiffnessFront = (tireStiffnessFront_civic * tire_stiffness_factor) * \ + ret.mass / mass_civic * \ + (centerToRear / ret.wheelbase) / (centerToRear_civic / wheelbase_civic) + ret.tireStiffnessRear = (tireStiffnessRear_civic * tire_stiffness_factor) * \ + ret.mass / mass_civic * \ + (ret.centerToFront / ret.wheelbase) / (centerToFront_civic / wheelbase_civic) # no rear steering, at least on the listed cars above ret.steerRatioRear = 0.