From 04083e4995b7ea648acf6920a8d01263968f1ae4 Mon Sep 17 00:00:00 2001 From: raf Date: Tue, 11 Jun 2019 17:41:06 -0400 Subject: [PATCH 1/3] Fix for crash with no git remote --- selfdrive/registration.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/selfdrive/registration.py b/selfdrive/registration.py index 8ec0a21009e9f9..3bb21b20017d1b 100644 --- a/selfdrive/registration.py +++ b/selfdrive/registration.py @@ -22,9 +22,12 @@ def get_git_branch(): return subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).strip() def get_git_remote(): - local_branch = subprocess.check_output(["git", "name-rev", "--name-only", "HEAD"]).strip() - tracking_remote = subprocess.check_output(["git", "config", "branch."+local_branch+".remote"]).strip() - return subprocess.check_output(["git", "config", "remote."+tracking_remote+".url"]).strip() + try: + local_branch = subprocess.check_output(["git", "name-rev", "--name-only", "HEAD"]).strip() + tracking_remote = subprocess.check_output(["git", "config", "branch."+local_branch+".remote"]).strip() + return subprocess.check_output(["git", "config", "remote."+tracking_remote+".url"]).strip() + except subprocess.CalledProcessError: + return "" def register(): params = Params() From cee67b6fcaf140b1f05b0de3d6e96a6bf3e23420 Mon Sep 17 00:00:00 2001 From: BogGyver Date: Wed, 12 Jun 2019 08:19:50 -0400 Subject: [PATCH 2/3] reduce phantom brakes when lead car is detected --- selfdrive/car/tesla/PCC_module.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/selfdrive/car/tesla/PCC_module.py b/selfdrive/car/tesla/PCC_module.py index 61447ce7dbb503..58803e90313815 100644 --- a/selfdrive/car/tesla/PCC_module.py +++ b/selfdrive/car/tesla/PCC_module.py @@ -165,6 +165,7 @@ def __init__(self,carcontroller): self.a_acc_sol = 0.0 self.v_cruise = 0.0 self.a_cruise = 0.0 + self.had_lead = False #Long Control self.LoC = None #when was radar data last updated? @@ -497,7 +498,10 @@ def calc_follow_speed_ms(self, CS): else: lead_dist_m = _visual_radar_adjusted_dist_m(self.lead_1.dRel, CS) # Grab the relative speed. - rel_speed_kph = self.lead_1.vRel * CV.MS_TO_KPH + rel_speed_kph = 0. + if self.had_lead: + #avoid inital break when lead just detected + rel_speed_kph = self.lead_1.vRel * CV.MS_TO_KPH # v_ego is in m/s, so safe_distance is in meters. safe_dist_m = _safe_distance_m(CS.v_ego) # Current speed in kph @@ -509,7 +513,9 @@ def calc_follow_speed_ms(self, CS): # If no lead is present, accel up to max speed if lead_dist_m == 0: new_speed_kph = self.pedal_speed_kph + self.had_lead = False elif lead_dist_m > 0: + self.had_lead = True lead_absolute_speed_kph = actual_speed_kph + rel_speed_kph if lead_dist_m < MIN_SAFE_DIST_M: new_speed_kph = MIN_PCC_V_KPH @@ -543,7 +549,7 @@ def calc_follow_speed_ms(self, CS): # still an acceptable speed, accept it. This could happen if the # driver manually accelerates, or if we roll down a hill. In either # case, don't fight the extra velocity unless necessary. - if actual_speed_kph > new_speed_kph and min_kph < actual_speed_kph < max_kph: + if (actual_speed_kph > new_speed_kph) and (min_kph < actual_speed_kph < max_kph): new_speed_kph = actual_speed_kph new_speed_kph = clip(new_speed_kph, min_kph, max_kph) @@ -594,7 +600,7 @@ def _min_safe_vrel_kph(m): # (meters, safe relative velocity in kph) # Remember, a negative relative velocity means we are closing the distance. (MIN_SAFE_DIST_M, 1), # If lead is close, it better be pulling away. - (200, -15)]) # if lead is far, it's ok if we're closing. + (100, -15)]) # if lead is far, it's ok if we're closing. return _interp_map(m, min_vrel_by_distance) def _is_present(lead): From d5abe288803e1ef5dce46c99128f8d64fb300e2d Mon Sep 17 00:00:00 2001 From: BogGyver Date: Wed, 12 Jun 2019 09:56:10 -0400 Subject: [PATCH 3/3] make pedal flash CAN compatible --- panda/board/pedal_tesla/Makefile | 16 ++++++++++++---- panda/board/pedal_tesla/main.c | 5 +++-- panda/tests/pedal/enter_canloader_tesla.py | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/panda/board/pedal_tesla/Makefile b/panda/board/pedal_tesla/Makefile index 9917e381503b03..c49f7aa33aa44a 100644 --- a/panda/board/pedal_tesla/Makefile +++ b/panda/board/pedal_tesla/Makefile @@ -19,23 +19,31 @@ CERT = ../../certs/debug CFLAGS += "-DALLOW_DEBUG" canflash: obj/$(PROJ_NAME).bin - ../../tests/pedal/enter_canloader.py $< + ../../tests/pedal/enter_canloader_tesla.py $< usbflash: obj/$(PROJ_NAME).bin - ../../tests/pedal/enter_canloader.py; sleep 0.5 + ../../tests/pedal/enter_canloader_tesla.py; sleep 0.5 PYTHONPATH=../../ python -c "from python import Panda; p = [x for x in [Panda(x) for x in Panda.list()] if x.bootstub]; assert(len(p)==1); p[0].flash('obj/$(PROJ_NAME).bin', reconnect=False)" recover: obj/bootstub.bin obj/$(PROJ_NAME).bin - ../../tests/pedal/enter_canloader.py --recover; sleep 0.5 + ../../tests/pedal/enter_canloader_tesla.py --recover; sleep 0.5 $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000 -D obj/$(PROJ_NAME).bin $(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.bin +include ../../common/version.mk + +obj/cert.h: ../../crypto/getcertheader.py + ../../crypto/getcertheader.py ../../certs/debug.pub ../../certs/release.pub > $@ + obj/main.o: main.c ../*.h mkdir -p obj $(CC) $(CFLAGS) -o $@ -c $< -obj/bootstub.o: ../bootstub.c ../*.h +obj/bootstub.o: ../bootstub.c ../*.h obj/gitversion.h obj/cert.h mkdir -p obj + mkdir -p ../obj + cp obj/gitversion.h ../obj/gitversion.h + cp obj/cert.h ../obj/cert.h $(CC) $(CFLAGS) -o $@ -c $< obj/$(STARTUP_FILE).o: ../$(STARTUP_FILE).s diff --git a/panda/board/pedal_tesla/main.c b/panda/board/pedal_tesla/main.c index 9f189120c89a7e..2fe08456453f91 100644 --- a/panda/board/pedal_tesla/main.c +++ b/panda/board/pedal_tesla/main.c @@ -20,14 +20,13 @@ #define CAN CAN1 -//#define PEDAL - //#define PEDAL_USB #ifdef PEDAL_USB #include "drivers/usb.h" #endif +#define ENTER_BOOTLOADER_MAGIC 0xdeadbeef uint32_t enter_bootloader_mode; void __initialize_hardware_early() { @@ -87,6 +86,8 @@ int can_cksum(uint8_t *dat, int len, int addr) { // addresses to be used on CAN #define CAN_GAS_INPUT 0x551 #define CAN_GAS_OUTPUT 0x552 +#define CAN_GAS_SIZE 6 +#define COUNTER_CYCLE 0xF void CAN1_TX_IRQHandler() { // clear interrupt diff --git a/panda/tests/pedal/enter_canloader_tesla.py b/panda/tests/pedal/enter_canloader_tesla.py index 7f55cd6822537e..b293b3fb23e4b3 100755 --- a/panda/tests/pedal/enter_canloader_tesla.py +++ b/panda/tests/pedal/enter_canloader_tesla.py @@ -64,6 +64,7 @@ def bulkRead(self, endpoint, length, timeout=0): exit(0) else: p.can_send(0x551, "\xce\xfa\xad\xde\x1e\x0b\xb0\x0a", 2) + if args.fn: time.sleep(0.1) print "flashing", args.fn