comma.ai - Openpilot with the Nissan Leaf [Part 2]
This article will get obsolet as soon as this gets merged: https://github.com/commaai/openpilot/pull/19619
If you have an instrument cluster Leaf and you are not interested in the progress on how to fix it just scroll
down to Making it work
.
How to fix it
I spend a few ours to actually make this work. I ran into 2 issues. First comma two was not able to recognize the car itself.
To fix this, you will need the correct fingerprint. Bad news, if comma does not know your car yet, chances are high you will also need to modify some code. More on that later.
Adding the unknown fingerprint
You need to establish a ssh connection, and then execute openpilot/selfdrive/debug/get_fingerprint.py
.
This will then print the fingerprint of your car. There are a lot of guides on how todo that.
I used the following resources:
- https://medium.com/@comma_ai/openpilot-port-guide-for-toyota-models-e5467f4b5fe6
- https://github.com/commaai/openpilot/wiki/SSH
I then forked the comma ai repository in order to be able to make code changes.
I added the new fingerprint to selfdrive/car/nissan/values.py
and restarted the comma two. Car does now get
recognized almost everytime. 1 of 100 it happens that you may need to turn the car on and off again. Not yet sure why.
You can see the changes I made here: https://github.com/razem-io/openpilot/commit/b3de59d348eada91fb2943e736af74458e7a2c98
Thrilled I calibrated the camera and tried to engage openpilot. No luck. I was always rejected by a message telling me
to fasten my seatbelt. Back to comma ai discord user avolmensky
told me that this is by design as a workaround for
the not yet working cancel signal of the leaf. So I checked the code and after some testing all that was needed was
to comment a line in selfdrive/car/nissan/carstate.py
.
You can see the changes I made here: https://github.com/razem-io/openpilot/commit/5091fcae3e0fde5e0d57b032d2bbc93c7125be49
I am not yet sure, why this line was there. After more than 100 km of testing I am not able to find any issues.
Making it work
Please be aware, that if you modify code on your own device, no one can be held responsible but you! I also guess this ship sailed once you purchased a comma two ;). Make sure you know what you are doing or can life with the consequences before proceeding!
You will need to have a ssh connection to your car.
If you have a ssh connection to your device enter the following:
# This will switch to my custom fork.
git remote set-url origin https://github.com/razem-io/openpilot.git
# This will make sure, you are on the correct branch.
git fetch
git checkout nissan-ic-2
reboot
The device should now reboot. Once it is done, let's hope everything works. If you run into issues, jump to the next section on how to reverse the changes we made.
Reversing the changes
If you want to switch back to the original comma ai software type this:
# This will switch to my custom fork.
git remote set-url origin https://github.com/commaai/openpilot.git
# This will make sure, you are on the correct branch.
git checkout release2
reboot