Skip to content

Commit

Permalink
Integrate zorropilot into master (#15)
Browse files Browse the repository at this point in the history
* Use my own panda & cereal repos

* 📏 Enable Toyota Distance Button to Change Distance Lines

__Additions__

* Forward distance button presses to car can
* Read distance_lines can message from car and use to set distance
profile.
* Alter T_Follow based on distance profile
  * Stock = 1.45
  * Relaxed = 1.25
  * Traffic ~= 1.05 (at low speeds closer to 1.25)
* Adjust J_Cost, A_Change_Cost, and D_Cost based on distance profile
  * Weights for Costs need to be adjusted when T_Follow is decreased.

__Tests__
* Add Longitudinal Tests for Additional Following Profiles
  * Copy the comma tests, with appropriate following distance for
each profile.
* Tweak Process_Replay Action - Ignores the new carState.distanceLines
message, so that replay refs still pass.

Thanks to sshane for help with this. See the tree ending with
commit 73237de

Repos

cereal distance lines

use zorropilot cereal repo

wat

* 🏎️ More Aggresive Start from Standstill

Uses Dynamic MPC Costs which decreases the a_change and jerk
costs at low speeds.

Also dynamically decreases the Stop_Distance as the lead pulls
away so that the long_mpc commands forward accel just a
little bit sooner.

Lower overall Stop_Distance slightly, since we stop a bit more
assertively now with the decreased costs, the stop distance
doesn't need to be as high.

Add a test_accel file for testing sluggish starts.

Ignore longitudinalPlan Msgs in Process Replay.

Update long_mpc.py

* 🔧 Tweak Toyota Long Tuning for My Tastes

The Rav4 2019 TSS2 has ~1.4s lag between when accel commands are sent
to the car and when they are acted upon when the car is starting from
a dead stop.  Stock feels fine with this limitation, so OP can too.

Most of these changes are designed to fix any sluggishness caused by
the Toyota Tune.  Additional changes need to be made to the Long MPC
in order to solve the sluggish start completely.

Changes:

Decrease vEgoStopping and vEgoStarting to 0.2.  Car is perfectly
capable of controlling at these speeds.  Lower value allows for state
machine to exit stopping phase just a bit faster.

Double the ActuatorDelay lag to .3 so we look into the future just a bit
more, seems a bit more inline with realworld experience.

Halve stoppingDecelRate to match the OEM stop_accel of -.4m/s2.  Makes
the final jerk in stopping a bit smoother

Increase the PID max accel to 1.8 m/s2 tappering back to 1.5 m/s2 at 5m/s.

Increase planner max accel to 1.4 m/s2 from 1.2 m/s2 starting from a stop
tapering back to 1.2 m/s2 at 10m/s.

Decreased planner max accel at 55mph, seemed a little uncomfortable to me.

Decrease A_Change Timescale in Long_MPC to match more closely what toyota
lag is.

Ignore some messages and fields in process_replay test in order to
keep it working.

* ⛽ Add Toggle to Enable Use of Gas Pedal While Openpilot is Engaged

USE AT YOUR OWN RISK

* 📄 Add Toggle to Enable Automatic Raw Log Uploading

Brings back the raw log toggle that was used prior to version
8.12.

Upload RLogs First then Videos

This reverts in part commit 2e0c73f.

* Update README.md

Update README.md

* bump submodules

* interpolate for lower rate lateral plan

interpolate for lower rate lateral plan

fix

should be correct now

same convention as longcontrol.py

* Update README.md

* Try this

ClockeNessMnstr@618386a

* distance cost

* Revert "interpolate for lower rate lateral plan"

This reverts commit 5ef248d.

* Squashed commit of the following:

commit 8fc2566
Merge: 3168372 92e9823
Author: Ross Fisher <zorrobyte@gmail.com>
Date:   Sat Feb 19 13:49:13 2022 -0500

    Merge branch 'master' into zorropilot

commit 3168372
Author: Ross Fisher <zorrobyte@gmail.com>
Date:   Sat Feb 19 13:48:47 2022 -0500

    Revert "interpolate for lower rate lateral plan"

    This reverts commit 5ef248d.

commit 92e9823
Author: George Hotz <72895+geohot@users.noreply.github.com>
Date:   Fri Feb 18 20:15:20 2022 -0800

    camerad: fast debayer on c2 cameras (commaai#23795)

    * fast debayer on c2 dcam

    * add casts

    * 128 local worksize on HDR debayer, 8 ms -> 3.5 ms

    * width instead of saving rgb_width

    Co-authored-by: Comma Device <device@comma.ai>

* c3 no offsets

* Revert "c3 no offsets"

This reverts commit bde09b3.

* Revert "Try this"

This reverts commit 40f0781.

Co-authored-by: Ross Fisher <zorrobyte@gmail.com>
Co-authored-by: KRKeegan <kevin@krkeegan.com>
Co-authored-by: Shane Smiskol <shane@smiskol.com>
  • Loading branch information
4 people committed Feb 19, 2022
1 parent edc800f commit ceb1cec
Show file tree
Hide file tree
Showing 25 changed files with 282 additions and 180 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/selfdrive_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,12 @@ jobs:
- name: Run replay
run: |
${{ env.RUN }} "scons -j$(nproc) && \
FILEREADER_CACHE=1 CI=1 coverage run selfdrive/test/process_replay/test_processes.py && \
FILEREADER_CACHE=1 CI=1 coverage run selfdrive/test/process_replay/test_processes.py \
--ignore-fields carControl.actuators.accel carControl.actuatorsOutput.accel \
carParams.longitudinalActuatorDelayLowerBound \
carParams.longitudinalActuatorDelayUpperBound carParams.stoppingDecelRate \
carParams.vEgoStarting carParams.vEgoStopping controlsState.ufAccelCmd \
--ignore-msgs longitudinalPlan sendcan && \
coverage xml"
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v2
Expand Down
6 changes: 4 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[submodule "panda"]
path = panda
url = ../../commaai/panda.git
url = https://github.com/zorrobyte/panda.git
branch = master
[submodule "opendbc"]
path = opendbc
url = ../../commaai/opendbc.git
Expand All @@ -9,7 +10,8 @@
url = ../../commaai/laika.git
[submodule "cereal"]
path = cereal
url = ../../commaai/cereal.git
url = https://github.com/zorrobyte/cereal.git
branch = zorropilot
[submodule "rednose_repo"]
path = rednose_repo
url = ../../commaai/rednose.git
148 changes: 8 additions & 140 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,142 +1,10 @@
![](https://i.imgur.com/b0ZyIx5.jpg)
This is my fork for my 2019 Rav4. Should be good for all TSS2, however, YMMV.

Table of Contents
=======================
This adds:
* TSS2 Distane Button with 3 profiles
* More Aggresive Start from Standstill
* Tweak Toyota Long Tuning for My Tastes
* Add Toggle to Enable Use of Gas Pedal While Openpilot is Engaged
* Add Toggle to Enable Automatic Raw Log and camera file Uploading

* [What is openpilot?](#what-is-openpilot)
* [Running in a car](#running-in-a-car)
* [Running on PC](#running-on-pc)
* [Community and Contributing](#community-and-contributing)
* [User Data and comma Account](#user-data-and-comma-account)
* [Safety and Testing](#safety-and-testing)
* [Directory Structure](#directory-structure)
* [Licensing](#licensing)

---

What is openpilot?
------

[openpilot](http://github.com/commaai/openpilot) is an open source driver assistance system. Currently, openpilot performs the functions of Adaptive Cruise Control (ACC), Automated Lane Centering (ALC), Forward Collision Warning (FCW) and Lane Departure Warning (LDW) for a growing variety of [supported car makes, models and model years](docs/CARS.md). In addition, while openpilot is engaged, a camera based Driver Monitoring (DM) feature alerts distracted and asleep drivers. See more about [the vehicle integration](docs/INTEGRATION.md) and [limitations](docs/LIMITATIONS.md).

<table>
<tr>
<td><a href="https://youtu.be/NmBfgOanCyk" title="Video By Greer Viau"><img src="https://i.imgur.com/1w8c6d2.jpg"></a></td>
<td><a href="https://youtu.be/VHKyqZ7t8Gw" title="Video By Logan LeGrand"><img src="https://i.imgur.com/LnBucik.jpg"></a></td>
<td><a href="https://youtu.be/VxiR4iyBruo" title="Video By Charlie Kim"><img src="https://i.imgur.com/4Qoy48c.jpg"></a></td>
<td><a href="https://youtu.be/-IkImTe1NYE" title="Video By Aragon"><img src="https://i.imgur.com/04VNzPf.jpg"></a></td>
</tr>
<tr>
<td><a href="https://youtu.be/iIUICQkdwFQ" title="Video By Logan LeGrand"><img src="https://i.imgur.com/b1LHQTy.jpg"></a></td>
<td><a href="https://youtu.be/XOsa0FsVIsg" title="Video By PinoyDrives"><img src="https://i.imgur.com/6FG0Bd8.jpg"></a></td>
<td><a href="https://youtu.be/bCwcJ98R_Xw" title="Video By JS"><img src="https://i.imgur.com/zO18CbW.jpg"></a></td>
<td><a href="https://youtu.be/BQ0tF3MTyyc" title="Video By Tsai-Fi"><img src="https://i.imgur.com/eZzelq3.jpg"></a></td>
</tr>
</table>


Running in a car
------

To use openpilot in a car, you need four things
* This software. It's free and available right here.
* One of [the 150+ supported cars](docs/CARS.md). We support Honda, Toyota, Hyundai, Nissan, Kia, Chrysler, Lexus, Acura, Audi, VW, and more. If your car is not supported, but has adaptive cruise control and lane keeping assist, it's likely able to run openpilot.
* A supported device to run this software. This can be a [comma two](https://comma.ai/shop/products/two), [comma three](https://comma.ai/shop/products/three), or if you like to experiment, a [Ubuntu computer with webcams](https://github.com/commaai/openpilot/tree/master/tools/webcam).
* A way to connect to your car. With a comma two or three, you need only a [car harness](https://comma.ai/shop/products/car-harness). With an EON Gold or PC, you also need a [black panda](https://comma.ai/shop/products/panda).

We have detailed instructions for [how to install the device in a car](https://comma.ai/setup).

Running on PC
------

All of openpilot's services can run as normal on a PC, even without special hardware or a car. To develop or experiment with openpilot you can run openpilot on recorded or simulated data.

With openpilot's tools you can plot logs, replay drives and watch the full-res camera streams. See [the tools README](tools/README.md) for more information.

You can also run openpilot in simulation [with the CARLA simulator](tools/sim/README.md). This allows openpilot to drive around a virtual car on your Ubuntu machine. The whole setup should only take a few minutes, but does require a decent GPU.


Community and Contributing
------

openpilot is developed by [comma](https://comma.ai/) and by users like you. We welcome both pull requests and issues on [GitHub](http://github.com/commaai/openpilot). Bug fixes and new car ports are encouraged. Check out [the contributing docs](docs/CONTRIBUTING.md).

Documentation related to openpilot development can be found on [docs.comma.ai](https://docs.comma.ai). Information about running openpilot (e.g. FAQ, fingerprinting, troubleshooting, custom forks, community hardware) should go on the [wiki](https://github.com/commaai/openpilot/wiki).

You can add support for your car by following guides we have written for [Brand](https://blog.comma.ai/how-to-write-a-car-port-for-openpilot/) and [Model](https://blog.comma.ai/openpilot-port-guide-for-toyota-models/) ports. Generally, a car with adaptive cruise control and lane keep assist is a good candidate. [Join our Discord](https://discord.comma.ai) to discuss car ports: most car makes have a dedicated channel.

Want to get paid to work on openpilot? [comma is hiring](https://comma.ai/jobs/).

And [follow us on Twitter](https://twitter.com/comma_ai).

User Data and comma Account
------

By default, openpilot uploads the driving data to our servers. You can also access your data through [comma connect](https://connect.comma.ai/). We use your data to train better models and improve openpilot for everyone.

openpilot is open source software: the user is free to disable data collection if they wish to do so.

openpilot logs the road facing cameras, CAN, GPS, IMU, magnetometer, thermal sensors, crashes, and operating system logs.
The driver facing camera is only logged if you explicitly opt-in in settings. The microphone is not recorded.

By using openpilot, you agree to [our Privacy Policy](https://comma.ai/privacy). You understand that use of this software or its related services will generate certain types of user data, which may be logged and stored at the sole discretion of comma. By accepting this agreement, you grant an irrevocable, perpetual, worldwide right to comma for the use of this data.

Safety and Testing
----

* openpilot observes ISO26262 guidelines, see [SAFETY.md](docs/SAFETY.md) for more details.
* openpilot has software in the loop [tests](.github/workflows/selfdrive_tests.yaml) that run on every commit.
* The code enforcing the safety model lives in panda and is written in C, see [code rigor](https://github.com/commaai/panda#code-rigor) for more details.
* panda has software in the loop [safety tests](https://github.com/commaai/panda/tree/master/tests/safety).
* Internally, we have a hardware in the loop Jenkins test suite that builds and unit tests the various processes.
* panda has additional hardware in the loop [tests](https://github.com/commaai/panda/blob/master/Jenkinsfile).
* We run the latest openpilot in a testing closet containing 10 comma devices continuously replaying routes.

Directory Structure
------
.
├── cereal # The messaging spec and libs used for all logs
├── common # Library like functionality we've developed here
├── docs # Documentation
├── opendbc # Files showing how to interpret data from cars
├── panda # Code used to communicate on CAN
├── third_party # External libraries
├── pyextra # Extra python packages
└── selfdrive # Code needed to drive the car
├── assets # Fonts, images, and sounds for UI
├── athena # Allows communication with the app
├── boardd # Daemon to talk to the board
├── camerad # Driver to capture images from the camera sensors
├── car # Car specific code to read states and control actuators
├── common # Shared C/C++ code for the daemons
├── controls # Planning and controls
├── debug # Tools to help you debug and do car ports
├── locationd # Precise localization and vehicle parameter estimation
├── logcatd # Android logcat as a service
├── loggerd # Logger and uploader of car data
├── modeld # Driving and monitoring model runners
├── proclogd # Logs information from proc
├── sensord # IMU interface code
├── test # Unit tests, system tests, and a car simulator
└── ui # The UI

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>

[![openpilot tests](https://github.com/commaai/openpilot/workflows/openpilot%20tests/badge.svg?event=push)](https://github.com/commaai/openpilot/actions)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/alerts/)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/context:python)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/context:cpp)
[![codecov](https://codecov.io/gh/commaai/openpilot/branch/master/graph/badge.svg)](https://codecov.io/gh/commaai/openpilot)
Big thanks to https://github.com/krkeegan/openpilot
2 changes: 1 addition & 1 deletion cereal
Binary file added selfdrive/assets/offroad/icon_gas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from cereal import car
from common.kalman.simple_kalman import KF1D
from common.params import Params
from common.realtime import DT_CTRL
from selfdrive.car import gen_empty_fingerprint
from selfdrive.config import Conversions as CV
Expand Down Expand Up @@ -44,6 +45,10 @@ def __init__(self, CP, CarController, CarState):
if CarController is not None:
self.CC = CarController(self.cp.dbc_name, CP, self.VM)

# KRKeegan Option to Enable Gas on Cruise
params = Params()
self.enable_gas_on_cruise = params.get_bool("EnableGasOnCruise")

@staticmethod
def get_pid_accel_limits(CP, current_speed, cruise_speed):
return ACCEL_MIN, ACCEL_MAX
Expand Down Expand Up @@ -73,6 +78,9 @@ def get_std_params(candidate, fingerprint):
ret = car.CarParams.new_message()
ret.carFingerprint = candidate
ret.unsafeMode = 0 # see panda/board/safety_declarations.h for allowed values
params = Params()
if params.get_bool("EnableGasOnCruise"):
ret.unsafeMode = ret.unsafeMode | 1

# standard ALC params
ret.steerControlType = car.CarParams.SteerControlType.torque
Expand Down Expand Up @@ -127,7 +135,7 @@ def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True):
events.add(EventName.wrongCarMode)
if cs_out.espDisabled:
events.add(EventName.espDisabled)
if cs_out.gasPressed:
if cs_out.gasPressed and not self.enable_gas_on_cruise:
events.add(EventName.gasPressed)
if cs_out.stockFcw:
events.add(EventName.stockFcw)
Expand Down Expand Up @@ -156,7 +164,7 @@ def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True):
events.add(EventName.steerUnavailable)

# Disable on rising edge of gas or brake. Also disable on brake when speed > 0.
if (cs_out.gasPressed and not self.CS.out.gasPressed) or \
if (not self.enable_gas_on_cruise and cs_out.gasPressed and not self.CS.out.gasPressed) or \
(cs_out.brakePressed and (not self.CS.out.brakePressed or not cs_out.standstill)):
events.add(EventName.pedalPressed)

Expand Down
9 changes: 6 additions & 3 deletions selfdrive/car/toyota/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
create_fcw_command, create_lta_steer_command
from selfdrive.car.toyota.values import CAR, STATIC_DSU_MSGS, NO_STOP_TIMER_CAR, TSS2_CAR, \
MIN_ACC_SPEED, PEDAL_TRANSITION, CarControllerParams
from selfdrive.car.toyota.interface import CarInterface
from opendbc.can.packer import CANPacker
VisualAlert = car.CarControl.HUDControl.VisualAlert

Expand All @@ -17,6 +18,7 @@ def __init__(self, dbc_name, CP, VM):
self.last_standstill = False
self.standstill_req = False
self.steer_rate_limited = False
self.CP = CP

self.packer = CANPacker(dbc_name)
self.gas = 0
Expand All @@ -41,7 +43,8 @@ def update(self, enabled, active, CS, frame, actuators, pcm_cancel_cmd, hud_aler
interceptor_gas_cmd = clip(pedal_command, 0., MAX_INTERCEPTOR_GAS)
else:
interceptor_gas_cmd = 0.
pcm_accel_cmd = clip(actuators.accel, CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX)
pid_accel_limits = CarInterface.get_pid_accel_limits(self.CP, CS.out.vEgo, None) # Need to get cruise speed from somewhere
pcm_accel_cmd = clip(actuators.accel, pid_accel_limits[0], pid_accel_limits[1])

# steer torque
new_steer = int(round(actuators.steer * CarControllerParams.STEER_MAX))
Expand Down Expand Up @@ -95,10 +98,10 @@ def update(self, enabled, active, CS, frame, actuators, pcm_cancel_cmd, hud_aler
if pcm_cancel_cmd and CS.CP.carFingerprint in (CAR.LEXUS_IS, CAR.LEXUS_RC):
can_sends.append(create_acc_cancel_command(self.packer))
elif CS.CP.openpilotLongitudinalControl:
can_sends.append(create_accel_command(self.packer, pcm_accel_cmd, pcm_cancel_cmd, self.standstill_req, lead, CS.acc_type))
can_sends.append(create_accel_command(self.packer, pcm_accel_cmd, pcm_cancel_cmd, self.standstill_req, lead, CS.acc_type, CS.distance_btn))
self.accel = pcm_accel_cmd
else:
can_sends.append(create_accel_command(self.packer, 0, pcm_cancel_cmd, False, lead, CS.acc_type))
can_sends.append(create_accel_command(self.packer, 0, pcm_cancel_cmd, False, lead, CS.acc_type, CS.distance_btn))

if frame % 2 == 0 and CS.CP.enableGasInterceptor and CS.CP.openpilotLongitudinalControl:
# send exactly zero if gas cmd is zero. Interceptor will send the max between read value and gas cmd.
Expand Down
15 changes: 15 additions & 0 deletions selfdrive/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def __init__(self, CP):
self.low_speed_lockout = False
self.acc_type = 1

# KRKeegan - Add support for toyota distance button
self.distance_btn = 0

def update(self, cp, cp_cam):
ret = car.CarState.new_message()

Expand Down Expand Up @@ -94,6 +97,10 @@ def update(self, cp, cp_cam):
if self.CP.carFingerprint in TSS2_CAR:
self.acc_type = cp_cam.vl["ACC_CONTROL"]["ACC_TYPE"]

# KRKeegan - Add support for toyota distance button
self.distance_btn = 1 if cp_cam.vl["ACC_CONTROL"]["DISTANCE"] == 1 else 0
ret.distanceLines = cp.vl["PCM_CRUISE_SM"]["DISTANCE_LINES"]

# some TSS2 cars have low speed lockout permanently set, so ignore on those cars
# these cars are identified by an ACC_TYPE value of 2.
# TODO: it is possible to avoid the lockout and gain stop and go if you
Expand Down Expand Up @@ -202,6 +209,11 @@ def get_can_parser(CP):
]
checks.append(("BSM", 1))

# KRKeegan - Add support for toyota distance button
if CP.carFingerprint in TSS2_CAR:
signals.append(("DISTANCE_LINES", "PCM_CRUISE_SM", 0))
checks.append(("PCM_CRUISE_SM", 1))

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0)

@staticmethod
Expand All @@ -221,4 +233,7 @@ def get_cam_can_parser(CP):
signals.append(("ACC_TYPE", "ACC_CONTROL"))
checks.append(("ACC_CONTROL", 33))

# KRKeegan - Add support for toyota distance button
signals.append(("DISTANCE", "ACC_CONTROL", 0))

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2)
16 changes: 14 additions & 2 deletions selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
from cereal import car
from common.numpy_fast import interp
from selfdrive.config import Conversions as CV
from selfdrive.car.toyota.tunes import LatTunes, LongTunes, set_long_tune, set_lat_tune
from selfdrive.car.toyota.values import Ecu, CAR, ToyotaFlags, TSS2_CAR, NO_DSU_CAR, MIN_ACC_SPEED, EPS_SCALE, CarControllerParams
Expand All @@ -12,7 +13,13 @@
class CarInterface(CarInterfaceBase):
@staticmethod
def get_pid_accel_limits(CP, current_speed, cruise_speed):
return CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX
if CP.carFingerprint in TSS2_CAR:
# Allow for higher accel from PID controller at low speeds
return CarControllerParams.ACCEL_MIN, interp(current_speed,
CarControllerParams.ACCEL_MAX_TSS2_BP,
CarControllerParams.ACCEL_MAX_TSS2_VALS)
else:
return CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX

@staticmethod
def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value
Expand Down Expand Up @@ -236,7 +243,12 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
set_long_tune(ret.longitudinalTuning, LongTunes.PEDAL)
elif candidate in TSS2_CAR:
set_long_tune(ret.longitudinalTuning, LongTunes.TSS2)
ret.stoppingDecelRate = 0.3 # reach stopping target smoothly
# Improved longitudinal tune settings from sshane
ret.vEgoStopping = 0.2 # car is near 0.1 to 0.2 when car starts requesting stopping accel
ret.vEgoStarting = 0.2 # needs to be > or == vEgoStopping
ret.stoppingDecelRate = 0.4 # reach stopping target smoothly - seems to take 0.5 seconds to go from 0 to -0.4
ret.longitudinalActuatorDelayLowerBound = 0.3
ret.longitudinalActuatorDelayUpperBound = 0.3
else:
set_long_tune(ret.longitudinalTuning, LongTunes.TSS)

Expand Down
Loading

0 comments on commit ceb1cec

Please sign in to comment.