Difference between revisions of "SoftPanda"

From Tinkla: Tinkering with Tesla
m (Download softPanda Executable)
m (Reverted edits by BogGyver (talk) to last revision by F. John)
(Tag: Rollback)
 
(52 intermediate revisions by 6 users not shown)
Line 1: Line 1:
  To install and use the softPanda for IC/CID integration you have to have root access and mofiy important files on the IC and CID of your Tesla car. Please read carefully the whole document as well as the disclaimers. If you have questions or doubts, please reach out to our user group on the Comma.ai Tesla channel on Discord.
+
  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.
  
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.  
+
SoftPanda is a piece of software that makes the car's interfaces look and feel like OpenPilot shipped with the car.
=== Which source code branch is needed? ===
+
The IC integration runs the AutoPilot view, powered by OpenPilot. CID integration adds settings for OpenPilot in the car's menu.<br>
 +
Additionally, softPanda adds map based speed control as well as control over max speed offset.<br>
 +
'''To install and use the softPanda for IC/CID integration you have to have root access and modify important files on the IC and CID of your Tesla car. Please read carefully the whole document as well as the disclaimers. If you have questions or doubts, please reach out to our user group on the Comma.ai Tesla channel on Discord.'''
  
You will have to be on one of the branches in my [https://github.com/BogGyver/openpilot repo] that is based on OpenPilot 0.5.9 or above.
+
__TOC__
  
 +
Before Attempting Integreation with SoftPanda, have you considered trying [[Tinkla Buddy]]?
 +
[[file:T_Buddy.png|600px|center|link=Tinkla_Buddy]]
 +
Seriously, [[Tinkla Buddy]] is worth a shot.
  
 
=== Changes to OpenPilot Configuration File ===
 
=== 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:
 
The following options must be set to true in the [[OpenPilot Configuration File]] for the IC/CID integration to work:
 +
<source lang="bash">
 +
enable_das_emulation = True
 +
has_tesla_ic_integration = True
  
use_tesla_gps = True
+
# if this is false, the corresponding setting on CID will switch to on after every restart
use_tesla_map_data = True
+
use_tesla_map_data = True
has_tesla_ic_integration = True
+
</source>
# 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 ===
 
=== Download softPanda Executable ===
  
Dwnload the [http://tinkla.us/files/softPanda softPanda] Executable and place it in '''/var/root/bin'''
+
Download the [https://tinkla.us/files/softPanda softPanda] executable to '''/var/root/bin''' on your CID with the following commands:
 +
<source lang="bash">
 +
cd /var/root/bin
 +
curl -O https://tinkla.us/files/softPanda
 +
</source>
  
 
=== Download Language Strings File ===
 
=== Download Language Strings File ===
Line 25: Line 35:
 
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.
 
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.
  
English - [http://tinkla.us/files/QtCar_en.qm QtCar_en.qm]
+
English - [https://tinkla.us/files/QtCar_en.qm QtCar_en.qm]<br>
 +
German - [https://tinkla.us/files/QtCar_de.qm QtCar_de.qm]<br>
 +
Spanish - [https://tinkla.us/files/QtCar_es.qm QtCar_es.qm]
  
German - [http://tinkla.us/files/QtCar_de.qm QtCar_de.qm]
+
To get the files you can do this '''on both IC and CID''' (change the file URL to the language your car displays)
 +
<source lang="bash">
 +
cd /var/root/lang
 +
curl -O https://tinkla.us/files/QtCar_en.qm
 +
</source>
 +
<source lang="bash">
 +
ssh ic
 +
cd /var/root/lang
 +
curl -O https://tinkla.us/files/QtCar_en.qm
 +
</source>
  
 
=== Changes on IC ===
 
=== Changes on IC ===
Line 33: Line 54:
 
  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.  
 
  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.
+
Add the following 5 lines at the top of this '''[[Root:special file|special file]]''' on '''IC'''.<br>
 
+
Make sure both language file names match your car's language.
/bin/mount | /bin/grep -c /var/root/lang/QtCar >/dev/null || /bin/mount --bind /var/root/lang/QtCar_en.qm  
+
<source lang="bash">
/usr/tesla/UI/bin/QtCar_en.qm
+
/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"
+
QCPORT=":20201"
export QCPORT
+
export QCPORT
 
+
QCHPPORT=":31515"
 
+
export QCHPPORT
 +
</source>
  
 
=== Changes on CID ===
 
=== Changes on CID ===
Line 46: Line 68:
 
  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.  
 
  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.
+
CID integration (OpenPilot Menu) is currently only supported on '''2019.4.2''' and below.<br>
 +
Add the following 4 lines at the top of this '''[[Root:special file|special file]]''' on '''CID'''.<br>
 +
Make sure both language file names match your car's language.
 +
<source lang="bash">
 +
/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
 +
</source>
  
  /bin/mount | /bin/grep -c /var/root/lang/QtCar >/dev/null || /bin/mount --bind /var/root/lang/QtCar_en.qm
+
  NOTE: Do NOT declare QCHPPORT on CID!!!
/usr/tesla/UI/bin/QtCar_en.qm
 
QCPORT=":20201"
 
export QCPORT
 
  
 
=== Updating Maps ===
 
=== Updating Maps ===
  
==== Remove any old Map data: ====
+
If you have older version of maps on your CID, you might need to [[Root: update maps|update]] them.
If you have these files from the old Maps 3.x.x system in /opt/navigoff  delete them to free up space (otherwise rsync may run out of space); 5.5GB free space is required:
 
 
 
dr-xr-xr-x 4 nvidia fuse 4.0K Dec 19  2016 NA
 
dr-xr-xr-x 2 nvidia fuse  16K Dec 19  2016 lost+found
 
-r--r--r-- 1 nvidia fuse  17 Dec 19  2016 FILESYNC.VERSION
 
dr-xr-xr-x 2 nvidia fuse 4.0K Dec 19  2016 sound
 
 
 
==== Download Maps: ====
 
 
 
A high speed internet connection (wifi or LTE) is recommended, 3G will take a long time
 
 
 
sudo rsync -r -v --progress --partial --append-verify spam@maps-1620467086.us-west-2.elb.amazonaws.com:/var/data/maps/NA-180906-1605/ /opt/navigoff/
 
 
 
  
 
=== Startup Script ===
 
=== Startup Script ===
  
Place in '''/var/root/scripts/setupSoftPanda.sh''' and make executable
+
Use [[Root: startSoftPanda|'''/var/root/scripts/startSoftPanda.sh''']] script.
 
 
#!/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 cron ===
  
=== Changing the crontab ===
+
In order to start the script you need to modify your [[Root: crontab|cron]] and add the following 2 lines:
 
+
<source lang="bash">
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.
+
@reboot /sbin/start-stop-daemon --start --quiet --make-pidfile --oknodo --background --pidfile /var/run/softPanda.pid --exec /bin/bash /var/root/scripts/startSoftPanda.sh
 
+
*/1 * * * * /sbin/start-stop-daemon --start --quiet --make-pidfile --oknodo --background --pidfile /var/run/softPanda.pid --exec /bin/bash /var/root/scripts/startSoftPanda.sh
In order to start the script you need to modify your crontab. To make the script always-running:
+
</source>
 
 
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
 
  
 
=== A simple restart script ===
 
=== A simple restart script ===
  
The softPanda startup script creates a lock file and prevents two restarts in less than 10 minutes to allow you to still access your car computers in the event of a mistake. To manually restart the process you have to delete the lock file and then kill the softPanda process. Or just create a bash file with this content and run it.
+
The softPanda startup script creates a lock file and prevents two restarts in less than 10 minutes to allow you to still access your car computers in the event of a mistake. To manually restart the process you have to delete the lock file and then kill the softPanda process. Or just create a [[Root: restartSoftPanda|bash file]] with this content and run it.
 
 
PID=`ps -ef | grep softPanda | grep bridge | awk -F'[ ,]+' '{print $2}'`
 
if [ $PID -gt 0 ]
 
then
 
  rm /var/etc/softPanda.lock
 
  kill -9 $PID
 
fi
 
  
 
=== Optional Flags ===
 
=== Optional Flags ===
  
 
Here are the optional flags for softPanda EtherCan Proxy
 
Here are the optional flags for softPanda EtherCan Proxy
 +
 +
NOTE: If you are running Tesla software 2019.16 or later, you have to enable the '''-fix1916''' flag!
  
 
* -runOnIc: sets the spammer to run on IC instead of CID (CID default)
 
* -runOnIc: sets the spammer to run on IC instead of CID (CID default)
Line 191: Line 121:
 
* -forwardDebug: forward also the debug messages show in Developer Mode (OFF by default)
 
* -forwardDebug: forward also the debug messages show in Developer Mode (OFF by default)
 
* -forwardUnique: forward only unique CAN messages in each direction (OFF by default)
 
* -forwardUnique: forward only unique CAN messages in each direction (OFF by default)
 +
* -fix1916: fix DI_Status CAN change that started with 2019.16 (OFF by default)
 +
* -tpmsConti: Allows tire pressure display on Baloong TPMS system, DO NOT USE ON CONTI
  
 
=== Help, All Screens Are Black! ===
 
=== Help, All Screens Are Black! ===

Latest revision as of 19:41, 30 September 2020

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.

SoftPanda is a piece of software that makes the car's interfaces look and feel like OpenPilot shipped with the car. The IC integration runs the AutoPilot view, powered by OpenPilot. CID integration adds settings for OpenPilot in the car's menu.
Additionally, softPanda adds map based speed control as well as control over max speed offset.
To install and use the softPanda for IC/CID integration you have to have root access and modify important files on the IC and CID of your Tesla car. Please read carefully the whole document as well as the disclaimers. If you have questions or doubts, please reach out to our user group on the Comma.ai Tesla channel on Discord.

Before Attempting Integreation with SoftPanda, have you considered trying Tinkla Buddy? 
T Buddy.png
Seriously, Tinkla Buddy is worth a shot.

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:

enable_das_emulation = True
has_tesla_ic_integration = True

# if this is false, the corresponding setting on CID will switch to on after every restart
use_tesla_map_data = True

Download softPanda Executable

Download the softPanda executable to /var/root/bin on your CID with the following commands:

cd /var/root/bin
curl -O https://tinkla.us/files/softPanda

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.

English - QtCar_en.qm
German - QtCar_de.qm
Spanish - QtCar_es.qm

To get the files you can do this on both IC and CID (change the file URL to the language your car displays)

cd /var/root/lang 
curl -O https://tinkla.us/files/QtCar_en.qm
ssh ic
cd /var/root/lang 
curl -O https://tinkla.us/files/QtCar_en.qm

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 5 lines at the top of this special file on IC.
Make sure both language file names match your car's language.

/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
QCHPPORT=":31515"
export QCHPPORT

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. 

CID integration (OpenPilot Menu) is currently only supported on 2019.4.2 and below.
Add the following 4 lines at the top of this special file on CID.
Make sure both language file names match your car's language.

/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
NOTE: Do NOT declare QCHPPORT on CID!!!

Updating Maps

If you have older version of maps on your CID, you might need to update them.

Startup Script

Use /var/root/scripts/startSoftPanda.sh script.

Changing the cron

In order to start the script you need to modify your cron and add the following 2 lines:

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

A simple restart script

The softPanda startup script creates a lock file and prevents two restarts in less than 10 minutes to allow you to still access your car computers in the event of a mistake. To manually restart the process you have to delete the lock file and then kill the softPanda process. Or just create a bash file with this content and run it.

Optional Flags

Here are the optional flags for softPanda EtherCan Proxy

NOTE: If you are running Tesla software 2019.16 or later, you have to enable the -fix1916 flag!
  • -runOnIc: sets the spammer to run on IC instead of CID (CID default)
  • -triggerOnCan: start the spam only when receiving a certain CAN message from EON (OFF by default)
  • -autoRestartQtCarCluster: sends command to restart QtCarCluster when app starts (OFF by default)
  • -onlyCarConfig3: sends spam only for DasHw in GTW_carConfig3 (OFF by default)
  • -spamFrequency XX: spam frequency in Hz (100Hz by default)
  • -autopilot Y: autopilot mode (1:Highway, 2:Enhanced DEFAULT, 3:SelfDrive)
  • -bridge ZZZZZ: bridge mode where the packets received on 20101 are sent to port ZZZZZ (20102-27000)
  • -hBridge ZZZZZ: bridge mode where the packets received on 31415 are sent to port ZZZZZ (31515-32000)
  • -sendAfterReceive: sends modded message right after it is received (OFF by default)
  • -bindToPort WWWWW: Binds to a certain port and local IP address for sending (OFF by default)
  • -sendDiAccStatus: Send the DI_accStatus message; experimental for now (OFF by default)
  • -modifyDiState: Modifies the DI_state message for long control showing on IC (OFF by default)
  • -includeParrot: Include data from parrot to be sent through the bridge (OFF by default)
  • -includeLb: Include data from LB to be sent through the bridge (OFF by default)
  • -forwardDebug: forward also the debug messages show in Developer Mode (OFF by default)
  • -forwardUnique: forward only unique CAN messages in each direction (OFF by default)
  • -fix1916: fix DI_Status CAN change that started with 2019.16 (OFF by default)
  • -tpmsConti: Allows tire pressure display on Baloong TPMS system, DO NOT USE ON CONTI

Help, All Screens Are Black!

It’s not uncommon to see both IC and CID black the first time you start your car after enabling everything. This is caused by the CID not receiving messages from the gateway to wake up, which in turn is caused by softPanda having either not started or crashed. (Remember in the steps above we tell the CID to only listen to the gateway on the port softPanda proxies data to it on). The car will still drive with no screens, if you push the brake and wait 30 seconds for the gateway to give up trying to contact the screens.

Quickfix: Reboot the CID using the steering wheel (sometimes the speakers give a slight pop when the reboot command is executed). If everything is setup properly, the screens should come up. Steering wheel reboots are not preferred as they aren’t graceful restarts.

Preferred fix: ssh into the CID and restart softPanda, or troubleshoot what happened and then restart it.