forked from ziparker/flir_adk_ethernet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sendCommand
executable file
·114 lines (108 loc) · 2.69 KB
/
sendCommand
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
#!/bin/bash
usageMsg="$(cat <<EOF
\nusage: sendCommand <command> <command param> [args]
\n
\nCommands:
\nautoFFC <setting>
\n\tset the auto FFC setting on Boson. Valid values are "true" or "false"
\npixelFormat <setting>
\n\tset the pixel format. Valid values are "mono_8" and "mono_16" for Boson and, additionally, "color_8" for BlackFly
\n
\nOptions:
\n-n <namespace> DEFAULT flir_adk
\n\tSpecifies a namespace for the topic
\n-s <sub-namespace>
\n\tSpecifies a sub-namespace for the topic. Typically left or right
\n\te.g. topic is /flir_adk/left/pixel_format then run sendCommand
\n\tpixelFormat mono_8 -n flir_adk -s left
\n
EOF
)"
command=""
commandParam=""
commandValue=""
namespace="flir_adk"
subNamespace=""
while (( "$#" )); do
case "$1" in
-n)
namespace=$2
shift 2
;;
-s)
subNamespace=$2
shift 2
;;
-h|--help)
echo -e $usageMsg
exit 0
;;
--) # end argument parsing
shift
break
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
echo -e $usageMsg
exit 1
;;
ffc)
command="ffc"
shift 1
;;
nodeMap)
command="nodeMap"
commandParam=$2
shift 2
if [[ "$1" != "-"* ]]
then
commandValue=$1
shift 1
fi
;;
*) # preserve positional arguments
command=$1
commandParam=$2
shift 2
;;
esac
done
if [[ $command != "ffc" && (-z $command || -z $commandParam) ]]
then
echo "Error: must specify command and command parameter" >&2
echo -e $usageMsg
exit 1
fi
topicNamespace="/$namespace"
if [ ! -z $subNamespace ]
then
topicNamespace="$topicNamespace/$subNamespace"
fi
case "$command" in
autoFFC)
rostopic pub -1 "$topicNamespace/auto_ffc" std_msgs/Bool "data: $commandParam"
;;
pixelFormat)
rostopic pub -1 "$topicNamespace/pixel_format" std_msgs/String "$commandParam"
;;
ffc)
rostopic pub -1 "$topicNamespace/ffc" std_msgs/Empty "{}"
;;
setROI)
rostopic pub -1 "$topicNamespace/set_roi" sensor_msgs/RegionOfInterest "{$commandParam}"
;;
setCenterROI)
rostopic pub -1 "$topicNamespace/set_center_roi" sensor_msgs/RegionOfInterest "{$commandParam}"
;;
nodeMap)
if [ -z $commandValue ]
then
rosservice call "$topicNamespace/get_node" "$commandParam"
else
rostopic pub -1 "$topicNamespace/set_node" diagnostic_msgs/KeyValue "{key: '$commandParam', value: \'$commandValue\'}"
fi
;;
*)
echo -e "\nError: command '$command' not recognized\n"
;;
esac