?? nclient.h
字號:
/* * refresh_laser_sensor - causes laser drawings in graphics to be erased */int refresh_laser_sensor(void);/* * refresh_client_graphics - causes drawings performed by any clients into * graphics window to be erased */int refresh_client_graphics(void);/******************************* * * * Miscellaneous robot control * * * *******************************//* * init_mask - initialize the sensor mask, Smask. */void init_mask(void);/* * init_sensors - initialize the sensor mask, Smask, and send it to the * robot. It has no effect on the sensors */int init_sensors(void);/* * place_robot - places the robot at configuration (x, y, th, tu). * In simulation mode, it will place both the Encoder-robot * and the Actual-robot at this configuration. In real robot * mode, it will call dp(x, y) and da(th, tu). * * parameters: * int x, y -- x-y position of the desired robot configuration * int th, tu -- the steering and turret orientation of the robot * desired configuration */int place_robot(int x, int y, int th, int tu);/* * special_request - sends a special request (stored in user_send_buffer) * to the robot and waits for the robot's response (which * will be stored in user_receive_buffer). * * parameters: * unsigned char *user_send_buffer -- stores data to be sent to the robot * Should be a pointer to an array of * 1024 elements * unsigned char *user_receive_buffer -- stores data received from the robot * Should be a pointer to an array of * 1024 elements */int special_request(unsigned char *user_send_buffer, unsigned char *user_receive_buffer);/******************************* * * * Graphic Interface Functions * * * *******************************//* * draw_robot - this function allows the client to draw a robot at * configuration x, y, th, tu (using the robot world * coordinates). * * No effect in direct mode. * * parameters: * long x, y -- the x-y position of the robot. * int th, tu -- the steering and turret orientation of the robot * int mode - the drawing mode. If mode = 1, the robot is drawn in * BlackPixel using GXxor (using GXxor you can erase the trace * of robotby drawing over it). If mode = 2, the robot is * drawn in BlackPixel using GXxor and in addition, a small arrow * is drawn at the center of the robot using GXcopy (using this * mode you can leave a trace of small arrow). If mode = 3, * the robot is drawn in BlackPixel using GXcopy. When mode > 3, * the robot is drawn in color (GXxor) using color(mode-3), see * Color table below. */int draw_robot(long x, long y, int th, int tu, int mode);/* * draw_line - this function allows the client to draw a line from * (x_1, y_1) to (x_2, y_2) (using the robot world coordinates). * * No effect in direct mode. * * parameters: * long x_1, y_1, x_2, y_2 -- the two end-points of the line * int mode -- the mode of drawing: when mode is 1, the drawing is * done in BlackPixel using GXcopy; when mode is 2, the drawing * is done in BlackPixel using GXxor, when mode > 2, the drawing * is done in color (GXxor) using color(mode-2), see Color table * below. */int draw_line(long x_1, long y_1, long x_2, long y_2, int mode);/* * draw_arc - this function allows the client to draw arc which is part * of an ellipse (using the robot world coordinates). * * No effect in direct mode. * * parameters: * long x_0, y_0, w, h -- (x_0, y_0) specifies the upper left corner of the * rectangle bounding the ellipse while w and h * specifies the width and height of the bounding * rectangle, respectively. * int th1, th2 -- th1 and th2 specifies the angular range of the arc. * int mode -- the mode of drawing: when mode is 1, the drawing is * done in BlackPixel using GXcopy; when mode is 2, the drawing * is done in BlackPixel using GXxor, when mode > 2, the drawing * is done in color (GXxor) using color(mode-2), see Color table * below. */int draw_arc(long x_0, long y_0, long w, long h, int th1, int th2, int mode);/* * Color table: * color1 = Blue * color2 = NavyBlue * color3 = RoyalBlue * color4 = SteelBlue * color5 = CadetBlue * color6 = Green * color7 = SeaGreen * color8 = ForestGreen * color9 = DarkGreen * color10 = LimeGreen * color11 = Yellow * color12 = Orange * color13 = LightCoral * color14 = DeepPink * color15 = OrangeRed * color16 = Red * color17 = IndianRed * color18 = VioletRed * color19 = DeepPink * color20 = Maroon *//************************************* * * * Miscellaneous Interface Functions * * * *************************************//* * server_is_running - this function queries the server to see * if it is up and running. If so, this function * returns a TRUE, otherwise it returns FALSE. * This function is replaced by connect_robot, but * is defined here for backward compatibility * * No effect in direct mode. * */int server_is_running(void);/* * quit_server - this function allows the client to quit the server * assuming this feature is enabled in the setup file * of the server * * No effect in direct mode. * */int quit_server(void);/* * real_robot - this function allows the client to switch to * real robot mode in the server * * No effect in direct mode. * */int real_robot(void);/* * simulated_robot - this function allows the client to switch to * simulated robot mode in the server * * No effect in direct mode. * */int simulated_robot(void);/* * predict_sensors - this function predicts the sensor reading of * the robot assuming it is at position (x, y) * and orientation th and tu using the map of the * simulated robot environment. The predicted sensor * data values are stored in "state" and "laser". * * No effect in direct mode. * * parameters: * int x, y, th, tu -- the configuration of the robot * long *state -- where to put the predicted state data * int *laser -- where to put the predicted laser data */int predict_sensors(int x, int y, int th, int tu, long *state, int *laser);/* * motion_check - this function computes the intersection of a path * specified by the parameters: type, a1, ..., a7 with * the obstacles in the robot's environment. If there is * collision, the function returns 1 and the x-y configuration * of the robot is stored in collide[0] and collide[1] while * collide[2] stores the inward normal of the obstacle edge * that the robot collides with (this information can be * used to calculate which bumper is hit.). If there is no * collision, the function returns 0. * * No effect in direct mode. * * parameters: * long type - 0 if the path is a line segment * 1 if the path is an arc of circle * double a1 a2 - x-y coordinates of the first point of the path (the path * is directional). * depending on the value of type, a3 - a7 have different meanings. * if (type == 0), line segment mode * double a3 a4 are the x-y coordinates of the second point of the path * a5, a6, a7 have no meaning * if (type == 1), arc of circle mode * double a3 is the angle (in radiance) of the vector connecting the * center of the circle to the first end-point of the arc * double a4 is the angle of the vector connecting the center * of the circle to the second end-point of the arc * double a5 is the radius of the circle * double a6 a7 are the x-y coordinate of the center of the circle */int motion_check(long type, double a1, double a2, double a3, double a4, double a5, double a6, double a7, double collide[3]);/* * get_robot_conf - interactively getting the robot's conf, by clicking * the mouse in the server's Robot window * * No effect in direct mode. * * parameters: * long *conf -- should be an array of 4 long integers. The configuration * of the robot is returned in this array. */int get_robot_conf(long *conf);/******************************************* * * * The following are helper functions for * * developing user defined host <-> robot * * communication * * * *******************************************//* * init_receive_buffer - sets the index to 4 which is the point * at which data should begin to be extracted * * parameters: * unsigned short *index -- is the buffer index */int init_receive_buffer(unsigned short *index);/* * extract_receive_buffer_header - extracts the header information: * length, serial_number, and packettype from the beginning of the * receive buffer. * * parameters: * short *length -- is the returns the number of chars in the buffer * * unsigned char *serial_number -- returns the serial number to be * assigned to the packet * unsigned char *packet_type -- returns the type number to be * assigned to the packet * unsigned char *buffer -- is the receive buffer */int extract_receive_buffer_header(unsigned short *length, unsigned char *serial_number, unsigned char *packet_type, unsigned char *buffer);/* * init_send_buffer - sets the index to 4 which is the point * at which data should be inserted * * parameters: * unsigned short *index -- is the buffer index */int init_send_buffer(unsigned short *index);/* * stuff_send_buffer_header - loads the header information, * length,serial_number, and packettype into the beginning of the * buffer. It should be called after the data has been stuffed, * i.e. index represents the length of the packet. * * parameters: * int index -- is the buffer index which holds the number of chars * in the buffer * unsigned char serial_number -- holds the serial number to be * assigned to the packet * unsigned char packet_type -- holds the type number to be * assigned to the packet * * unsigned char *buffer -- is the send buffer */int stuff_send_buffer_header(unsigned short index, unsigned char serial_number, unsigned char packet_type, unsigned char *buffer);/* * stuffchar - stuffs a 1 byte char into the send buffer * * parameters: * signed char data -- is the char to be stuffed * unsigned char *buffer -- is the send buffer * unsigned short *index -- is the buffer index which will be incremented * to reflect the bytes stuffed into the buffer */int stuffchar(signed char data, unsigned char *buffer, unsigned short *index);/* * stuff2byteint - stuffs a short int(2 bytes) into the send buffer * * parameters: * signed int data -- is the value which will be split apart and stuffed * bytewise into the send buffer * unsigned char *buffer -- is the send buffer * unsigned short *index -- is the buffer index which will be incremented * to reflect the bytes stuffed into the buffer */int stuff2byteint(signed short data, unsigned char *buffer, unsigned short *index);/* * stuff4byteint - stuffs a long int(4 bytes) into the send buffer * * parameters: * signed long data -- is the value which will be split apart and stuffed * bytewise into the send buffer * unsigned char *buffer -- is the send buffer * unsigned short *index -- is the buffer index which will be incremented * to reflect the bytes stuffed into the buffer */int stuff4byteint(signed long data, unsigned char *buffer, unsigned short *index);/* * stuffuchar - stuffs an unsigned char into the send buffer *
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -