setup¶
After initial setup, configure autopilot: create an autopilot directory and a prefs.json file
Data:
performance: |
Classes:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Functions:
Unfold nested values from the SetupForm. |
|
|
Call a series of commands, giving a single return code on completion or failure |
|
|
|
Make a directory if it doesn’t exist and set its permissions to 0777 |
-
PILOT_ENV_CMDS
= {'bluetooth': ["sudo sed - i '$s/$/\ndtoverlay=pi3-disable-bt/' / boot / config.txt", 'sudo systemctl disable hciuart.service', 'sudo systemctl disable bluealsa.service', 'sudo systemctl disable bluetooth.service'], 'change_pw': ['passwd'], 'env_pilot': ['sudo apt-get update', 'sudo apt-get install -y build-essential cmake git python3-dev libatlas-base-dev libsamplerate0-dev libsndfile1-dev libreadline-dev libasound-dev i2c-tools libportmidi-dev liblo-dev libhdf5-dev libzmq-dev libffi-dev'], 'hifiberry': [{'command': 'sudo adduser pi i2c', 'optional': True}, "sudo sed -i 's/^dtparam=audio=on/#dtparam=audio=on/g' /boot/config.txt", "sudo sed -i '$s/$/\\ndtoverlay=hifiberry-dacplus\\ndtoverlay=i2s-mmap\\ndtoverlay=i2c-mmap\\ndtparam=i2c1=on\\ndtparam=i2c_arm=on/' /boot/config.txt", "echo -e 'pcm.!default {\\n type hw card 0\\n}\\nctl.!default {\\n type hw card 0\\n}' | sudo tee /etc/asound.conf"], 'jackd': ['sudo apt update && sudo apt install -y jackd2'], 'jackd_source': ['git clone git://github.com/jackaudio/jack2 --depth 1', 'cd jack2', './waf configure --alsa=yes --libdir=/usr/lib/arm-linux-gnueabihf/', './waf build -j6', 'sudo ./waf install', 'sudo ldconfig', 'sudo sh -c "echo @audio - memlock 256000 >> /etc/security/limits.conf"', 'sudo sh -c "echo @audio - rtprio 75 >> /etc/security/limits.conf"', 'cd ..', 'rm -rf ./jack2'], 'opencv': ['sudo apt-get install -y build-essential cmake ccache unzip pkg-config libjpeg-dev libpng-dev libtiff-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev ffmpeg libgtk-3-dev libcanberra-gtk* libatlas-base-dev gfortran python2-dev python-numpy', 'git clone https://github.com/opencv/opencv.git', 'git clone https://github.com/opencv/opencv_contrib', 'cd opencv', 'mkdir build', 'cd build', 'cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/home/pi/git/opencv_contrib/modules -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_DOCS=OFF -D WITH_TBB=ON -D CMAKE_CXX_FLAGS="-DTBB_USE_GCC_BUILTINS=1 -D__TBB_64BIT_ATOMICS=0" -D WITH_OPENMP=ON -D WITH_IPP=OFF -D WITH_OPENCL=ON -D WITH_V4L=ON -D WITH_LIBV4L=ON -D ENABLE_NEON=ON -D ENABLE_VFPV3=ON -D PYTHON3_EXECUTABLE=/usr/bin/python3 -D PYTHON_INCLUDE_DIR=/usr/include/python3.7 -D PYTHON_INCLUDE_DIR2=/usr/include/arm-linux-gnueabihf/python3.7 -D OPENCV_ENABLE_NONFREE=ON -D INSTALL_PYTHON_EXAMPLES=OFF -D WITH_CAROTENE=ON -D CMAKE_SHARED_LINKER_FLAGS=\'-latomic\' -D BUILD_EXAMPLES=OFF ..', "sudo sed -i 's/^CONF_SWAPSIZE=100/CONF_SWAPSIZE=2048/g' /etc/dphys-swapfile", 'sudo /etc/init.d/dphys-swapfile stop', 'sudo /etc/init.d/dphys-swapfile start', 'make -j4', 'sudo make install', 'sudo ldconfig', "sudo sed -i 's/^CONF_SWAPSIZE=2048/CONF_SWAPSIZE=100/g' /etc/dphys-swapfile", 'sudo /etc/init.d/dphys-swapfile stop', 'sudo /etc/init.d/dphys-swapfile start'], 'performance': ['sudo systemctl disable raspi-config', 'sudo sed -i \'/^exit 0/i echo "performance" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor\' /etc/rc.local', 'sudo sh -c "echo @audio - memlock 256000 >> /etc/security/limits.conf"', 'sudo sh -c "echo @audio - rtprio 75 >> /etc/security/limits.conf"'], 'performance_cameras': ["sudo sh -c 'echo options uvcvideo nodrop=1 timeout=10000 quirks=0x80 > /etc/modprobe.d/uvcvideo.conf'", 'sudo rmmod uvcvideo', 'sudo modprobe uvcvideo', 'sudo sed -i "/^exit 0/i sudo sh -c \'echo ${usbfs_size} > /sys/module/usbcore/parameters/usbfs_memory_mb\'" /etc/rc.local'], 'set_locale': ['sudo dpkg-reconfigure locales', 'sudo dpkg-reconfigure keyboard-configuration'], 'viz': []}¶ - performance:
disable startup script that changes cpu governor,
change cpu governor to “performance” on boot
increase memlock and realtime priority limits for audio group
- hifiberry:
turn onboard audio off
enable hifiberry stuff in /boot/config.txt
edit alsa config so hifiberry is default sound card
viz:
Todo
Need to find a more elegant way to do this, for now see lines 160-200 in the presetup_pilot.sh legacy script
-
class
Autopilot_Form
(*args, **kwargs)[source]¶ Bases:
npyscreen.fmForm.Form
Methods:
populate_dependencies
(params)populate_form
(params)update_depends
(param_name)
-
class
Hardware_Form
(*args, **kwargs)[source]¶ Bases:
npyscreen.fmFormWithMenus.FormWithMenus
Methods:
create
()Programmers should over-ride this in derived classes, creating widgets here
add_hardware
(module, class_name)
-
class
Agent_Form
(name=None, parentApp=None, framed=None, help=None, color='FORMDEFAULT', widget_list=None, cycle_widgets=False, *args, **keywords)[source]¶ Bases:
npyscreen.fmForm.Form
Methods:
create
()Programmers should over-ride this in derived classes, creating widgets here
-
class
Pilot_Env_Form
(*args, **kwargs)[source]¶ Bases:
autopilot.setup.setup_autopilot.Autopilot_Form
Methods:
create
()Programmers should over-ride this in derived classes, creating widgets here
-
class
Pilot_Config_Form_1
(*args, **kwargs)[source]¶ Bases:
autopilot.setup.setup_autopilot.Autopilot_Form
Methods:
create
()Programmers should over-ride this in derived classes, creating widgets here
-
class
Pilot_Config_Form_2
(*args, **kwargs)[source]¶ Bases:
autopilot.setup.setup_autopilot.Autopilot_Form
Methods:
create
()Programmers should over-ride this in derived classes, creating widgets here
-
class
Terminal_Form
(*args, **kwargs)[source]¶ Bases:
autopilot.setup.setup_autopilot.Autopilot_Form
Methods:
create
()Programmers should over-ride this in derived classes, creating widgets here
-
class
Autopilot_Setup
(prefs)[source]¶ Bases:
npyscreen.apNPSApplicationManaged.NPSAppManaged
Methods:
onStart
()Override this method to perform any initialisation.
-
unfold_values
(v)[source]¶ Unfold nested values from the SetupForm. Called recursively.
- Parameters
v (dict) – unfolded values