/* * aerobics_stubs.c - Notify and event callback function stubs. * This file was generated by `gxv' from `aerobics.G'. * DO NOT EDIT BY HAND. */ /* David A. Hess CS455 Robot Exerciser Assignment File : aerobicstubs.c */ #include #include #include #include #include #include #include #include #include "aerobics_ui.h" #ifdef MAIN /* * Instance XV_KEY_DATA key. An instance is a set of related * user interface objects. A pointer to an object's instance * is stored under this key in every object. This must be a * global variable. */ Attr_attribute INSTANCE; void main(argc, argv) int argc; char **argv; { aerobics_window1_objects *aerobics_window1; ROBOT$OPEN(); mr_port_default(); mr_setup_port(); VIS$OPEN(); VIS$INIT_FB(); VIS$INIT_LUTS(); ROBOT$SPEECH_INIT(); /* * Initialize XView. */ xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0); INSTANCE = xv_unique_key(); /* * Initialize user interface components. */ aerobics_window1 = aerobics_window1_objects_initialize(NULL, NULL); /* * Turn control over to XView. */ xv_main_loop(aerobics_window1->window1); ROBOT$SPEECH_CLOSE(); exit(0); } #endif /* * Notify callback function for `PITCH'. */ float xpos = 0.0; float ypos = 0.0; float zpos = 0.0; float pitch = 0.0; float roll = 0.0; float spd = 0.0; float rotdeg = 0.0; int movdist = 0; int movspd = 0; int rotspd = 0; int routine = 0; int speech = 0; void PITCH(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); pitch = (float)value; } /* * Notify callback function for `ROLL'. */ void ROLL(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); roll = (float)value; } /* * Notify callback function for `HOME_ARM'. */ void HOME_ARM(item, event) Panel_item item; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); ROBOT$INIT(); } /* * Notify callback function for `MOVE_ARM'. */ void MOVE_ARM(item, event) Panel_item item; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); ROBOT$MOVE(spd,xpos,ypos,zpos,pitch,roll); } /* * Notify callback function for `X_POSITION'. */ void X_POSITION(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); xpos = (float)value; } /* * Notify callback function for `Y_POSITION'. */ void Y_POSITION(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); ypos = (float)value; } /* * Notify callback function for `Z_POSITION'. */ void Z_POSITION(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); zpos = (float)value; } /* * Notify callback function for `GRIPPER'. */ void GRIPPER(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); switch (value) { case 0 : ROBOT$OPEN_GRIPPER(3.0); break; case 1 : ROBOT$CLOSE_GRIPPER(); break; } } /* * Notify callback function for `ARM_SPEED'. */ void ARM_SPEED(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); spd = (float)value; } /* * Notify callback function for `MOVE_DISTANCE'. */ void MOVE_DISTANCE(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); movdist = value; } /* * Notify callback function for `INIT_BASE'. */ void INIT_BASE(item, event) Panel_item item; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); mr_port_default(); mr_setup_port(); } /* * Notify callback function for `MOVE_BASE'. */ void MOVE_BASE(item, event) Panel_item item; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); mr_set_move_speed(movspd); mr_move(movdist); } /* * Notify callback function for `MOVE_SPEED'. */ void MOVE_SPEED(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); movspd = value; } /* * Notify callback function for `FORWARD'. */ void FORWARD(item, event) Panel_item item; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); mr_set_move_speed(movspd); mr_move_forward(); } /* * Notify callback function for `HALT_BASE'. */ void HALT_BASE(item, event) Panel_item item; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); mr_halt(); } /* * Notify callback function for `ROTATE_DEGREES'. */ void ROTATE_DEGREES(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); rotdeg= (float)value; } /* * Notify callback function for `ROTATE_BASE'. */ void ROTATE_BASE(item, event) Panel_item item; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); mr_set_rotate_speed(rotspd); mr_rotate(rotdeg); } /* * Notify callback function for `REVERSE'. */ void REVERSE(item, event) Panel_item item; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); mr_set_move_speed(movspd); mr_move_backward(); } /* * Notify callback function for `ROTATE_SPEED'. */ void ROTATE_SPEED(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); rotspd = value; } /* * Notify callback function for `EXCERCISE_SEL'. */ void EXCERCISE_SEL(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); routine = value; } /* * Notify callback function for `CAMERA_SELECT'. */ void CAMERA_SELECT(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); switch (value) { case 0 : setcamera(1); VIS$VIEW(); break; case 1 : setcamera(2); VIS$VIEW(); break; } } /* * Notify callback function for `SPEECH'. */ void SPEECH(item, value, event) Panel_item item; int value; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); switch (value) { case 0 : speech = 0; break; case 1 : speech = 1; break; } } void EXERCISE_ARM() { char *up = "up"; char *ready = "ready"; char *begin = "begin"; char *right = "right"; char *left = "left"; char *down = "down"; char *stretch_high = "stretch high"; char *stretch_low = "stretch low"; char *retract = "retract"; char *tired = "eye am tired"; char *home ="eye am going home"; char *exercise = "lets exercise"; ROBOT$INIT(); if (speech) { ROBOT$SPEAK(exercise); sleep(1); ROBOT$SPEAK(ready); sleep(1); ROBOT$SPEAK(begin); sleep(1); ROBOT$SPEAK(right); } ROBOT$MOVE(230.0,5.0,-15.0,3.0,0.0,0.0); if (speech) ROBOT$SPEAK(up); ROBOT$MOVE(230.0,5.0,-15.0,15.0,0.0,0.0); if (speech) ROBOT$SPEAK(left); ROBOT$MOVE(230.0,5.0,15.0,15.0,0.0,0.0); if (speech) ROBOT$SPEAK(down); ROBOT$MOVE(230.0,5.0,15.0,3.0,0.0,0.0); if (speech) ROBOT$SPEAK(stretch_high); ROBOT$MOVE(230.0,3.0,0.0,22.0,0.0,0.0); ROBOT$MOVE(230.0,3.0,0.0,22.0,0.0,-180.0); ROBOT$MOVE(230.0,3.0,0.0,22.0,0.0,180.0); ROBOT$MOVE(230.0,3.0,0.0,22.0,0.0,0.0); ROBOT$OPEN_GRIPPER(3.0); ROBOT$CLOSE_GRIPPER(); if (speech) ROBOT$SPEAK(stretch_low); ROBOT$MOVE(230.0,13.0,0.0,0.0,-60.0,0.0); if (speech) ROBOT$SPEAK(retract); ROBOT$MOVE(220.0,1.0,0.0,0.0,-90.0,0.0); if (speech) { ROBOT$SPEAK(tired); sleep(1); ROBOT$SPEAK(home); } ROBOT$HOME(); } void EXERCISE_BASE() { char *lets_jog = "lets jog"; char *tired = "eye am tired"; char *home ="eye am going home"; int mov = 2500; int rot = 4000; mr_port_default(); mr_setup_port(); if (speech) ROBOT$SPEAK(lets_jog); mr_set_move_speed(mov); mr_set_rotate_speed(rot); mr_move(200); sleep(8); mr_rotate(45.0); sleep(10); mr_move(172); sleep(8); mr_rotate(-90.0); sleep(10); mr_move(172); sleep(8); mr_rotate(-90.0); sleep(10); mr_move(172); sleep(8); mr_rotate(-90.0); sleep(10); mr_move(172); sleep(8); if (speech) { ROBOT$SPEAK(tired); sleep(1); ROBOT$SPEAK(home); } mr_rotate(45.0); sleep(10); mr_move(200); sleep(8); mr_rotate(180.0); } /* * Notify callback function for `ACTIVATE_ROUTINE'. */ void ACTIVATE_ROUTINE(item, event) Panel_item item; Event *event; { aerobics_window1_objects *ip = (aerobics_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); switch (routine) { case 0 : EXERCISE_ARM(); break; case 1 : EXERCISE_BASE(); break; } }