forked from nasa/astrobee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_to_astrobee.sh
executable file
·130 lines (115 loc) · 3.92 KB
/
install_to_astrobee.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
#!/bin/bash
#
# Copyright (c) 2017, United States Government, as represented by the
# Administrator of the National Aeronautics and Space Administration.
#
# All rights reserved.
#
# The Astrobee platform is 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.
#
# usage: install_to_astrobee armhf_dir [ config_version=p4 ]
shopt -s extglob
# Check to see if there are arguments
if [ $# -lt 2 ]; then
echo "Please supply the armhf folder and target robot as arguments."
echo " e.g ./install_to_astrobee.sh ~/freeflyer_armhf_install p4d"
exit 1
fi
source $(dirname "$0")/deploy/constants.sh
# find which robot is available (or if the specified one is available, if any specified
robot_index=-1
for i in "${!robot_names[@]}"
do
if [ $# -gt 1 ] && [ $2 != ${robot_names[$i]} ]; then
continue;
fi
robot_index=$i
break;
done
if [ $robot_index -lt 0 ]; then
echo "No robot online."
exit 1
fi
echo "Installing to ${robot_names[$robot_index]}..."
# Remove accidental trailing slashes
self_path=$(dirname "$0")
target=${1%/}
dirname=$(basename ${target})
master_ip=${llp_ips[${robot_index}]}
config_ver=${2:-p4}
# Customize option for mlp and llp IP's
usage()
{
echo "usage: sysinfo_page [[[-mlp mlp_ip ] [-llp llp_ip]] | [-h]]"
}
while [ "$3" != "" ]; do
case $3 in
--mlp ) shift
mlp_ip=$3
;;
--llp ) shift
llp_ip=$3
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
# Some sanity check for the keyboard impaired...
libfile=$target/lib/libexecutive.so
if [ ! -f "$libfile" ]; then
echo "Specified directory does not contain ARS software ready to install!"
exit 1
fi
if ! readelf -A "$libfile" | grep -q "v7"; then
echo "Specified directory built for wrong target architecture (not armhf)!"
exit 1
fi
if [ -z ${FREEFLYER_MASTER} ]; then
# See if we have an IP on the Astrobee network
ip_addr=$(ip -4 addr show | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep '${subnet}')
if [ -n "$ip_addr" ]; then
master_ip=$ip_addr
fi
fi
FREEFLYER_TARGETS=${FREEFLYER_TARGETS=llp mlp}
FREEFLYER_MASTER=${FREEFLYER_MASTER:=http://${master_ip}:11311/}
FREEFLYER_LLP_FIXES=${FREEFLYER_LLP_FIXES=rpath}
FREEFLYER_INSTALL_DIR=/opt/astrobee
if [[ ${FREEFLYER_TARGETS,,} =~ 'mlp' ]]; then
echo "Copying files to MLP..."
if ! rsync -azh --delete --info=progress2 --exclude=/platform --exclude=/firmware --exclude=/avionics --exclude '*imu_bias.config' --exclude=/ops $target/ astrobee@${mlp_ip:-${mlp_ips[${robot_index}]}}:${FREEFLYER_INSTALL_DIR}
then
exit 1
fi
fi
if [[ ${FREEFLYER_TARGETS,,} =~ 'llp' ]]; then
# Install to LLP
if [[ "${llp_ips[${robot_index}]}" != "0.0.0.0" ]]; then # for dock, skip this step
echo "Copying files to LLP..."
if ! rsync -azh --delete --info=progress2 --exclude=/platform --exclude=/avionics --exclude '*imu_bias.config' --exclude=/ops $target/ astrobee@${llp_ip:-${llp_ips[${robot_index}]}}:${FREEFLYER_INSTALL_DIR}
then
exit 1
fi
fi
fi
if [ -n "$ip_addr" ]; then
echo '*** NOTE ***'
echo 'Be sure to export the following before running anything from this machine: '
echo " export ROS_MASTER_URI=${FREEFLYER_MASTER}"
echo " export ROS_HOSTNAME=${ip_addr}"
echo " export ROS_SSH_UNKNOWN=1"
fi