Difference between revisions of "SoftPanda"

From Tinkla: Tinkering with Tesla
m
m
Line 49: Line 49:
 
=== Startup Script ===
 
=== Startup Script ===
  
Place in “/var/spool/setupSoftPanda.sh” and make executable
+
Place in “/var/root/scripts/setupSoftPanda.sh” and make executable
  
 
  #!/bin/bash
 
  #!/bin/bash
Line 122: Line 122:
 
   $SOFTPANDA_RUN/$SOFTPANDA -bridge 20201 -dasHw 1 -hBridge 31515 -includeParrot -includeLb -modifyDiState -forwardDebug -forwardUnique
 
   $SOFTPANDA_RUN/$SOFTPANDA -bridge 20201 -dasHw 1 -hBridge 31515 -includeParrot -includeLb -modifyDiState -forwardDebug -forwardUnique
 
  fi
 
  fi
 +
 +
 +
=== Changing the crontab ===
 +
 +
DISCLAMER: Improper changes to IC or CID can result in the system (and thus your car) being rederend unusable. Potentially not even Tesla can revert some of the changes if done incorrectly. You are doing this at your own risk. You alone are ultimately responsible, not the creator of this site, Comma.ai, Comma.ai community, Tesla, or anyone else.
 +
 +
In order to start the script you need to modify your crontab. To make the script always-running:
 +
 +
sudo crontab -e
 +
 +
Then insert:
 +
 +
@reboot /sbin/start-stop-daemon --start --quiet --make-pidfile --oknodo --background --pidfile /var/run/proxy.pid --exec /bin/bash /var/root/scripts/setupSoftPanda.sh
 +
*/1 * * * * /sbin/start-stop-daemon --start --quiet --make-pidfile --oknodo --background --pidfile /var/run/proxy.pid --exec /bin/bash /var/root/scripts/setupSoftPanda.sh

Revision as of 18:43, 23 May 2019

Which source code branch is needed?

You will have to be on one of the branches in my repo that is based on OpenPilot 0.5.9 or above.


Changes to OpenPilot Configuration File

The following options must be set to true in the OpenPilot Configuration File for the IC/CID integration to work:

use_tesla_gps = True
use_tesla_map_data = True
has_tesla_ic_integration = True
# below is optional changes speedo from flying car to old non-ap gauge when EON is not connected; not implemented yet
use_analog_when_no_eon = True

Download softPanda Executable

Dwnload the softPanda Executable and place it in /var/root/run

Download Language Strings File

Find and download the QtCar_xx.qm specific to your language (for example English is en) on both IC and CID and place it in /var/root/lang on both systems.

Changes on IC

DISCLAMER: Improper changes to IC or CID can result in the system (and thus your car) being rederend unusable. Potentially not even Tesla can revert some of the changes if done incorrectly. You are doing this at your own risk. You alone are ultimately responsible, not the creator of this site, Comma.ai, Comma.ai community, Tesla, or anyone else. 

Add the following 4 lines at the top of your /var/etc/tesla.env. the language file should match the language set on your car and the file you downloaded above.

/bin/mount | /bin/grep -c /var/root/lang/QtCar >/dev/null || /bin/mount --bind /var/root/lang/QtCar_en.qm 
/usr/tesla/UI/bin/QtCar_en.qm
QCPORT=":20201"
export QCPORT


Changes on CID

DISCLAMER: Improper changes to IC or CID can result in the system (and thus your car) being rederend unusable. Potentially not even Tesla can revert some of the changes if done incorrectly. You are doing this at your own risk. You alone are ultimately responsible, not the creator of this site, Comma.ai, Comma.ai community, Tesla, or anyone else. 

Add the following 4 lines at the top of your /var/etc/tesla.env. the language file should match the language set on your car and the file you downloaded above.

/bin/mount | /bin/grep -c /var/root/lang/QtCar >/dev/null || /bin/mount --bind /var/root/lang/QtCar_en.qm 
/usr/tesla/UI/bin/QtCar_en.qm
QCPORT=":20201"
export QCPORT

Startup Script

Place in “/var/root/scripts/setupSoftPanda.sh” and make executable

