openpilot is an open source driving agent. Currently, it performs the functions of Adaptive Cruise Control (ACC) and Lane Keeping Assist System (LKAS). It's about on par with Tesla Autopilot. This OLD_CAR Branch brings openpilot to almost every car. Follow this readme to get an overview how it works.
Big thank you goes to @wocsor. He developed the whole thing and modified the code.
๐งWATER๐ง = COMMA + OLD_CAR
CHANGES FOR OLD_CAR:
- ๐งOLD_CAR is in selfdrive/car/toyota (use /Toyota/interface.py for tuning)
- ๐งCanValid was set to True to avoid can / communication error messages.
- ๐งIt uses the SteeringRatio which is set in interface.py. Vehicle_model.py does not change it anymore.
- ๐งCAMERA offset is set to 0.00. (Set it to where ever your EON is mounted in lane_planner.py)
- ๐งSteering Angle sensor is flipped because it is mounted upside down in my van. (Delete "-" in Toyota/carstate.py line 166 to flip it back)
- ๐งIt is forced to send GAS_PEDAL command on canID 0x200
I think retrofitting and #old_car is the hidden future of openpilot. Eon and openpilot, like it is expected to be used, is limited to a few makes and type of cars which are build in 2018-2021. In a few years cars will have better selfdriving on stock, than comma can ever deliver - due to better hardware an software. All older cars will not be plug and play. That's where #old_cars comes in. Plus, there is no limitation due to brands or types. There are billions of cars which can be upgraded. Right now we are using the same actuators in completely different types of cars. (Celica 2003, VW Vanagon 1988, Ford E350 1994). We upgrade cars from zero assistant to level 2 self driving. We make driving safe and chill. That's really impressive! Let's see where our journey will end. I can think of like a dev-kit with some actuators and interceptors for easy DIY projects. Thank you <@Wocsor> for spending so much effort. He is doing fundamental research and hacking!
To make openpilot work in an old car, we need to retrofit actuators from supported cars like toyota corolla 2018. Some small ECU needs to be build DIY.
Brain:
Steering:
Throttle:
Radar:
Brake (not finished yet):
Community
First, we need a brain to control everything. This is EON. An extremely powerful piece of hardware which runs openpilot. We also need Panda, which connects EON to the OBD2 port of the car. So that EON can talk to the car via CAN-Bus. Oh wait! - we do not have a CAN-Bus network in our car. Don't worry we will build it DIY. For more informations to EON or PANDA visit comma.ai.
I have used a cheap OBD2 wire connector to pinout the panda.
I have used an EPS (electronic power steering) out of a Toyota corolla 2018. This is already supported by Openpilot so we do not have to port it from sketch.
It is important, that it provides LKAS (lane keep assistent). The steering column and motor might be the same like in older corollas. But the ECU is different. So make sure to buy the ECU with LKAS ( "KV" on the sticker).
This is how to wire the steering ECU:
z11 and z7 connectors will be connected to the EPS Motor.
Now it's time to retrofit the steering column. Since every car is slightly different, you need to be a little creative. Im my case, I have cut my stock column in half and welded both ends to the corolla steering column. If you already have a hydraulic power steering, you might want to disable that. Otherwise you would have a power steering on top of a power steering, and your steering wheel will never return to center by itself.
This is how my conversion looks like:
Now we have a working power steering in our car! Unfortunately it goes into failsafe, which means that it will disable LKAS. Cruise_ECU will take care of this issue.
Eon needs to know how fast we are driving. Therefore we need to add a sensor which measure the "speed" of the car. Most cars already provide such a signal already. For example for the radio. If you have such a signal, you can grab that. In my case I have added a hall sensor to the rotary disc of the speedometer. This counts 4000 signal each km. Cruis_Ecu will calculate that signal with some math. NOTE: you need to adjust the "counts per km" of your specific sensor in Cruise_ECU code.
Since we do not have original toyota buttons, - guess what - we need to build it ourself. Be creative, it is simple task. Pull-down buttons, which will be connected to Cruise_ECU.
Cruise_ECU Hardware is an Arduino Uno with a CAN bus shield attached to it.
It handles the following functions:
-
Cruise_ECU sends some CAN messages on the bus, which let the EPS thinks that it is still in a corolla. The EPS is happy and does not go into failsafe. LKAS is ready to take control of it !!!
-
Cruise_ECU calculates the current speed by reading the VSS. It sends a 0xb4 and 0xaa message on the CAN-Bus. EON and Throttle_ECU can read and use those messages.
-
Cruise_ECU digitalReads the buttons and sends the associated CAN messages to the bus. It let's us enable and disable Openpilot. We can also increase or decrease the set speed.
-
It provides some safety function. It will disable immediately, if it looses CAN safety checksum.
This is how you wire Cruise_ECU:
Note: The LED stuff is optional. "Interrupt to Throttle_ecu" is an extra safety feature, not necessary but recommended.
Attach a switch to the brake pedal and wire it to D7 (button_cancel). Openpilot will disengage when pressing the brake pedal. If you have a manual transmition, do the same for clutch pedal.
I am using the stock steering angle sensor out of a toyota corolla / rav4. I highly recommend buying it with the hair spring attached. Also we do not need the hair spring, it takes care of the sensor while shipping. Fortunatley the sensor provides it's own ECU. Therefor it is like plug and play.
The stock Toyota sensor is laggy and not very precise. Zorrobyte has started to build a high precision, fast like hell, sensor. Itยดs cheap and provides a stunning performance. Zorrobyte invented a super clever mounting position. Check out his Github. I will definetely upgrade to zorro_angle_sensor.
Add an electric cruise control actuator to your throttle. Choose what ever brand you like. They are all very similar and it is easy to get one cheap out of a 90th car on ebay. It needs to have an electric motor, and something similar to a clutch. The "clutch" is basically a solenoid, which disconnects everything mechanically. Pretty nice safety feature :) If you already have stock cruise control in your car, take that one!
To measure the position of the throttle we use the stock potentiometer. Almost every throttle has a potentiometer attached. We read that amount in Throttle_ECU.
Note: Throttle_ECU sketch must be adjusted for your specific potentiometer. Therefore you need to "measure" the min and max value of your potentiometer with analog_read_to_serial. If you have your min and max values you can set those in Throttle_ECU sketch.
Throttle ECU hardware is an Arduino Uno with a CAN-bus shield and a H-bridge attached.
It handles the following functions:
-
Throttle_ECU receives the angle_requests from EON and runs the cruise actuator motor and solenoid.
-
It calculates the acceleration amount depending on the current speed. That means it accelerates faster when driving fast, and more smooth and carefully when driving slow.
-
It provides some safety function. It will disengage immediately, if it looses CAN-safety messages.
Download Throttle_ECU Code.
Similar to the steering angle sensor, the radar out of a corolla / rav4 provides its own ECU. Therefore it is pretty easy to install.
You may need to fingerprint after you have installed the radar.
Brake is not finished yet. Therefore I will not go to much in detail.
Polysync /oscc build a board with an Arduino mega attached to control a toyota prius ABS actuator.
This actuator will be placed on top of the stock brake system.
To do: merge / port the OSCC DBC to openpilot
I would appreciate if someone could help us with that. If you want to know more about that. Feel free to contact us on Github.
Community is the most important thing on this project.
The [legendary Arne Fork] does support old_cars now. Big thanks to Arne182 for his awesome work.
Comma Twitter you should follow.
Also, we have a several thousand people community on Discord.
openpilot is released under the MIT license. Some parts of the software are released under other licenses as specified.
Any user of this software shall indemnify and hold harmless Comma.ai, Inc. and its directors, officers, employees, agents, stockholders, affiliates, subcontractors and customers from and against all allegations, claims, actions, suits, demands, damages, liabilities, obligations, losses, settlements, judgments, costs and expenses (including without limitation attorneysโ fees and costs) which arise out of, relate to or result from any use of this software by user.
THIS IS ALPHA QUALITY SOFTWARE FOR RESEARCH PURPOSES ONLY. THIS IS NOT A PRODUCT. YOU ARE RESPONSIBLE FOR COMPLYING WITH LOCAL LAWS AND REGULATIONS. NO WARRANTY EXPRESSED OR IMPLIED.