diff --git a/README.md b/README.md index 25f424b98f8313..575fa77b2a431b 100644 --- a/README.md +++ b/README.md @@ -63,24 +63,27 @@ openpilot should preserve all other vehicle's stock features, including, but are Supported Hardware ------ -At the moment, openpilot supports the [EON DevKit](https://comma.ai/shop/products/eon-dashcam-devkit) and the [comma two](https://comma.ai/shop/products/comma-two-devkit). A [car harness](https://comma.ai/shop/products/car-harness) is recommended to connect the EON or comma two to the car. For experimental purposes, openpilot can also run on an Ubuntu computer with external [webcams](https://github.com/commaai/openpilot/tree/master/tools/webcam). +At the moment, openpilot supports the [EON DevKit](https://comma.ai/shop/products/eon-dashcam-devkit) and the [comma two](https://comma.ai/shop/products/comma-two-devkit). A [car harness](https://comma.ai/shop/products/car-harness) is recommended to connect the EON or comma two to the car. In the future, we'd like to support other platforms as well, like gaming PCs. Supported Cars ------ | Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below | | ----------| ------------------------------| ------------------| -----------------| -------------------| ------------------| -| Acura | ILX 2016-18 | AcuraWatch Plus | openpilot | 25mph1 | 25mph | -| Acura | RDX 2016-18 | AcuraWatch Plus | openpilot | 25mph1 | 12mph | +| Acura | ILX 2016-18 | AcuraWatch Plus | openpilot | 25mph6 | 25mph | +| Acura | RDX 2016-18 | AcuraWatch Plus | openpilot | 25mph6 | 12mph | +| Chrysler | Pacifica 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph | +| Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph | +| Chrysler | Pacifica Hybrid 2019-20 | Adaptive Cruise | Stock | 0mph | 39mph | | Honda | Accord 2018-19 | All | Stock | 0mph | 3mph | | Honda | Accord Hybrid 2018-19 | All | Stock | 0mph | 3mph | | Honda | Civic Hatchback 2017-19 | Honda Sensing | Stock | 0mph | 12mph | | Honda | Civic Sedan/Coupe 2016-18 | Honda Sensing | openpilot | 0mph | 12mph | -| Honda | Civic Sedan/Coupe 2019-20 | Honda Sensing | Stock | 0mph | 2mph2 | -| Honda | CR-V 2015-16 | Touring | openpilot | 25mph1 | 12mph | +| Honda | Civic Sedan/Coupe 2019 | Honda Sensing | Stock | 0mph | 2mph4 | +| Honda | CR-V 2015-16 | Touring | openpilot | 25mph6 | 12mph | | Honda | CR-V 2017-19 | Honda Sensing | Stock | 0mph | 12mph | | Honda | CR-V Hybrid 2017-2019 | Honda Sensing | Stock | 0mph | 12mph | -| Honda | Fit 2018-19 | Honda Sensing | openpilot | 25mph1 | 12mph | +| Honda | Fit 2018-19 | Honda Sensing | openpilot | 25mph6 | 12mph | | Honda | Insight 2019 | Honda Sensing | Stock | 0mph | 3mph | | Honda | Odyssey 2018-20 | Honda Sensing | openpilot | 25mph1 | 0mph | | Honda | Passport 2019 | All | openpilot | 25mph1 | 12mph | @@ -94,38 +97,41 @@ Supported Cars | Lexus | ES Hybrid 2019 | All | openpilot | 0mph | 0mph | | Lexus | IS 2017-2019 | All | Stock | 22mph | 0mph | | Lexus | IS Hybrid 2017 | All | Stock | 0mph | 0mph | -| Lexus | NX Hybrid 2018 | All | Stock3| 0mph | 0mph | -| Lexus | RX 2016-17 | All | Stock3| 0mph | 0mph | +| Lexus | NX Hybrid 2018 | All | Stock5| 0mph | 0mph | +| Lexus | RX 2016-17 | All | Stock5| 0mph | 0mph | | Lexus | RX 2020 | All | openpilot | 0mph | 0mph | -| Lexus | RX Hybrid 2016-19 | All | Stock3| 0mph | 0mph | -| Toyota | Avalon 2016 | TSS-P | Stock3| 20mph1 | 0mph | -| Toyota | Avalon 2017-18 | All | Stock3| 20mph1 | 0mph | -| Toyota | Camry 2018-20 | All | Stock | 0mph4 | 0mph | -| Toyota | Camry Hybrid 2018-19 | All | Stock | 0mph4 | 0mph | +| Lexus | RX Hybrid 2016-19 | All | Stock5| 0mph | 0mph | +| Subaru | Crosstrek 2018-19 | EyeSight | Stock | 0mph | 0mph | +| Subaru | Impreza 2019-20 | EyeSight | Stock | 0mph | 0mph | +| Toyota | Avalon 2016 | TSS-P | Stock5| 20mph6 | 0mph | +| Toyota | Avalon 2017-18 | All | Stock5| 20mph6 | 0mph | +| Toyota | Camry 2018-19 | All | Stock | 0mph2 | 0mph | +| Toyota | Camry Hybrid 2018-19 | All | Stock | 0mph2 | 0mph | | Toyota | C-HR 2017-19 | All | Stock | 0mph | 0mph | | Toyota | C-HR Hybrid 2017-19 | All | Stock | 0mph | 0mph | -| Toyota | Corolla 2017-19 | All | Stock3| 20mph1 | 0mph | +| Toyota | Corolla 2017-19 | All | Stock5| 20mph6 | 0mph | | Toyota | Corolla 2020 | All | openpilot | 0mph | 0mph | | Toyota | Corolla Hatchback 2019-20 | All | openpilot | 0mph | 0mph | | Toyota | Corolla Hybrid 2020 | All | openpilot | 0mph | 0mph | -| Toyota | Highlander 2017-19 | All | Stock3| 0mph | 0mph | -| Toyota | Highlander Hybrid 2017-19 | All | Stock3| 0mph | 0mph | +| Toyota | Highlander 2017-19 | All | Stock5| 0mph | 0mph | +| Toyota | Highlander Hybrid 2017-19 | All | Stock5| 0mph | 0mph | | Toyota | Highlander 2020 | All | openpilot | 0mph | 0mph | -| Toyota | Prius 2016 | TSS-P | Stock3| 0mph | 0mph | -| Toyota | Prius 2017-19 | All | Stock3| 0mph | 0mph | -| Toyota | Prius Prime 2017-20 | All | Stock3| 0mph | 0mph | -| Toyota | Rav4 2016 | TSS-P | Stock3| 20mph1 | 0mph | -| Toyota | Rav4 2017-18 | All | Stock3| 20mph1 | 0mph | -| Toyota | Rav4 2019-20 | All | openpilot | 0mph | 0mph | -| Toyota | Rav4 Hybrid 2016 | TSS-P | Stock3| 0mph | 0mph | -| Toyota | Rav4 Hybrid 2017-18 | All | Stock3| 0mph | 0mph | +| Toyota | Prius 2016 | TSS-P | Stock5| 0mph | 0mph | +| Toyota | Prius 2017-19 | All | Stock5| 0mph | 0mph | +| Toyota | Prius Prime 2017-20 | All | Stock5| 0mph | 0mph | +| Toyota | Rav4 2016 | TSS-P | Stock5| 20mph6 | 0mph | +| Toyota | Rav4 2017-18 | All | Stock5| 20mph6 | 0mph | +| Toyota | Rav4 2019 | All | openpilot | 0mph | 0mph | +| Toyota | Rav4 Hybrid 2016 | TSS-P | Stock5| 0mph | 0mph | +| Toyota | Rav4 Hybrid 2017-18 | All | Stock5| 0mph | 0mph | | Toyota | Rav4 Hybrid 2019-20 | All | openpilot | 0mph | 0mph | -| Toyota | Sienna 2018 | All | Stock3| 0mph | 0mph | +| Toyota | Sienna 2018 | All | Stock5| 0mph | 0mph | +| Volkswagen| Golf 2016-193 | Driver Assistance | Stock | 0mph | 0mph | -1[Comma Pedal](https://community.comma.ai/wiki/index.php/Comma_Pedal) is used to provide stop-and-go capability to some of the openpilot-supported cars that don't currently support stop-and-go. Here is how to [build a Comma Pedal](https://medium.com/@jfrux/comma-pedal-building-with-macrofab-6328bea791e8). ***NOTE: The Comma Pedal is not officially supported by [comma](https://comma.ai).***
-22019 Honda Civic 1.6L Diesel Sedan does not have ALC below 12mph.
-3When disconnecting the Driver Support Unit (DSU), openpilot ACC will replace stock ACC. For DSU locations, see [Toyota Wiki page](https://community.comma.ai/wiki/index.php/Toyota). ***NOTE: disconnecting the DSU disables Automatic Emergency Braking (AEB).***
-428mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control.
+1Requires a [panda](https://comma.ai/shop/products/panda-obd-ii-dongle) and open sourced [Hyundai giraffe](https://github.com/commaai/neo/tree/master/giraffe/hyundai), designed for the 2019 Sante Fe; pinout may differ for other Hyundai and Kia models.
+228mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control.
+3Requires a [custom connector](https://community.comma.ai/wiki/index.php/Volkswagen#Integration_at_R242_Camera) for the [car harness](https://comma.ai/shop/products/car-harness)
+42019 Honda Civic 1.6L Diesel Sedan does not have ALC below 12mph.
Community Maintained Cars and Features ------ @@ -164,22 +170,18 @@ Community Maintained Cars and Features | Subaru | Impreza 2019-20 | EyeSight | Stock | 0mph | 0mph | | Volkswagen| Golf 2016-193 | Driver Assistance | Stock | 0mph | 0mph | -1Requires a [panda](https://comma.ai/shop/products/panda-obd-ii-dongle) and [community built giraffe](https://zoneos.com/volt/). ***NOTE: disconnecting the ASCM disables Automatic Emergency Braking (AEB).***
-2Requires a [panda](https://comma.ai/shop/products/panda-obd-ii-dongle) and open sourced [Hyundai giraffe](https://github.com/commaai/neo/tree/master/giraffe/hyundai), designed for the 2019 Sante Fe; pinout may differ for other Hyundai and Kia models.
-3Requires a [custom connector](https://community.comma.ai/wiki/index.php/Volkswagen#Integration_at_R242_Camera) for the [car harness](https://comma.ai/shop/products/car-harness)
- -Although it's not upstream, there's a community of people getting openpilot to run on Tesla's [here](https://tinkla.us/) +5When disconnecting the Driver Support Unit (DSU), openpilot ACC will replace stock ACC. For DSU locations, see [Toyota Wiki page](https://community.comma.ai/wiki/index.php/Toyota). ***NOTE: disconnecting the DSU disables Automatic Emergency Braking (AEB).***
+6[Comma Pedal](https://community.comma.ai/wiki/index.php/Comma_Pedal) is used to provide stop-and-go capability to some of the openpilot-supported cars that don't currently support stop-and-go. Here is how to [build a Comma Pedal](https://medium.com/@jfrux/comma-pedal-building-with-macrofab-6328bea791e8). ***NOTE: The Comma Pedal is not officially supported by [comma](https://comma.ai).***
+7Requires a [panda](https://comma.ai/shop/products/panda-obd-ii-dongle) and [community built giraffe](https://zoneos.com/volt/). ***NOTE: disconnecting the ASCM disables Automatic Emergency Braking (AEB).***
Community Maintained Cars and Features are not verified by comma to meet our [safety model](SAFETY.md). Be extra cautious using them. They are only available after enabling the toggle in `Settings->Developer->Enable Community Features`. -To promote a car from community maintained, it must meet a few requirements. We must own one from the brand, we must sell the harness for it, has full ISO26262 in both panda and openpilot, there must be a path forward for longitudinal control, it must have AEB still enabled, and it must support fingerprinting 2.0 - Installation Instructions ------ -Install openpilot on an EON or comma two by entering ``https://openpilot.comma.ai`` during the installer setup. +Install openpilot on a EON by entering ``https://openpilot.comma.ai`` during the installer setup. -Follow these [video instructions](https://youtu.be/3nlkomHathI) to properly mount the device on the windshield. Note: openpilot features an automatic pose calibration routine and openpilot performance should not be affected by small pitch and yaw misalignments caused by imprecise device mounting. +Follow this [video instructions](https://youtu.be/3nlkomHathI) to properly mount the EON on the windshield. Note: openpilot features an automatic pose calibration routine and openpilot performance should not be affected by small pitch and yaw misalignments caused by imprecise EON mounting. Before placing the device on your windshield, check the state and local laws and ordinances where you drive. Some state laws prohibit or restrict the placement of objects on the windshield of a motor vehicle. @@ -197,7 +199,7 @@ Many factors can impact the performance of openpilot ALC and openpilot LDW, caus * Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation. * The road facing camera is obstructed, covered or damaged by mud, ice, snow, etc. * Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle. -* The device is mounted incorrectly. +* The EON is mounted incorrectly. * When in sharp curves, like on-off ramps, intersections etc...; openpilot is designed to be limited in the amount of steering torque it can produce. * In the presence of restricted lanes or construction zones. * When driving on highly banked roads or in presence of strong cross-wind. @@ -217,7 +219,7 @@ Many factors can impact the performance of openpilot ACC and openpilot FCW, caus * Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation. * The road facing camera or radar are obstructed, covered, or damaged by mud, ice, snow, etc. * Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle. -* The device is mounted incorrectly. +* The EON is mounted incorrectly. * Approaching a toll booth, a bridge or a large metal plate. * When driving on roads with pedestrians, cyclists, etc... * In presence of traffic signs or stop lights, which are not detected by openpilot at this time. @@ -235,13 +237,13 @@ The list above does not represent an exhaustive list of situations that may inte Limitations of openpilot DM ------ -openpilot DM should not be considered an exact measurement of the alertness of the driver. +openpilot DM should not be considered an exact measurements of the status of alertness of the driver. Many factors can impact the performance of openpilot DM, causing it to be unable to function as intended. These include, but are not limited to: * Low light conditions, such as driving at night or in dark tunnels. * Bright light (due to oncoming headlights, direct sunlight, etc.). -* The driver's face is partially or completely outside field of view of the driver facing camera. +* The driver face is partially or completely outside field of view of the driver facing camera. * Right hand driving vehicles. * The driver facing camera is obstructed, covered, or damaged. @@ -263,7 +265,7 @@ Safety and Testing ---- * openpilot observes ISO26262 guidelines, see [SAFETY.md](SAFETY.md) for more detail. -* openpilot has software in the loop [tests](.github/workflows/test.yaml) that run on every commit. +* openpilot has software in the loop [tests](run_docker_tests.sh) that run on every commit. * The safety model code 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. @@ -290,15 +292,15 @@ Directory Structure ------ . ├── apk # The apk files used for the UI - ├── cereal # The messaging spec and libs used for all logs + ├── cereal # The messaging spec and libs used for all logs on EON ├── common # Library like functionality we've developed here ├── installer/updater # Manages auto-updates of openpilot ├── opendbc # Files showing how to interpret data from cars ├── panda # Code used to communicate on CAN - ├── phonelibs # Libraries used on NEOS devices - ├── pyextra # Libraries used on NEOS devices + ├── phonelibs # Libraries used on EON + ├── pyextra # Libraries used on EON └── selfdrive # Code needed to drive the car - ├── assets # Fonts, images, and sounds for UI + ├── assets # Fonts and images for UI ├── athena # Allows communication with the app ├── boardd # Daemon to talk to the board ├── camerad # Driver to capture images from the camera sensors @@ -312,7 +314,7 @@ Directory Structure ├── modeld # Driving and monitoring model runners ├── proclogd # Logs information from proc ├── sensord # IMU / GPS interface code - ├── test # Unit tests, system tests and a car simulator + ├── tests # Unit tests, system tests and a car simulator └── ui # The UI To understand how the services interact, see `cereal/service_list.yaml`. diff --git a/common/realtime.py b/common/realtime.py index c21222e88c2285..d97eb88b28f677 100644 --- a/common/realtime.py +++ b/common/realtime.py @@ -55,10 +55,12 @@ def remaining(self): return self._remaining # Maintain loop rate by calling this at the end of each loop - def keep_time(self): + def keep_time(self, offset=0.): lagged = self.monitor_time() if self._remaining > 0: time.sleep(self._remaining) + elif not offset == 0.: + self._next_frame_time += offset return lagged # this only monitor the cumulative lag, but does not enforce a rate diff --git a/selfdrive/boardd/boardd_setup.py b/selfdrive/boardd/boardd_setup.py index b8997f85427905..e19f99dbf82989 100644 --- a/selfdrive/boardd/boardd_setup.py +++ b/selfdrive/boardd/boardd_setup.py @@ -21,7 +21,7 @@ ARCH_DIR = 'x64' else: libraries = [':libcan_list_to_can_capnp.a', 'capnp', 'kj'] - if os.path.isdir("/system"): + if os.path.isdir("/system") or os.path.isdir('/data/oprun'): ARCH_DIR = 'aarch64' else: ARCH_DIR = 'larch64' diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index c85ad04e5e3244..740018fcfd2294 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -17,6 +17,9 @@ def __init__(self, CP, CarController, CarState): self.VM = VehicleModel(CP) self.frame = 0 + self.gas_pressed_prev = False + self.brake_pressed_prev = False + self.cruise_enabled_prev = False self.low_speed_alert = False self.CS = CarState(CP) @@ -105,8 +108,8 @@ def create_common_events(self, cs_out, extra_gears=[], gas_resume_speed=-1, pcm_ # Disable on rising edge of gas or brake. Also disable on brake when speed > 0. # Optionally allow to press gas at zero speed to resume. # e.g. Chrysler does not spam the resume button yet, so resuming with gas is handy. FIXME! - if (cs_out.gasPressed and (not self.CS.out.gasPressed) and cs_out.vEgo > gas_resume_speed) or \ - (cs_out.brakePressed and (not self.CS.out.brakePressed or not cs_out.standstill)): + if (cs_out.gasPressed and (not self.gas_pressed_prev) and cs_out.vEgo > gas_resume_speed) or \ + (cs_out.brakePressed and (not self.brake_pressed_prev or not cs_out.standstill)): events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) # we engage when pcm is active (rising edge) diff --git a/selfdrive/car/tesla/carstate.py b/selfdrive/car/tesla/carstate.py index a3fdb63962d9d0..4713be3d61cdbd 100644 --- a/selfdrive/car/tesla/carstate.py +++ b/selfdrive/car/tesla/carstate.py @@ -235,6 +235,11 @@ def __init__(self, CP): self.ahbOffDuration = 5 self.roadCameraID = "" self.driverCameraID = "" + self.roadCameraFx = 0.73 + self.driverCameraFx = 0.75 + self.roadCameraFlip = 0 + self.driverCameraFlip = 0 + self.monitorForcedRes = "" #read config file read_config_file(self) ### END OF MAIN CONFIG OPTIONS ### diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 6ffbc22603a7d7..8709c7929e546d 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -30,8 +30,8 @@ LANE_DEPARTURE_THRESHOLD = 0.1 -STEER_ANGLE_SATURATION_TIMEOUT = 1.0 / DT_CTRL -STEER_ANGLE_SATURATION_THRESHOLD = 2.5 # Degrees +EER_ANGLE_SATURATION_TIMEOUT = 1.0 / DT_CTRL +STEER_ANGLE_SATURATION_THRESHOLD = 250 # Degrees ThermalStatus = log.ThermalData.ThermalStatus State = log.ControlsState.OpenpilotState @@ -119,7 +119,7 @@ def data_sample(CI, CC, sm, can_sock, state, mismatch_counter, can_error_counter else: events.append(create_event('calibrationInvalid', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - if CS.vEgo > 92 * CV.MPH_TO_MS: +if CS.vEgo > 150 * CV.MPH_TO_MS: events.append(create_event('speedTooHigh', [ET.NO_ENTRY, ET.SOFT_DISABLE])) # When the panda and controlsd do not agree on controls_allowed @@ -470,10 +470,6 @@ def controlsd_thread(sm=None, pm=None, can_sock=None): passive = passive or not openpilot_enabled_toggle - # Passive if internet needed - internet_needed = params.get("Offroad_ConnectivityNeeded", encoding='utf8') is not None - passive = passive or internet_needed - # Pub/Sub Sockets if pm is None: pm = messaging.PubMaster(['sendcan', 'controlsState', 'carState', 'carControl', 'carEvents', 'carParams']) @@ -548,6 +544,7 @@ def controlsd_thread(sm=None, pm=None, can_sock=None): # controlsd is driven by can recv, expected at 100Hz rk = Ratekeeper(100, print_delay_threshold=None) + internet_needed = params.get("Offroad_ConnectivityNeeded", encoding='utf8') is not None prof = Profiler(False) # off by default diff --git a/selfdrive/controls/lib/alerts.py b/selfdrive/controls/lib/alerts.py index eec4426b2d11cd..4bd125abc142a0 100644 --- a/selfdrive/controls/lib/alerts.py +++ b/selfdrive/controls/lib/alerts.py @@ -110,7 +110,7 @@ def __gt__(self, alert2): Alert( "preDriverDistracted", - "KEEP EYES ON ROAD: Driver Distracted", + "KEEP EYES ON ROAD: Driver Appears Distracted", "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), @@ -272,7 +272,7 @@ def __gt__(self, alert2): Alert( "dataNeededNoEntry", "openpilot Unavailable", - "Calibration Needs Data. Upload Drive, Try Again", + "Data Needed for Calibration. Upload Drive, Try Again", AlertStatus.normal, AlertSize.mid, Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 0., 3.), @@ -526,13 +526,6 @@ def __gt__(self, alert2): AlertStatus.normal, AlertSize.mid, Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), - Alert( - "speedTooHigh", - "Speed Too High", - "Slow down to resume operation", - AlertStatus.normal, AlertSize.mid, - Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), - # Cancellation alerts causing non-entry Alert( "overheatNoEntry", @@ -551,7 +544,7 @@ def __gt__(self, alert2): Alert( "calibrationInvalidNoEntry", "openpilot Unavailable", - "Calibration Invalid: Reposition Device & Recalibrate", + "Calibration Invalid: Reposition Device and Recalibrate", AlertStatus.normal, AlertSize.mid, Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), @@ -752,13 +745,6 @@ def __gt__(self, alert2): AlertStatus.normal, AlertSize.mid, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), - Alert( - "invalidLkasSettingPermanent", - "Stock LKAS is turned on", - "Turn off stock LKAS to engage", - AlertStatus.normal, AlertSize.mid, - Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), - Alert( "internetConnectivityNeededPermanent", "Please connect to Internet", diff --git a/tools/webcam/README.md b/tools/webcam/README.md index 89f1ac3a625ea0..14574c16c63ac1 100644 --- a/tools/webcam/README.md +++ b/tools/webcam/README.md @@ -17,10 +17,10 @@ git clone https://github.com/commaai/openpilot.git ``` - Follow [this readme](https://github.com/commaai/openpilot/tree/master/tools) to install the requirements - Add line "export PYTHONPATH=$HOME/openpilot" to your ~/.bashrc -- You also need to install tensorflow-gpu 2.1.0 (if not working, try 2.0.0) and nvidia drivers: nvidia-xxx/cuda10.0/cudnn7.6.5 +- You also need to install tensorflow-gpu 2.1.0 and nvidia drivers: nvidia-xxx/cuda10.0/cudnn7.6.5 - Install [OpenCL Driver](http://registrationcenter-download.intel.com/akdlm/irc_nas/12556/opencl_runtime_16.1.2_x64_rh_6.4.0.37.tgz) - (Note: the code assumes cl platforms order to be 0.GPU/1.CPU when running clinfo; if reverse, change the -1 to -2 in selfdrive/modeld/modeld.cc#L130; helping us refactor this mess is encouraged) -- Install [OpenCV4](https://www.pyimagesearch.com/2018/08/15/how-to-install-opencv-4-on-ubuntu/) (ignore the Python part) +- Install [OpenCV4](https://www.pyimagesearch.com/2018/08/15/how-to-install-opencv-4-on-ubuntu/) ## Build openpilot for webcam ``` diff --git a/tools/webcam/front_mount_helper.py b/tools/webcam/front_mount_helper.py index 1fdca3225aef0b..0ac32acc25e0ae 100755 --- a/tools/webcam/front_mount_helper.py +++ b/tools/webcam/front_mount_helper.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3.6 import numpy as np # copied from common.transformations/camera.py @@ -15,7 +15,7 @@ [ 0., webcam_focal_length, 720/2.], [ 0., 0., 1.]]) -cam_id = 2 +cam_id = 1 if __name__ == "__main__": import cv2 @@ -32,4 +32,4 @@ img = cv2.warpPerspective(img, trans_webcam_to_eon_front, (1152,864), borderMode=cv2.BORDER_CONSTANT, borderValue=0) img = img[:,-864//2:,:] cv2.imshow('preview', img) - cv2.waitKey(10) \ No newline at end of file + cv2.waitKey(10) diff --git a/tools/webcam/jetson_test_cam.py b/tools/webcam/jetson_test_cam.py index d07d5f4905c659..89bda70e0c9fcb 100755 --- a/tools/webcam/jetson_test_cam.py +++ b/tools/webcam/jetson_test_cam.py @@ -11,7 +11,8 @@ " nvvidconv ! video/x-raw(memory:NVMM),format=I420 !" " nvvidconv ! video/x-raw,format=BGRx !" " videoconvert ! video/x-raw,format=BGR !" - " videoscale ! video/x-raw,width=%d,height=%d !" + " videoscale ! video/x-raw,width=%d,height=%d ! %s" + " videobox autocrop=true ! video/x-raw,width=%d,height=%d !" " appsink ") cs = CarSettings() if len(sys.argv) != 2: @@ -21,11 +22,15 @@ if cam == "road" or cam == "driver": print ("Processing camera [%s]\n" % cam) if cam == "road": - strm = strm_template % (cs.roadCameraID, 800, 600, 20, 1164,874) - dx = round(1164/4) - dy = round(874/4) + flip_command = "" + if cs.roadCameraFlip == 1: + flip_command = "videoflip method=rotate-180 ! " + strm = strm_template % (cs.roadCameraID, 800, 600, 20, round(1164*cs.roadCameraFx*1.5),round(874*cs.roadCameraFx*1.5),flip_command,1164,874) else: - strm = strm_template % (cs.driverCameraID, 640, 480, 10, 1152,864) + flip_command = "" + if cs.driverCameraFlip == 1: + flip_command = "videoflip method=180 ! " + strm = strm_template % (cs.driverCameraID, 640, 480, 10, round(1152*cs.driverCameraFx),round(864*cs.driverCameraFx),flip_command,1152,864) dx = round(1152/4) dy = round(864/4) print("Capturing with stream [%s}\n" % strm) @@ -35,7 +40,7 @@ while True: ret, frame = cap.read() if cam == "road": - img = frame[ dy:3*dy, dx:3*dx] + img = frame else: img = frame[:,-864//2:,:] if ret: diff --git a/tools/webcam/warp_vis.py b/tools/webcam/warp_vis.py index 547f1be99ada23..fb838b873a30e9 100755 --- a/tools/webcam/warp_vis.py +++ b/tools/webcam/warp_vis.py @@ -5,7 +5,7 @@ eon_focal_length = 910.0 # pixels eon_dcam_focal_length = 860.0 # pixels -webcam_focal_length = -908.0/1.5 # pixels +webcam_focal_length = 1408.0/1.5 # pixels eon_intrinsics = np.array([ [eon_focal_length, 0., 1164/2.], @@ -18,8 +18,8 @@ [ 0, 0, 1]]) webcam_intrinsics = np.array([ - [webcam_focal_length, 0., 1280/2/1.5], - [ 0., webcam_focal_length, 720/2/1.5], + [webcam_focal_length, 0., 960/2/1.5], + [ 0., webcam_focal_length, 544/2/1.5], [ 0., 0., 1.]]) if __name__ == "__main__": @@ -29,17 +29,18 @@ print("trans_webcam_to_eon_rear:\n", trans_webcam_to_eon_rear) print("trans_webcam_to_eon_front:\n", trans_webcam_to_eon_front) - cap = cv2.VideoCapture(1) - cap.set(cv2.CAP_PROP_FRAME_WIDTH, 853) - cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480) + cap = cv2.VideoCapture(2) + cap.set(cv2.CAP_PROP_FRAME_WIDTH, 960) + cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 544) while (True): - ret, img = cap.read() + ret, img = cap.read(1) if ret: - # img = cv2.warpPerspective(img, trans_webcam_to_eon_rear, (1164,874), borderMode=cv2.BORDER_CONSTANT, borderValue=0) - img = cv2.warpPerspective(img, trans_webcam_to_eon_front, (1164,874), borderMode=cv2.BORDER_CONSTANT, borderValue=0) + #img = cv2.warpPerspective(img, trans_webcam_to_eon_rear, (1164,874), borderMode=cv2.BORDER_CONSTANT, borderValue=0) + img = cv2.warpPerspective(img, trans_webcam_to_eon_front, (1164,874), borderMode=cv2.BORDER_CONSTANT, borderValue=100) print(img.shape, end='\r') cv2.imshow('preview', img) cv2.waitKey(10) +