forked from ldrobotSensorTeam/sdk_ld06_raspberry_ros
-
Notifications
You must be signed in to change notification settings - Fork 3
/
lidar_ros_setup.sh
executable file
·143 lines (119 loc) · 4.56 KB
/
lidar_ros_setup.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
#!/bin/bash
# Exit on error
set -e
set -x
if grep -q Raspberry /proc/cpuinfo; then
echo "Running on a Raspberry Pi"
else
echo "Not running on a Raspberry Pi. Use at your own risk!"
fi
echo "Update sources list"
# Chinese users, please uncomment the following 3 lines:
#ARCHIVE_SOURCE='deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui'
#sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.orig
#echo "$ARCHIVE_SOURCE" | sudo tee /etc/apt/sources.list.d/raspi.list > /dev/null
# If you are a user outside China please uncomment one of the following SOURCE lines:
# Install any source from the following URL: https://www.raspbian.org/RaspbianMirrors
# Example:
# [1]
#SOURCE='deb http://mirror.nus.edu.sg/raspbian/raspbian/ buster main contrib non-free rpi'
# [2]
#SOURCE='deb http://ftp.jaist.ac.jp/raspbian/ buster main contrib non-free rpi'
# [3]
SOURCE='deb http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian/ buster main contrib non-free rpi'
# [4]
#SOURCE='deb http://mirrors.ocf.berkeley.edu/raspbian/raspbian/ buster main contrib non-free rpi'
# [5]
#SOURCE='deb http://reflection.oss.ou.edu/raspbian/raspbian/ buster main contrib non-free rpi'
# [6]
#SOURCE='deb http://mirror.liquidtelecom.com/raspbian/raspbian/ buster main contrib non-free rpi'
# [7]
#SOURCE='deb http://mirrordirector.raspbian.org/raspbian/ buster main contrib non-free rpi'
# [8]
#SOURCE='deb https://archive.raspbian.org/raspbian/ buster main contrib non-free rpi'
# [9]
#SOURCE='deb https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi'
# [10]
#SOURCE='deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi'
# [11]
#SOURCE='deb http://ftp.cse.yzu.edu.tw/Linux/raspbian/raspbian/ buster main contrib non-free rpi'
# Chinese users, please uncomment the following source:
#SOURCE='deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi'
sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
echo "$SOURCE" | sudo tee /etc/apt/sources.list > /dev/null
echo "STEP1: Install Dependencies and Download ROS source packages"
# Where will the output go?
WORK_DIR="/home/pi/ros_catkin_ws"
BUILD_DEPS="build-essential cmake"
PYTHON_DEPS="python-rosdep python-rosinstall-generator python-wstool python-rosinstall"
echo "Adding ros repo https://www.ros.org/"
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install -y $BUILD_DEPS $PYTHON_DEPS
pwd
echo "Press space bar to continue"
read -r -s -d ' '
echo "STEP2: Initialising ROS"
if [ ! -f /etc/ros/rosdep/sources.list.d/20-default.list ]; then
sudo rosdep init
fi
rosdep update
pwd
echo "Press space bar to continue"
read -r -s -d ' '
echo "STEP3: Install Melodic Desktop"
if [ ! -d "$WORK_DIR" ]; then
mkdir "$WORK_DIR"
fi
cd $WORK_DIR
rosinstall_generator desktop --rosdistro melodic --deps --wet-only --tar > melodic-desktop-wet.rosinstall
if [ ! -d "$WORK_DIR"/src ]; then
wstool init -j8 src melodic-desktop-wet.rosinstall
else
#echo "If wstool init fails or is interrupted, you can resume the download by running:"
wstool update -j4 -t src
fi
pwd
echo "Press space bar to continue"
read -r -s -d ' '
echo "STEP4: Fix the Issues"
# Install compatible version of Assimp (Open Asset Import Library) to fix collada_urdf dependency problem.
if [ ! -d "$WORK_DIR"/external_src ]; then
mkdir "$WORK_DIR"/external_src
fi
cd "$WORK_DIR/external_src"
wget https://github.com/assimp/assimp/archive/refs/tags/v5.0.1.zip
unzip -o v5.0.1.zip
cd assimp-5.0.1
cmake .
make
sudo make install
pwd
echo "Press space bar to continue"
read -r -s -d ' '
echo "Install OGRE for rviz"
sudo apt install -y libogre-1.9-dev
pwd
echo "Press space bar to continue"
read -r -s -d ' '
cd $WORK_DIR
echo "Install other deps using rosdep"
rosdep install -y --from-paths src --ignore-src --rosdistro melodic -r --os=debian:buster
pwd
echo "Press space bar to continue"
read -r -s -d ' '
echo "STEP5: Build and Source the Installation"
cd $WORK_DIR
sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/melodic -j2
pwd
echo "Press space bar to continue"
read -r -s -d ' '
echo "Update bashrc"
if ! grep -xq 'source /opt/ros/melodic/setup.bash' ~/.bashrc; then
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
fi
# *************************
# End of ROS build
# reboot and test with:
# roscore