Skip to content

Commit a04b4e4

Browse files
authored
Merge pull request #36 from BCLab-UNM/StartupScripts
Automated deployment and physical rover node startup.
2 parents 079d5de + 8b10d95 commit a04b4e4

File tree

2 files changed

+339
-1
lines changed

2 files changed

+339
-1
lines changed

.catkin_tools/profiles/default/packages/behaviours/package.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
<build_depend>std_msgs</build_depend>
1616
<build_depend>random_numbers</build_depend>
1717
<build_depend>tf</build_depend>
18-
18+
<build_depend>apriltags_ros</build_depend>
19+
1920
<run_depend>geometry_msgs</run_depend>
2021
<run_depend>roscpp</run_depend>
2122
<run_depend>sensor_msgs</run_depend>
2223
<run_depend>std_msgs</run_depend>
2324
<run_depend>random_numbers</run_depend>
2425
<run_depend>tf</run_depend>
26+
<run_depend>apriltags_ros</run_depend>
2527

2628
<export>
2729

misc/deploy.sh

Lines changed: 336 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,336 @@
1+
#!/bin/bash
2+
3+
OPTION=$1
4+
5+
roverpass=""
6+
roverIP=""
7+
8+
cd ..
9+
dirPath="$(pwd)"
10+
dirName="$(basename `pwd`)"
11+
12+
#Functions
13+
#--------------------------------------------------------------------------
14+
15+
Check()
16+
{
17+
18+
cd ~
19+
20+
if [ -z "$(ls -A $dirPath/src/ublox/)" ]; then
21+
echo "The ublox submodule is missing."
22+
exit 1
23+
fi
24+
25+
if [ -z "$(ls -A $dirPath/src/apriltags_ros/)" ]; then
26+
echo "The apriltags submodule is missing."
27+
exit 1
28+
fi
29+
}
30+
31+
PullGit_Pack()
32+
{
33+
gnome-terminal -x bash -c "cd $dirPath;
34+
echo 'Checking out branch $3';
35+
git checkout $2;
36+
sleep 2;
37+
echo 'Pulling latest build on branch $2';
38+
git pull;
39+
sleep 2;
40+
echo 'Compiling $dirName branch $2...';
41+
catkin build;
42+
sleep 2;
43+
cd -;
44+
echo 'Packing up the repository... ';
45+
tar czf $dirName.tgz $dirPath;
46+
exit 1;
47+
/bin/bash;' exec $SHELL"
48+
}
49+
50+
Pack()
51+
{
52+
gnome-terminal -x bash -c "cd $dirPath;
53+
echo 'Compiling $dirName';
54+
catkin build;
55+
sleep 2;
56+
cd ~;
57+
echo 'Packing up the repository... ';
58+
tar czf $dirName.tgz $dirName;
59+
sleep 2;
60+
exit 1;
61+
/bin/bash;' exec $SHELL"
62+
}
63+
64+
Transfer()
65+
{
66+
67+
echo "Copying compressed repository to swarmie at $roverIP"
68+
scp $dirName.tgz swarmie@$roverIP:~
69+
}
70+
71+
Unpack_Run()
72+
{
73+
echo "Unpacking repository $dirName on swarmie at $roverIP"
74+
75+
gnome-terminal -x bash -c "ssh -t swarmie@$roverIP 'echo 'Unpacking $dirName.tgz ...';
76+
tar xzf $dirName.tgz;
77+
sleep 2;
78+
echo 'Starting ROS nodes on swarmie at $roverIP with master at $hostName';
79+
sleep 2;
80+
cd $dirName/misc/;
81+
./rover_onboard_node_launch.sh $hostName;
82+
exit 1;
83+
/bin/bash;' exec $SHELL"
84+
85+
echo "Starting ROS nodes on swarmie at $3 with master at $hostName"
86+
echo ""
87+
}
88+
89+
Run()
90+
{
91+
92+
#ssh and run script from rover --WORKS
93+
gnome-terminal -x bash -c "ssh -t swarmie@$roverIP 'cd SwarmBaseCode-ROS/misc;
94+
./rover_onboard_node_launch.sh $hostName;
95+
exit 1;
96+
exit 1;
97+
/bin/bash;' exec $SHELL"
98+
}
99+
100+
DispOpt()
101+
{
102+
clear
103+
104+
echo "Your network info: $hostName@$userIP"
105+
echo ""
106+
echo "Type 'exit' to quit"
107+
108+
if [ "$OPTION" != "-G" ]; then
109+
echo "Type '-G' to pull, transfer, and run on swarmie(s) "
110+
fi
111+
112+
if [ "$OPTION" != "-L" ]; then
113+
echo "Type '-L' to transfer local code and run on swarmie(s)"
114+
fi
115+
116+
if [ "$OPTION" != "-R" ]; then
117+
echo "Type '-R' to run current code loaded on Swarmies"
118+
fi
119+
120+
echo "-------------------------------------------------------------"
121+
echo ""
122+
}
123+
124+
SuccessPing()
125+
{
126+
cd ~
127+
echo "Found $roverIP"
128+
echo "-------------------------------------------------------------"
129+
echo "Uploading to $roverIP"
130+
echo ""
131+
}
132+
133+
FailPing()
134+
{
135+
echo "$roverIP was not found on the network. Check IP and network settings!"
136+
echo "-------------------------------------------------------------"
137+
sleep 4
138+
echo ""
139+
}
140+
141+
#Code Start
142+
#-----------------------------------------------------------------
143+
144+
#find users current IP and store it
145+
userIP=$(ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}')
146+
hostName=$(hostname)
147+
148+
echo "$dirPath"
149+
echo "$dirName"
150+
151+
#No Connection
152+
#-------------------------------------------------------------
153+
if [ -z "$userIP" ]; then
154+
echo "No Current Internet Connection Found"
155+
echo "Cannot SSH into rover without IP Address!"
156+
exit 1
157+
fi
158+
159+
#No Command Given
160+
#-------------------------------------------------------------
161+
if [ -z $OPTION ]; then
162+
echo "-------------------------------------------------------------"
163+
echo "Please run this script with the following commands:"
164+
echo "'-G'[ithub] {branch} pulls and transfers workspace to swarmie(s)"
165+
echo "'-L'[ocal Files] duplicates current workspace and transfers to swarmie(s)"
166+
echo "'-R'[un] to run current code on all swarmie(s)"
167+
echo "-------------------------------------------------------------"
168+
exit 1
169+
fi
170+
171+
clear
172+
173+
#check OPTION given
174+
#------------------------------------------------------------
175+
176+
while(true); do
177+
178+
#GitHub Selection
179+
#------------------------------------------------------------
180+
if [ $OPTION == "-G" ]; then
181+
182+
branch=$2
183+
184+
#if not everything is filled out
185+
if [ "$branch"="" ]; then
186+
echo ""
187+
read -p "Branch?: " branch
188+
echo ""
189+
fi
190+
191+
#Tell User Option
192+
193+
echo "Retrieving and Transferring Code from GitHub: "
194+
195+
DispOpt
196+
197+
echo "dir: $dirPath branch: $branch"
198+
echo "-------------------------------------------------------------"
199+
echo ""
200+
201+
Check
202+
PullGit_Pack
203+
204+
while(true); do
205+
read -p "Rover Name/IP To Start: " roverIP
206+
if [ "$roverIP" = "exit" ]; then
207+
exit 1
208+
elif [ "$roverIP" = "-R" ]; then
209+
OPTION="-R"
210+
echo ""
211+
echo ""
212+
break
213+
elif [ "$roverIP" = "-L" ]; then
214+
OPTION="-L"
215+
echo ""
216+
echo ""
217+
break
218+
elif [ "$roverIP" = "branch" ]; then
219+
branch=""
220+
echo ""
221+
echo ""
222+
break
223+
fi
224+
225+
#If rover is on the network
226+
ping -q -w2 $roverIP > /dev/null
227+
if [ $? -eq 0 ]; then
228+
229+
SuccessPing
230+
231+
#Transfer/Unpack/Run
232+
Transfer
233+
Unpack_Run
234+
sleep 10
235+
236+
#if not on the network
237+
else
238+
FailPing
239+
fi
240+
241+
done
242+
243+
fi
244+
245+
#Transfer Local Copy
246+
#-------------------------------------------------------------
247+
if [ $OPTION == "-L" ]; then
248+
249+
Check
250+
251+
echo "Copying and transferring current folder to swarmie(s)"
252+
253+
DispOpt
254+
255+
echo "dir: $dirPath"
256+
echo "-------------------------------------------------------------"
257+
echo ""
258+
259+
Pack
260+
261+
while(true); do
262+
read -p "Rover Name/IP To Start: " roverIP
263+
if [ "$roverIP" = "exit" ]; then
264+
exit 1
265+
elif [ "$roverIP" = "-G" ]; then
266+
OPTION="-G"
267+
echo ""
268+
echo ""
269+
break
270+
elif [ "$roverIP" = "-R" ]; then
271+
OPTION="-R"
272+
echo ""
273+
echo ""
274+
break
275+
fi
276+
277+
#If rover is on the network
278+
ping -q -w2 $roverIP > /dev/null
279+
if [ $? -eq 0 ]; then
280+
281+
SuccessPing
282+
283+
#Transfer/Unpack/Run
284+
Transfer
285+
Unpack_Run
286+
sleep 10
287+
288+
#if not on the network
289+
else
290+
FailPing
291+
fi
292+
done
293+
fi
294+
295+
#Just Run
296+
#-------------------------------------------------------------
297+
if [ $OPTION == "-R" ]; then
298+
299+
DispOpt
300+
301+
echo "Running current swarmie(s) code"
302+
echo "-------------------------------------------------------------"
303+
echo ""
304+
305+
while(true); do
306+
read -p "Rover Name/IP To Start: " roverIP
307+
if [ "$roverIP" = "exit" ]; then
308+
exit 1
309+
elif [ "$roverIP" = "-G" ]; then
310+
OPTION="-G"
311+
echo ""
312+
echo ""
313+
break
314+
elif [ "$roverIP" = "-L" ]; then
315+
OPTION="-L"
316+
echo ""
317+
echo ""
318+
break
319+
fi
320+
321+
#If rover is on the network
322+
ping -q -w2 $roverIP > /dev/null
323+
if [ $? -eq 0 ]; then
324+
325+
SuccessPing
326+
Run
327+
sleep 10
328+
329+
#if not on the network
330+
else
331+
FailPing
332+
fi
333+
done
334+
fi
335+
336+
done

0 commit comments

Comments
 (0)