Skip to content

Commit

Permalink
Updates (commaai#500)
Browse files Browse the repository at this point in the history
* updates to long_mpc

* 066 updates (commaai#208)

* add custom error messages to arne182.capnp

* add explanations for some parameters in op_params, add parameter to specify custom following distance
updates to dynamic_follow:
- fix v_lead that should have been a_lead
- made relative velocity mod more aggressive

* make customTR a bit safer

* perhaps this will work

* remove travis detected message

* start updating op_params, fix issue with lane_hugging mod where it wouldn't work with right hugging

* revert custom alert message

* testing new op_edit

* testing new op_edit

* testing new op_edit

* testing new op_edit

* testing new op_edit

* testing new op_edit

* testing new op_edit

* testing new op_edit

* testing new op_edit

* add description!

* add description!

* testing op_edit

* testing op_edit

* testing op_edit

* testing op_edit

* testing op_edit

* testing op_edit

* testing op_edit

* testing op_edit

* testing op_edit

* testing op_edit

* testing op_edit

* finish updating opEdit

* final update

* tuned dynamic follow relative velocity values to be slightly more aggressive at high rel vels
fix error in get_cost function causing it to always return 0.1 above 5 mph

* updates to long control, testing without dynamic gas

* testing customTR

* testing old cost function

* revert to 066-clean

* revert to 066-clean

* use clip instead

* updates to long_mpc

* revert TR values

* updates to long_mpc

* revert new costs to how they were in 05

* refactor, remove unneeded variable

* Create __init__.py

* At least 2m needed to keep stopping for traffic lights

* Refine one-way logic

Now both roads need to be a one way and it will only choose it if there is one way in the right direction and the other is not.

* fix for right hand turns not slowing down.

* remove integrated value on release and not press of brake/gas

* new lane hugging mod, seems to work a lot better! tuning for corolla steering, less seems to be better

* time wasn't imported

* tiny bit of refactor

* Try the reset for pid after gas pedal is

* treat brake pressed or gas pressed as LongCtrlState.off

* I also want events

* Fix hex value

* add possibility for arne182 events

* fix

* fix arne capnp

* return ret_arne182

* Try and combine events together.

This could probably not work

* think this will be better, we want to modify as little of comma's code as possible

* test

* test if messages from arne.capnp will be accepted by AM

* test combined events

* this should work

* final changes to make custom alerts work only for toyotas for now

* Stop data_send from crashing because of unknown events

* Pass in sendevents to state_transition

* try prepend

* Append lists together

* Thank goodness for syntax highlighting

* fix right hand turns

The negative value is already in steering angle which causes tan to be negative so we do not need an extra minus there.

* Completely seperate events_arne182 and events

* Add arne_ret to all interfaces (commaai#497)

* add ret_arne to honda.interface

* add ret_arne to chrysler.interface

* add ret_arne to rest of interfaces

* first version (commaai#499)

* Add exception for gas and brake press for planner

This could be the cause of the steering braking after manual gas and brake input

* Try remove red screen and loud beep at low speed reverseGear Engagement

* Add custom alert without chimeWarningRepeat

* Use new custom reverse Warning without chime

* fix create_event_arne

* Update arne182.capnp

* Fix
  • Loading branch information
arne182 committed Dec 8, 2019
1 parent 95dd09d commit ed59088
Show file tree
Hide file tree
Showing 28 changed files with 597 additions and 215 deletions.
70 changes: 70 additions & 0 deletions README_arne182.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Welcome to arne fork of openpilot

This README describes the custom features build by me (Arne Schwarck) on top of [openpilot](http://github.com/commaai/openpilot) of [comma.ai](http://comma.ai). This fork is optimized for the Toyota RAV4 Hybrid 2016 and for driving in Germany but also works with other cars and in other countries
- [ ] TODO describe which other cars and countries are known
[![](https://i.imgur.com/xY2gdHv.png)](#)

For a demo of this version of openpilot check the video below:
[![demo of openpilot with this branch](https://img.youtube.com/vi/WKwSq8TPdpo/0.jpg)](https://www.youtube.com/watch?v=WKwSq8TPdpo)

# Installation

- [ ] TODO describe when Panda flashing is needed, what it does and a link to how this can be done
- [ ] TODO add a link how to install a custom fork

# Configuration

- [ ] TODO describe how to change/add custom setting in json file

# Branches

- [ ] TODO described relevant branches

# Features

- [ ] TODO add other features

- [ ] TODO check if these features are still relevant

- [ ] TODO if applicable describe what config options are available

## Automatic Lane Change Assist (ALC)
Check your surroundings, signal in the direction you would like to change lanes, and let openpilot do the rest. You can choose between three ALC profiles, Wifey, Normal, and Mad Max. Each increasing in steering torque.


## Stock Lane Keeping Assist (LKA)
Arne has worked on recreating the lane keeping assist system present in your car for openpilot. It works with cruise control not engaged, attempting to steer to keep you inside your lane when it detects you are departing it.


## [Dynamic Following Distance Profile](https://github.com/ShaneSmiskol/openpilot/blob/dynamic-follow/README.md)
(outdated: on 0.5.8, `dynamic-follow` branch only): Three following distance (TR) profiles are available to select; 0.9 seconds, 2.7 seconds, and a custom tuned dynamic follow profile. The first two behave as your stock cruise control system does. Dynamic follow aims to provide a more natural feeling drive, adjusting your distance from the lead car based on your speed, your relative velocity with the lead car, and your acceleration (or deceleration). If the system detects the lead car decelerating, your car should start to brake sooner than a hard-coded TR value. Same with accelerating.


## Slow Mode (SLO)
For cars with longitudinal control down to 0 mph, you have the option to activate SLO mode which enables you to set your car's cruise control under your car's limit. For example, you could coast along at 15, 10, or even 5 mph.

## Acceleration Profiles (GAS)
You can select from three acceleration profiles with the GAS button. If your car accelerates too slowly for your liking, this will solve that. **Recently added**: dynamic acceleration profile for users with comma pedals. This should provide a smoother acceleration experience in stop and go traffic.

## Select Vision Model (on 0.5.8, `dynamic-follow` branch only)
You can select whether you would like to use the wiggly model or the normal vision model for path planning. Wiggly has more torque and can better guess the road curvature without lane lines, but it occasionally crashes or mispredicts the path.

## EON and openpilot Stats
With the on-screen UI, you can view stats about your EON such as its temperature, your grey panda's GPS accuracy, the lead car's relative velocity, its distance, and more.

Warning from kegman: `WARNING: Do NOT depend on OP to stop the car in time if you are approaching an object which is not in motion in the same direction as your car. The radar will NOT detect the stationary object in time to slow your car enough to stop. If you are approaching a stopped vehicle you must disengage and brake as radars ignore objects that are not in motion.`


# Licensing

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.**

---

<img src="https://d1qb2nb5cznatu.cloudfront.net/startups/i/1061157-bc7e9bf3b246ece7322e6ffe653f6af8-medium_jpg.jpg?buster=1458363130" width="75"></img> <img src="https://cdn-images-1.medium.com/max/1600/1*C87EjxGeMPrkTuVRVWVg4w.png" width="225"></img>
37 changes: 31 additions & 6 deletions cereal/arne182.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,31 @@ $Java.outerClassname("arne182");

@0xca61a35dedbd6328;

struct CarEventArne182 @0x9b1657f34caf3ad4 {
name @0 :EventNameArne182;
enable @1 :Bool;
noEntry @2 :Bool;
warning @3 :Bool;
userDisable @4 :Bool;
softDisable @5 :Bool;
immediateDisable @6 :Bool;
preEnable @7 :Bool;
permanent @8 :Bool;

enum EventNameArne182 @0xbaa8c5d505f727ea {
# TODO: copy from error list
longControlDisabled @0;
longControlBrakeDisabled @1;
reverseGearArne @2;
}
}


struct CarStateArne182 {
events @0 :List(CarEventArne182);
}


struct Arne182Status {
blindspot @0 :Bool;
distanceToggle @1 :Float32;
Expand All @@ -23,7 +48,7 @@ struct LiveTrafficData {
speedLimit @1 :Float32;
speedAdvisoryValid @2 :Bool;
speedAdvisory @3 :Float32;
}
}

struct LatControl {
anglelater @0 :Float32;
Expand All @@ -45,10 +70,10 @@ struct EventArne182 {
valid @6 :Bool = true;

union {
arne182Status @1:Arne182Status;
liveTrafficData @2:LiveTrafficData;
latControl @3:LatControl;
phantomData @4:PhantomData;
managerData @5:ManagerData;
arne182Status @1:Arne182Status;
liveTrafficData @2:LiveTrafficData;
latControl @3:LatControl;
phantomData @4:PhantomData;
managerData @5:ManagerData;
}
}
1 change: 0 additions & 1 deletion cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ struct CarEvent @0x9b1657f34caf3ad3 {
laneChange @59;
invalidGiraffeToyota @60;
internetConnectivityNeeded @61;
longControlDisabled @62;
}
}

Expand Down
38 changes: 24 additions & 14 deletions common/op_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,30 @@ def read_params(params_file, default_params):
with open(params_file, "r") as f:
params = json.load(f)
return params, True
except:
except Exception as e:
print(e)
params = default_params
return params, False


class opParams:
def __init__(self):
self.default_params = {'camera_offset': {'default': 0.06, 'allowed_types': [float, int], 'description': 'Your camera offset to use in lane_planner.py'},
'awareness_factor': {'default': 2.0, 'allowed_types': [float, int], 'description': 'Multiplier for the awareness times'},
'lane_hug_direction': {'default': None, 'allowed_types': [type(None), str], 'description': "(NoneType, 'left', 'right'): Direction of your lane hugging, if present, else, None"},
'lane_hug_angle_offset': {'default': 0.0, 'allowed_types': [float, int], 'description': 'This is the angle your wheel reads when driving straight at highway speeds. Used to offset angle_steers to help fix lane hugging'},
'use_car_caching': {'default': True, 'allowed_types': [bool], 'description': 'Whether to use fingerprint caching'},
'osm': {'default': True, 'allowed_types': [bool], 'description': 'Whether to use OSM for drives'},
'force_pedal': {'default': False, 'allowed_types': [bool], 'description': "If openpilot isn't recognizing your comma pedal, set this to True"},
'following_distance': {'default': None, 'allowed_types': [type(None), float], 'description': 'None has no effect, while setting this to a float will let you change the TR'},
'keep_openpilot_engaged': {'default': True, 'allowed_types': [bool], 'description': 'True is stock behavior in this fork. False lets you use the brake and cruise control stalk to disengage as usual'},
'speed_offset': {'default': 0, 'allowed_types': [float, int], 'description': 'Speed limit offset'}}

self.params = {}
self.params_file = "/data/op_params.json"
self.kegman_file = "/data/kegman.json"
self.last_read_time = time.time()
self.read_timeout = 1.0 # max frequency to read with self.get(...) (sec)
self.default_params = {'camera_offset': 0.06, 'awareness_factor': 2.0, 'lane_hug_direction': None,
'lane_hug_mod': 1.2, 'lane_hug_angle': 10, 'use_car_caching': True, 'osm': True,
'speed_offset': 0, 'keep_openpilot_engaged': True, 'force_pedal': False}
self.force_update = False # replaces values with default params if True, not just add add missing key/value pairs
self.run_init() # restores, reads, and updates params

Expand All @@ -50,24 +59,25 @@ def add_default_params(self):
prev_params = dict(self.params)
if not travis:
self.create_id()
for i in self.default_params:
for key in self.default_params:
if self.force_update:
self.params.update({i: self.default_params[i]})
elif i not in self.params:
self.params.update({i: self.default_params[i]})
self.params[key] = self.default_params[key]['default']
elif key not in self.params:
self.params[key] = self.default_params[key]['default']
return prev_params == self.params

def format_default_params(self):
return {key: self.default_params[key]['default'] for key in self.default_params}

def run_init(self): # does first time initializing of default params, and/or restoring from kegman.json
if travis:
print("Travis detected...")
self.params = self.default_params
self.add_default_params()
self.params = self.format_default_params()
return
self.params = self.default_params # in case any file is corrupted
self.params = self.format_default_params() # in case any file is corrupted
to_write = False
no_params = False
if os.path.isfile(self.params_file):
self.params, read_status = read_params(self.params_file, self.default_params)
self.params, read_status = read_params(self.params_file, self.format_default_params())
if read_status:
to_write = not self.add_default_params() # if new default data has been added
else: # don't overwrite corrupted params, just print to screen
Expand All @@ -91,7 +101,7 @@ def put(self, key, value):

def get(self, key=None, default=None): # can specify a default value if key doesn't exist
if (time.time() - self.last_read_time) >= self.read_timeout and not travis: # make sure we aren't reading file too often
self.params, read_status = read_params(self.params_file, self.default_params)
self.params, read_status = read_params(self.params_file, self.format_default_params())
self.last_read_time = time.time()
if key is None: # get all
return self.params
Expand Down
Loading

0 comments on commit ed59088

Please sign in to comment.