/* ********************************************************************* * NAME: Gary E. Shay, Jr. * * CLASS: CS-498 Robotics Honors: Dr. Roger Webster * ********************************************************************* */ #include #include #include /* --------------------------------------------------------------------- */ /* - Global variables and structures... - */ /* --------------------------------------------------------------------- */ #define S5 326.505 #define S6 384.548 #define DEG_PER_RAD 57.2958 #define fabs(x) ((x < 0) ? (-x) : (x)) #define VIEW_MIN_Y 132.25 /* Inches to bottom of View Window */ #define VIEW_HEIGHT 66.25 /* View is VIEW_HEIGHT inches top-to-bottom */ #define STR_CONST 3.0 /* Difference in 'speeds' needed to hit the */ /* ball to the bottom of the view and the */ /* top of the view. */ #define BASE_STREN 245.0 /* The base speed to hit the bottom of view */ #define BASE_BACK 25.0 main() { char buffer[80]; float angle, dist; int speed, pitch; ROBOT$INIT(); /* Begin the Golfer. */ ROBOT$HIT_BALL ( angle, speed, pitch ); } ROBOT$HIT_BALL ( angle, speed, pitch ) float angle; int speed, pitch; { float ang2, swing_back, inches_in_view, fract_part; int swing_forth, s_back1, s_back2, ang_step, dec_speed, slow_speed=220; char buffer1[80]; char buffer2[80]; ROBOT$MOVE(248.0, 8.0, 0.0, 1.45, -90.0, -90.0); /* printf("Please input an angle < -45 to 45 >\n"); scanf("%f",&angle); */ printf("Please input a speed.........:\n"); scanf("%d",&speed); printf("Please input a pitch.........:\n"); scanf("%d",&pitch); getchar(); ang_step = floor ((angle/DEG_PER_RAD) * S5); swing_forth = (-2 * pitch); s_back1 = pitch - ang_step; s_back2 = pitch + ang_step; sprintf(buffer1, "@STEP %d,0,0,0,%d,%d",slow_speed,s_back1,s_back2); ROBOT$SEND(buffer1); printf("@STEP is %s\n", buffer1); sleep(1); sprintf(buffer2, "@STEP %d,0,0,0,%d,%d", speed,swing_forth,swing_forth); ROBOT$SEND(buffer2); printf("@STEP is %s\n", buffer2); ROBOT$READ(); ROBOT$MOVE(245.0, 8.0, 0.0, 4.65, -90.0, -90.0); } /* end of program */