⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nclient.h

📁 一个多机器人的仿真平台
💻 H
📖 第 1 页 / 共 4 页
字号:
/* * Nclient.h * * Interface file for direct connections to the robot or for * connections to Nserver. *  * Copyright 1993,94,95, Nomadic Technologies, Inc. * *//* $Header: /home/trb/teambots/src/EDU/gatech/cc/is/nomad150/RCS/Nclient.h,v 1.1 1999/11/14 00:12:54 trb Exp $ */#ifndef _HOST_CLIENT_NCLIENT_H_#define _HOST_CLIENT_NCLIENT_H_#ifdef __cplusplusextern "C" {#endif/* constants */#ifndef FALSE#define FALSE			0#endif#ifndef TRUE#define TRUE			1#endif#define MAX_VERTICES     10#define NUM_STATE        45#define NUM_MASK         44 #define NUM_LASER        482 #define BUFSIZE          4096#define MAX_USER_BUF     0xFFFF/* the number of sonars and infrareds */#define SONARS           16#define INFRAREDS        16/* * The following defines allow you to access the State vector in a  * more readable way. */#define STATE_SIM_SPEED            0#define STATE_IR_0                 1#define STATE_IR_1                 2#define STATE_IR_2                 3#define STATE_IR_3                 4#define STATE_IR_4                 5#define STATE_IR_5                 6#define STATE_IR_6                 7#define STATE_IR_7                 8#define STATE_IR_8                 9#define STATE_IR_9                 10#define STATE_IR_10                11#define STATE_IR_11                12#define STATE_IR_12                13#define STATE_IR_13                14#define STATE_IR_14                15#define STATE_IR_15                16#define STATE_SONAR_0              17#define STATE_SONAR_1              18#define STATE_SONAR_2              19#define STATE_SONAR_3              20#define STATE_SONAR_4              21#define STATE_SONAR_5              22#define STATE_SONAR_6              23#define STATE_SONAR_7              24#define STATE_SONAR_8              25#define STATE_SONAR_9              26#define STATE_SONAR_10             27#define STATE_SONAR_11             28#define STATE_SONAR_12             29#define STATE_SONAR_13             30#define STATE_SONAR_14             31#define STATE_SONAR_15             32 #define STATE_BUMPER               33#define STATE_CONF_X               34#define STATE_CONF_Y               35#define STATE_CONF_STEER           36#define STATE_CONF_TURRET          37#define STATE_VEL_TRANS            38#define STATE_VEL_STEER            39#define STATE_VEL_TURRET           40#define STATE_MOTOR_STATUS         41#define STATE_LASER                42#define STATE_COMPASS              43#define STATE_ERROR                44/* * The following defines allow you to access the Smask vector in a  * more readable way. */#define SMASK_POS_DATA             0#define SMASK_IR_1                 1#define SMASK_IR_2                 2#define SMASK_IR_3                 3#define SMASK_IR_4                 4#define SMASK_IR_5                 5#define SMASK_IR_6                 6#define SMASK_IR_7                 7#define SMASK_IR_8                 8#define SMASK_IR_9                 9#define SMASK_IR_10                10#define SMASK_IR_11                11#define SMASK_IR_12                12#define SMASK_IR_13                13#define SMASK_IR_14                14#define SMASK_IR_15                15#define SMASK_IR_16                16#define SMASK_SONAR_1              17#define SMASK_SONAR_2              18#define SMASK_SONAR_3              19#define SMASK_SONAR_4              20#define SMASK_SONAR_5              21#define SMASK_SONAR_6              22#define SMASK_SONAR_7              23#define SMASK_SONAR_8              24#define SMASK_SONAR_9              25#define SMASK_SONAR_10             26#define SMASK_SONAR_11             27#define SMASK_SONAR_12             28#define SMASK_SONAR_13             29#define SMASK_SONAR_14             30#define SMASK_SONAR_15             31#define SMASK_SONAR_16             32 #define SMASK_BUMPER               33#define SMASK_CONF_X               34#define SMASK_CONF_Y               35#define SMASK_CONF_STEER           36#define SMASK_CONF_TURRET          37#define SMASK_VEL_TRANS            38#define SMASK_VEL_STEER            39#define SMASK_VEL_TURRET           40#define SMASK_RESERVED             41#define SMASK_LASER                42#define SMASK_COMPASS              43/* * These defines are used for specifying the control modes in the * robot motion command 'mv'. If MV_IGNORE is specified for an axis * the current motion command for it will remain active. Specifying * MV_VM or MV_PR will select velocity and position control as in  * the vm and pr robot motion commands  */#define MV_IGNORE 0#define MV_VM     1#define MV_PR     2#define MV_LP     3#define MV_AC     4#define MV_SP     5#define MV_PWM_LOW_0   10#define MV_PWM_HIGH_0  11#define MV_PWM_LOW_1   12#define MV_PWM_HIGH_1  13#define MV_PWM_LOW_2   14#define MV_PWM_HIGH_2  15#define MV_PWM_LOW_3   16#define MV_PWM_HIGH_3  17/* * For requesting the PosData the following defines should be used. * Each sensor has a bit, if it is set the pos-data is attached * when the sensory data is returned. */#define POS_NONE          ( 0 << 0 )#define POS_INFRARED      ( 1 << 0 )#define POS_SONAR         ( 1 << 1 )#define POS_BUMPER        ( 1 << 2 )#define POS_LASER         ( 1 << 3 )#define POS_COMPASS       ( 1 << 4 )/*  * these macros enable the user to determine if the pos-attachment * is requested for a specific sensor. 1 is returned if the  * attachment is requested, 0 otherwise *  * Note that the function posDataCheck() is called (see below) */#define POS_INFRARED_P  ( ( (posDataCheck()) & POS_INFRARED ) ? 1 : 0 )#define POS_SONAR_P     ( ( (posDataCheck()) & POS_SONAR    ) ? 1 : 0 )#define POS_BUMPER_P    ( ( (posDataCheck()) & POS_BUMPER   ) ? 1 : 0 )#define POS_LASER_P     ( ( (posDataCheck()) & POS_LASER    ) ? 1 : 0 )#define POS_COMPASS_P   ( ( (posDataCheck()) & POS_COMPASS  ) ? 1 : 0 )/* * The user will be able to call a function that fills out a  * list of position data for a specific sensor reading.  * To access the sensors in that structure the following defines  * should be used. They should also be used if data for a single * infrared sensor / sonar is requested. */#define POS_IR_1             0#define POS_IR_2             1#define POS_IR_3             2#define POS_IR_4             3#define POS_IR_5             4#define POS_IR_6             5#define POS_IR_7             6 #define POS_IR_8             7#define POS_IR_9             8#define POS_IR_10            9#define POS_IR_11           10#define POS_IR_12           11#define POS_IR_13           12#define POS_IR_14           13#define POS_IR_15           14#define POS_IR_16           15#define POS_SONAR_1          0#define POS_SONAR_2          1#define POS_SONAR_3          2#define POS_SONAR_4          3#define POS_SONAR_5          4#define POS_SONAR_6          5 #define POS_SONAR_7          6  #define POS_SONAR_8          7#define POS_SONAR_9          8#define POS_SONAR_10         9#define POS_SONAR_11        10#define POS_SONAR_12        11#define POS_SONAR_13        12#define POS_SONAR_14        13#define POS_SONAR_15        14#define POS_SONAR_16        15/* Define the length of the user buffer (Maximal short). * Due to Protocol bytes, the effective length is 65526  */#define USER_BUFFER_LENGTH	0xFFFF/******************** *                  * * Type definitions * *                  * ********************//* * The following type definitions are used for the PosData. * PosData is an information packet that is attached to  * each sensor reading, if requested. Note that the use of  * PosData could cause compatibility problems when different * releases of the software are used on the robot and on the * server side.  * * The information packet can be used to determine how up-to-date * a sensory reading is. It contains the configuration of the robot. * This is the most updated configuration at the time of the sensor * reading. However, it is possible that the sensory reading * was taken after the integration of the coniguration. * To determine the interval that has passed two timestamps are in- * cluded in this information package: a timestamp for the computation * of the configuration and another timestamp for the actual capturing * of the senor reading. * * The timestamps are in milliseconds of the internal clock of the  * board that handles the sensors (Intellisys 100 sensor-board). *//* * TimeData contains the current time of the Intellisys 100  * in milliseconds */typedef unsigned long TimeData;/* * ConfigData is where the i486 writes the current configuration * of the robot, so that the Intellisys 100 can attach current * integration values to the sensor readings. * It is also used inside of the Pos data. */typedef struct _ConfigData{    /* the configuration of the robot */    long          configX;    long          configY;    long          configSteer;    long          configTurret;    /* the velocities of the robot*/    long          velTrans;    long          velSteer;    long          velTurret;    /* time of integration in milliseconds (Intellisys 100 time) */    TimeData      timeStamp;} ConfigData;/*  * PosData contains information that is attached to a sensor * reading in order to determine how recent it is. */typedef struct _PosData{    /* the configuration of the robot at the time of the reading */    ConfigData config;    /* the time of the sensing in milliseconds (Intellisys 100 time) */    TimeData   timeStamp;} PosData;/* these type definitions are for user defined package processing */typedef union{  char            bytes[8];  double          data;} double_union;typedef union{  char	        bytes[4];  short		words[2];  long	        data;} long_union;typedef union{  unsigned char	bytes[2];  short		data;} short_union;typedef union{  unsigned char   bytes[2];  unsigned short  data;} ushort_union;typedef union{  unsigned char	bytes[4];  unsigned short	words[2];  unsigned long	data;} ulong_union;struct request_struct{  short type;  unsigned short size;  long  mesg[USER_BUFFER_LENGTH];};struct reply_struct{  short type;  unsigned short size;  long  mesg[USER_BUFFER_LENGTH];};/******************** *                  * * Global Variables * *                  * ********************//* The State vector is an array of 45 long integers: * *   State[0] - stores actual simulation speed with 10 being realtime  *              (20 meaning twice as fast as realtime and 5 meaning half the  *	        speed of realtime). *   State[1 ... 16] - stores the 16 infrared data. *   State[17 ... 32] - stores the 16 sonar data. *   State[33] - stores bumper data *   State[34 ... 37] - stores robot configuration *   State[38 ... 40] - stores robot's current velocities *   State[41] - motor status: the lowest bit is set to 1 if the translational *               motor is active; the second lowest bit is set to 1 if the  *               steering motor is active; the third lowest bit is set to 1 if  *               the turret motor is active. *   State[42] - laser mode: the mode of the laser. *   State[43] - compass value. *   State[44] - error number. */extern long State[NUM_STATE];/* The Smask vector is an array of 44 integers: * *   Smask[0] - used for the posData attachment to sensory data *   Smask[1 ... 16] - infrared mask *   Smask[17 ... 32] - sonar mask *   Smask[33] - bumper mask *   Smask[34 ... 37] - configuration mask *   Smask[38 ... 40] - velocity mask *   Smask[41] - irrelevant. *   Smask[42] - laser mask *   Smask[43] - compass mask */extern int Smask[NUM_MASK];/* Mask is now just a pointer to Smask. This is because Mask is a declared * variable in X11 library. So if you are not using X11, you can uncomment * the following line and keep using Mask as before. However, if you want * to use X11 graphic in your application program, you can simply use Smask * instead.  *//* static int *Mask = Smask; *//* The Laser vector is an array of 965 elements. The Laser vector * can contain laser data in one of the three formats: pixel, point, or line. * *    In pixel mode (not available in simulation, Laser[0] keeps the number of  *    pixels in the Laser vector. The can be a maximum of 482 pixels. * *    In point mode, Laser[0] keeps the number of points. Each point is  *    specified y the two numbers: the x and y coordinates of the point in  *    the robot's local coordinate. There can be a maximum of 482 points  *    (thus 964 numbers). * *    In line mode, Laser[0] keeps the number of lines. Each line segment is  *    specified by its two end points and each end point is specified by its  *    x and y coordinates in the robot's local coordinate. There can be a  *    maximum of 241 points.  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -