forked from linorobot/linorobot2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_linorobot2.bash
366 lines (315 loc) · 11.1 KB
/
install_linorobot2.bash
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#!/usr/bin/env bash
# Copyright (c) 2021 Juan Miguel Jimeno
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
ROSDISTRO="$(printenv ROS_DISTRO)"
BASE=$1
LASER_SENSOR=$2
DEPTH_SENSOR=$3
ARCH="$(uname -m)"
WORKSPACE="$HOME/linorobot2_ws"
ROBOT_TYPE_ARRAY=(2wd 4wd mecanum)
DEPTH_SENSOR_ARRAY=(realsense zed zedm zed2 zed2i oakd oakdlite oakdpro)
LASER_SENSOR_ARRAY=(ydlidar xv11 ld06 ld19 stl27l a1 a2 a3 c1 s1 s2 s3)
LASER_SENSOR_ARRAY+=(${DEPTH_SENSOR_ARRAY[@]})
if [ -z "$LASER_SENSOR" ]
then
LASER_SENSOR=""
fi
if [ -z "$DEPTH_SENSOR" ]
then
DEPTH_SENSOR=""
fi
function install_cuda_jetson {
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/sbsa/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget http://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_arm64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_arm64.deb
sudo apt-key add /var/cuda-repo-ubuntu2004-11-4-local/7fa2af80.pub #verify this
sudo apt-get update
sudo apt-get -y install cuda
# Errors were encountered while processing:
# /tmp/apt-dpkg-install-TvUCLd/14-libnvidia-compute-470_470.57.02-0ubuntu1_arm64.deb
# /tmp/apt-dpkg-install-TvUCLd/18-libnvidia-gl-470_470.57.02-0ubuntu1_arm64.deb
# E: Sub-process /usr/bin/dpkg returned an error code (1)
}
function install_xv11 {
cd $WORKSPACE
git clone https://github.com/mjstn/xv_11_driver src/xv_11_driver
colcon build
source $WORKSPACE/install/setup.bash
}
function install_ydlidar {
cd /tmp
git clone https://github.com/YDLIDAR/YDLidar-SDK.git
mkdir YDLidar-SDK/build
cd YDLidar-SDK/build
cmake ..
make
sudo make install
cd $WORKSPACE
git clone https://github.com/YDLIDAR/ydlidar_ros2_driver src/ydlidar_ros2_driver
chmod 0777 src/ydlidar_ros2_driver/startup/*
sudo echo 'KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE:="0666", GROUP:="dialout", SYMLINK+="ydlidar"' >/etc/udev/rules.d/ydlidar.rules
sudo echo 'KERNEL=="ttyACM*", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", MODE:="0666", GROUP:="dialout", SYMLINK+="ydlidar"' >/etc/udev/rules.d/ydlidar-V2.rules
sudo echo 'KERNEL=="ttyUSB*", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", MODE:="0666", GROUP:="dialout", SYMLINK+="ydlidar"' >/etc/udev/rules.d/ydlidar-2303.rules
colcon build --symlink-install
source $WORKSPACE/install/setup.bash
}
function install_ldlidar_stl_ros2 {
cd $WORKSPACE
git clone https://github.com/hippo5329/ldlidar_stl_ros2.git src/ldlidar_stl_ros2
colcon build
source $WORKSPACE/install/setup.bash
cd /tmp
wget https://raw.githubusercontent.com/linorobot/ldlidar/ros2/ldlidar.rules
sudo cp ldlidar.rules /etc/udev/rules.d
}
function install_ld06 {
install_ldlidar_stl_ros2
}
function install_ld19 {
install_ldlidar_stl_ros2
}
function install_stl27l {
install_ldlidar_stl_ros2
}
function install_sllidar_ros2 {
cd $WORKSPACE
git clone https://github.com/Slamtec/sllidar_ros2.git
colcon build
source $WORKSPACE/install/setup.bash
sudo cp sllidar_ros2/scripts/rplidar.rules /etc/udev/rules.d
}
function install_a1 {
install_sllidar_ros2
}
function install_a2 {
install_sllidar_ros2
}
function install_a3 {
install_sllidar_ros2
}
function install_c1 {
install_sllidar_ros2
}
function install_s1 {
install_sllidar_ros2
}
function install_s2 {
install_sllidar_ros2
}
function install_s3 {
install_sllidar_ros2
}
function install_realsense {
sudo apt install -y ros-$ROS_DISTRO-realsense2-camera
cd /tmp
wget https://raw.githubusercontent.com/IntelRealSense/librealsense/master/config/99-realsense-libusb.rules
sudo cp 99-realsense-libusb.rules /etc/udev/rules.d
}
function install_astra {
cd $WORKSPACE
sudo apt install -y libuvc-dev libopenni2-dev
git clone https://github.com/linorobot/ros_astra_camera src/ros_astra_camera
sudo cp src/ros_astra_camera/56-orbbec-usb.rules /etc/udev/rules.d/
colcon build
source $WORKSPACE/install/setup.bash
}
function install_zed {
cd /tmp
if [[ -f /etc/nv_tegra_release ]]
then
#TODO ADD CUDA INSTALLATION HERE
wget https://download.stereolabs.com/zedsdk/3.5/jp45/jetsons -O zed_sdk
elif lspci | grep VGA | grep -o NVIDIA
then
wget https://download.stereolabs.com/zedsdk/3.5/cu111/ubuntu20 -O zed_sdk
else
echo "Linux Machine not supported by Zed Camera"
exit 1
fi
chmod +x zed_sdk
./zed_sdk -- silent
cd $WORKSPACE
git clone https://github.com/stereolabs/zed-ros2-wrapper src/zed-ros2-wrapper
git clone https://github.com/ros-perception/image_common -b $ROS_DISTRO src/image_common #https://github.com/stereolabs/zed-ros2-wrapper#image-transport-and-topic-subscriptions
rosdep install --from-paths src --ignore-src -r -y
colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release
# colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release --cmake-args=-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.4
source $WORKSPACE/install/setup.bash
source ~/.bashrc
}
function install_zedm {
install_zed
}
function install_zed2 {
install_zed
}
function install_zed2i {
install_zed
}
function install_oakd {
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | sudo tee /etc/udev/rules.d/80-movidius.rules
sudo udevadm control --reload-rules && sudo udevadm trigger
sudo apt install ros-$ROS_DISTRO-depthai-ros
}
function install_oakdlite {
install_oakd
}
function install_oakdpro {
install_oakd
}
if [[ "$ROSDISTRO" == "" || "$ROSDISTRO" == "<unknown>" ]]
then
echo "No ROS2 distro detected"
echo "Try running $ source /opt/ros/<ros_distro>/setup.bash and try again."
exit 1
fi
if [ "$*" == "" ]
then
echo "No arguments provided"
echo
echo "Example: $ bash install_linorobot2.bash 2wd a1"
echo "Example: $ bash install_linorobot2.bash 2wd a1 realsense"
echo "Example: $ bash install_linorobot2.bash 2wd - realsense"
echo "Example: $ bash install_linorobot2.bash 2wd"
echo
exit 1
fi
if [[ "$BASE" != "ci" ]] && !(printf '%s\n' "${ROBOT_TYPE_ARRAY[@]}" | grep -xq $BASE)
then
echo "Invalid linorobot base: $1"
echo
echo "Valid Options:"
for key in "${!ROBOT_TYPE_ARRAY[@]}"; do echo "${ROBOT_TYPE_ARRAY[$key]}"; done
echo
exit 1
fi
if [[ "$BASE" != "ci" && "$LASER_SENSOR" != "" && "$LASER_SENSOR" != "-" ]] && !(printf '%s\n' "${LASER_SENSOR_ARRAY[@]}" | grep -xq $LASER_SENSOR)
then
echo "Invalid linorobot2 laser sensor: $LASER_SENSOR"
echo
echo "Valid Options:"
for key in "${!LASER_SENSOR_ARRAY[@]}"; do echo "${LASER_SENSOR_ARRAY[$key]}"; done
echo
exit 1
fi
if [[ "$BASE" != "ci" && "$DEPTH_SENSOR" != "" ]] && !(printf '%s\n' "${DEPTH_SENSOR_ARRAY[@]}" | grep -xq $DEPTH_SENSOR)
then
echo "Invalid linorobot2 depth sensor: $DEPTH_SENSOR"
echo
echo "Valid Options:"
for key in "${!DEPTH_SENSOR_ARRAY[@]}"; do echo "${DEPTH_SENSOR_ARRAY[$key]}"; done
echo
exit 1
fi
if [[ "$BASE" != "ci" ]]
then
echo
echo "You are installing linorobot2 on your robot computer."
echo
echo "===========SUMMARY============"
echo "ROBOT TYPE : $BASE"
echo "LASER SENSOR : $LASER_SENSOR"
echo "DEPTH SENSOR : $DEPTH_SENSOR"
echo
echo "This installer will edit your ~/.bashrc."
echo "Create a linorobot2_ws on your $HOME directory."
echo "Install linorobot2 ROS2 dependencies."
echo "Install udev rules on /etc/udev/rules.d folder."
echo -n "Enter [y] to continue. "
read reply
if [[ "$reply" != "y" && "$reply" != "Y" ]]
then
echo "Exiting now."
exit 1
fi
fi
echo
echo "INSTALLING NOW...."
echo
#### 1.1 Source your ROS2 distro and workspace
cd $HOME
mkdir -p $WORKSPACE/src
source /opt/ros/$ROS_DISTRO/setup.bash
cd $WORKSPACE
colcon build
source $WORKSPACE/install/setup.bash
#### 1.2/1.3 Install LIDAR/Depth Sensor ROS2 drivers:
if (printf '%s\n' "${LASER_SENSOR_ARRAY[@]}" | grep -xq $LASER_SENSOR)
then
install_$LASER_SENSOR
fi
if (printf '%s\n' "${DEPTH_SENSOR_ARRAY[@]}" | grep -xq $DEPTH_SENSOR)
then
install_$DEPTH_SENSOR
fi
if [[ "$BASE" == "ci" ]]
then
for key in "${!LASER_SENSOR_ARRAY[@]}"; do install_${LASER_SENSOR_ARRAY[$key]}; done
fi
#### 1.4 Download and install micro-ROS:
cd $WORKSPACE
git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup
sudo apt install -y python3-vcstool build-essential
sudo apt update && rosdep update
rosdep install --from-path src --ignore-src -y
colcon build
source $WORKSPACE/install/setup.bash
#### 1.5 Setup micro-ROS agent:
ros2 run micro_ros_setup create_agent_ws.sh
ros2 run micro_ros_setup build_agent.sh
source $WORKSPACE/install/setup.bash
#### 2.1 Download linorobot2:
cd $WORKSPACE
git clone -b $ROS_DISTRO https://github.com/linorobot/linorobot2 src/linorobot2
#### 2.2 Ignore Gazebo Packages on robot computer (optional)
cd $WORKSPACE/src/linorobot2/linorobot2_gazebo
touch COLCON_IGNORE
#### 2.3 Install linorobot2 package:
cd $WORKSPACE
rosdep update && rosdep install --from-path src --ignore-src -y --skip-keys microxrcedds_agent
colcon build
source $WORKSPACE/install/setup.bash
## ENV Variables
if [[ "$BASE" != "ci" ]]
then
### 1. Robot Type
echo "export LINOROBOT2_BASE=$BASE" >> ~/.bashrc
### 2. Sensors
if [[ "$LASER_SENSOR" != "-" || "$LASER_SENSOR" != "" ]]
then
echo "export LINOROBOT2_LASER_SENSOR=$LASER_SENSOR" >> ~/.bashrc
fi
if [[ "$DEPTH_SENSOR" != "-" || "$DEPTH_SENSOR" != "" ]]
then
echo "export LINOROBOT2_DEPTH_SENSOR=$DEPTH_SENSOR" >> ~/.bashrc
fi
echo
echo "Do you want to add sourcing of linorobot2_ws on your ~/.bashrc?"
echo -n "Yes [y] or No [n]: "
read reply
if [[ "$reply" == "y" || "$reply" == "Y" ]]
then
echo "source \$HOME/linorobot2_ws/install/setup.bash" >> ~/.bashrc
else
echo
echo "Remember to run $ source ~/linorobot2_ws/install/setup.bash every time you open a terminal."
fi
fi
echo
echo "INSTALLATION DONE."
echo
echo "Restart your robot computer now."