-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-workspace.sh
executable file
·124 lines (104 loc) · 3.48 KB
/
build-workspace.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
#!/bin/bash
BIRed='\033[1;91m' # Red
BIGreen='\033[1;92m' # Green
BIBlue='\033[1;94m' # Blue
BICyan='\033[1;96m' # Cyan
BIWhite='\033[1;97m' # White
Off='\033[0m' # Text Reset
echo -e "${BIBlue}This script will build the catkin workspace for hera_robot.${Off}"
# Check if script is running with sudo
if [ "$EUID" -ne 0 ]
then echo -e "${BIRed}Please run this script with sudo!!${Off}"
exit
fi
# Set the user's home directory
HOME_DIR=/home/"$SUDO_USER"
# Check if ROS Noetic is installed
if ! dpkg -s ros-noetic-desktop-full > /dev/null 2>&1; then
echo -e "${BIRed}ROS Noetic is not installed. Please install it before running this script!!${Off}"
exit
fi
# Check if bash or zsh is being used
if [ -n "$BASH_VERSION" ]; then
SHELL="bash"
elif [ -n "$ZSH_VERSION" ]; then
SHELL="zsh"
else
echo -e "${BIRed}This script only supports bash and zsh.${Off}"
exit
fi
# Source ROS
source /opt/ros/noetic/setup."$SHELL"
# Prompt user to enter GitHub personal access token
echo ""
echo -e "${BIBlue}Please enter your GitHub personal access token:${Off}"
# shellcheck disable=SC2162
read -s TOKEN
# Create the catkin workspace
echo ""
echo -e "${BICyan}Creating catkin workspace...${Off}"
sudo -u "$SUDO_USER" mkdir -p $HOME_DIR/catkin_ws/src && cd $HOME_DIR/catkin_ws || exit 1
catkin_make
# Source the workspace
source devel/setup."$SHELL"
# Clone the repositories from hera_robot
cd $HOME_DIR/catkin_ws/src || exit 1
sudo -u "$SUDO_USER" mkdir -p hera_robot && cd hera_robot || exit 1
# List of repositories to clone
REPOS=(
"robofeiathome/hera"
"robofeiathome/hera_control"
"robofeiathome/hera_description"
"robofeiathome/hera_tasks"
"robofeiathome/hera_telegram"
"robofeiathome/hera_moveit_config"
"robofeiathome/hera_scripts"
)
# Clone the repositories
echo -e "${BIWhite}Cloning hera_robot repositories...${Off}"
for REPO in "${REPOS[@]}"; do
git clone "https://$TOKEN:[email protected]/$REPO.git"
done
# Clone 3rd party repositories
echo -e "${BIWhite}Cloning 3rd party repositories...${Off}"
cd $HOME_DIR/catkin_ws/src || exit 1
sudo -u "$SUDO_USER" mkdir -p 3rd_party && cd 3rd_party || exit 1
# List of repositories to clone
REPOS=(
"robofeiathome/hera_agent"
"robofeiathome/robot_resources"
"ros-drivers/hokuyo_node"
"fagnerpimentel/map_server"
"fagnerpimentel/social_move_base"
"fagnerpimentel/social_msgs"
"robofei-home/speech_recognition"
"robofei-home/vision_system"
)
# Clone the repositories
echo -e "${BIWhite}Cloning 3rd party repositories...${Off}"
for REPO in "${REPOS[@]}"; do
git clone "https://$TOKEN:[email protected]/$REPO.git"
done
# Get the dependencies from hera/dependencies.txt
echo -e "${BICyan}Getting dependencies...${Off}"
DEPENDENCIES=()
while IFS= read -r LINE; do
DEPENDENCIES+=("$LINE")
done < $HOME_DIR/catkin_ws/src/hera_robot/hera_scripts/dependencies.txt
# Install dependencies
echo -e "${BIBlue}Installing dependencies...${Off}"
for DEPENDENCY in "${DEPENDENCIES[@]}"; do
apt-get install -y "$DEPENDENCY"
done
# Get the python dependencies from hera/requirements.txt
echo -e "${BICyan}Getting python dependencies...${Off}"
PYTHON_DEPENDENCIES=()
while IFS= read -r LINE; do
PYTHON_DEPENDENCIES+=("$LINE")
done < $HOME_DIR/catkin_ws/src/hera_robot/hera_scripts/requirements.txt
# Install python dependencies
echo -e "${BIBlue}Installing python dependencies...${Off}"
for PYTHON_DEPENDENCY in "${PYTHON_DEPENDENCIES[@]}"; do
pip3 install "$PYTHON_DEPENDENCY"
done
echo -e "${BIGreen}Done!${Off}"