-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall_from_source.sh
executable file
·116 lines (94 loc) · 4.45 KB
/
install_from_source.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
#!/bin/bash
#######################
BASEDIR=$PWD
if [ "$#" -eq 0 ]; then
echo "Please input a valid .repos file path"
exit 1;
fi
if [ ! -f "$1" ] || [[ "$1" != *.repos ]]; then
echo "$1 is not a valid file"
exit 1
fi
if [ "$#" -eq 2 ]; then
if [ ! -d "$2" ]; then
echo "$2 is not a directory"
exit 1
else
echo "Installation set to $2/workspace/ros/aerostack_catkin_ws"
if [ "$AEROSTACK_WORKSPACE" != "$2"/workspace/ros/aerostack_catkin_ws ] && [ -d "$AEROSTACK_WORKSPACE"/src ] && [[ -f "$AEROSTACK_WORKSPACE"/.catkin_workspace ]]; then
echo "Different Aerostack workspace already installed in $AEROSTACK_WORKSPACE/workspace/ros/aerostack_catkin_ws, please remove it or change installation folder"
exit 1
fi
fi
else
echo "Installation set to $HOME/workspace/ros/aerostack_catkin_ws"
if [ "$AEROSTACK_WORKSPACE" != "$HOME"/workspace/ros/aerostack_catkin_ws ] && [ -d "$AEROSTACK_WORKSPACE"/src ] && [[ -f "$AEROSTACK_WORKSPACE"/.catkin_workspace ]]; then
echo "Different Aerostack workspace already installed in $AEROSTACK_WORKSPACE/workspace/ros/aerostack_catkin_ws, please remove it or change installation folder"
exit 1
fi
fi
if ! command -v vcs &> /dev/null; then
echo "vcs could not be found"
echo "installing vcs_tool..."
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://pool.sks-keyservers.net --recv-key 0xAB17C654
sudo apt-get update
sudo apt-get install python3-vcstool
else
echo "vcs installed"
fi
# Absolute path of the aerostack workspace
if [ "$#" -eq 2 ]; then
AEROSTACK_WORKSPACE="$2/workspace/ros/aerostack_catkin_ws"
else
AEROSTACK_WORKSPACE="$HOME/workspace/ros/aerostack_catkin_ws"
fi
AEROSTACK_STACK="$AEROSTACK_WORKSPACE/src"
export AEROSTACK_WORKSPACE=$AEROSTACK_WORKSPACE
export AEROSTACK_STACK=$AEROSTACK_STACK
ROS_DISTRO="noetic"
export ROS_DISTRO=$ROS_DISTRO
echo "------------------------------------------------------"
echo "Obtaining aerostack git info and root source code"
echo "------------------------------------------------------"
mkdir -p $AEROSTACK_WORKSPACE
mkdir -p $AEROSTACK_STACK
cd $AEROSTACK_WORKSPACE/src
vcs import --recursive < "$1"
echo "-------------------------------------------------------"
echo "Setting environment variables"
echo "-------------------------------------------------------"
grep -q "source $AEROSTACK_WORKSPACE/devel/setup.bash" $HOME/.bashrc || echo "source $AEROSTACK_WORKSPACE/devel/setup.bash" >> $HOME/.bashrc
sed -i '/export AEROSTACK_STACK/d' $HOME/.bashrc && echo "export AEROSTACK_STACK=$AEROSTACK_WORKSPACE/src/aerostack_stack" >> $HOME/.bashrc
sed -i '/export AEROSTACK_WORKSPACE/d' $HOME/.bashrc && echo "export AEROSTACK_WORKSPACE=$AEROSTACK_WORKSPACE" >> $HOME/.bashrc
sed -i '/export LD_LIBRARY_PATH/d' $HOME/.bashrc && echo "export LD_LIBRARY_PATH=$AEROSTACK_WORKSPACE/devel/lib:/opt/ros/$ROS_DISTRO/lib:$AEROSTACK_WORKSPACE/devel/lib/parrot_arsdk" >> $HOME/.bashrc
echo "-------------------------------------------------------"
echo "Installing dependencies"
echo "-------------------------------------------------------"
. "$BASEDIR"/install_dependencies.sh
echo "------------------------------------------------------"
echo "Creating the ROS Workspace"
echo "------------------------------------------------------"
source /opt/ros/$ROS_DISTRO/setup.bash
cd $AEROSTACK_WORKSPACE/src
catkin_init_workspace
cd $AEROSTACK_WORKSPACE
catkin_make
echo "-------------------------------------------------------"
echo "Sourcing the ROS Aerostack WS"
echo "-------------------------------------------------------"
. ${AEROSTACK_WORKSPACE}/devel/setup.bash
echo "-------------------------------------------------------"
echo "Fixing CMakeLists.txt to be able to open QTCreator"
echo "-------------------------------------------------------"
cd $AEROSTACK_WORKSPACE/src
rm CMakeLists.txt
cp /opt/ros/$ROS_DISTRO/share/catkin/cmake/toplevel.cmake CMakeLists.txt
echo "-------------------------------------------------------"
echo "Compiling the Aerostack"
echo "-------------------------------------------------------"
cd ${AEROSTACK_WORKSPACE}
[ ! -f "$AEROSTACK_STACK/behaviors/behavior_packages/multi_sensor_fusion" ] && touch "$AEROSTACK_STACK/behaviors/behavior_packages/multi_sensor_fusion/CATKIN_IGNORE"
catkin_make
[ -f "$AEROSTACK_STACK/behaviors/behavior_packages/multi_sensor_fusion/CATKIN_IGNORE" ] && rm "$AEROSTACK_STACK/behaviors/behavior_packages/multi_sensor_fusion/CATKIN_IGNORE"
catkin_make -j1