📄 nclient.h
字号:
* * parameters: * int th, tu -- the steering and turret orientations to set the * robot to. */int da(int th, int tu);/* * ws - waits for stop of motors of the robot. This function is intended * to be used in conjunction with pr() and pa() to detect the desired * motion has finished * * parameters: * unsigned char t_ws, s_ws, r_ws -- These three parameters specify * which axis or combination of axis * (translation, steering, and turret) * to wait. * unsigned char timeout -- specifies how long to wait before timing out * (return without stopping the robot). */int ws(unsigned char t_ws, unsigned char s_ws, unsigned char r_ws, unsigned char timeout);/* * get_rpx - get the position of all nearby robots */int get_rpx(long *robot_pos);/***************************** * * * World Interface Functions * * * *****************************//* * add_obstacle - creates an obstacle and adds it to the obstacle list * of the robot environment. * * No effect in direct mode. * * parameters: * long obs[2*MAX_VERTICES+1] -- * The first element of obs specifies the number of * vertices of the polygonal obstacle (must be no greater * than MAX_VERTICES). The subsequent elements of obs * specifies the x and y coordinates of the vertices, * in counter-clockwise direction. */int add_obstacle(long obs[2*MAX_VERTICES+1]);/* * add_Obs - is the same as add_obstacle, for backward compatibility */int add_Obs(long obs[2*MAX_VERTICES+1]);/* * delete_obstacle - deletes an obstacle specified by obs from the robot * environment * parameters: * long obs[2*MAX_VERTICES+1] -- * The first element of obs specifies the number of * vertices of the polygonal obstacle (must be no greater * than MAX_VERTICES). The subsequent elements of obs * specifies the x and y coordinates of the vertices, * in counter-clockwise direction. */int delete_obstacle(long obs[2*MAX_VERTICES+1]);/* * delete_Obs - is the same as delete_obstacle, for backward compatibility */int delete_Obs(long obs[2*MAX_VERTICES+1]);/* * move_obstacle - moves the obstacle obs by dx along x direction and * dy along y direction. obs is modified. * * No effect in direct mode. * * parameters: * long obs[2*MAX_VERTICES+1] -- * The first element of obs specifies the number of * vertices of the polygonal obstacle (must be no greater * than MAX_VERTICES). The subsequent elements of obs * specifies the x and y coordinates of the vertices, * in counter-clockwise direction. * long dx, dy -- the x and y distances to translate the obstacle */int move_obstacle(long obs[2*MAX_VERTICES+1], long dx, long dy);/* * move_Obs - is the same as move_obstacle, for backward compatibility * * No effect in direct mode. * */int move_Obs(long obs[2*MAX_VERTICES+1], long dx, long dy);/* * new_world - deletes all obstacles in the current robot world * * No effect in direct mode. * */int new_world(void);/**************************** * * * Graphics refresh control * * * ****************************//* * refresh_all - causes all temporary drawing in graphics window, including * traces, sensors, and client graphics to be erased */int refresh_all(void);/* * refresh_all_traces - causes all robot traces in graphics to be erased */int refresh_all_traces(void);/* * refresh_actual_trace - causes actual robot trace in graphics to be erased */int refresh_actual_trace(void);/* * refresh_encoder_trace - causes encoder robot trace in graphics to be erased */int refresh_encoder_trace(void);/* * refresh_all_sensors - causes all sensor drawings in graphics to be erased */int refresh_all_sensors(void);/* * refresh_bumper_sensor - causes bumper drawings in graphics to be erased */int refresh_bumper_sensor(void);/* * refresh_infrared_sensor - causes infrared drawings in graphics to be erased */int refresh_infrared_sensor(void);/* * refresh_sonar_sensor - causes sonar drawings in graphics to be erased */int refresh_sonar_sensor(void);/* * 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -