mtp.x 7.78 KB
Newer Older
Timothy Stack's avatar
 
Timothy Stack committed
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
/*
 * EMULAB-COPYRIGHT
 * Copyright (c) 2005 University of Utah and the Flux Group.
 * All rights reserved.
 */

/**
 * @file mtp.x
 *
 * XDR specification for the data structures used in the MTP protocol.  This
 * file will be fed into rpcgen(1) to create "mtp_xdr.h" and "mtp_xdr.c".
 */

#ifdef RPC_HDR
%#include <rpc/types.h>
%#include <rpc/xdr.h>
%
%#ifdef __cplusplus
%extern "C" {
%#endif
#endif

/**
 * Current version number for the protocol.
 *
 * @see mtp_packet
 */
const MTP_VERSION	= 0x02;

/**
 * Opcodes for each message type.
 *
 * @see mtp_payload
 */
enum mtp_opcode_t {
    /**
     * An error message.
     */
    MTP_CONTROL_ERROR		= 11,

    /**
     * Unused.
     */
    MTP_CONTROL_NOTIFY		= 12,

    /**
     * Initialize a client connection with a server.
     */
    MTP_CONTROL_INIT		= 13,

    /**
     * Unused.
     */
    MTP_CONTROL_CLOSE		= 14,

    
    /**
     * VMC configuration packet, sent in response to an MTP_CONTROL_INIT.
     */
    MTP_CONFIG_VMC		= 20,
    
    /**
     * RMC configuration packet, sent in response to an MTP_CONTROL_INIT.
     */
    MTP_CONFIG_RMC		= 21,

Timothy Stack's avatar
   
Timothy Stack committed
67
68
69
70
71
    /**
     * VMC client configuration packet.
     */
    MTP_CONFIG_VMC_CLIENT	= 22,

Timothy Stack's avatar
 
Timothy Stack committed
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
    
    /**
     * Request the current position of a given robot.
     */
    MTP_REQUEST_POSITION	= 30,
    
    /**
     * Request the identity of a robot at a given position.
     */
    MTP_REQUEST_ID		= 31,

    
    /**
     * Update the current position of a robot, can be sent in response to an
     * MTP_REQUEST_POSITION or spontaneously.
     */
    MTP_UPDATE_POSITION		= 40,

    /**
     * Update the identity of a robot at a position, sent in response to an
     * MTP_REQUEST_ID.
     */
    MTP_UPDATE_ID		= 41,

    
    /**
     * Move the robot to a specific position or orientation.
     */
    MTP_COMMAND_GOTO		= 50,

    /**
     * Stop the robot from moving any further.
     */
    MTP_COMMAND_STOP		= 51,


    /**
     * Telemetry from a robot.
     */
    MTP_TELEMETRY		= 60,
112

113
114
115
116
117
    /**
     * Snapshot the state of a daemon.
     */
    MTP_SNAPSHOT		= 61,

118
119
120
    /**
     * vmcd tells emcd to wiggle a robot (for id purposes).
     */
Timothy Stack's avatar
   
Timothy Stack committed
121
    MTP_WIGGLE_REQUEST		= 70,
122
123
124
125

    /**
     * the result of a wiggle.
     */
Timothy Stack's avatar
   
Timothy Stack committed
126
    MTP_WIGGLE_STATUS		= 71,
Timothy Stack's avatar
   
Timothy Stack committed
127
128
129
130

    MTP_REQUEST_REPORT		= 80,
    
    MTP_CONTACT_REPORT		= 81,
Timothy Stack's avatar
 
Timothy Stack committed
131
    
Timothy Stack's avatar
   
Timothy Stack committed
132
133
134
    MTP_CREATE_OBSTACLE		= 90,
    MTP_UPDATE_OBSTACLE		= 91,
    MTP_REMOVE_OBSTACLE		= 92,
Timothy Stack's avatar
 
Timothy Stack committed
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

    MTP_OPCODE_MAX
};

/**
 * The "role" of the daemon that is sending a packet.
 *
 * @see mtp_packet
 */
enum mtp_role_t {
    MTP_ROLE_VMC	= 1,
    MTP_ROLE_EMC	= 2,
    MTP_ROLE_RMC	= 3,
    MTP_ROLE_EMULAB	= 4,
    MTP_ROLE_ROBOT	= 5,

    MTP_ROLE_MAX
};

/**
 * The status of the robot whose position is being updated.
 *
 * @see mtp_update_position
 */
enum mtp_status_t {
    MTP_POSITION_STATUS_UNKNOWN		= -1,
    MTP_POSITION_STATUS_IDLE		= 1,
    MTP_POSITION_STATUS_MOVING		= 2,
    MTP_POSITION_STATUS_ERROR		= 3,
    MTP_POSITION_STATUS_COMPLETE	= 4,
Timothy Stack's avatar
   
Timothy Stack committed
165
    MTP_POSITION_STATUS_CONTACT		= 5,
Timothy Stack's avatar
 
Timothy Stack committed
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
    MTP_POSITION_STATUS_ABORTED		= 6,
    MTP_POSITION_STATUS_CYCLE_COMPLETE	= 32
};

struct mtp_control {
    int id;
    int code;
    string msg<>;
};

struct robot_config {
    int id;
    string hostname<>;
};

Timothy Stack's avatar
   
Timothy Stack committed
181
182
183
struct camera_config {
    string hostname<>;
    int port;
Timothy Stack's avatar
   
Timothy Stack committed
184
185
186
187
    float x;
    float y;
    float width;
    float height;
Timothy Stack's avatar
   
Timothy Stack committed
188
189
    float fixed_x;
    float fixed_y;
Timothy Stack's avatar
   
Timothy Stack committed
190
191
};

192
193
struct obstacle_config {
    int id;
Timothy Stack's avatar
   
Timothy Stack committed
194
195
196
197
198
199
    float xmin;
    float ymin;
    float zmin;
    float xmax;
    float ymax;
    float zmax;
200
201
};

202
203
204
205
206
struct dyn_obstacle_config {
    int robot_id;
    obstacle_config config;
};

207
208
209
210
211
struct box {
    float x;
    float y;
    float width;
    float height;
Timothy Stack's avatar
 
Timothy Stack committed
212
213
214
215
};

struct mtp_config_rmc {
    robot_config robots<>;
216
    box bounds<>;
217
    obstacle_config obstacles<>;
Timothy Stack's avatar
 
Timothy Stack committed
218
219
220
221
};

struct mtp_config_vmc {
    robot_config robots<>;
Timothy Stack's avatar
   
Timothy Stack committed
222
    camera_config cameras<>;
Timothy Stack's avatar
 
Timothy Stack committed
223
224
};

Timothy Stack's avatar
   
Timothy Stack committed
225
226
227
228
229
struct mtp_config_vmc_client {
    float fixed_x;
    float fixed_y;
};

Timothy Stack's avatar
 
Timothy Stack committed
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
struct mtp_request_position {
    int robot_id;
};

struct robot_position {
    float x;
    float y;
    float theta;
    double timestamp;
};

struct mtp_update_position {
    int robot_id;
    robot_position position;
    mtp_status_t status;
Timothy Stack's avatar
   
Timothy Stack committed
245
    int command_id;
Timothy Stack's avatar
 
Timothy Stack committed
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
};

struct mtp_request_id {
    int request_id;
    robot_position position;
};

struct mtp_update_id {
    int request_id;
    int robot_id;
};

struct mtp_command_goto {
    int command_id;
    int robot_id;
    robot_position position;
Timothy Stack's avatar
   
Timothy Stack committed
262
    float speed;
Timothy Stack's avatar
 
Timothy Stack committed
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
};

struct mtp_command_stop {
    int command_id;
    int robot_id;
};

/**
 * The different types of robots that support telemetry.
 */
enum mtp_robot_type_t {
    MTP_ROBOT_GARCIA		= 1	/*< Acroname Garcia. */
};

struct mtp_garcia_telemetry {
278
    int robot_id;
Timothy Stack's avatar
 
Timothy Stack committed
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
    float battery_level;
    float battery_voltage;
    int battery_misses;
    float left_odometer;
    float right_odometer;
    float left_instant_odometer;
    float right_instant_odometer;
    float left_velocity;
    float right_velocity;
    unsigned int move_count;
    int move_time_sec;
    int move_time_usec;
    int down_ranger_left;
    int down_ranger_right;
    float front_ranger_left;
    float front_ranger_right;
    float front_ranger_threshold;
    float rear_ranger_left;
    float rear_ranger_right;
    float rear_ranger_threshold;
    float side_ranger_left;
    float side_ranger_right;
    float side_ranger_threshold;
    float speed;
    int status;
    int idle;
    int user_button;
    int user_led;
307
    int stall_contact;
Timothy Stack's avatar
 
Timothy Stack committed
308
309
};

310
enum mtp_wiggle_t {
Timothy Stack's avatar
   
Timothy Stack committed
311
    MTP_WIGGLE_START	= 1,
312
    /* turn 180deg from current pos */
Timothy Stack's avatar
   
Timothy Stack committed
313
    MTP_WIGGLE_180_R	= 10,
314
    /* turn 180deg from current pos, then 180deg in opposite direction */
Timothy Stack's avatar
   
Timothy Stack committed
315
    MTP_WIGGLE_180_R_L	= 11,
316
    /* turn 360deg from current pos */
Timothy Stack's avatar
   
Timothy Stack committed
317
    MTP_WIGGLE_360_R	= 12,
318
    /* turn 360deg from current pos, then 360deg in opposite direction */
Timothy Stack's avatar
   
Timothy Stack committed
319
    MTP_WIGGLE_360_R_L	= 13
320
321
322
323
324
325
326
327
328
329
330
331
};

struct mtp_wiggle_request {
    int robot_id;
    mtp_wiggle_t wiggle_type;
};

struct mtp_wiggle_status {
    int robot_id;
    mtp_status_t status;
};

Timothy Stack's avatar
   
Timothy Stack committed
332
333
334
335
336
337
338
339
340
341
struct contact_point {
    float x;
    float y;
};

struct mtp_contact_report {
    int count;
    contact_point points[8];
};

Timothy Stack's avatar
 
Timothy Stack committed
342
343
344
345
346
347
348
349
350
351
352
union mtp_telemetry switch (mtp_robot_type_t type) {
 case MTP_ROBOT_GARCIA:		mtp_garcia_telemetry	garcia;
};

union mtp_payload switch (mtp_opcode_t opcode) {
 case MTP_CONTROL_ERROR:	mtp_control		error;
 case MTP_CONTROL_NOTIFY:	mtp_control		notify;
 case MTP_CONTROL_INIT:		mtp_control		init;
 case MTP_CONTROL_CLOSE:	mtp_control		close;
 case MTP_CONFIG_RMC:		mtp_config_rmc		config_rmc;
 case MTP_CONFIG_VMC:		mtp_config_vmc		config_vmc;
Timothy Stack's avatar
   
Timothy Stack committed
353
 case MTP_CONFIG_VMC_CLIENT:	mtp_config_vmc_client	config_vmc_client;
Timothy Stack's avatar
 
Timothy Stack committed
354
355
356
357
358
359
360
 case MTP_REQUEST_POSITION:	mtp_request_position	request_position;
 case MTP_REQUEST_ID:		mtp_request_id		request_id;
 case MTP_UPDATE_POSITION:	mtp_update_position	update_position;
 case MTP_UPDATE_ID:		mtp_update_id		update_id;
 case MTP_COMMAND_GOTO:		mtp_command_goto	command_goto;
 case MTP_COMMAND_STOP:		mtp_command_stop	command_stop;
 case MTP_TELEMETRY:		mtp_telemetry		telemetry;
Timothy Stack's avatar
   
Timothy Stack committed
361
362
 case MTP_WIGGLE_REQUEST:	mtp_wiggle_request	wiggle_request;
 case MTP_WIGGLE_STATUS:	mtp_wiggle_status	wiggle_status;
Timothy Stack's avatar
   
Timothy Stack committed
363
364
 case MTP_REQUEST_REPORT:	mtp_request_position	request_report;
 case MTP_CONTACT_REPORT:	mtp_contact_report	contact_report;
365
 case MTP_CREATE_OBSTACLE:	dyn_obstacle_config	create_obstacle;
Timothy Stack's avatar
   
Timothy Stack committed
366
367
 case MTP_UPDATE_OBSTACLE:	obstacle_config		update_obstacle;
 case MTP_REMOVE_OBSTACLE:	int			remove_obstacle;
368
 case MTP_SNAPSHOT:		int			snapshot;
Timothy Stack's avatar
 
Timothy Stack committed
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
};

/**
 * The packet structure used for the MTP protocol, contains a simple header and
 * the payload with the actual message data.
 */
struct mtp_packet {
    short vers;
    short role;
    
    mtp_payload data;
};

#ifdef JAVA_RPC
program FOO {
    version FIRST_DEMO_VERSION {
        void nullcall(void) = 0;
    } = 1;
} = 0x20049679;
#endif

#ifdef RPC_HDR
%#ifdef __cplusplus
%}
%#endif
#endif