/*!***************************************************************************** ******************************************************************************* \note main \date Nov. 2007 \remarks A simple program creating multiple processes ******************************************************************************* Function Parameters: [in]=input,[out]=output \param[in] argc : number of elements in argv \param[in] argv : array of argc character strings ******************************************************************************/ int main(int argc, char**argv) { #include "SL_user_main_core.h" for (i=0; i<c; ++i) argv_ptr[i] = argv_array[i]; argv_ptr[c] = NULL; // the task servo if (fork() == 0) { sprintf(argv_ptr[geometry_argv],"90x30+%d+670",display_width-delta_width); if (read_parameter_pool_string(config_files[PARAMETERPOOL], "task_servo_geometry", string)) if (parseWindowSpecs(string, display_width,display_height,xstring, &x, &y, &w, &h)) strcpy(argv_ptr[geometry_argv],xstring); sprintf(argv_ptr[background_argv],"PowderBlue"); sprintf(argv_ptr[servo_argv],"xtask"); execvp("xterm",argv_ptr); exit(-1); } semTake(sm_init_process_ready_sem,WAIT_FOREVER); // the vision servo if (fork() == 0) { sprintf(argv_ptr[geometry_argv],"90x12+%d+484",display_width-delta_width); if (read_parameter_pool_string(config_files[PARAMETERPOOL], "vision_servo_geometry", string)) if (parseWindowSpecs(string, display_width,display_height,xstring, &x, &y, &w, &h)) strcpy(argv_ptr[geometry_argv],xstring); sprintf(argv_ptr[background_argv],"LightGoldenrod"); sprintf(argv_ptr[servo_argv],"xvision"); execvp("xterm",argv_ptr); exit(-1); } semTake(sm_init_process_ready_sem,WAIT_FOREVER); // the motor servo if (fork() == 0) { sprintf(argv_ptr[geometry_argv],"90x12+%d+298",display_width-delta_width); if (read_parameter_pool_string(config_files[PARAMETERPOOL], "motor_servo_geometry", string)) if (parseWindowSpecs(string, display_width,display_height,xstring, &x, &y, &w, &h)) strcpy(argv_ptr[geometry_argv],xstring); sprintf(argv_ptr[background_argv],"thistle"); sprintf(argv_ptr[servo_argv],"xmotor"); execvp("xterm",argv_ptr); exit(-1); } semTake(sm_init_process_ready_sem,WAIT_FOREVER); // the opengGL servo if (graphics_flag) { if (fork() == 0) { sprintf(argv_ptr[geometry_argv],"90x8+%d+164",display_width-delta_width); if (read_parameter_pool_string(config_files[PARAMETERPOOL], "openGL_servo_geometry", string)) if (parseWindowSpecs(string, display_width,display_height,xstring, &x, &y, &w, &h)) strcpy(argv_ptr[geometry_argv],xstring); sprintf(argv_ptr[background_argv],"LightYellow"); sprintf(argv_ptr[servo_argv],"xopengl"); sprintf(argv_ptr[nice_argv],"19"); execvp("xterm",argv_ptr); exit(-1); } semTake(sm_init_process_ready_sem,WAIT_FOREVER); } // the simulation if (fork() == 0) { sprintf(argv_ptr[geometry_argv],"90x8+%d+30",display_width-delta_width); if (read_parameter_pool_string(config_files[PARAMETERPOOL], "simulation_servo_geometry", string)) if (parseWindowSpecs(string, display_width,display_height,xstring, &x, &y, &w, &h)) strcpy(argv_ptr[geometry_argv],xstring); sprintf(argv_ptr[background_argv],"LightGray"); sprintf(argv_ptr[servo_argv],"xsimulation"); sprintf(argv_ptr[nice_argv],"0"); execvp("xterm",argv_ptr); exit(-1); } // monitor dying child process and kill all other if this happens waitpid(0,&stat_loc,options); return TRUE; }
/*!***************************************************************************** ******************************************************************************* \note initOscWindow \date May 2010 \remarks initializes the oscilloscope window ******************************************************************************* Function Parameters: [in]=input,[out]=output none ******************************************************************************/ int initOscWindow(void) { int i,j; int x = 600; int y = 20; int width = 600; int height = 400; char string[100]; char xstring[100]; Display *disp; int screen_num; int display_width; int display_height; double aux; // is the oscilloscope enabled? if (read_parameter_pool_int(config_files[PARAMETERPOOL],"osc_enabled", &i)) osc_enabled = macro_sign(abs(i)); if (!osc_enabled) return TRUE; // how many oscilloscope graphs? if (read_parameter_pool_int(config_files[PARAMETERPOOL],"n_osc_plots", &i)) { if (i > 0) n_oscilloscope_plots = i; } // #periods of oscilloscope A/D plot if (read_parameter_pool_int(config_files[PARAMETERPOOL],"osc_periods_ad", &i)) { if (i > 0) periods_window_AD = i; } // window size of variable display if (read_parameter_pool_double(config_files[PARAMETERPOOL],"osc_time_window_vars", &aux)) { if (aux > 0) time_window_vars = aux; } // allocate memory for the plots and initialize osc_data = (OscData *) my_calloc(n_oscilloscope_plots+1,sizeof(OscData),MY_STOP); for (i=0; i<=n_oscilloscope_plots; ++i) { for (j=1; j<=MAX_VARS_PER_PLOT; ++j) { osc_data[i].current_index[j] = 1; } osc_data[i].max = -1.e10; osc_data[i].min = 1.e10; } // connect to X server using the DISPLAY environment variable if ( (disp=XOpenDisplay(NULL)) == NULL ) { printf("Cannot connect to X servo %s\n",XDisplayName(NULL)); exit(-1); } // get screen size from display structure macro screen_num = DefaultScreen(disp); display_width = DisplayWidth(disp, screen_num); display_height = DisplayHeight(disp, screen_num); // overwrite the default window options from ParameterPool.cf if (read_parameter_pool_string(config_files[PARAMETERPOOL], "osc_window_geometry", string)) parseWindowSpecs(string, display_width,display_height,xstring, &x, &y, &width, &height); // create the window glutInitWindowPosition(x,y); glutInitWindowSize(width,height); openGLId_osc = glutCreateWindow("Oscilloscope"); // makes window current, too // attach appropriate OpenGL functions to the current window glutDisplayFunc(osc_display); glutReshapeFunc(osc_reshape); /* glutIdleFunc(idle); glutKeyboardFunc(keyboard); glutMouseFunc(mouse); glutMotionFunc(motion); glutSpecialFunc(special); glutMenu(wptr); */ return TRUE; }
/*!***************************************************************************** ******************************************************************************* \note createWindows \date July 1998 \remarks initializes graphic windows ******************************************************************************* Function Parameters: [in]=input,[out]=output none ******************************************************************************/ static int createWindows(void) { int i; OpenGLWPtr w; int width_eye=640/3; int height_eye=480/3; int height_main = 400; int width_main = 400; int hspace = 10; int vspace = 60; Display *disp; int screen_num; int display_width; int display_height; char string[100]; char xstring[100]; double eye[N_CART+1]; // connect to X server using the DISPLAY environment variable if ( (disp=XOpenDisplay(NULL)) == NULL ) { printf("Cannot connect to X servo %s\n",XDisplayName(NULL)); exit(-1); } // get screen size from display structure macro screen_num = DefaultScreen(disp); display_width = DisplayWidth(disp, screen_num); display_height = DisplayHeight(disp, screen_num); /* get a window structure, initialized with default values */ w=getOpenGLWindow(); if (w==NULL) return FALSE; w->display = display; w->idle = idle; w->width = width_main; w->height = height_main; // check for user parameters if (read_parameter_pool_string(config_files[PARAMETERPOOL], "main_window_geometry", string)) parseWindowSpecs(string, display_width,display_height,xstring, &(w->x), &(w->y), &(w->width), &(w->height)); if (read_parameter_pool_double_array(config_files[PARAMETERPOOL], "main_window_camera_pos", N_CART, eye)) for (i=1; i<=N_CART; ++i) w->eye[i] = eye[i]; // finally create the window for (i=1; i<=N_CART; ++i) w->eye0[i] = w->eye[i]; if (!createWindow(w)) return FALSE; /* get additional windows for the eyes */ w=getOpenGLWindow(); if (w==NULL) return FALSE; w->x += width_main+hspace; w->fovea = FOVEA_ANGLE; w->width = width_eye; w->height = height_eye; w->display = display; w->idle = idle; sprintf(w->name,"LeftEyeFovea"); if (!createWindow(w)) return FALSE; toggleHideWindow(w); w_left_eye_fovea = w; w=getOpenGLWindow(); if (w==NULL) return FALSE; w->x += width_main+hspace+width_eye+hspace; w->fovea = FOVEA_ANGLE; w->width = width_eye; w->height = height_eye; w->display = display; w->idle = idle; sprintf(w->name,"RightEyeFovea"); if (!createWindow(w)) return FALSE; toggleHideWindow(w); w_right_eye_fovea = w; w=getOpenGLWindow(); if (w==NULL) return FALSE; w->x += width_main+hspace; w->y += height_eye+vspace; w->fovea = WIDE_ANGLE; w->width = width_eye; w->height = height_eye; w->display = display; w->idle = idle; sprintf(w->name,"LeftEyeWide"); if (!createWindow(w)) return FALSE; toggleHideWindow(w); w_left_eye_wide = w; w=getOpenGLWindow(); if (w==NULL) return FALSE; w->x += width_main+hspace+width_eye+hspace; w->y += height_eye+vspace; w->fovea = WIDE_ANGLE; w->width = width_eye; w->height = height_eye; w->display = display; w->idle = idle; sprintf(w->name,"RightEyeWide"); if (!createWindow(w)) return FALSE; toggleHideWindow(w); w_right_eye_wide = w; return TRUE; }