#!/bin/bash
# mount /var/root/run on tmpfs to not wear down the eMMC flash chip

SOFTPANDA_SOURCE=/var/spool
SOFTPANDA_RUN=/var/root/run
SOFTPANDA_ETC=/var/etc
SOFTPANDALOCK=softPanda.lock
SOFTPANDA=softPanda
SHOULDRUN=0 

mkdir -p $SOFTPANDA_RUN 

ISTMPFS=`/bin/mount | /bin/grep -c "$SOFTPANDA_RUN type tmpfs"`

#check if lock file exists
if [ ! -f $SOFTPANDA_ETC/$SOFTPANDALOCK ]; then
    # no file, we can run
    SHOULDRUN=1
else
   # we have file, check file age
   while ! test `find "$SOFTPANDA_ETC/$SOFTPANDALOCK" -mmin +10`
   do
      # file is old enough
      echo "File not old enough! Waiting;"
      sleep 60
   done
   SHOULDRUN=1
fi 

if [ $ISTMPFS  -eq 0 ]; then
  /bin/mount -t tmpfs -o size=10M,mode=0755 tmpfs $SOFTPANDA_RUN
fi

if [ $SHOULDRUN -eq 1 ]
then
  touch $SOFTPANDA_ETC/$SOFTPANDALOCK
  echo "Set final GUI and DAS settings"
  sudo edit-settings-conf.pl -a vapi/forceHasAutopilot=true
  sudo edit-settings-conf.pl -a vapi/forceHasDriveOnNav=true
  sudo edit-settings-conf.pl -a vapi/forceHasDriveOnNavMaps=true
  sdv GUI_autopilotAlwaysOn true
  sdv GUI_autosteerOnRequest true
  sdv GUI_autosteerDisabled false
  sdv GUI_accFromZero true
  sdv DAS_mapAvailability true
  sdv GUI_redLightStopSignOnRequest true
  sdv GUI_enableMapStops true
  sdv GUI_enableVisionStops true
  sdv GUI_enableFSDFunctions true
  sdv GUI_stopAndGo true
  sdv GUI_noaEverywhere true
  sdv DAS_navAvailable true
  sdv GUI_accFollowDistance 2
  sdv GUI_accOvertakeOnRequest true
  sdv GUI_autopilotControlRequest 0
  sdv FEATURE_dasDriveOnNavEnabled true
  sdv FEATURE_dasDriveOnNavMapsOkay true
  sdv VAPI_backupCameraCalibrated true
  sdv VAPI_fisheyeCameraCalibrated true
  sdv VAPI_lPillarCameraCalibrated true
  sdv VAPI_lRepeaterCameraCalibrated true
  sdv VAPI_mainCameraCalibrated true
  sdv VAPI_narrowCameraCalibrated true
  sdv VAPI_rPillarCameraCalibrated true
  sdv VAPI_rRepeaterCameraCalibrated true

  cp $SOFTPANDA_SOURCE/$SOFTPANDA $SOFTPANDA_RUN
  chmod 755 $SOFTPANDA_RUN/$SOFTPANDA
  /usr/local/bin/emit-reboot-cluster
  $SOFTPANDA_RUN/$SOFTPANDA -bridge 20201 -dasHw 1 -hBridge 31515 -includeParrot -includeLb -modifyDiState -forwardDebug -forwardUnique
fi


Changing the crontab

DISCLAMER: Improper changes to IC or CID can result in the system (and thus your car) being rederend unusable. Potentially not even Tesla can revert some of the changes if done incorrectly. You are doing this at your own risk. You alone are ultimately responsible, not the creator of this site, Comma.ai, Comma.ai community, Tesla, or anyone else. 

In order to start the script you need to modify your crontab. To make the script always-running:

sudo crontab -e

Then insert:

@reboot /sbin/start-stop-daemon --start --quiet --make-pidfile --oknodo --background --pidfile /var/run/proxy.pid --exec /bin/bash /var/root/scripts/setupSoftPanda.sh
*/1 * * * * /sbin/start-stop-daemon --start --quiet --make-pidfile --oknodo --background --pidfile /var/run/proxy.pid --exec /bin/bash /var/root/scripts/setupSoftPanda.sh