openpilot icon indicating copy to clipboard operation
openpilot copied to clipboard

Hyundai: simplify gasPressed logic

Open rbiasini opened this issue 6 years ago • 17 comments

Currently, the logic is:

if (cp.vl["TCS13"]["DriverOverride"] == 0 and cp.vl["TCS13"]['ACC_REQ'] == 1):
  pedal_gas = 0
else:
  pedal_gas = cp.vl["EMS12"]['TPS']
ret.gasPressed = pedal_gas > 1e-3

This depends on too many signals. Moreover, I believe gasPressed only becomes true when the driver acceleration request exceeds the one from ACC.

Instead, it would be better to use a simple "gas pedal position" signal. @xx979xx, @tk211x any recommendation?

rbiasini avatar Feb 20 '20 17:02 rbiasini

Such a signal has only been discovered on EVs

TK211X avatar Feb 20 '20 23:02 TK211X

@rbiasini in theory, it should be like this:

ret.gas = cp.vl["EMS12"]['PV_AV_CAN'] / 100
ret.gasPressed = ret.gas and not cp.vl["TCS13"]['ACC_REQ'] or cp.vl["TCS13"]["DriverOverride"]

need test across all working cars ~~but still both signals are pedal gas only, computer gas to be added~~

xx979xx avatar Feb 21 '20 20:02 xx979xx

image

TK211X avatar Feb 21 '20 20:02 TK211X

@TK211X , based on what you posted, seems like PV_AV_CAN is "user+computer", no?

rbiasini avatar Feb 21 '20 20:02 rbiasini

I see, yes

xx979xx avatar Feb 21 '20 20:02 xx979xx

I’ll establish a demonstration.

TK211X avatar Feb 21 '20 20:02 TK211X

PV_AV_CAN vs TPS tps

xx979xx avatar Feb 21 '20 20:02 xx979xx

https://my.comma.ai/cabana/?route=53ac3251e03f95d7%7C2020-02-21--15-40-52&exp=1613853905&sig=eGuSmOTiRhRemSqQsobEFZViLMBdV%2BrGdhIW8I4XfIc%3D&max=1&url=https%3A%2F%2Fchffrprivate-vzn.azureedge.net%2Fchffrprivate3%2Fv2%2F53ac3251e03f95d7%2Fa2c993d96520119ee34ca5dcfedfaac7_2020-02-21--15-40-52

Near the start ACC is enabled and set.

Past the 55MPH speed limit sign going onto the bridge I floor the accelerator pedal.

At the end of the bridge I hit the brakes.

TK211X avatar Feb 21 '20 20:02 TK211X

image Green = SCC Set Yellow = Driver Accelerator Pedal Max Action Red = Driver Brake Action

TK211X avatar Feb 22 '20 09:02 TK211X

Actually....... I've spent some time comparing values from the various EMS messages and found a signal that may be of interest to you @rbiasini

CF_Ems_AclAct (EMS16)

It appears to be a flag that's specific to driver accelerator pedal actuation.

image image

TK211X avatar Feb 22 '20 09:02 TK211X

CF_Ems_AclAct (EMS16)

Literally appears to be a signal that says "hey, the driver is using the gas pedal."

Can't get more simple than that.

One thing to keep in mind is that not all vehicles have the same power-plant signals as some messages accomplish specific missions for that model.

Given the nature of this discovery and the fact that HKMC tends to keep signals and their formats universal, albeit, sometimes grouped differently under a different CAN message. I'm sure that finding a similar message for a given model is possible if EMS16 is not present for said model. For example as stated previously in EV's there exists an actual driver accelerator position sensor etc.

TK211X avatar Feb 22 '20 09:02 TK211X

what a wonderful job @TK211X so here you have it @rbiasini

ret.gas = cp.vl["EMS12"]['PV_AV_CAN'] / 100
ret.gasPressed = cp.vl["EMS16"]["CF_Ems_AclAct"]

xx979xx avatar Feb 22 '20 13:02 xx979xx

this is great, @TK211X ! I guess the only slightly confusing part is why cp.vl["EMS16"]["CF_Ems_AclAct"] is 2 bits. I'm going to consider any non-zero value as "pressed". Yeah, I'm going to change both gas and gasPressed as you wrote, @xx979xx . Nice.

rbiasini avatar Feb 22 '20 16:02 rbiasini

merged changes. If you end up driving the code, let me know if you have any issues. Thanks! https://github.com/commaai/openpilot/pull/1152

rbiasini avatar Feb 23 '20 04:02 rbiasini

lol, when is the harness being released. Doubt there would be a reason to use official until it comes out. I hear KU7 said official didn’t even work when he tested it.

So making these small changes doesn't really help.

There's no incentive to load up official and put in the work to polish it up properly. You guys don't even have a Hyundai. The only incentive is to give basic users less instructions to get setup. This type of user base won't flood in unless harness gets released.

If you can give us an approximate release date then we can work together to make it proper.

Otherwise, it's not exactly a priority for the existing user base that prefers features you won't upstream.

TK211X avatar Feb 23 '20 05:02 TK211X

image

TK211X avatar Feb 23 '20 05:02 TK211X

@TK211X , it's ok if you guys are on a custom fork. But I recommend to keep panda code in synch (which is affected by this change).

rbiasini avatar Feb 23 '20 05:02 rbiasini