forked from bitcraze/bitcraze-vm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
provision.sh
168 lines (140 loc) · 7.09 KB
/
provision.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash -x
# Replace apt source
sed -i "s@http://.*archive.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
sed -i "s@http://.*security.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
# Replace Ros source
sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
apt update
apt-get update
apt-get -y install curl # if you haven't already installed curl
echo "185.199.110.133 raw.githubusercontent.com" >> /etc/hosts
echo "192.30.255.112 github.com" >> /etc/hosts
#curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -
# Add KiCad stable PPA
sudo add-apt-repository --yes ppa:kicad/kicad-5.1-releases
# Update keys and repos
apt-key update
apt-get update
# Install packages
apt-get -y install build-essential git sdcc firefox python3-dev python3-pip qtcreator kicad \
dfu-util openocd gcc-arm-none-eabi gdb-multiarch docker.io\
ros-noetic-desktop-full python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool|| { echo 'apt-get install failed' ; exit 1; }
# Ros environment setup
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
# Ros Dependencies for building packages
rosdep init
rosdep update
# catkin workspace
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/NOKOV-MOCAP/mocap_nokov.git
cd ~/catkin_ws
catkin_make
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
# Ros2 Galactic
locale # check for UTF-8
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
locale # verify settings
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install curl gnupg2
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu focal main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update
sudo apt upgrade
sudo apt install ros-galactic-desktop
sudo apt install python3-colcon-common-extensions
# crazyswarm2
sudo apt install libboost-program-options-dev libusb-1.0-0-dev
pip3 install rowan
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
git clone https://github.com/IMRCLab/crazyswarm2 --recursive
git clone --branch ros2 --recursive https://github.com/IMRCLab/motion_capture_tracking.git
cd ../
source /opt/ros/galactic/setup.bash
colcon build --symlink-install
# Required for the VSCode embedded debug to work
ln -s /usr/bin/gdb-multiarch /usr/local/bin/arm-none-eabi-gdb
# Installing VirtualBox GuestAdditions
VBOX_ISO=VBoxGuestAdditions.iso
mkdir /tmp/isomount
mount -o loop ~/$VBOX_ISO /tmp/isomount
sh /tmp/isomount/VBoxLinuxAdditions.run
umount /tmp/isomount
rm -rf isomount ~/$VBOX_ISO
# Adding udev rules for Crazyradio and Crazyflie
usermod -a -G plugdev nokov
sh -c 'echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"1915\", ATTRS{idProduct}==\"7777\", MODE=\"0664\", GROUP=\"plugdev\" > /etc/udev/rules.d/99-crazyradio.rules'
sh -c 'echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"1915\", ATTRS{idProduct}==\"0101\", MODE=\"0664\", GROUP=\"plugdev\" >> /etc/udev/rules.d/99-crazyradio.rules'
sh -c 'echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"0483\", ATTRS{idProduct}==\"5740\", MODE=\"0664\", GROUP=\"plugdev\" >> /etc/udev/rules.d/99-crazyflie.rules'
# Add user to dialout group, to give access to serial ports
usermod -a -G dialout nokov
# Add user to docker group
usermod -a -G docker nokov
# Clone the git repos
mkdir ~/projects
cd ~/projects
git clone https://github.com/bitcraze/crazyflie-clients-python.git
git clone https://github.com/bitcraze/crazyflie-lib-python.git
git clone https://github.com/bitcraze/crazyflie-firmware.git --recursive
git clone https://github.com/bitcraze/crazyflie-bootloader.git
git clone https://github.com/bitcraze/crazyradio-firmware.git
git clone https://github.com/bitcraze/crazyflie-android-client.git
git clone https://github.com/bitcraze/crazyflie2-exp-template-electronics.git
git clone https://github.com/bitcraze/crazyflie2-stm-bootloader.git
git clone https://github.com/bitcraze/crazyflie2-nrf-bootloader.git
git clone https://github.com/bitcraze/crazyflie2-nrf-firmware.git
git clone https://github.com/bitcraze/lps-node-firmware.git --recursive
git clone https://github.com/USC-ACTLab/crazyswarm.git --recursive
echo "source ~/projects/crazyswarm/ros_ws/devel/setup.bash" >> ~/.bashrc
cd crazyswarm/ros_ws/src/crazyswarm/externalDependencies/
git switch main
cd ~/
chown nokov:nokov -R projects
ln -s ~/projects ~/Desktop/projects
# Install VSCode
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
apt install apt-transport-https
apt update
apt install code # or code-insiders
# Install VSCode extensions
sudo -H -u nokov code --install-exteman nsion ms-python.python
sudo -H -u nokov code --install-extension ms-python.vscode-pylance
sudo -H -u nokov code --install-extension ms-vscode.cpptools
sudo -H -u nokov code --install-extension seanwu.vscode-qt-for-python
sudo -H -u nokov code --install-extension marus25.cortex-debug
# Setup update_all_projects script
chmod +x ~/update_all_projects.sh
#mv ~/update_all_projects.sh ~/bin/update_all_projects.sh
# Set background image
#DISPLAY=:0 xfconf-query --channel xfce4-desktop --list
#DISPLAY=:0 xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set ~/Pictures/vm_background.jpg
#DISPLAY=:0 xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/workspace0/last-image --set ~/Pictures/vm_background.jpg
#HACK
cp /usr/share/xfce4/backdrops/xubuntu-wallpaper.png /usr/share/xfce4/backdrops/xubuntu-wallpaper-old.png
cp ~/Pictures/vm_background.png /usr/share/xfce4/backdrops/xubuntu-wallpaper.png
# Add user to vboxsf group so shares with host can be used
usermod -a -G vboxsf nokov
# Replace pip source
sudo -H -u nokov bash -c 'python3 -m pip install --upgrade pip'
sudo -H -u nokov bash -c 'pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple'
# Set up crazyflie-clients-python to use crazyflie-lib-python from source
sudo -H -u nokov bash -c 'pip3 install --user -e ~/projects/crazyflie-lib-python'
sudo -H -u nokov bash -c 'pip3 install --user -e ~/projects/crazyflie-clients-python'
# Disable screen saver (workaround)
mv /etc/xdg/autostart/light-locker.desktop /etc/xdg/autostart/light-locker.desktop.old
# Clean up VM
apt-get -y autoremove
apt-get -y autoclean
apt-get -y clean
fstrim -v /