Player
Frontpage
Contents
User
Installation
Quick start
Supported devices
Tutorials
Utilities
Client libraries
FAQ
Help
Developer
Architecture
libplayercore
libplayerinterface
interfaces
libplayerdrivers
drivers
libplayercommon
libplayersd
libplayertcp
libplayerxdr
TODO
Online
Homepage
Download
Project
Bugs
Help
server
drivers
mixed
nomad
Nclient.h
1
/*
2
* Copyright (C) 1991-2000 Nomadic Technologies
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2, or (at your option)
7
* any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*
18
*/
19
20
21
/*
22
* Nclient.h
23
*
24
* Interface file for direct connections to the robot or for
25
* connections to Nserver.
26
*/
27
28
/*
29
* $Log: Nclient.h,v $
30
* Revision 1.1.1.1 2001/08/23 19:05:14 bananajr
31
* initial commit
32
*
33
*/
34
35
#ifndef _HOST_CLIENT_NCLIENT_H_
36
#define _HOST_CLIENT_NCLIENT_H_
37
38
#ifdef __cplusplus
39
extern
"C"
{
40
#endif
41
42
/* constants */
43
44
#ifndef FALSE
45
#define FALSE 0
46
#endif
47
#ifndef TRUE
48
#define TRUE 1
49
#endif
50
#ifndef NULL
51
#define NULL 0
52
#endif
53
#define MAX_VERTICES 10
54
#define NUM_STATE 45
55
#define NUM_MASK 44
56
#define NUM_LASER 482
57
#define BUFSIZE 4096
58
#define MAX_USER_BUF 0xFFFF
59
60
/* Robot models. */
61
#define MODEL_N200 0
62
#define MODEL_N150 1
63
#define MODEL_SCOUT 2
64
#define MODEL_SCOUT2 2
65
66
/* the number of sonars and infrareds */
67
#define SONARS 16
68
#define INFRAREDS 16
69
70
/*
71
* The following defines allow you to access the State vector in a
72
* more readable way.
73
*/
74
75
#define STATE_SIM_SPEED 0
76
77
#define STATE_IR_0 1
78
#define STATE_IR_1 2
79
#define STATE_IR_2 3
80
#define STATE_IR_3 4
81
#define STATE_IR_4 5
82
#define STATE_IR_5 6
83
#define STATE_IR_6 7
84
#define STATE_IR_7 8
85
#define STATE_IR_8 9
86
#define STATE_IR_9 10
87
#define STATE_IR_10 11
88
#define STATE_IR_11 12
89
#define STATE_IR_12 13
90
#define STATE_IR_13 14
91
#define STATE_IR_14 15
92
#define STATE_IR_15 16
93
94
#define STATE_SONAR_0 17
95
#define STATE_SONAR_1 18
96
#define STATE_SONAR_2 19
97
#define STATE_SONAR_3 20
98
#define STATE_SONAR_4 21
99
#define STATE_SONAR_5 22
100
#define STATE_SONAR_6 23
101
#define STATE_SONAR_7 24
102
#define STATE_SONAR_8 25
103
#define STATE_SONAR_9 26
104
#define STATE_SONAR_10 27
105
#define STATE_SONAR_11 28
106
#define STATE_SONAR_12 29
107
#define STATE_SONAR_13 30
108
#define STATE_SONAR_14 31
109
#define STATE_SONAR_15 32
110
111
#define STATE_BUMPER 33
112
#define STATE_CONF_X 34
113
#define STATE_CONF_Y 35
114
#define STATE_CONF_STEER 36
115
#define STATE_CONF_TURRET 37
116
#define STATE_VEL_TRANS 38
117
#define STATE_VEL_RIGHT 38
/* for scout */
118
#define STATE_VEL_STEER 39
119
#define STATE_VEL_LEFT 39
/* for scout */
120
#define STATE_VEL_TURRET 40
121
#define STATE_MOTOR_STATUS 41
122
#define STATE_LASER 42
123
#define STATE_COMPASS 43
124
#define STATE_ERROR 44
125
126
/*
127
* The following defines allow you to access the Smask vector in a
128
* more readable way.
129
*/
130
131
#define SMASK_POS_DATA 0
132
133
#define SMASK_IR_1 1
134
#define SMASK_IR_2 2
135
#define SMASK_IR_3 3
136
#define SMASK_IR_4 4
137
#define SMASK_IR_5 5
138
#define SMASK_IR_6 6
139
#define SMASK_IR_7 7
140
#define SMASK_IR_8 8
141
#define SMASK_IR_9 9
142
#define SMASK_IR_10 10
143
#define SMASK_IR_11 11
144
#define SMASK_IR_12 12
145
#define SMASK_IR_13 13
146
#define SMASK_IR_14 14
147
#define SMASK_IR_15 15
148
#define SMASK_IR_16 16
149
150
#define SMASK_SONAR_1 17
151
#define SMASK_SONAR_2 18
152
#define SMASK_SONAR_3 19
153
#define SMASK_SONAR_4 20
154
#define SMASK_SONAR_5 21
155
#define SMASK_SONAR_6 22
156
#define SMASK_SONAR_7 23
157
#define SMASK_SONAR_8 24
158
#define SMASK_SONAR_9 25
159
#define SMASK_SONAR_10 26
160
#define SMASK_SONAR_11 27
161
#define SMASK_SONAR_12 28
162
#define SMASK_SONAR_13 29
163
#define SMASK_SONAR_14 30
164
#define SMASK_SONAR_15 31
165
#define SMASK_SONAR_16 32
166
167
#define SMASK_BUMPER 33
168
#define SMASK_CONF_X 34
169
#define SMASK_CONF_Y 35
170
#define SMASK_CONF_STEER 36
171
#define SMASK_CONF_TURRET 37
172
#define SMASK_VEL_TRANS 38
173
#define SMASK_VEL_STEER 39
174
#define SMASK_VEL_TURRET 40
175
#define SMASK_RESERVED 41
176
#define SMASK_LASER 42
177
#define SMASK_COMPASS 43
178
179
/*
180
* These defines are used for specifying the control modes in the
181
* robot motion command 'mv'. If MV_IGNORE is specified for an axis
182
* the current motion command for it will remain active. Specifying
183
* MV_VM or MV_PR will select velocity and position control as in
184
* the vm and pr robot motion commands
185
*/
186
187
#define MV_IGNORE 0
188
#define MV_VM 1
/* velocity mode */
189
#define MV_PR 2
/* position relative mode */
190
#define MV_LP 3
/* limp mode */
191
#define MV_AC 4
/* set acceleration for vm, pr, pa modes*/
192
#define MV_SP 5
/* set velocity for pr, pa modes */
193
#define MV_PA 6
/* position absolute mode */
194
#define MV_TQ 7
/* torque mode */
195
#define MV_MT 8
/* set maximum torque for vm, pr, pa, tq modes */
196
197
/*
198
* zeroing modes for arm
199
*/
200
201
#define ZR_CHECK 1
202
#define ZR_ORIENT 2
203
#define ZR_NO_N_GRIPPER 4
204
205
/*
206
* user packet constants for arm
207
*/
208
209
#define ARM_ZR 40
210
#define ARM_WS 41
211
#define ARM_MV 42
212
213
/*
214
* function prototypes for arm
215
*/
216
long
arm_mv(
long
l_mode,
long
l_v,
long
g_mode,
long
g_v);
217
long
arm_ws(
short
lift,
short
grip,
long
timeout,
long
*time_remain);
218
long
arm_zr(
short
mode);
219
220
/*
221
* For requesting the PosData the following defines should be used.
222
* Each sensor has a bit, if it is set the pos-data is attached
223
* when the sensory data is returned.
224
*/
225
226
#define POS_NONE ( 0 << 0 )
227
#define POS_INFRARED ( 1 << 0 )
228
#define POS_SONAR ( 1 << 1 )
229
#define POS_BUMPER ( 1 << 2 )
230
#define POS_LASER ( 1 << 3 )
231
#define POS_COMPASS ( 1 << 4 )
232
233
/*
234
* these macros enable the user to determine if the pos-attachment
235
* is requested for a specific sensor. 1 is returned if the
236
* attachment is requested, 0 otherwise
237
*
238
* Note that the function posDataCheck() is called (see below)
239
*/
240
241
#define POS_INFRARED_P ( ( (posDataCheck()) & POS_INFRARED ) ? 1 : 0 )
242
#define POS_SONAR_P ( ( (posDataCheck()) & POS_SONAR ) ? 1 : 0 )
243
#define POS_BUMPER_P ( ( (posDataCheck()) & POS_BUMPER ) ? 1 : 0 )
244
#define POS_LASER_P ( ( (posDataCheck()) & POS_LASER ) ? 1 : 0 )
245
#define POS_COMPASS_P ( ( (posDataCheck()) & POS_COMPASS ) ? 1 : 0 )
246
247
/*
248
* The user will be able to call a function that fills out a
249
* list of position data for a specific sensor reading.
250
* To access the sensors in that structure the following defines
251
* should be used. They should also be used if data for a single
252
* infrared sensor / sonar is requested.
253
*/
254
255
#define POS_IR_1 0
256
#define POS_IR_2 1
257
#define POS_IR_3 2
258
#define POS_IR_4 3
259
#define POS_IR_5 4
260
#define POS_IR_6 5
261
#define POS_IR_7 6
262
#define POS_IR_8 7
263
#define POS_IR_9 8
264
#define POS_IR_10 9
265
#define POS_IR_11 10
266
#define POS_IR_12 11
267
#define POS_IR_13 12
268
#define POS_IR_14 13
269
#define POS_IR_15 14
270
#define POS_IR_16 15
271
272
#define POS_SONAR_1 0
273
#define POS_SONAR_2 1
274
#define POS_SONAR_3 2
275
#define POS_SONAR_4 3
276
#define POS_SONAR_5 4
277
#define POS_SONAR_6 5
278
#define POS_SONAR_7 6
279
#define POS_SONAR_8 7
280
#define POS_SONAR_9 8
281
#define POS_SONAR_10 9
282
#define POS_SONAR_11 10
283
#define POS_SONAR_12 11
284
#define POS_SONAR_13 12
285
#define POS_SONAR_14 13
286
#define POS_SONAR_15 14
287
#define POS_SONAR_16 15
288
289
290
/* Define the length of the user buffer (Maximal short).
291
* Due to Protocol bytes, the effective length is 65526
292
*/
293
#define USER_BUFFER_LENGTH 0xFFFF
294
295
296
/* these definitions apply to the Scout and SuperScout */
297
#define ROTATION_CONSTANT 0.118597
/* inches/degree (known to 100 ppm) */
298
299
#define RIGHT(trans, steer) (trans + (int)((float)steer*ROTATION_CONSTANT))
300
#define LEFT(trans, steer) (trans - (int)((float)steer*ROTATION_CONSTANT))
301
302
#define scout_vm(trans, steer) vm(RIGHT(trans, steer), LEFT(trans, steer), 0)
303
304
/********************
305
* *
306
* Type definitions *
307
* *
308
********************/
309
310
/*
311
* The following type definitions are used for the PosData.
312
* PosData is an information packet that is attached to
313
* each sensor reading, if requested. Note that the use of
314
* PosData could cause compatibility problems when different
315
* releases of the software are used on the robot and on the
316
* server side.
317
*
318
* The information packet can be used to determine how up-to-date
319
* a sensory reading is. It contains the configuration of the robot.
320
* This is the most updated configuration at the time of the sensor
321
* reading. However, it is possible that the sensory reading
322
* was taken after the integration of the coniguration.
323
* To determine the interval that has passed two timestamps are in-
324
* cluded in this information package: a timestamp for the computation
325
* of the configuration and another timestamp for the actual capturing
326
* of the senor reading.
327
*
328
* The timestamps are in milliseconds of the internal clock of the
329
* board that handles the sensors (Intellisys 100 sensor-board).
330
*/
331
332
/*
333
* TimeData contains the current time of the Intellisys 100
334
* in milliseconds
335
*/
336
337
typedef
unsigned
long
TimeData;
338
339
/*
340
* ConfigData is where the i486 writes the current configuration
341
* of the robot, so that the Intellisys 100 can attach current
342
* integration values to the sensor readings.
343
* It is also used inside of the Pos data.
344
*/
345
346
typedef
struct
_ConfigData
347
{
348
/* the configuration of the robot */
349
long
configX;
350
long
configY;
351
long
configSteer;
352
long
configTurret;
353
354
/* the velocities of the robot*/
355
long
velTrans;
356
long
velSteer;
357
long
velTurret;
358
359
/* time of integration in milliseconds (Intellisys 100 time) */
360
TimeData timeStamp;
361
362
}
ConfigData
;
363
364
365
/*
366
* PosData contains information that is attached to a sensor
367
* reading in order to determine how recent it is.
368
*/
369
370
typedef
struct
_PosData
371
{
372
/* the configuration of the robot at the time of the reading */
373
ConfigData
config;
374
375
/* the time of the sensing in milliseconds (Intellisys 100 time) */
376
TimeData timeStamp;
377
378
}
PosData
;
379
380
/* these type definitions are for user defined package processing */
381
382
typedef
union
383
{
384
char
bytes[8];
385
double
data;
386
}
double_union
;
387
388
typedef
union
389
{
390
char
bytes[4];
391
short
words[2];
392
long
data;
393
}
long_union
;
394
395
typedef
union
396
{
397
unsigned
char
bytes[2];
398
short
data;
399
}
short_union
;
400
401
typedef
union
402
{
403
unsigned
char
bytes[2];
404
unsigned
short
data;
405
}
ushort_union
;
406
407
typedef
union
408
{
409
unsigned
char
bytes[4];
410
unsigned
short
words[2];
411
unsigned
long
data;
412
}
ulong_union
;
413
414
struct
request_struct
415
{
416
short
type;
417
unsigned
short
size;
418
long
mesg[USER_BUFFER_LENGTH];
419
};
420
421
struct
reply_struct
422
{
423
short
type;
424
unsigned
short
size;
425
long
mesg[USER_BUFFER_LENGTH];
426
};
427
428
/********************
429
* *
430
* Global Variables *
431
* *
432
********************/
433
434
/* The State vector is an array of 45 long integers:
435
*
436
* State[0] - stores actual simulation speed with 10 being realtime
437
* (20 meaning twice as fast as realtime and 5 meaning half the
438
* speed of realtime).
439
* State[1 ... 16] - stores the 16 infrared data.
440
* State[17 ... 32] - stores the 16 sonar data.
441
* State[33] - stores bumper data
442
* State[34 ... 37] - stores robot configuration
443
* State[38 ... 40] - stores robot's current velocities
444
* State[41] - motor status: the lowest bit is set to 1 if the translational
445
* motor is active; the second lowest bit is set to 1 if the
446
* steering motor is active; the third lowest bit is set to 1 if
447
* the turret motor is active.
448
* State[42] - laser mode: the mode of the laser.
449
* State[43] - compass value.
450
* State[44] - error number.
451
*/
452
extern
long
State[NUM_STATE];
453
454
/* The Smask vector is an array of 44 integers:
455
*
456
* Smask[0] - used for the posData attachment to sensory data
457
* Smask[1 ... 16] - infrared mask
458
* Smask[17 ... 32] - sonar mask
459
* Smask[33] - bumper mask
460
* Smask[34 ... 37] - configuration mask
461
* Smask[38 ... 40] - velocity mask
462
* Smask[41] - irrelevant.
463
* Smask[42] - laser mask
464
* Smask[43] - compass mask
465
*/
466
extern
int
Smask[NUM_MASK];
467
468
/* Mask is now just a pointer to Smask. This is because Mask is a declared
469
* variable in X11 library. So if you are not using X11, you can uncomment
470
* the following line and keep using Mask as before. However, if you want
471
* to use X11 graphic in your application program, you can simply use Smask
472
* instead.
473
*/
474
/* static int *Mask = Smask; */
475
476
/* The Laser vector is an array of 965 elements. The Laser vector
477
* can contain laser data in one of the three formats: pixel, point, or line.
478
*
479
* In pixel mode (not available in simulation, Laser[0] keeps the number of
480
* pixels in the Laser vector. The can be a maximum of 482 pixels.
481
*
482
* In point mode, Laser[0] keeps the number of points. Each point is
483
* specified y the two numbers: the x and y coordinates of the point in
484
* the robot's local coordinate. There can be a maximum of 482 points
485
* (thus 964 numbers).
486
*
487
* In line mode, Laser[0] keeps the number of lines. Each line segment is
488
* specified by its two end points and each end point is specified by its
489
* x and y coordinates in the robot's local coordinate. There can be a
490
* maximum of 241 points.
491
*/
492
extern
int
Laser[2*NUM_LASER+1];
493
494
/* If linking the application program with Nclient.o, it will connect
495
* to Nserver. To specify to which machine to connect and which port
496
* to use the following variables can be redefined, otherwise default
497
* values are used:
498
* SERVER_MACHINE_NAME
499
* SERV_TCP_PORT
500
*
501
* If linking the application program with Ndirect.o, it will connect
502
* directly to the robot. To specify to which robot to connect and
503
* which parameters to use for the connection the following variables
504
* can be redefined, otherwise default vaues are used:
505
* ROBOT_MACHINE_NAME
506
* usually don't need to be changed:
507
* CONN_TYPE
508
* SERIAL_PORT
509
* SERIAL_BAUD
510
* ROBOT_TCP_PORT
511
*
512
* If an application program should run with Nclient.o and Ndirect.o
513
* all of the above variables should be initialized.
514
*
515
* The concerend variables are define below.
516
*/
517
518
/* SERVER_MACHINE_NAME is the name of the machine where the server is
519
* running. You should specify the server machine name in your
520
* program if the server is running on a computer different from
521
* where the client is running
522
*/
523
extern
char
SERVER_MACHINE_NAME[80];
524
525
/* SERV_TCP_PORT is an arbitrary port number the server listens to for
526
* request of connection. It should be the same as that specified in the
527
* world.setup file. You may modify this number and that in the world.setup
528
* file to allow multiple servers running on the same machine.
529
*/
530
extern
int
SERV_TCP_PORT;
531
532
/* ROBOT_MACHINE_NAME is the name of the machine on the robot
533
*/
534
extern
char
ROBOT_MACHINE_NAME[80];
535
536
/* CONN_TYPE is the selection between using a serial port or a TCP/IP port.
537
* If set to 1, serial port is used. If set to 2 (the default), TCP/IP port
538
* is used. If set to any other value, connection will fail.
539
*/
540
extern
int
CONN_TYPE;
541
542
/* SERIAL_PORT is a string containing the filename of the serial port you
543
* choose to communicate to the robot on. The default is "/dev/ttyS0".
544
*/
545
extern
char
SERIAL_PORT[40];
546
547
/* SERIAL_BAUD is the baud rate to set the serial communication to. It
548
* defaults to 9600.
549
*/
550
extern
int
SERIAL_BAUD;
551
552
/* ROBOT_TCP_PORT is the port number the robot listens on for request of
553
* connection. It defaults (and should always be set) to 65001 for the
554
* standard binary port.
555
*/
556
extern
int
ROBOT_TCP_PORT;
557
558
/* LASER_CALIBRATION and LASER_OFFSET are the values that the laser
559
* calibration software returns to you in the file Laser.cal, and that
560
* are normally stored in the file robot.setup under [laser]calibration
561
* and [laser]offset when Nserver is present. Set these values with
562
* the properly calculated values for your laser system if you have one.
563
* This is only needed for linking with Ndirect.o.
564
*/
565
566
extern
double
LASER_CALIBRATION[8];
567
extern
double
LASER_OFFSET[2];
568
569
/*****************************
570
* *
571
* Robot Interface Functions *
572
* *
573
*****************************/
574
575
/*
576
* create_robot - requests the server to create a robot with
577
* id = robot_id and establishes a connection with
578
* the robot. This function is disabled in this
579
* version of the software.
580
*
581
* parameters:
582
* long robot_id -- id of the robot to be created. The robot
583
* will be referred to by this id. If a process
584
* wants to talk (connect) to a robot, it must
585
* know its id.
586
*/
587
int
create_robot(
long
robot_id);
588
589
/*
590
* connect_robot - requests the server to connect to the robot
591
* with id = robot_id. In order to talk to the server,
592
* the SERVER_MACHINE_NAME and SERV_TCP_PORT must be
593
* set properly. If a robot with robot_id exists,
594
* a connection is established with that robot. If
595
* no robot exists with robot_id, no connection is
596
* established.
597
*
598
* parameters:
599
* long robot_id -- robot's id. In this multiple robot version, in order
600
* to connect to a robot, you must know it's id.
601
* model -- robot type: 0 = Nomad 200, 1 = Nomad 150, 2 = Scout
602
* *dev -- hostname for TCP, device file for serial ("/dev/" prefix
603
* or ":" suffix means serial)
604
* conn -- TCP port for TCP, baud rate for serial
605
*/
606
int
connect_robot(
long
robot_id, ...);
607
608
/*
609
* disconnect_robot - requests the server to close the connect with robot
610
* with id = robot_id.
611
*
612
* parameters:
613
* long robot_id -- robot's id. In order to disconnect a robot, you
614
* must know it's id.
615
*/
616
int
disconnect_robot(
long
robot_id);
617
618
/*
619
* ac - sets accelerations of the robot. Currently it has no effect in
620
* simulation mode.
621
*
622
* parameters:
623
* int t_ac, s_ac, r_ac -- the translation, steering, and turret
624
* accelerations. t_ac is in 1/10 inch/sec^2
625
* s_ac and r_ac are in 1/10 degree/sec^2.
626
*/
627
int
ac(
int
t_ac,
int
s_ac,
int
r_ac);
628
629
/*
630
* sp - sets speeds of the robot, this function will not cause the robot to
631
* move. However, the set speed will be used when executing a pr()
632
* or a pa().
633
*
634
* parameters:
635
* int t_sp, s_sp, r_sp -- the translation, steering, and turret
636
* speeds. t_sp is in 1/10 inch/sec and
637
* s_sp and r_sp are in 1/10 degree/sec.
638
*/
639
int
sp(
int
t_sp,
int
s_sp,
int
r_sp);
640
641
/*
642
* pr - moves the motors of the robot by a relative distance, using the speeds
643
* set by sp(). The three parameters specify the relative distances for
644
* the three motors: translation, steering, and turret. All the three
645
* motors move concurrently if the speeds are not set to zero and the
646
* distances to be traveled are non-zero. Depending on the timeout
647
* period set (by function conf_tm(timeout)), the motion may
648
* terminate before the robot has moved the specified distances
649
*
650
* parameters:
651
* int t_pr, s_pr, r_pr -- the specified relative distances of the
652
* translation, steering, and turret motors.
653
* t_pr is in 1/10 inch and s_pr and r_pr are
654
* in 1/10 degrees.
655
*/
656
int
pr(
int
t_pr,
int
s_pr,
int
r_pr);
657
658
/*
659
* vm - velocity mode, command the robot to move at translational
660
* velocity = tv, steering velocity = sv, and rotational velocity =
661
* rv. The robot will continue to move at these velocities until
662
* either it receives another command or this command has been
663
* timeout (in which case it will stop its motion).
664
*
665
* parameters:
666
* int t_vm, s_vm, r_vm -- the desired translation, steering, and turret
667
* velocities. tv is in 1/10 inch/sec and
668
* sv and rv are in 1/10 degree/sec.
669
*/
670
int
vm(
int
t_vm,
int
s_vm,
int
r_vm);
671
672
/*
673
* mv - move, send a generalized motion command to the robot.
674
* For each of the three axis (translation, steering, and
675
* turret) a motion mode (t_mode, s_mode, r_mode) can be
676
* specified (using the values MV_IGNORE, MV_AC, MV_SP,
677
* MV_LP, MV_VM, and MV_PR defined above):
678
*
679
* MV_IGNORE : the argument for this axis is ignored
680
* and the axis's motion will remain
681
* unchanged.
682
* MV_AC : the argument for this axis specifies
683
* an acceleration value that will be used
684
* during motion commands.
685
* MV_SP : the argument for this axis specifies
686
* a speed value that will be used during
687
* position relative (PR) commands.
688
* MV_LP : the arguemnt for this axis is ignored
689
* but the motor is turned off.
690
* MV_VM : the argument for this axis specifies
691
* a velocity and the axis will be moved
692
* with this velocity until a new motion
693
* command is issued (vm,pr,mv) or
694
* recieves a timeout.
695
* MV_PR : the argument for this axis specifies
696
* a position and the axis will be moved
697
* to this position, unless this command
698
* is overwritten by another (vm,pr,mv).
699
*
700
* parameters:
701
* int t_mode - the desired mode for the tranlation axis
702
* int t_mv - the value for that axis, velocity or position,
703
* depending on t_mode
704
* int s_mode - the desired mode for the steering axis
705
* int s_mv - the value for that axis, velocity or position,
706
* depending on t_mode
707
* int r_mode - the desired mode for the turret axis
708
* int r_mv - the value for that axis, velocity or position,
709
* depending on t_mode
710
*/
711
int
mv(
int
t_mode,
int
t_mv,
int
s_mode,
int
s_mv,
int
r_mode,
int
r_mv);
712
713
/*
714
* ct - send the sensor mask, Smask, to the robot. You must first change
715
* the global variable Smask to the desired communication mask before
716
* calling this function.
717
*/
718
int
ct(
void
);
719
720
/*
721
* gs - get the current state of the robot according to the mask (of
722
* the communication channel)
723
*/
724
int
gs(
void
);
725
726
/*
727
* st - stops the robot (the robot holds its current position)
728
*/
729
int
st(
void
);
730
731
/*
732
* lp - set motor limp (the robot may not hold its position).
733
*/
734
int
lp(
void
);
735
736
/*
737
* tk - sends the character stream, talk_string, to the voice synthesizer
738
* to make the robot talk.
739
*
740
* parameters:
741
* char *talk_string -- the string to be sent to the synthesizer.
742
*/
743
int
tk(
char
*talk_string);
744
745
/*
746
* dp - define the current position of the robot as (x,y)
747
*
748
* parameters:
749
* int x, y -- the position to set the robot to.
750
*/
751
int
dp(
int
x,
int
y);
752
753
/*
754
* zr - zeroing the robot, align steering and turret with bumper zero.
755
* The position, steering and turret angles are all set to zero.
756
* This function returns when the zeroing process has completed.
757
*/
758
int
zr(
void
);
759
760
/*
761
* conf_ir - configure infrared sensor system.
762
*
763
* parameters:
764
* int history -- specifies the percentage dependency of the current
765
* returned reading on the previous returned reading.
766
* It should be set between 0 and 10: 0 = no dependency
767
* 10 = full dependency, i.e. the reading will not change
768
* int order[16] -- specifies the firing sequence of the infrared
769
* (#0 .. #15). You can terminate the order list by a
770
* "255". For example, if you want to use only the
771
* front three infrared sensors then set order[0]=0,
772
* order[1]=1, order[2]=15, order[3]=255 (terminator).
773
*/
774
int
conf_ir(
int
history,
int
order[16]);
775
776
/*
777
* conf_sn - configure sonar sensor system.
778
*
779
* parameters:
780
* int rate -- specifies the firing rate of the sonar in 4 milli-seconds
781
* interval;
782
* int order[16] -- specifies the firing sequence of the sonar (#0 .. #15).
783
* You can terminate the order list by a "255". For
784
* example, if you want to use only the front three
785
* sensors, then set order[0]=0, order[1]=1, order[2]=15,
786
* order[3]=255 (terminator).
787
*/
788
int
conf_sn(
int
rate,
int
order[16]);
789
790
/*
791
* conf_cp - configure compass system.
792
*
793
* parameters:
794
* int mode -- specifies compass on/off: 0 = off ; 1 = on; 2 = calibrate.
795
* When you call conf_cp (2), the robot will rotate slowly 360
796
* degrees. You must wait till the robot stops rotating before
797
* issuing another command to the robot (takes ~3 minutes).
798
*/
799
int
conf_cp(
int
mode);
800
801
/*
802
* conf_ls - configure laser sensor system:
803
*
804
* parameters:
805
* unsigned int mode -- specifies the on-board processing mode of the laser
806
* sensor data which determines the mode of the data
807
* coming back:
808
* the first bit specifies the on/off;
809
* the second bit specifies point/line mode;
810
* the third to fifth bits specify the
811
* returned data types:
812
* 000 = peak pixel,
813
* 001 = rise pixel,
814
* 010 = fall pixel,
815
* 011 = magnitude,
816
* 100 = distance;
817
* the sixth bit specifies data integrity checking.
818
*
819
* unsigned int threshold -- specifies the inverted acceptable brightness
820
* of the laser line.
821
*
822
* unsigned int width -- specifies the acceptable width in terms
823
* of number of pixels that are brighter than the
824
* set threshold.
825
*
826
* unsigned int num_data -- specifies the number of sampling points.
827
* unsigned int processing -- specifies the number of neighboring
828
* pixels for averaging
829
*
830
* If you don't understand the above, try this one:
831
* conf_ls(51, 20, 20, 20, 4)
832
*/
833
int
conf_ls(
unsigned
int
mode,
834
unsigned
int
threshold,
835
unsigned
int
width,
836
unsigned
int
num_data,
837
unsigned
int
processing);
838
839
/*
840
* conf_tm - sets the timeout period of the robot in seconds. If the
841
* robot has not received a command from the host computer
842
* for more than the timeout period, it will abort its
843
* current motion
844
*
845
* parameters:
846
* unsigned int timeout -- timeout period in seconds. If it is 0, there
847
* will be no timeout on the robot.
848
*/
849
int
conf_tm(
unsigned
char
timeout);
850
851
/*
852
* get_ir - get infrared data, independent of mask. However, only
853
* the active infrared sensor readings are valid. It updates
854
* the State vector.
855
*/
856
int
get_ir(
void
);
857
858
/*
859
* get_sn - get sonar data, independent of mask. However, only
860
* the active sonar sensor readings are valid. It updates
861
* the State vector.
862
*/
863
int
get_sn(
void
);
864
865
/*
866
* get_rc - get robot configuration data (x, y, th, tu), independent of
867
* mask. It updates the State vector.
868
*/
869
int
get_rc(
void
);
870
871
/*
872
* get_rv - get robot velocities (translation, steering, and turret) data,
873
* independent of mask. It updates the State vector.
874
*/
875
int
get_rv(
void
);
876
877
/*
878
* get_ra - get robot acceleration (translation, steering, and turret) data,
879
* independent of mask. It updates the State vector.
880
*/
881
int
get_ra(
void
);
882
883
/*
884
* get_cp - get compass data, independent of mask. However, the
885
* data is valid only if the compass is on. It updates the
886
* State vector.
887
*/
888
int
get_cp(
void
);
889
890
/*
891
* get_ls - get laser data point mode, independent of mask. However the
892
* data is valid only of the laser is on. It updates the Laser
893
* vector.
894
*/
895
int
get_ls(
void
);
896
897
/*
898
* get_bp - get bumper data, independent of mask. It updates the State
899
* vector.
900
*/
901
int
get_bp(
void
);
902
903
/*
904
* conf_sg - configure laser sensor system line segment processing mode:
905
*
906
* parameters:
907
* unsigned int threshold -- specifies the threshold value for least-square
908
* fitting. When the error term grows above the
909
* threshold, the line segment will be broken
910
* unsigned int min_points -- specifies the acceptable number of points
911
* to form a line segment.
912
* unsigned int gap -- specifies the acceptable "gap" between two segments
913
* while they can still be treated as one (in 1/10 inch)
914
*
915
* If you don't understand the above, try this one:
916
* conf_sg(50, 4, 30)
917
*/
918
int
conf_sg(
unsigned
int
threshold,
919
unsigned
int
min_points,
920
unsigned
int
gap);
921
922
/*
923
* get_sg - get laser data line mode, independent of mask. It updates
924
* the laser vector.
925
*/
926
int
get_sg(
void
);
927
928
/*
929
* da - define the current steering angle of the robot to be th
930
* and the current turret angle of the robot to be tu.
931
*
932
* parameters:
933
* int th, tu -- the steering and turret orientations to set the
934
* robot to.
935
*/
936
int
da(
int
th,
int
tu);
937
938
/*
939
* ws - waits for stop of motors of the robot. This function is intended
940
* to be used in conjunction with pr() and pa() to detect the desired
941
* motion has finished
942
*
943
* parameters:
944
* unsigned char t_ws, s_ws, r_ws -- These three parameters specify
945
* which axis or combination of axis
946
* (translation, steering, and turret)
947
* to wait.
948
* unsigned char timeout -- specifies how long to wait before timing out
949
* (return without stopping the robot).
950
*/
951
int
ws(
unsigned
char
t_ws,
unsigned
char
s_ws,
952
unsigned
char
r_ws,
unsigned
char
timeout);
953
954
/*
955
* get_rpx - get the position of all nearby robots
956
*/
957
int
get_rpx(
long
*robot_pos);
958
959
/*****************************
960
* *
961
* World Interface Functions *
962
* *
963
*****************************/
964
965
/*
966
* add_obstacle - creates an obstacle and adds it to the obstacle list
967
* of the robot environment.
968
*
969
* No effect in direct mode.
970
*
971
* parameters:
972
* long obs[2*MAX_VERTICES+1] --
973
* The first element of obs specifies the number of
974
* vertices of the polygonal obstacle (must be no greater
975
* than MAX_VERTICES). The subsequent elements of obs
976
* specifies the x and y coordinates of the vertices,
977
* in counter-clockwise direction.
978
*/
979
int
add_obstacle(
long
obs[2*MAX_VERTICES+1]);
980
981
/*
982
* add_Obs - is the same as add_obstacle, for backward compatibility
983
*/
984
int
add_Obs(
long
obs[2*MAX_VERTICES+1]);
985
986
987
/*
988
* delete_obstacle - deletes an obstacle specified by obs from the robot
989
* environment
990
* parameters:
991
* long obs[2*MAX_VERTICES+1] --
992
* The first element of obs specifies the number of
993
* vertices of the polygonal obstacle (must be no greater
994
* than MAX_VERTICES). The subsequent elements of obs
995
* specifies the x and y coordinates of the vertices,
996
* in counter-clockwise direction.
997
*/
998
int
delete_obstacle(
long
obs[2*MAX_VERTICES+1]);
999
1000
/*
1001
* delete_Obs - is the same as delete_obstacle, for backward compatibility
1002
*/
1003
int
delete_Obs(
long
obs[2*MAX_VERTICES+1]);
1004
1005
/*
1006
* move_obstacle - moves the obstacle obs by dx along x direction and
1007
* dy along y direction. obs is modified.
1008
*
1009
* No effect in direct mode.
1010
*
1011
* parameters:
1012
* long obs[2*MAX_VERTICES+1] --
1013
* The first element of obs specifies the number of
1014
* vertices of the polygonal obstacle (must be no greater
1015
* than MAX_VERTICES). The subsequent elements of obs
1016
* specifies the x and y coordinates of the vertices,
1017
* in counter-clockwise direction.
1018
* long dx, dy -- the x and y distances to translate the obstacle
1019
*/
1020
int
move_obstacle(
long
obs[2*MAX_VERTICES+1],
long
dx,
long
dy);
1021
1022
/*
1023
* move_Obs - is the same as move_obstacle, for backward compatibility
1024
*
1025
* No effect in direct mode.
1026
*
1027
*/
1028
int
move_Obs(
long
obs[2*MAX_VERTICES+1],
long
dx,
long
dy);
1029
1030
/*
1031
* new_world - deletes all obstacles in the current robot world
1032
*
1033
* No effect in direct mode.
1034
*
1035
*/
1036
int
new_world(
void
);
1037
1038
/****************************
1039
* *
1040
* Graphics refresh control *
1041
* *
1042
****************************/
1043
1044
/*
1045
* refresh_all - causes all temporary drawing in graphics window, including
1046
* traces, sensors, and client graphics to be erased
1047
*/
1048
int
refresh_all(
void
);
1049
1050
/*
1051
* refresh_all_traces - causes all robot traces in graphics to be erased
1052
*/
1053
int
refresh_all_traces(
void
);
1054
1055
/*
1056
* refresh_actual_trace - causes actual robot trace in graphics to be erased
1057
*/
1058
int
refresh_actual_trace(
void
);
1059
1060
/*
1061
* refresh_encoder_trace - causes encoder robot trace in graphics to be erased
1062
*/
1063
int
refresh_encoder_trace(
void
);
1064
1065
/*
1066
* refresh_all_sensors - causes all sensor drawings in graphics to be erased
1067
*/
1068
int
refresh_all_sensors(
void
);
1069
1070
/*
1071
* refresh_bumper_sensor - causes bumper drawings in graphics to be erased
1072
*/
1073
int
refresh_bumper_sensor(
void
);
1074
1075
/*
1076
* refresh_infrared_sensor - causes infrared drawings in graphics to be erased
1077
*/
1078
int
refresh_infrared_sensor(
void
);
1079
1080
/*
1081
* refresh_sonar_sensor - causes sonar drawings in graphics to be erased
1082
*/
1083
int
refresh_sonar_sensor(
void
);
1084
1085
/*
1086
* refresh_laser_sensor - causes laser drawings in graphics to be erased
1087
*/
1088
int
refresh_laser_sensor(
void
);
1089
1090
/*
1091
* refresh_client_graphics - causes drawings performed by any clients into
1092
* graphics window to be erased
1093
*/
1094
int
refresh_client_graphics(
void
);
1095
1096
/*******************************
1097
* *
1098
* Miscellaneous robot control *
1099
* *
1100
*******************************/
1101
1102
/*
1103
* init_mask - initialize the sensor mask, Smask.
1104
*/
1105
void
init_mask(
void
);
1106
1107
/*
1108
* init_sensors - initialize the sensor mask, Smask, and send it to the
1109
* robot. It has no effect on the sensors
1110
*/
1111
int
init_sensors(
void
);
1112
1113
/*
1114
* place_robot - places the robot at configuration (x, y, th, tu).
1115
* In simulation mode, it will place both the Encoder-robot
1116
* and the Actual-robot at this configuration. In real robot
1117
* mode, it will call dp(x, y) and da(th, tu).
1118
*
1119
* parameters:
1120
* int x, y -- x-y position of the desired robot configuration
1121
* int th, tu -- the steering and turret orientation of the robot
1122
* desired configuration
1123
*/
1124
int
place_robot(
int
x,
int
y,
int
th,
int
tu);
1125
1126
/*
1127
* special_request - sends a special request (stored in user_send_buffer)
1128
* to the robot and waits for the robot's response (which
1129
* will be stored in user_receive_buffer).
1130
*
1131
* parameters:
1132
* unsigned char *user_send_buffer -- stores data to be sent to the robot
1133
* Should be a pointer to an array of
1134
* 1024 elements
1135
* unsigned char *user_receive_buffer -- stores data received from the robot
1136
* Should be a pointer to an array of
1137
* 1024 elements
1138
*/
1139
int
special_request(
unsigned
char
*user_send_buffer,
1140
unsigned
char
*user_receive_buffer);
1141
1142
/*******************************
1143
* *
1144
* Graphic Interface Functions *
1145
* *
1146
*******************************/
1147
1148
/*
1149
* draw_robot - this function allows the client to draw a robot at
1150
* configuration x, y, th, tu (using the robot world
1151
* coordinates).
1152
*
1153
* No effect in direct mode.
1154
*
1155
* parameters:
1156
* long x, y -- the x-y position of the robot.
1157
* int th, tu -- the steering and turret orientation of the robot
1158
* int mode - the drawing mode. If mode = 1, the robot is drawn in
1159
* BlackPixel using GXxor (using GXxor you can erase the trace
1160
* of robotby drawing over it). If mode = 2, the robot is
1161
* drawn in BlackPixel using GXxor and in addition, a small arrow
1162
* is drawn at the center of the robot using GXcopy (using this
1163
* mode you can leave a trace of small arrow). If mode = 3,
1164
* the robot is drawn in BlackPixel using GXcopy. When mode > 3,
1165
* the robot is drawn in color (GXxor) using color(mode-3), see
1166
* Color table below.
1167
*/
1168
int
draw_robot(
long
x,
long
y,
int
th,
int
tu,
int
mode);
1169
1170
1171
/*
1172
* draw_line - this function allows the client to draw a line from
1173
* (x_1, y_1) to (x_2, y_2) (using the robot world coordinates).
1174
*
1175
* No effect in direct mode.
1176
*
1177
* parameters:
1178
* long x_1, y_1, x_2, y_2 -- the two end-points of the line
1179
* int mode -- the mode of drawing: when mode is 1, the drawing is
1180
* done in BlackPixel using GXcopy; when mode is 2, the drawing
1181
* is done in BlackPixel using GXxor, when mode > 2, the drawing
1182
* is done in color (GXxor) using color(mode-2), see Color table
1183
* below.
1184
*/
1185
int
draw_line(
long
x_1,
long
y_1,
long
x_2,
long
y_2,
int
mode);
1186
1187
1188
/*
1189
* draw_arc - this function allows the client to draw arc which is part
1190
* of an ellipse (using the robot world coordinates).
1191
*
1192
* No effect in direct mode.
1193
*
1194
* parameters:
1195
* long x_0, y_0, w, h -- (x_0, y_0) specifies the upper left corner of the
1196
* rectangle bounding the ellipse while w and h
1197
* specifies the width and height of the bounding
1198
* rectangle, respectively.
1199
* int th1, th2 -- th1 and th2 specifies the angular range of the arc.
1200
* int mode -- the mode of drawing: when mode is 1, the drawing is
1201
* done in BlackPixel using GXcopy; when mode is 2, the drawing
1202
* is done in BlackPixel using GXxor, when mode > 2, the drawing
1203
* is done in color (GXxor) using color(mode-2), see Color table
1204
* below.
1205
*/
1206
int
draw_arc(
long
x_0,
long
y_0,
long
w,
long
h,
int
th1,
int
th2,
int
mode);
1207
1208
/*
1209
* Color table:
1210
* color1 = Blue
1211
* color2 = NavyBlue
1212
* color3 = RoyalBlue
1213
* color4 = SteelBlue
1214
* color5 = CadetBlue
1215
* color6 = Green
1216
* color7 = SeaGreen
1217
* color8 = ForestGreen
1218
* color9 = DarkGreen
1219
* color10 = LimeGreen
1220
* color11 = Yellow
1221
* color12 = Orange
1222
* color13 = LightCoral
1223
* color14 = DeepPink
1224
* color15 = OrangeRed
1225
* color16 = Red
1226
* color17 = IndianRed
1227
* color18 = VioletRed
1228
* color19 = DeepPink
1229
* color20 = Maroon
1230
*/
1231
1232
/*************************************
1233
* *
1234
* Miscellaneous Interface Functions *
1235
* *
1236
*************************************/
1237
1238
/*
1239
* server_is_running - this function queries the server to see
1240
* if it is up and running. If so, this function
1241
* returns a TRUE, otherwise it returns FALSE.
1242
* This function is replaced by connect_robot, but
1243
* is defined here for backward compatibility
1244
*
1245
* No effect in direct mode.
1246
*
1247
*/
1248
int
server_is_running(
void
);
1249
1250
/*
1251
* quit_server - this function allows the client to quit the server
1252
* assuming this feature is enabled in the setup file
1253
* of the server
1254
*
1255
* No effect in direct mode.
1256
*
1257
*/
1258
int
quit_server(
void
);
1259
1260
/*
1261
* real_robot - this function allows the client to switch to
1262
* real robot mode in the server
1263
*
1264
* No effect in direct mode.
1265
*
1266
*/
1267
int
real_robot(
void
);
1268
1269
/*
1270
* simulated_robot - this function allows the client to switch to
1271
* simulated robot mode in the server
1272
*
1273
* No effect in direct mode.
1274
*
1275
*/
1276
int
simulated_robot(
void
);
1277
1278
/*
1279
* predict_sensors - this function predicts the sensor reading of
1280
* the robot assuming it is at position (x, y)
1281
* and orientation th and tu using the map of the
1282
* simulated robot environment. The predicted sensor
1283
* data values are stored in "state" and "laser".
1284
*
1285
* No effect in direct mode.
1286
*
1287
* parameters:
1288
* int x, y, th, tu -- the configuration of the robot
1289
* long *state -- where to put the predicted state data
1290
* int *laser -- where to put the predicted laser data
1291
*/
1292
int
predict_sensors(
int
x,
int
y,
int
th,
int
tu,
long
*state,
int
*laser);
1293
1294
/*
1295
* motion_check - this function computes the intersection of a path
1296
* specified by the parameters: type, a1, ..., a7 with
1297
* the obstacles in the robot's environment. If there is
1298
* collision, the function returns 1 and the x-y configuration
1299
* of the robot is stored in collide[0] and collide[1] while
1300
* collide[2] stores the inward normal of the obstacle edge
1301
* that the robot collides with (this information can be
1302
* used to calculate which bumper is hit.). If there is no
1303
* collision, the function returns 0.
1304
*
1305
* No effect in direct mode.
1306
*
1307
* parameters:
1308
* long type - 0 if the path is a line segment
1309
* 1 if the path is an arc of circle
1310
* double a1 a2 - x-y coordinates of the first point of the path (the path
1311
* is directional).
1312
* depending on the value of type, a3 - a7 have different meanings.
1313
* if (type == 0), line segment mode
1314
* double a3 a4 are the x-y coordinates of the second point of the path
1315
* a5, a6, a7 have no meaning
1316
* if (type == 1), arc of circle mode
1317
* double a3 is the angle (in radiance) of the vector connecting the
1318
* center of the circle to the first end-point of the arc
1319
* double a4 is the angle of the vector connecting the center
1320
* of the circle to the second end-point of the arc
1321
* double a5 is the radius of the circle
1322
* double a6 a7 are the x-y coordinate of the center of the circle
1323
*/
1324
int
motion_check(
long
type,
double
a1,
double
a2,
double
a3,
double
a4,
1325
double
a5,
double
a6,
double
a7,
double
collide[3]);
1326
1327
/*
1328
* get_robot_conf - interactively getting the robot's conf, by clicking
1329
* the mouse in the server's Robot window
1330
*
1331
* No effect in direct mode.
1332
*
1333
* parameters:
1334
* long *conf -- should be an array of 4 long integers. The configuration
1335
* of the robot is returned in this array.
1336
*/
1337
int
get_robot_conf(
long
*conf);
1338
1339
/*******************************************
1340
* *
1341
* The following are helper functions for *
1342
* developing user defined host <-> robot *
1343
* communication *
1344
* *
1345
*******************************************/
1346
1347
/*
1348
* init_receive_buffer - sets the index to 4 which is the point
1349
* at which data should begin to be extracted
1350
*
1351
* parameters:
1352
* unsigned short *index -- is the buffer index
1353
*/
1354
int
init_receive_buffer(
unsigned
short
*index);
1355
1356
/*
1357
* extract_receive_buffer_header - extracts the header information:
1358
* length, serial_number, and packettype from the beginning of the
1359
* receive buffer.
1360
*
1361
* parameters:
1362
* short *length -- is the returns the number of chars in the buffer
1363
*
1364
* unsigned char *serial_number -- returns the serial number to be
1365
* assigned to the packet
1366
* unsigned char *packet_type -- returns the type number to be
1367
* assigned to the packet
1368
* unsigned char *buffer -- is the receive buffer
1369
*/
1370
int
extract_receive_buffer_header(
unsigned
short
*length,
1371
unsigned
char
*serial_number,
1372
unsigned
char
*packet_type,
1373
unsigned
char
*buffer);
1374
1375
/*
1376
* init_send_buffer - sets the index to 4 which is the point
1377
* at which data should be inserted
1378
*
1379
* parameters:
1380
* unsigned short *index -- is the buffer index
1381
*/
1382
int
init_send_buffer(
unsigned
short
*index);
1383
1384
/*
1385
* stuff_send_buffer_header - loads the header information,
1386
* length,serial_number, and packettype into the beginning of the
1387
* buffer. It should be called after the data has been stuffed,
1388
* i.e. index represents the length of the packet.
1389
*
1390
* parameters:
1391
* int index -- is the buffer index which holds the number of chars
1392
* in the buffer
1393
* unsigned char serial_number -- holds the serial number to be
1394
* assigned to the packet
1395
* unsigned char packet_type -- holds the type number to be
1396
* assigned to the packet
1397
*
1398
* unsigned char *buffer -- is the send buffer
1399
*/
1400
int
stuff_send_buffer_header(
unsigned
short
index,
unsigned
char
serial_number,
1401
unsigned
char
packet_type,
unsigned
char
*buffer);
1402
1403
/*
1404
* stuffchar - stuffs a 1 byte char into the send buffer
1405
*
1406
* parameters:
1407
* signed char data -- is the char to be stuffed
1408
* unsigned char *buffer -- is the send buffer
1409
* unsigned short *index -- is the buffer index which will be incremented
1410
* to reflect the bytes stuffed into the buffer
1411
*/
1412
int
stuffchar(
signed
char
data,
unsigned
char
*buffer,
unsigned
short
*index);
1413
1414
/*
1415
* stuff2byteint - stuffs a short int(2 bytes) into the send buffer
1416
*
1417
* parameters:
1418
* signed int data -- is the value which will be split apart and stuffed
1419
* bytewise into the send buffer
1420
* unsigned char *buffer -- is the send buffer
1421
* unsigned short *index -- is the buffer index which will be incremented
1422
* to reflect the bytes stuffed into the buffer
1423
*/
1424
int
stuff2byteint(
signed
short
data,
1425
unsigned
char
*buffer,
unsigned
short
*index);
1426
1427
/*
1428
* stuff4byteint - stuffs a long int(4 bytes) into the send buffer
1429
*
1430
* parameters:
1431
* signed long data -- is the value which will be split apart and stuffed
1432
* bytewise into the send buffer
1433
* unsigned char *buffer -- is the send buffer
1434
* unsigned short *index -- is the buffer index which will be incremented
1435
* to reflect the bytes stuffed into the buffer
1436
*/
1437
int
stuff4byteint(
signed
long
data,
1438
unsigned
char
*buffer,
unsigned
short
*index);
1439
1440
/*
1441
* stuffuchar - stuffs an unsigned char into the send buffer
1442
*
1443
* parameters:
1444
* unsigned char data -- is the char to be stuffed
1445
* unsigned char *buffer -- is the send buffer
1446
* unsigned short *index -- is the buffer index which will be incremented
1447
* to reflect the bytes stuffed into the buffer
1448
*/
1449
int
stuffuchar(
unsigned
char
data,
1450
unsigned
char
*buffer,
unsigned
short
*index);
1451
1452
/*
1453
* stuff2byteuint - stuffs an unsigned short int(2 bytes) into the send buffer
1454
*
1455
* parameters:
1456
* unsigned short data -- is the value which will be split apart and
1457
* stuffed bytewise into the send buffer
1458
* unsigned char *buffer -- is the send buffer
1459
* unsigned short *index -- is the buffer index which will be incremented
1460
* to reflect the bytes stuffed into the buffer
1461
*/
1462
int
stuff2byteuint(
unsigned
short
data,
unsigned
char
*buffer,
unsigned
short
*index);
1463
1464
/*
1465
* stuff4byteuint - stuffs an unsigned long int(4 bytes) into the send buffer
1466
*
1467
* parameters:
1468
* unsigned long data -- is the value which will be split apart and stuffed
1469
* bytewise into the send buffer
1470
* unsigned char *buffer -- is the send buffer
1471
* unsigned short *index -- is the buffer index which will be incremented
1472
* to reflect the bytes stuffed into the buffer
1473
*/
1474
int
stuff4byteuint(
unsigned
long
data,
unsigned
char
*buffer,
unsigned
short
*index);
1475
1476
/*
1477
* stuffdouble - stuffs a double(8 bytes) into the send buffer
1478
*
1479
* parameters:
1480
* double data -- is the value which will be split apart and stuffed
1481
* bytewise into the send buffer
1482
* unsigned char *buffer -- is the send buffer
1483
* unsigned short *index -- is the buffer index which will be incremented
1484
* to reflect the bytes stuffed into the buffer
1485
*/
1486
int
stuffdouble(
double
data,
unsigned
char
*buffer,
unsigned
short
*index);
1487
1488
/*
1489
* extractchar - extracts a char from the receive buffer
1490
*
1491
* parameters:
1492
* unsigned char *buffer -- is the receive buffer which holds the data
1493
* unsigned short *index -- is the receive buffer index which will be
1494
* incremented to reflect the position of the
1495
* next piece of data to be extracted
1496
*/
1497
signed
char
extractchar(
unsigned
char
*buffer,
unsigned
short
*index);
1498
1499
/*
1500
* extract2byteint - extracts a short int(2 bytes) from the receive buffer
1501
*
1502
* parameters:
1503
* unsigned char *buffer -- is the receive buffer which holds the data
1504
* unsigned short *index -- is the receive buffer index which will be
1505
* incremented to reflect the position of the
1506
* next piece of data to be extracted
1507
*/
1508
signed
short
extract2byteint(
unsigned
char
*buffer,
unsigned
short
*index);
1509
1510
/*
1511
* extract4byteint - extracts a long int(4 bytes) from the receive buffer
1512
*
1513
* parameters:
1514
* unsigned char *buffer -- is the receive buffer which holds the data
1515
* unsigned short *index -- is the receive buffer index which will be
1516
* incremented to reflect the position of the
1517
* next piece of data to be extracted
1518
*/
1519
signed
long
extract4byteint(
unsigned
char
*buffer,
unsigned
short
*index);
1520
1521
/*
1522
* extractuchar - extracts an unsigned char from the receive buffer
1523
*
1524
* parameters:
1525
* unsigned char *buffer -- is the receive buffer which holds the data
1526
* unsigned short *index -- is the receive buffer index which will be
1527
* incremented to reflect the position of the
1528
* next piece of data to be extracted
1529
*/
1530
unsigned
char
extractuchar(
unsigned
char
*buffer,
unsigned
short
*index);
1531
1532
/*
1533
* extract2byteuint - extracts an unsigned short int(2 bytes) from the
1534
* receive buffer
1535
*
1536
* parameters:
1537
* unsigned char *buffer -- is the receive buffer which holds the data
1538
* unsigned short *index -- is the receive buffer index which will be
1539
* incremented to reflect the position of the
1540
* next piece of data to be extracted
1541
*/
1542
unsigned
short
extract2byteuint(
unsigned
char
*buffer,
unsigned
short
*index);
1543
1544
/*
1545
* extract4byteuint - extracts an unsigned long int(4 bytes) from the
1546
* receive buffer
1547
*
1548
* parameters:
1549
* unsigned char *buffer -- is the receive buffer which holds the data
1550
* unsigned short *index -- is the receive buffer index which will be
1551
* incremented to reflect the position of the
1552
* next piece of data to be extracted
1553
*/
1554
unsigned
long
extract4byteuint(
unsigned
char
*buffer,
unsigned
short
*index);
1555
1556
/*
1557
* extractdouble - extracts a double(8 bytes) from the receive buffer
1558
*
1559
* parameters:
1560
* unsigned char *buffer -- is the receive buffer which holds the data
1561
* unsigned short *index -- is the receive buffer index which will be
1562
* incremented to reflect the position of the
1563
* next piece of data to be extracted
1564
*/
1565
double
extractdouble(
unsigned
char
*buffer,
unsigned
short
*index);
1566
1567
/************************************************
1568
* *
1569
* Global variable access functions for Allegro *
1570
* Common Lisp interface *
1571
* *
1572
************************************************/
1573
1574
int
get_state(
long
state[NUM_STATE]);
1575
1576
int
get_laser(
int
laser[2*NUM_LASER+1]);
1577
1578
int
get_mask(
int
mask[NUM_MASK]);
1579
1580
int
set_mask(
int
mask[NUM_MASK]);
1581
1582
int
set_server_machine_name(
char
*sname);
1583
1584
int
set_serv_tcp_port(
int
port);
1585
1586
1587
/*************************************************
1588
* *
1589
* Functions for the attachment of position *
1590
* data to sensory readings. *
1591
* *
1592
*************************************************/
1593
1594
/***************
1595
* FUNCTION: posDataRequest
1596
* PURPOSE: request position information for sensors
1597
* ARGUMENTS: int posRequest :
1598
* The argument of this function specifies the sensors
1599
* for which the position information (PosData) should
1600
* be attached to the sensory reading.
1601
* Its value is obtained by ORing the desired defines.
1602
* EXAMPLE: To attach PosData to sonars and laser:
1603
* posDataRequest ( POS_SONAR | POS_LASER );
1604
* ALGORITHM: currently sets the global variable Smask[0] and
1605
* then calls ct() to transmit the change to the server
1606
* RETURN: TRUE if the argument was correct, else FALSE
1607
* SIDE EFFECT: Smask[0]
1608
* CALLS:
1609
* CALLED BY:
1610
***************/
1611
int
posDataRequest (
int
posRequest );
1612
1613
1614
/***************
1615
* FUNCTION: posDataCheck
1616
* PURPOSE: return the sensors for which the PosData attachment
1617
* is currently requested.
1618
* ARGUMENTS: None
1619
* ALGORITHM: returns the usedSmask that is not globally accessible
1620
* (is set by ct() to be the value of Smask[0])
1621
* RETURN: int, see posDataRequest
1622
* the macros POS_*_P can be used to examine the value
1623
* SIDE EFFECT:
1624
* CALLS:
1625
* CALLED BY:
1626
***************/
1627
int
posDataCheck (
void
);
1628
1629
1630
/***************
1631
* FUNCTION: posInfraredRingGet
1632
* PURPOSE: copy the PosData for all infrareds to accessible memory
1633
* ARGUMENTS: PosData posData [INFRAREDS] :
1634
* an array of PosData structures that is filled with
1635
* PosData. The position information for each infrared
1636
* containts the configuration of the robot at the time
1637
* of the sensory reading and a timestamp for the
1638
* configuration and the senosry reading .
1639
* ALGORITHM: copies blocks of memory
1640
* RETURN: int, return always TRUE
1641
* SIDE EFFECT:
1642
* CALLS:
1643
* CALLED BY:
1644
***************/
1645
int
posInfraredRingGet (
PosData
posData[INFRAREDS] );
1646
1647
1648
/***************
1649
* FUNCTION: posInfraredGet
1650
* PURPOSE: copy the PosData for a specific infrared to accessible
1651
* memory
1652
* ARGUMENTS: PosData *posData : the memory location that the information
1653
* will be copied to
1654
* int infraredNumber : the number of the infrared
1655
* ALGORITHM: copies block of memory
1656
* RETURN: int, always returns TRUE
1657
* SIDE EFFECT:
1658
* CALLS:
1659
* CALLED BY:
1660
***************/
1661
int
posInfraredGet (
PosData
*posData ,
int
infraredNumber );
1662
1663
1664
/***************
1665
* FUNCTION: posSonarRingGet
1666
* PURPOSE: copy the PosData for all sonars to accessible memory
1667
* ARGUMENTS: PosData posData [SONARS] :
1668
* an array of PosData structures that is filled with
1669
* PosData. The position information for each sonar
1670
* containts the configuration of the robot at the time
1671
* of the sensory reading and a timestamp for the
1672
* configuration and the senosry reading .
1673
* ALGORITHM: copies blocks of memory
1674
* RETURN: int, return always TRUE
1675
* SIDE EFFECT:
1676
* CALLS:
1677
* CALLED BY:
1678
***************/
1679
int
posSonarRingGet (
PosData
posData[SONARS] );
1680
1681
1682
/***************
1683
* FUNCTION: posSonarGet
1684
* PURPOSE: copy the PosData for a specific sonar to accessible memory
1685
* ARGUMENTS: PosData *posData : the memory location that the information
1686
* will be copied to
1687
* int sonarNumber : the number of the sonar
1688
* ALGORITHM: copies block of memory
1689
* RETURN: int, always returns TRUE
1690
* SIDE EFFECT:
1691
* CALLS:
1692
* CALLED BY:
1693
***************/
1694
int
posSonarGet (
PosData
*posData ,
int
sonarNumber );
1695
1696
1697
/***************
1698
* FUNCTION: posBumperGet
1699
* PURPOSE: copy PosData for the bumper to accessible memory
1700
* ARGUMENTS: PosData *posData : where the data is copied to
1701
* ALGORITHM: copies a block of memory
1702
* RETURN: int, always returns TRUE
1703
* SIDE EFFECT:
1704
* CALLS:
1705
* CALLED BY:
1706
* NOTE: The bumper differs from other sensors in that the
1707
* posData is only updated after one of the bumper sensors
1708
* change its value from zero to one. This means that the
1709
* posData for the bumper always contains the position and
1710
* timeStamps of the latest hit, or undefined information
1711
* if the bumper was not hit yet.
1712
***************/
1713
int
posBumperGet (
PosData
*posData );
1714
1715
1716
/***************
1717
* FUNCTION: posLaserGet
1718
* PURPOSE: copy PosData for the laser to accessible memory
1719
* ARGUMENTS: PosData *posData : where the data is copied to
1720
* ALGORITHM: copies a block of memory
1721
* RETURN: int, always returns TRUE
1722
* SIDE EFFECT:
1723
* CALLS:
1724
* CALLED BY:
1725
* NOTE: The laser is updated at a frequency of 30Hz.
1726
***************/
1727
int
posLaserGet (
PosData
*posData );
1728
1729
1730
/***************
1731
* FUNCTION: posCompassGet
1732
* PURPOSE: copy PosData for the compass to accessible memory
1733
* ARGUMENTS: PosData *posData : where the data is copied to
1734
* ALGORITHM: copies a block of memory
1735
* RETURN: int, always returns TRUE
1736
* SIDE EFFECT:
1737
* CALLS:
1738
* CALLED BY:
1739
* NOTE: The compass is updated ad a frequency of 10Hz.
1740
***************/
1741
int
posCompassGet (
PosData
*posData );
1742
1743
1744
/***************
1745
* FUNCTION: posTimeGet
1746
* PURPOSE: get the PosData time (Intellisys 100) in milliseconds
1747
* ARGUMENTS: None
1748
* ALGORITHM: ---
1749
* RETURN: int
1750
* SIDE EFFECT:
1751
* CALLS:
1752
* CALLED BY:
1753
* NOTE: The resolution of this timer is 16.4 milliseconds;
1754
* the timer starts out at zero when the system is
1755
* turned on and will flow over after 49 days.
1756
***************/
1757
int
posTimeGet (
void
);
1758
1759
1760
/*************************************************
1761
* *
1762
* Functions to determine the charge level *
1763
* of the batteries for the cpu and the motors. *
1764
* *
1765
*************************************************/
1766
1767
/***************
1768
* FUNCTION: voltCpuGet
1769
* PURPOSE: get the voltage of the power supply for the CPU
1770
* ARGUMENTS: None
1771
* ALGORITHM: ---
1772
* RETURN: float (the voltage in volt)
1773
* SIDE EFFECT:
1774
* CALLS:
1775
* CALLED BY:
1776
* NOTE: This should never drop below 10.8 volts.
1777
***************/
1778
float
voltCpuGet (
void
);
1779
1780
1781
/***************
1782
* FUNCTION: voltMotorGet
1783
* PURPOSE: get the voltage of the power supply for the motors
1784
* ARGUMENTS: None
1785
* ALGORITHM: ---
1786
* RETURN: float (the voltage in volt)
1787
* SIDE EFFECT:
1788
* CALLS:
1789
* CALLED BY:
1790
* NOTE: This should never drop below 10.8 volts.
1791
* Returns average of the two motor batteries.
1792
***************/
1793
float
voltMotorGet (
void
);
1794
1795
#ifdef __cplusplus
1796
}
1797
#endif
1798
1799
#endif
/* _HOST_CLIENT_NCLIENT_H_ */
_ConfigData
Definition
Nclient.h:347
_PosData
Definition
Nclient.h:371
reply_struct
Definition
Nclient.h:422
request_struct
Definition
Nclient.h:415
double_union
Definition
Nclient.h:383
long_union
Definition
Nclient.h:389
short_union
Definition
Nclient.h:396
ulong_union
Definition
Nclient.h:408
ushort_union
Definition
Nclient.h:402
Generated on Thu Jul 25 2024 00:00:00 for Player by
1.12.0