forked from zkytony/robotdev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_movo.bash
122 lines (109 loc) · 3.77 KB
/
setup_movo.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
# Path to MOVO workspace, relative to repository root;
# No begin or trailing slash.
MOVO_PATH="movo"
#------------- FUNCTIONS ----------------
function install_libfreenect2
{
# follow instructions here: https://github.com/OpenKinect/libfreenect2#linux
if [ ! -d "thirdparty/libfreenect2/" ]; then
cd thirdparty
git clone https://github.com/OpenKinect/libfreenect2.git
cd ..
fi
cd thirdparty/libfreenect2
if [ -d "build" ]; then
if confirm "libfreenect2 build exists. Rebuild?"; then
rm -rf build
else
cd $repo_root
return
fi
fi
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libusb-1.0-0-dev
if ubuntu_version_equal 16.04; then
sudo apt-get install libturbojpeg libjpeg-turbo8-dev
elif ubuntu_version_equal 20.04; then
sudo apt-get install libturbojpeg0-dev
fi
sudo apt-get install libglfw3-dev
mkdir build && cd build
# Note: You need to specify cmake
# -Dfreenect2_DIR=$HOME/freenect2/lib/cmake/freenect2 for CMake based
# third-party application to find libfreenect2.
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
make
make install
cd $repo_root
}
function setup_movo_remote_pc
{
echo -e "Adding route to movo's internal network. Requires sudo rights"
sudo route add -net ${MOVO_INTERNAL_NETWORK}\
netmask 255.255.255.0\
gw ${MOVO2_IP}\
dev $(get_rlab_interface)
export ROS_MASTER_URI="http://movo2:11311"
export ROS_IP="$(get_rlab_ip)"
echo -e "You computer has been configured. Now do:"
echo -e "- ssh movo@movo2"
echo -e "- ssh into movo1 from movo2 (run ssh movo1)"
echo -e "- sudo ifconfig wlan0 down in movo1"
echo -e "- go back to movo2, run:"
echo -e " roslaunch movo_bringup movo_system.launch"
cd $repo_root
}
#------------- Main Logic ----------------
# Run this script by source setup_movo.bash
if [[ ! $PWD = *robotdev ]]; then
echo "You must be in the root directory of the robotdev repository."
else
. "./tools.sh"
fi
repo_root=$PWD
MOVO2_IP="138.16.161.17"
MOVO_INTERNAL_NETWORK="10.66.171.0"
if first_time_build movo; then
if ubuntu_version_equal 16.04; then
pip install netifaces
pip install pathlib
pip install pyyaml==3.11
install_libfreenect2
build_ros_ws $MOVO_PATH
fi
fi
if ubuntu_version_equal 16.04; then
useros
export ROS_PACKAGE_PATH=$repo_root/${MOVO_PATH}/src/:${ROS_PACKAGE_PATH}
source $repo_root/${MOVO_PATH}/devel/setup.bash
fi
# Even though MOVO is for Ubuntu 16.04, we may want
# to use it from a computer that runs ROS Noetic
# because we may have code in Python 3. The workspace
# that contains packages we want to use under 20.04
# are at '$MOVO_PATH/noetic_ws'
if ubuntu_version_equal 20.04; then
if ! command -v ip &> /dev/null
then
echo "ip could not be found; installing..."
sudo apt install iproute2
pip install netifaces
sudo apt-get install -y python3-pykdl
sudo apt-get install ros-noetic-moveit-msgs
fi
if [ ! -d "${MOVO_PATH}/venv/movo" ]; then
cd ${MOVO_PATH}/
virtualenv -p python3 venv/movo
cd ..
fi
source $repo_root/${MOVO_PATH}/venv/movo/bin/activate
useros
export ROS_PACKAGE_PATH=$repo_root/${MOVO_PATH}/noetic_ws/src/:$repo_root/${MOVO_PATH}/src/:${ROS_PACKAGE_PATH}
source $repo_root/${MOVO_PATH}/noetic_ws/devel/setup.bash
export PYTHONPATH="$repo_root/${MOVO_PATH}/venv/movo/lib/python3.8/site-packages:${PYTHONPATH}:/usr/lib/python3/dist-packages"
fi
if confirm "Are you working on the real robot (i.e. setup ROS_MASTER_URI, packet forwarding etc) ?"; then
echo -e "OK"
setup_movo_remote_pc
fi
cd $repo_root/$MOVO_PATH