Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Genesis fix, working #4

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion panda/board/drivers/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/hyundai/camstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
emmertex marked this conversation as resolved.
Show resolved Hide resolved
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
emmertex marked this conversation as resolved.
Show resolved Hide resolved



Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked this against GPS?
Your Dash could be reporting a false high speed (common for most manufacturers)
We want the speed to be accurate, not equal to the dash.

self.low_speed_lockout = self.v_wheel < 1.0

# Kalman filter
Expand Down
33 changes: 24 additions & 9 deletions selfdrive/car/hyundai/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -74,21 +84,22 @@ 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.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 = 1985 + std_cargo
ret.wheelbase = 2.78
ret.steerRatio = 15.0
ret.steerKpV, ret.steerKiV = [[0.20], [0.007]]
ret.mass = 2060 + std_cargo
ret.wheelbase = 3.01
ret.steerRatio = 16.5
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]

# 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 * CV.KPH_TO_MS

centerToRear = ret.wheelbase - ret.centerToFront
# TODO: get actual value, for now starting with reasonable value for
Expand All @@ -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.
Expand Down