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

📄 nclient.h

📁 TeamBots 是一个可移植的多代理机器人仿真器
💻 H
📖 第 1 页 / 共 4 页
字号:
extern int Laser[2*NUM_LASER+1];/* If linking the application program with Nclient.o, it will connect  * to Nserver. To specify to which machine to connect and which port * to use the following variables can be redefined, otherwise default  * values are used: *     SERVER_MACHINE_NAME *     SERV_TCP_PORT * * If linking the application program with Ndirect.o, it will connect * directly to the robot. To specify to which robot to connect and * which parameters to use for the connection the following variables * can be redefined, otherwise default vaues are used: *     ROBOT_MACHINE_NAME * usually don't need to be changed: *     CONN_TYPE *     SERIAL_PORT *     SERIAL_BAUD *     ROBOT_TCP_PORT * * If an application program should run with Nclient.o and Ndirect.o * all of the above variables should be initialized. * * The concerend variables are define below. *//* SERVER_MACHINE_NAME is the name of the machine where the server is  * running. You should specify the server machine name in your * program if the server is running on a computer different from  * where the client is running  */extern char SERVER_MACHINE_NAME[80];/* SERV_TCP_PORT is an arbitrary port number the server listens to for  * request of connection. It should be the same as that specified in the  * world.setup file. You may modify this number and that in the world.setup  * file to allow multiple servers running on the same machine.  */extern int SERV_TCP_PORT;/* ROBOT_MACHINE_NAME is the name of the machine on the robot  */extern char ROBOT_MACHINE_NAME[80];/* CONN_TYPE is the selection between using a serial port or a TCP/IP port. * If set to 1, serial port is used.  If set to 2 (the default), TCP/IP port * is used.  If set to any other value, connection will fail. */extern int CONN_TYPE;/* SERIAL_PORT is a string containing the filename of the serial port you * choose to communicate to the robot on.  The default is "/dev/ttyS0". */extern char SERIAL_PORT[40];/* SERIAL_BAUD is the baud rate to set the serial communication to.  It * defaults to 9600. */extern int SERIAL_BAUD;/* ROBOT_TCP_PORT is the port number the robot listens on for request of * connection.  It defaults (and should always be set) to 65001 for the * standard binary port. */extern int ROBOT_TCP_PORT;/* LASER_CALIBRATION and LASER_OFFSET are the values that the laser * calibration software returns to you in the file Laser.cal, and that * are normally stored in the file robot.setup under [laser]calibration * and [laser]offset when Nserver is present.  Set these values with * the properly calculated values for your laser system if you have one. * This is only needed for linking with Ndirect.o.  */extern double LASER_CALIBRATION[8];extern double LASER_OFFSET[2];/***************************** *                           * * Robot Interface Functions * *                           * *****************************//* * create_robot - requests the server to create a robot with *                id = robot_id and establishes a connection with *                the robot. This function is disabled in this *                version of the software. *  * parameters: *    long robot_id -- id of the robot to be created. The robot *                     will be referred to by this id. If a process *                     wants to talk (connect) to a robot, it must *                     know its id. */int create_robot(long robot_id);/* * connect_robot - requests the server to connect to the robot *                 with id = robot_id. In order to talk to the server, *                 the SERVER_MACHINE_NAME and SERV_TCP_PORT must be *                 set properly. If a robot with robot_id exists, *                 a connection is established with that robot. If *                 no robot exists with robot_id, no connection is *                 established. * * parameters: *    long robot_id -- robot's id. In this multiple robot version, in order *                     to connect to a robot, you must know it's id. */int connect_robot(long robot_id);/* * disconnect_robot - requests the server to close the connect with robot *                    with id = robot_id.  * * parameters: *    long robot_id -- robot's id. In order to disconnect a robot, you *                     must know it's id. */int disconnect_robot(long robot_id);/*  * ac - sets accelerations of the robot. Currently it has no effect in  *      simulation mode. * * parameters: *    int t_ac, s_ac, r_ac -- the translation, steering, and turret *                            accelerations. t_ac is in 1/10 inch/sec^2 *                            s_ac and r_ac are in 1/10 degree/sec^2. */int ac(int t_ac, int s_ac, int r_ac);/* * sp - sets speeds of the robot, this function will not cause the robot to *      move. However, the set speed will be used when executing a pr() *      or a pa(). * * parameters: *    int t_sp, s_sp, r_sp -- the translation, steering, and turret *                            speeds. t_sp is in 1/10 inch/sec and *                            s_sp and r_sp are in 1/10 degree/sec. */int sp(int t_sp, int s_sp, int r_sp);/* * pr - moves the motors of the robot by a relative distance, using the speeds *      set by sp(). The three parameters specify the relative distances for *      the three motors: translation, steering, and turret. All the three *      motors move concurrently if the speeds are not set to zero and the  *      distances to be traveled are non-zero. Depending on the timeout  *      period set (by function conf_tm(timeout)), the motion may  *      terminate before the robot has moved the specified distances * * parameters: *    int t_pr, s_pr, r_pr -- the specified relative distances of the *                            translation, steering, and turret motors. *                            t_pr is in 1/10 inch and s_pr and r_pr are *                            in 1/10 degrees. */int pr(int t_pr, int s_pr, int r_pr);/* * vm - velocity mode, command the robot to move at translational *      velocity = tv, steering velocity = sv, and rotational velocity = *      rv. The robot will continue to move at these velocities until *      either it receives another command or this command has been *      timeout (in which case it will stop its motion). * * parameters:  *    int t_vm, s_vm, r_vm -- the desired translation, steering, and turret *                            velocities. tv is in 1/10 inch/sec and *                            sv and rv are in 1/10 degree/sec. */int vm(int t_vm, int s_vm, int r_vm);/* * mv - move, send a generalized motion command to the robot. *      For each of the three axis (translation, steering, and *      turret) a motion mode (t_mode, s_mode, r_mode) can be  *      specified (using the values MV_IGNORE, MV_AC, MV_SP, *      MV_LP, MV_VM, and MV_PR defined above): * *         MV_IGNORE : the argument for this axis is ignored *                     and the axis's motion will remain  *                     unchanged. *         MV_AC :     the argument for this axis specifies *                     an acceleration value that will be used *                     during motion commands. *         MV_SP :     the argument for this axis specifies *                     a speed value that will be used during *                     position relative (PR) commands. *         MV_LP :     the arguemnt for this axis is ignored *                     but the motor is turned off. *         MV_VM :     the argument for this axis specifies *                     a velocity and the axis will be moved *                     with this velocity until a new motion *                     command is issued (vm,pr,mv) or  *                     recieves a timeout. *         MV_PR :     the argument for this axis specifies *                     a position and the axis will be moved *                     to this position, unless this command *                     is overwritten by another (vm,pr,mv). * * parameters:  *    int t_mode - the desired mode for the tranlation axis *    int t_mv   - the value for that axis, velocity or position, *                 depending on t_mode *    int s_mode - the desired mode for the steering axis *    int s_mv   - the value for that axis, velocity or position, *                 depending on t_mode *    int r_mode - the desired mode for the turret axis *    int r_mv   - the value for that axis, velocity or position, *                 depending on t_mode */int mv(int t_mode, int t_mv, int s_mode, int s_mv, int r_mode, int r_mv);/* * ct - send the sensor mask, Smask, to the robot. You must first change *      the global variable Smask to the desired communication mask before *      calling this function.  */int ct(void);/* * gs - get the current state of the robot according to the mask (of  *      the communication channel) */int gs(void);/* * st - stops the robot (the robot holds its current position) */int st(void);/* * lp - set motor limp (the robot may not hold its position). */int lp(void);/* * tk - sends the character stream, talk_string, to the voice synthesizer *      to make the robot talk. * * parameters: *    char *talk_string -- the string to be sent to the synthesizer. */int tk(char *talk_string);/* * dp - define the current position of the robot as (x,y) *  * parameters: *    int x, y -- the position to set the robot to. */int dp(int x, int y);/* * zr - zeroing the robot, align steering and turret with bumper zero. *      The position, steering and turret angles are all set to zero. *      This function returns when the zeroing process has completed. */int zr(void);/* * conf_ir - configure infrared sensor system. * * parameters:  *    int history -- specifies the percentage dependency of the current  *                   returned reading on the previous returned reading. *                   It should be set between 0 and 10: 0 = no dependency  *                   10 = full dependency, i.e. the reading will not change *    int order[16] --  specifies the firing sequence of the infrared  *                      (#0 .. #15). You can terminate the order list by a  *                      "255". For example, if you want to use only the  *                      front three infrared sensors then set order[0]=0, *                      order[1]=1, order[2]=15, order[3]=255 (terminator). */int conf_ir(int history, int order[16]);/* * conf_sn - configure sonar sensor system. * * parameters: *    int rate -- specifies the firing rate of the sonar in 4 milli-seconds  *                interval;  *    int order[16] -- specifies the firing sequence of the sonar (#0 .. #15). *                     You can terminate the order list by a "255". For  *                     example, if you want to use only the front three  *                     sensors, then set order[0]=0, order[1]=1, order[2]=15,  *                     order[3]=255 (terminator). */int conf_sn(int rate, int order[16]);/* * conf_cp - configure compass system. *  * parameters: *    int mode -- specifies compass on/off: 0 = off ; 1 = on; 2 = calibrate. *                When you call conf_cp (2), the robot will rotate slowly 360 *                degrees. You must wait till the robot stops rotating before *                issuing another command to the robot (takes ~3 minutes). */int conf_cp(int mode);/* * conf_ls - configure laser sensor system: * * parameters: *    unsigned int mode -- specifies the on-board processing mode of the laser  *                         sensor data which determines the mode of the data  *                         coming back:  *                           the first bit specifies the on/off; *                           the second bit specifies point/line mode; *                           the third to fifth bits specify the  *                           returned data types:  *                             000 = peak pixel,  *                             001 = rise pixel,  *                             010 = fall pixel,  *                             011 = magnitude, *                             100 = distance; *                           the sixth bit specifies data integrity checking. * *   unsigned int threshold -- specifies the inverted acceptable brightness *                             of the laser line.  * *   unsigned int width -- specifies the acceptable width in terms *                         of number of pixels that are brighter than the  *                         set threshold. *   *   unsigned int num_data -- specifies the number of sampling points.  *   unsigned int processing --  specifies the number of neighboring  *                               pixels for averaging * * If you don't understand the above, try this one: *   conf_ls(51, 20, 20, 20, 4) */int conf_ls(unsigned int mode,	    unsigned int threshold,	    unsigned int width,	    unsigned int num_data,	    unsigned int processing);/* * conf_tm - sets the timeout period of the robot in seconds. If the *           robot has not received a command from the host computer *           for more than the timeout period, it will abort its  *           current motion *  * parameters: *    unsigned int timeout -- timeout period in seconds. If it is 0, there *                            will be no timeout on the robot. */int conf_tm(unsigned char timeout);/* * get_ir - get infrared data, independent of mask. However, only  *          the active infrared sensor readings are valid. It updates *          the State vector. */int get_ir(void);/* * get_sn - get sonar data, independent of mask. However, only  *          the active sonar sensor readings are valid. It updates *          the State vector. */int get_sn(void);/* * get_rc - get robot configuration data (x, y, th, tu), independent of  *          mask. It updates the State vector. */int get_rc(void);/* * get_rv - get robot velocities (translation, steering, and turret) data, *          independent of mask. It updates the State vector. */int get_rv(void);/* * get_ra - get robot acceleration (translation, steering, and turret) data, *          independent of mask. It updates the State vector. */int get_ra(void);/* * get_cp - get compass data, independent of mask. However, the *          data is valid only if the compass is on. It updates the *          State vector. */int get_cp(void);/* * get_ls - get laser data point mode, independent of mask. However the *          data is valid only of the laser is on. It updates the Laser  *          vector. */int get_ls(void);/* * get_bp - get bumper data, independent of mask. It updates the State *          vector. */int get_bp(void);/* * conf_sg - configure laser sensor system line segment processing mode: * * parameters: *    unsigned int threshold -- specifies the threshold value for least-square *                             fitting. When the error term grows above the  *                             threshold, the line segment will be broken *    unsigned int min_points -- specifies the acceptable number of points *                              to form a line segment. *    unsigned int gap -- specifies the acceptable "gap" between two segments *                        while they can still be treated as one (in 1/10 inch) * * If you don't understand the above, try this one: *    conf_sg(50, 4, 30) */int conf_sg(unsigned int threshold, 	    unsigned int min_points, 	    unsigned int gap);/* * get_sg - get laser data line mode, independent of mask. It updates *          the laser vector. */int get_sg(void);/* * da - define the current steering angle of the robot to be th *      and the current turret angle of the robot to be tu.

⌨️ 快捷键说明

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