EDIT: Angle offsetting is broken in 0.6.3, should be fixed by next release. Until then, https://github.com/commaai/openpilot/pull/798
EDIT 2: Current model lane fitting (0.6.3) isn’t perfect, which can cause oversteer in corners.
EDIT 3: I wrote a curvature factor learner that learns the proper factor. It works for any car, use the branch or copy the changes over: https://github.com/commaai/openpilot/compare/devel…zorrobyte:devel_curvatureFactorLearner This fixes hugging in curves.
Hugging left? Hugging right? Hugging in curves? Re-mounted your Eon so many times that you’ve invested in a gallon container of goo-gone? Fear not, you’ll become a CAMERA_OFFSET variable pro in no time.
What is CAMERA_OFFSET?
CAMERA_OFFSET: The distance, in meters, from the center of vehicle to the openpilot device’s camera module.
This variable can be found in:
- selfdrive/controls/lib/lane_planner.py in OP 0.6.3 and above (as of this article date)
- selfdrive/controls/lib/model_parser.py in OP 0.6.2 and below
The default CAMERA_OFFSET is 0.06 meters, meaning, your openpilot device should be mounted dead center, with the camera module 0.06 meters to the driver’s side for lane centering.
But openpilot hugs too far left, or right!
Calm down now, it’s alright. Most people drive a bit right on two lane, opposed traffic roads (such as state highways) for comfort. openpilot, on the other hand, wants to drive in the exact center of the lane, which is handy for its intended use case: on the interstate.
But, I want Openpilot to drive further to the passenger side anyway. I do most my driving on two lane, opposed traffic highways, local roads, etc!
Fine. Lower the CAMERA_OFFSET value to move the car within the lane to the passenger side, heighten it to move the car to the driver’s side of the lane (Left hand drive). Negative values are okay and work perfectly fine (such as -0.06). The only issue here is that it impacts corner centering and you could find yourself hugging in curves. It’s best to just get used to being center in the lane if you don’t feel like maintaining your own fork (comma, PLEASE parameterize this value, and make it accessible in the settings UI).
Corner hugging fix example for those with OP dev experience (I use this with INDI, which always hugs; but the same concept can be used for any control scheme):
if v_ego < 0.3 or not active: indi_log.active = False self.output_steer = 0.0 self.delayed_output = 0.0 else: if self.angle_steers_des > 0.5: self.angle_steers_des = round(path_plan.angleSteers / (interp(abs(path_plan.angleSteers), [0,10], [1.1, 1.2])), 2) elif self.angle_steers_des < -0.5: self.angle_steers_des = round(path_plan.angleSteers / (interp(abs(path_plan.angleSteers), [0,10], [1.0, 1.2])), 2) else: self.angle_steers_des = round(path_plan.angleSteers, 2)
But, I don’t know how to code!
Sure thing. Move your Eon’s mount further to the driver’s side to move the car towards the passenger side. Move the mount further to the passenger’s side to move the car towards the driver side. Keep in mind the 0.06 meter factory offset, and you’ll be good.
Doesn’t this value “learn” over time anyway?
No, and it never has (at least since I’ve been involved with OP, starting in version 0.5.8).
Long story short, you can go nuts with the measuring tape, lasers, and all sorts of stuff; but unless you are blind, just mount the OP device itself (NOT THE CAMERA MODULE) to the center of the windscreen as best as your eyeballs can get it. If it’s off, it’s likely going to be off by a few cm anyway, a little more at the most; but are you really going to notice being an inch or two closer or further from center of the lane anyway?
But, I still hug in curves!
Yep. Follow my blog, I’ll have an article out about steerRatio and tuning sometime soon. In the meantime, check out my OP observations after my 3,000 mile road trip here. It explains, briefly, why OP hugs curves.