-
Notifications
You must be signed in to change notification settings - Fork 0
/
move_robot.sh
executable file
·59 lines (50 loc) · 925 Bytes
/
move_robot.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
#!/bin/bash
deviceId="300032001147343339383037"
accessTkn=""
funcName="makeMove"
cmd="NONE"
if [ "$1" == "forward" ]
then
cmd="forward"
addDistance="Y"
fi
if [ "$1" == "backward" ]
then
cmd="backward"
addDistance="Y"
fi
if [ "$1" == "stop" ]
then
cmd="stop"
fi
if [ "$1" == "turnLeft" ]
then
cmd="turnLeft"
addDistance="Y"
fi
if [ "$1" == "turnRight" ]
then
cmd="turnRight"
addDistance="Y"
fi
if [ "$1" == "setSpeed" ]
then
cmd="setSpeed,$2"
fi
if [ "$1" == "calibrateTurning" ]
then
cmd="calibrateTurning,$2"
fi
if [ "$addDistance" == "Y" ] && [ -n "$2" ] && [ -n "$3" ]
then
if [ "$3" == "m" ] || [ "$3" == "mm" ] || [ "$3" == "cm" ] || [ "$3" == "degrees" ]
then
cmd+=",$2,$3"
else
echo "Must be \"mm\", \"cm\", \"m\" or \"degrees\"."
fi
fi
if [ "$cmd" != "NONE" ]
then
curl https://api.particle.io/v1/devices/$deviceId/$funcName -d arg=$cmd -d access_token=$accessTkn
fi