forked from commaai/openpilot
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
26,278 additions
and
1,402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
import sys | ||
import errno | ||
import shutil | ||
import time | ||
from urllib.request import urlopen | ||
from glob import glob | ||
import subprocess | ||
import importlib.util | ||
|
||
# NOTE: Do NOT import anything here that needs be built (e.g. params) | ||
from openpilot.common.spinner import Spinner | ||
from openpilot.common.basedir import BASEDIR | ||
|
||
sys.path.append(os.path.join(BASEDIR, "third_party")) | ||
OPSPLINE_SPEC = importlib.util.find_spec('scipy') | ||
OVERPY_SPEC = importlib.util.find_spec('overpy') | ||
MAX_BUILD_PROGRESS = 100 | ||
TMP_DIR = '/data/tmp' | ||
THIRD_PARTY_DIR = '/data/openpilot/third_party' | ||
|
||
|
||
def wait_for_internet_connection(return_on_failure=False): | ||
retries = 0 | ||
while True: | ||
try: | ||
_ = urlopen('https://www.google.com/', timeout=10) | ||
return True | ||
except Exception as e: | ||
print(f'Wait for internet failed: {e}') | ||
if return_on_failure and retries == 15: | ||
return False | ||
retries += 1 | ||
time.sleep(2) # Wait for 2 seconds before retrying | ||
|
||
|
||
def install_dep(spinner): | ||
wait_for_internet_connection() | ||
|
||
TOTAL_PIP_STEPS = 2986 | ||
|
||
try: | ||
os.makedirs(TMP_DIR) | ||
except OSError as e: | ||
if e.errno != errno.EEXIST: | ||
raise | ||
my_env = os.environ.copy() | ||
my_env['TMPDIR'] = TMP_DIR | ||
|
||
pip_target = [f'--target={THIRD_PARTY_DIR}'] | ||
packages = [] | ||
if OPSPLINE_SPEC is None: | ||
packages.append('scipy==1.7.1') | ||
if OVERPY_SPEC is None: | ||
packages.append('overpy==0.6') | ||
|
||
pip = subprocess.Popen([sys.executable, "-m", "pip", "install", "-v"] + pip_target + packages, | ||
stdout=subprocess.PIPE, env=my_env) | ||
|
||
# Read progress from pip and update spinner | ||
steps = 0 | ||
while True: | ||
output = pip.stdout.readline() | ||
if pip.poll() is not None: | ||
break | ||
if output: | ||
steps += 1 | ||
spinner.update_progress(MAX_BUILD_PROGRESS * min(1., steps / TOTAL_PIP_STEPS), 100.) | ||
print(output.decode('utf8', 'replace')) | ||
|
||
shutil.rmtree(TMP_DIR) | ||
os.unsetenv('TMPDIR') | ||
|
||
# remove numpy installed to THIRD_PARTY_DIR since numpy is already present in the AGNOS image | ||
if OPSPLINE_SPEC is None: | ||
for directory in glob(f'{THIRD_PARTY_DIR}/numpy*'): | ||
shutil.rmtree(directory) | ||
shutil.rmtree(f'{THIRD_PARTY_DIR}/bin') | ||
|
||
|
||
if __name__ == "__main__" and (OPSPLINE_SPEC is None or OVERPY_SPEC is None): | ||
spinner = Spinner() | ||
spinner.update_progress(0, 100) | ||
install_dep(spinner) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Map query config | ||
|
||
QUERY_RADIUS = 3000 # mts. Radius to use on OSM data queries. | ||
MIN_DISTANCE_FOR_NEW_QUERY = 1000 # mts. Minimum distance to query area edge before issuing a new query. | ||
FULL_STOP_MAX_SPEED = 1.39 # m/s Max speed for considering car is stopped. | ||
LOOK_AHEAD_HORIZON_TIME = 15. # s. Time horizon for look ahead of turn speed sections to provide on liveMapData msg. | ||
LANE_WIDTH = 3.7 # Lane width estimate. Used for detecting departures from way. |
Oops, something went wrong.