This repository has been archived by the owner on Oct 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PROTOCOL
179 lines (139 loc) · 5.32 KB
/
PROTOCOL
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
ROVER PROTOCOLS
===============================================================================
Full Table of Commands
----------------------
+--------------+-------+
|Label | Value |
+--------------+-------+
|forward | 0x01 |
|reverse | 0x02 |
|forwardLeft | 0x03 |
|forwardRight | 0x04 |
|stop | 0x05 |
|queryproc | 0x06 |
|startvid | 0x07 |
|stopvid | 0x08 |
|reverseLeft | 0x09 |
|reverseRight | 0x10 |
|sensinfo | 0x11 |
|graceful | 0xFF |
+--------------+-------+
GRACEFUL SHUTDOWN
-----------------
To stop the listener from listening you send the 'graceful' command to the
server.
+--------------+-------------+
| ActionLabel | ActionHex |
+--------------+-------------+
| graceful | 0xFF |
+--------------+-------------+
A 'number' is an integer, positive, or negative. We use integers for movement
speed, and wheel rotation (rotation for turns).
Number is a negative, or positive integer. Limits for now are up to 255.
number ::= (-)[0-9]+
Movement forward:
forward <number>
Movement backwards:
reverse <number>
Turning forward:
forwardLeft <number>
forwardRight <number>
Turning backwards:
reverseLeft <number>
reverseRight <number>
Stoping motor wheels:
stop <number>
When we're actually sending the commands, we want to turn the above into udp
packets. It would not make sense to send whole strings over the network.
Therefore we can bind hex values to the commands in this manner:
+--------------+-------------+
| ActionLabel | ActionHex |
+--------------+-------------+
| forward | 0x01 |
| reverse | 0x02 |
| forwardLeft | 0x03 |
| forwardRight | 0x04 |
| stop | 0x05 |
| reverseLeft | 0x09 |
| reverseRight | 0x10 |
+--------------+-------------+
PROCESS MANAGER (QUERYPROC)
===============================================================================
We are able to query about different running processes with the following
messages:
+--------------+-------------+
| ActionLabel | ActionHex |
+--------------+-------------+
| queryproc | 0x06 |
+--------------+-------------+
Once the client sends one packet with the above value, the client must wait to
receive a response. The first byte is to signal that this is a queryproc
response (NB: This is received on the client side).
+----------------+-------------+
| ActionLabel | ActionHex |
+----------------+-------------+
| queryprocresp | 0x04 |
+----------------+-------------+
What is expected afterwards is a list of processes. The list of processes
returned will be tuples of ids, to classify processes, and their status.
The labels of the processes are found in the following table.
+-------------------+-------------+
| Process Label | Hex id |
+-------------------+-------------+
| rovercore | 0x00 |
| camera1 | 0x01 |
| camera2 | 0x02 |
| camera3 | 0x03 |
+-------------------+-------------+
And they're bound to the following possible status IDs:
+-------------------+-------------+
| Proc Status Label | Hex |
+-------------------+-------------+
| Dead | 0x00 |
| Running | 0x01 |
| BadState | 0x02 |
+-------------------+-------------+
So for example, the following sequence:
[ <0x00, 0x01>, <0x01, 0x01>, <0x03, 0x03> ]
would mean that the rovercore is in `running` state, the `first camera` process
is running, but the `third` one is in `bad state`.
START / STOP VIDEO
===============================================================================
To start the video, we just need to send the start and stop constants. There is
no response. If we want to find out status of the video process, we use the
queryproc command (discussed in this document).
+-------------------+-------------+
| Process Label | Hex id |
+-------------------+-------------+
| startvid | 0x07 |
| stopvid | 0x08 |
+-------------------+-------------+
SENSINFO
===============================================================================
This is to return information from different sensors on the rover. Invoke this
command on the server. Await for a response. The response contains all the
information needed in order to parse the complete reply.
+-------------------+-------------+
| Label | Hex ID |
+-------------------+-------------+
| sensinfo | 0x11 |
+-------------------+-------------+
Once this is invoked, a reply is sent back. The reply starts with the following
byte.
+-------------------+-------------+
| Label | Hex ID |
+-------------------+-------------+
| sensinforesp | 0x12 |
+-------------------+-------------+
The second byte lists how many sensor information we'll be receiving back. If we
receive information about 3 sensors, we'll receive 6 total bytes (one byte for
sensor id, and the other byte for the magnitude recorded).
[0x12, 0x03,
0x01, 0x30,
0x02, 0x43,
0x04, 0x120]
First byte: 0x12: sensifo command response
[sensinfo] 0x03: 3 sensors to received/parsed
[sensinfo:1] temperature: value 30 (hex) received
[sensinfo:2] somesensor1: value 43 (hex) received
[sensinfo:3] somesensor2: value 120 (hex) received