diff --git a/sw/in_progress/antenna_track/Makefile b/sw/in_progress/antenna_track/Makefile index 2618c3a731..87f092656e 100644 --- a/sw/in_progress/antenna_track/Makefile +++ b/sw/in_progress/antenna_track/Makefile @@ -30,6 +30,4 @@ ant_track_pmm : ant_track_pmm.c $(CC) $(CFLAGS) -g -o $@ $^ $(LDFLAGS) clean: - rm -f *~* *.cm* *.o *.out *.opt .depend - - + rm -f *~* *.cm* *.o *.out *.opt .depend diff --git a/sw/in_progress/antenna_track/ant_track_pmm.c b/sw/in_progress/antenna_track/ant_track_pmm.c index 80ecae56ca..9d7a70528d 100644 --- a/sw/in_progress/antenna_track/ant_track_pmm.c +++ b/sw/in_progress/antenna_track/ant_track_pmm.c @@ -4,7 +4,7 @@ * Copyright (C) 2010 * * Modified by: Mark Griffin and Todd Sandercock - * Modified by: Chris Efstathiou for the Pololu Micro Mestro usb servo controller Jun/2010 + * Modified by: Chris Efstathiou for the Pololu Micro Mestro usb servo controller Jun/2010 * Added command line options, a 360 pan option and "MANUAL" control. * * This file is part of paparazzi. @@ -95,8 +95,8 @@ void on_mode_changed(GtkRadioButton *radiobutton, gpointer user_data) { void on_azimuth_changed(GtkAdjustment *hscale, gpointer user_data) { -if (mode == MANUAL) { - ant_azim = gtk_range_get_value(GTK_RANGE (azim_scale)); +if (mode == MANUAL) { + ant_azim = gtk_range_get_value(GTK_RANGE (azim_scale)); ant_elev = gtk_range_get_value(GTK_RANGE (elev_scale)); set_servos(); } @@ -107,8 +107,8 @@ if (mode == MANUAL) { //void on_elevation_changed(GtkRange *elev_scale, gpointer user_data) { void on_elevation_changed(GtkAdjustment *hscale, gpointer user_data) { -if (mode == MANUAL) { - ant_azim = gtk_range_get_value(GTK_RANGE (azim_scale)); +if (mode == MANUAL) { + ant_azim = gtk_range_get_value(GTK_RANGE (azim_scale)); ant_elev = gtk_range_get_value(GTK_RANGE (elev_scale)); set_servos(); } @@ -121,7 +121,7 @@ if (mode == MANUAL) { #define GLADE_HOOKUP_OBJECT(component,widget,name) \ g_object_set_data_full (G_OBJECT (component), name, \ - gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) + gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ g_object_set_data (G_OBJECT (component), name, widget) @@ -256,79 +256,79 @@ double hpos, vpos; int hservo = theta_servo_center_pw, vservo = psi_servo_center_pw; // The magic is done here - - if (ant_tracker_pan_mode == 180){ + + if (ant_tracker_pan_mode == 180){ // Take the vertical angle relative to the neutral point "vnp" vpos = ant_elev - vnp; - // keep within the field of view "vfov" - if (vpos > (vfov / 2)) { vpos = vfov / 2; } else if(-vpos > (vfov / 2)){ vpos = -vfov / 2; } + // keep within the field of view "vfov" + if (vpos > (vfov / 2)) { vpos = vfov / 2; } else if(-vpos > (vfov / 2)){ vpos = -vfov / 2; } - // First take the horizontal angle relative to the neutral point "hnp" + // First take the horizontal angle relative to the neutral point "hnp" hpos = ant_azim - hnp; - // Keep the range between (-180,180). this is done so that it consistently swaps sides + // Keep the range between (-180,180). this is done so that it consistently swaps sides if (hpos < -180){ hpos += 360; }else if(hpos > 180){ hpos -= 360; } - // Swap sides to obtain 360 degrees of Azimuth coverage. - if(hpos > 90){ hpos = hpos-180; vpos = 180-vpos; }else if(hpos < -90){ hpos = hpos+180; vpos = 180-vpos; } + // Swap sides to obtain 360 degrees of Azimuth coverage. + if(hpos > 90){ hpos = hpos-180; vpos = 180-vpos; }else if(hpos < -90){ hpos = hpos+180; vpos = 180-vpos; } - // keep the range within the field of view "hfov" - if (hpos > (hfov / 2)) { hpos = hfov / 2; } else if (-hpos > (hfov / 2)) { hpos = -hfov / 2; } + // keep the range within the field of view "hfov" + if (hpos > (hfov / 2)) { hpos = hfov / 2; } else if (-hpos > (hfov / 2)) { hpos = -hfov / 2; } - // Convert angles to servo microsecond values suitable for the Pololu micro Maestro servo controller. - vpos = (psi_servo_center_pw-(psi_servo_pw_span/2)) + (vpos*(psi_servo_pw_span/vfov)); - hpos = theta_servo_center_pw + (hpos*(theta_servo_pw_span/(hfov/2))); + // Convert angles to servo microsecond values suitable for the Pololu micro Maestro servo controller. + vpos = (psi_servo_center_pw-(psi_servo_pw_span/2)) + (vpos*(psi_servo_pw_span/vfov)); + hpos = theta_servo_center_pw + (hpos*(theta_servo_pw_span/(hfov/2))); - //convert the values to integer. - hservo = hpos; - vservo = vpos; + //convert the values to integer. + hservo = hpos; + vservo = vpos; - }else{ - vpos = ant_elev; + }else{ + vpos = ant_elev; - // First take the horizontal angle relative to the neutral point "hnp" - hpos = ant_azim - hnp; + // First take the horizontal angle relative to the neutral point "hnp" + hpos = ant_azim - hnp; - // Keep the range between (-180,180). - if (hpos < -180){ hpos += 360; }else if(hpos > 180){ hpos -= 360; } + // Keep the range between (-180,180). + if (hpos < -180){ hpos += 360; }else if(hpos > 180){ hpos -= 360; } - // Keep the range between 0 to 360. - //if (hpos < 0) { hpos += 360; } else if (hpos > 360){ hpos -= 360; } + // Keep the range between 0 to 360. + //if (hpos < 0) { hpos += 360; } else if (hpos > 360){ hpos -= 360; } - // keep the range within the field of view "hfov" - if (hpos > (hfov / 2)) { hpos = hfov / 2; } else if (-hpos > (hfov / 2)) { hpos = -hfov / 2; } + // keep the range within the field of view "hfov" + if (hpos > (hfov / 2)) { hpos = hfov / 2; } else if (-hpos > (hfov / 2)) { hpos = -hfov / 2; } - // Convert angles to servo microsecond values suitable for the Pololu micro Maestro servo controller. - vpos = (psi_servo_center_pw-(psi_servo_pw_span/2)) + (fabs(vpos)*(psi_servo_pw_span/vfov)); - hpos = theta_servo_center_pw + (hpos*(theta_servo_pw_span/hfov)); - - //convert the values to integer. - hservo = hpos; - vservo = vpos; - } + // Convert angles to servo microsecond values suitable for the Pololu micro Maestro servo controller. + vpos = (psi_servo_center_pw-(psi_servo_pw_span/2)) + (fabs(vpos)*(psi_servo_pw_span/vfov)); + hpos = theta_servo_center_pw + (hpos*(theta_servo_pw_span/hfov)); - // Sanity check. - if (vservo < (psi_servo_center_pw-fabs(psi_servo_pw_span/2)) ){ - vservo = (psi_servo_center_pw-fabs(psi_servo_pw_span/2)); - - }else if(vservo > (psi_servo_center_pw+fabs(psi_servo_pw_span/2))){ vservo = (psi_servo_center_pw+fabs(psi_servo_pw_span/2)); } + //convert the values to integer. + hservo = hpos; + vservo = vpos; + } - if (hservo < (theta_servo_center_pw-fabs(theta_servo_pw_span/2)) ){ - hservo = (theta_servo_center_pw-fabs(theta_servo_pw_span/2)); - - }else if(hservo > (theta_servo_center_pw+fabs(theta_servo_pw_span/2))){ hservo = (theta_servo_center_pw+fabs(theta_servo_pw_span/2)); } + // Sanity check. + if (vservo < (psi_servo_center_pw-fabs(psi_servo_pw_span/2)) ){ + vservo = (psi_servo_center_pw-fabs(psi_servo_pw_span/2)); - hservo *= 4; //The pololu Maestro uses 0.25 microsecond increments so we need to multiply microseconds by 4. - vservo *= 4; //The pololu Maestro uses 0.25 microsecond increments so we need to multiply microseconds by 4. - //g_message("home_alt %f gps_alt %f azim %f elev %f", home_alt, gps_alt, ant_azim, ant_elev); + }else if(vservo > (psi_servo_center_pw+fabs(psi_servo_pw_span/2))){ vservo = (psi_servo_center_pw+fabs(psi_servo_pw_span/2)); } + + if (hservo < (theta_servo_center_pw-fabs(theta_servo_pw_span/2)) ){ + hservo = (theta_servo_center_pw-fabs(theta_servo_pw_span/2)); + + }else if(hservo > (theta_servo_center_pw+fabs(theta_servo_pw_span/2))){ hservo = (theta_servo_center_pw+fabs(theta_servo_pw_span/2)); } + + hservo *= 4; //The pololu Maestro uses 0.25 microsecond increments so we need to multiply microseconds by 4. + vservo *= 4; //The pololu Maestro uses 0.25 microsecond increments so we need to multiply microseconds by 4. + //g_message("home_alt %f gps_alt %f azim %f elev %f", home_alt, gps_alt, ant_azim, ant_elev); // Send servo position. char buffer1[]={ POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_POSITION_COMMAND, psi_servo_address, vservo%128, vservo/128, - POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_POSITION_COMMAND, theta_servo_address, hservo%128, hservo/128 - }; + POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_POSITION_COMMAND, theta_servo_address, hservo%128, hservo/128 + }; serial_error = write(fd, buffer1, 12); @@ -358,7 +358,7 @@ void on_NAV_STATUS(IvyClientPtr app, void *user_data, int argc, char *argv[]) { gps_pos_x = atof(argv[2]); gps_pos_y = atof(argv[3]); /* calculate azimuth */ - //should be "atan2(gps_pos_y, gps_pos_x)" but it is reversed to give 0 when North. + //should be "atan2(gps_pos_y, gps_pos_x)" but it is reversed to give 0 when North. ant_azim = atan2(gps_pos_x, gps_pos_y) * 180. / M_PI; if (ant_azim < 0) @@ -366,14 +366,14 @@ void on_NAV_STATUS(IvyClientPtr app, void *user_data, int argc, char *argv[]) { /* calculate elevation */ ant_elev = atan2((gps_alt - home_alt), sqrt(atof(argv[5]))) * 180. / M_PI; - // Sanity check - if (ant_elev < 0){ ant_elev = 0.; } + // Sanity check + if (ant_elev < 0){ ant_elev = 0.; } gtk_range_set_value(GTK_RANGE (azim_scale), ant_azim); gtk_range_set_value(GTK_RANGE (elev_scale), ant_elev); - - set_servos(); - - } + + set_servos(); + + } } @@ -382,15 +382,15 @@ int open_port(char* port ) { struct termios options; // would probably be good to set the port up as an arg. - // The Pololu micro maestro registers two ports /dev/ttyACM0 and /dev/ttyACM1, /dev/ttyACM0 is the data port. + // The Pololu micro maestro registers two ports /dev/ttyACM0 and /dev/ttyACM1, /dev/ttyACM0 is the data port. fd = open(port, O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) { //perror("open_port: Unable to open /dev/ttyUSB1"); - printf ("open_port: Unable to open %s \n", port); - serial_error = fd; - + printf ("open_port: Unable to open %s \n", port); + serial_error = fd; + } else - printf("Success %s %s \n", port, "opened"); + printf("Success %s %s \n", port, "opened"); fcntl(fd, F_SETFL, 0); tcgetattr(fd, &options); @@ -406,25 +406,25 @@ int open_port(char* port ) { // Send initialisation to the pololu micro maestro board. // if "speed" is nonzero then 1 is the slowest 127 is the fastest. 0 = no speed restriction - char buffer_0[] = { POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_SPEED_COMMAND, psi_servo_address, 0x00, 0x00, - POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_SPEED_COMMAND, theta_servo_address, 0x00, 0x00 - }; + char buffer_0[] = { POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_SPEED_COMMAND, psi_servo_address, 0x00, 0x00, + POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_SPEED_COMMAND, theta_servo_address, 0x00, 0x00 + }; serial_error = write(fd, buffer_0, 12); // Set servo acceleration to 3 for protecting the servo gears. Fastest = 0, slowest = 255 char buffer_1[] = { POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_ACCELERATION_COMMAND, psi_servo_address, (servo_acceleration%128), - (servo_acceleration/128), - POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_ACCELERATION_COMMAND, theta_servo_address, (servo_acceleration%128), - (servo_acceleration/128) - }; + (servo_acceleration/128), + POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_ACCELERATION_COMMAND, theta_servo_address, (servo_acceleration%128), + (servo_acceleration/128) + }; serial_error = write(fd, buffer_1, 12); - // Set the two servos to their neutral position, Azimuth = 1500us = EAST = 0 degrees & Elevation = 1000 = parallel to ground. - char buffer_2[] = { POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_POSITION_COMMAND, theta_servo_address, - (((int)theta_servo_center_pw*4) % 128), (((int)theta_servo_center_pw*4) / 128), - POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_POSITION_COMMAND, psi_servo_address, - (((int)psi_servo_center_pw*4) % 128), (((int)psi_servo_center_pw*4) / 128) - }; + // Set the two servos to their neutral position, Azimuth = 1500us = EAST = 0 degrees & Elevation = 1000 = parallel to ground. + char buffer_2[] = { POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_POSITION_COMMAND, theta_servo_address, + (((int)theta_servo_center_pw*4) % 128), (((int)theta_servo_center_pw*4) / 128), + POLOLU_PROTOCOL_START, pololu_board_id, SET_SERVO_POSITION_COMMAND, psi_servo_address, + (((int)psi_servo_center_pw*4) % 128), (((int)psi_servo_center_pw*4) / 128) + }; serial_error = write(fd, buffer_2, 12); @@ -435,277 +435,277 @@ int open_port(char* port ) { int main(int argc, char** argv) { gtk_init(&argc, &argv); - - int x = 0, y = 0, z = 0; - char buffer[20]; - char serial_open = 0; - printf ("Antenna Tracker for the Paparazzi autopilot, Chris Efstathiou 2010 \n"); - if (argc > 1){ - char arg_string1[] = "--help"; - for (x=1; x < argc; x++){ - if ( (strncmp(argv[x], arg_string1, (sizeof(arg_string1)-1))) == 0 ){ - printf ("OPTIONS \n"); - printf ("-------------------------------------------------------------------------------- \n"); - printf ("'--help' displays this screen \n"); - printf ("'--port=xxx..x' opens port xxx..x, example --port=/dev/ttyACM0 (Default) \n"); - printf ("'--pan=xxx' sets pan mode to 180 or 360 degrees. Example --pan=180 (Default) \n"); - printf ("'--zero_angle=xxx' set the mechanical zero angle. Default is 0 (North)\n"); - printf ("'--id=xx' sets the Pololu board id. Example --id=12 (Default)\n"); - printf ("'--servo_acc=xxx' sets the servo acceleration. Example --servo_acc=3 (Default)\n"); - printf ("'--pan_servo=x' sets the pan (Theta) servo number. Example --pan_servo=0 (Default)\n"); - printf ("'--tilt_servo=x' sets the tilt (Psi) servo number.Example --tilt_servo=1 (Default) \n"); - printf ("'--pan_epa=xx..x' sets the Azimuth servo's max travel (Default is 1100us) \n"); - printf ("'--tilt_epa=xx..x' sets the elevation servo's max travel (Default is 1100us). \n"); - printf ("HINT a negative value EPA value reverses the servo direction \n"); - printf ("'--pan_servo_center_pw=xx..x' sets the Azimuth servo's center position (Default is 1500us) \n"); - printf ("'--tilt_servo_center_pw=xx..x' sets the elevation servo's center position (Default is 1500us) \n"); - printf ("WARNING: The pololu board limit servo travel to 1000-2000 microseconds. \n"); - printf ("WARNING: Use the pololu board setup program to change the above limits. \n"); - printf ("Example --tilt_epa=1100 sets the PW from 950 to 2050 microseconds \n"); - printf ("Example --pan_epa=-1000 sets the PW from 1000 to 2000 microseconds and reverses the servo direction \n"); - printf ("An EPA of 1100 sets the servo travel from 1500+(1100/2)=2050us to 1500-(1100/2)=950us. \n"); - printf ("Use programmable servos like the Hyperion Atlas. \n"); - printf ("You can also use the proportional 360 degree GWS S125-1T as the Theta (Azimuth) \n"); - printf ("servo or the mighty but expensive Futaba S5801 \n"); - printf (" \n"); - printf ("FOR THE 360 DEGREE PAN MODE: \n"); - printf ("Mechanical zero (0 degrees or 1500 ms) is to the NORTH, 90 = EAST, +-180 = SOUTH and -90 = WEST. \n"); - printf ("Elevation center is 45 degrees up (1500ms), 0 degrees = horizontal, 90 degrees is vertical (up) \n"); - printf ("Of course use this mode if your PAN servo can do a full 360 degrees rotation (GWS S125-1T for example) \n"); - printf (" \n"); - printf ("FOR THE 180 DEGREE PAN MODE: \n"); - printf ("Mechanical zero (0 degrees or 1500 ms) is to the NORTH, 90 = EAST, -90 = WEST. \n"); - printf ("Elevation center is 90 degrees up (1500ms), 0 degrees = horizontal, 180 degrees is horizontal to the opposite side \n"); - printf ("When the azimuth is > 90 or < -90 the azimuth and elevation servos swap sides to obtain the full 360 degree coverage. \n"); - printf ("Of course your PAN and TILT servos must be true 180 degrees servos like the Hyperion ATLAS servos for example. \n"); - printf (" \n"); - printf ("-------------------------------------------------------------------------------- \n"); - printf ("Antenna Tracker V1.2 for the Paparazzi autopilot 28/June/2010 \n"); - printf ("-------------------------------------------------------------------------------- \n"); - return 0; - } - } - printf ("Type '--help' for help \n"); + int x = 0, y = 0, z = 0; + char buffer[20]; + char serial_open = 0; + printf ("Antenna Tracker for the Paparazzi autopilot, Chris Efstathiou 2010 \n"); - for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. - char arg_string2[] = "--port="; - for (x=1; x < argc; x++){ - - if ( (strncmp(argv[x], arg_string2, (sizeof(arg_string2)-1))) == 0 ){ - y=sizeof(arg_string2)-1; - z=0; - while (1){ - buffer[z] = argv[x][y]; - if(buffer[z] != '\0'){ y++; z++; }else{ break; } - } - printf ("Trying to open %s \n", buffer); - open_port(buffer); - } - } - for(z=0; z 1){ + char arg_string1[] = "--help"; + for (x=1; x < argc; x++){ + if ( (strncmp(argv[x], arg_string1, (sizeof(arg_string1)-1))) == 0 ){ + printf ("OPTIONS \n"); + printf ("-------------------------------------------------------------------------------- \n"); + printf ("'--help' displays this screen \n"); + printf ("'--port=xxx..x' opens port xxx..x, example --port=/dev/ttyACM0 (Default) \n"); + printf ("'--pan=xxx' sets pan mode to 180 or 360 degrees. Example --pan=180 (Default) \n"); + printf ("'--zero_angle=xxx' set the mechanical zero angle. Default is 0 (North)\n"); + printf ("'--id=xx' sets the Pololu board id. Example --id=12 (Default)\n"); + printf ("'--servo_acc=xxx' sets the servo acceleration. Example --servo_acc=3 (Default)\n"); + printf ("'--pan_servo=x' sets the pan (Theta) servo number. Example --pan_servo=0 (Default)\n"); + printf ("'--tilt_servo=x' sets the tilt (Psi) servo number.Example --tilt_servo=1 (Default) \n"); + printf ("'--pan_epa=xx..x' sets the Azimuth servo's max travel (Default is 1100us) \n"); + printf ("'--tilt_epa=xx..x' sets the elevation servo's max travel (Default is 1100us). \n"); + printf ("HINT a negative value EPA value reverses the servo direction \n"); + printf ("'--pan_servo_center_pw=xx..x' sets the Azimuth servo's center position (Default is 1500us) \n"); + printf ("'--tilt_servo_center_pw=xx..x' sets the elevation servo's center position (Default is 1500us) \n"); + printf ("WARNING: The pololu board limit servo travel to 1000-2000 microseconds. \n"); + printf ("WARNING: Use the pololu board setup program to change the above limits. \n"); + printf ("Example --tilt_epa=1100 sets the PW from 950 to 2050 microseconds \n"); + printf ("Example --pan_epa=-1000 sets the PW from 1000 to 2000 microseconds and reverses the servo direction \n"); + printf ("An EPA of 1100 sets the servo travel from 1500+(1100/2)=2050us to 1500-(1100/2)=950us. \n"); + printf ("Use programmable servos like the Hyperion Atlas. \n"); + printf ("You can also use the proportional 360 degree GWS S125-1T as the Theta (Azimuth) \n"); + printf ("servo or the mighty but expensive Futaba S5801 \n"); + printf (" \n"); + printf ("FOR THE 360 DEGREE PAN MODE: \n"); + printf ("Mechanical zero (0 degrees or 1500 ms) is to the NORTH, 90 = EAST, +-180 = SOUTH and -90 = WEST. \n"); + printf ("Elevation center is 45 degrees up (1500ms), 0 degrees = horizontal, 90 degrees is vertical (up) \n"); + printf ("Of course use this mode if your PAN servo can do a full 360 degrees rotation (GWS S125-1T for example) \n"); + printf (" \n"); + printf ("FOR THE 180 DEGREE PAN MODE: \n"); + printf ("Mechanical zero (0 degrees or 1500 ms) is to the NORTH, 90 = EAST, -90 = WEST. \n"); + printf ("Elevation center is 90 degrees up (1500ms), 0 degrees = horizontal, 180 degrees is horizontal to the opposite side \n"); + printf ("When the azimuth is > 90 or < -90 the azimuth and elevation servos swap sides to obtain the full 360 degree coverage. \n"); + printf ("Of course your PAN and TILT servos must be true 180 degrees servos like the Hyperion ATLAS servos for example. \n"); + printf (" \n"); + printf ("-------------------------------------------------------------------------------- \n"); + printf ("Antenna Tracker V1.2 for the Paparazzi autopilot 28/June/2010 \n"); + printf ("-------------------------------------------------------------------------------- \n"); + return 0; + } + } + printf ("Type '--help' for help \n"); - }else{ - perror("ERROR: Pan mode can be either 180 or 360 degrees"); - ant_tracker_pan_mode = 180; - hfov = 180; - vfov = 180; - printf ("PAN servo set to %i %s \n", ant_tracker_pan_mode, "degrees"); - } - } - } + for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. + char arg_string2[] = "--port="; + for (x=1; x < argc; x++){ - for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. - char arg_string4[] = "--pan_epa="; - for (x=1; x < argc; x++){ - if ( (strncmp(argv[x], arg_string4, (sizeof(arg_string4)-1))) == 0 ){ - y=(sizeof(arg_string4)-1); - z=0; - while (1){ - buffer[z] = argv[x][y]; - if(buffer[z] != '\0'){ y++; z++; }else{ break; } - } - theta_servo_pw_span = atoi(buffer); - printf ("THETA servo EPA set to %i \n", atoi(buffer)); - if (abs(theta_servo_pw_span) > 1000){ - printf ("REMEMBER TO SET THE MIN/MAX SERVO LIMITS WITH THE POLOLU SETUP PROGRAM \n"); - printf ("OTHERWISE THE MAX SERVO MOVEMENT WILL BE RESTRAINED TO 1000 MICROSECONDS \n"); - } - } - } + if ( (strncmp(argv[x], arg_string2, (sizeof(arg_string2)-1))) == 0 ){ + y=sizeof(arg_string2)-1; + z=0; + while (1){ + buffer[z] = argv[x][y]; + if(buffer[z] != '\0'){ y++; z++; }else{ break; } + } + printf ("Trying to open %s \n", buffer); + open_port(buffer); + } + } + for(z=0; z 1000){ - printf ("REMEMBER TO SET THE MIN/MAX SERVO LIMITS WITH THE POLOLU SETUP PROGRAM \n"); - printf ("OTHERWISE THE MAX SERVO MOVEMENT WILL BE RESTRAINED TO 1000 MICROSECONDS \n"); - } - } - } - for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. - char arg_string8[] = "--id="; - for (x=1; x < argc; x++){ - if ( (strncmp(argv[x], arg_string8, (sizeof(arg_string8)-1))) == 0 ){ - y=(sizeof(arg_string8)-1); - z=0; - while (1){ - buffer[z] = argv[x][y]; - if(buffer[z] != '\0'){ y++; z++; }else{ break; } - } - pololu_board_id = (char)atoi(buffer); - printf ("Pololu Board id set to %i \n", atoi(buffer)); - } - } - for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. - char arg_string9[] = "--servo_acc="; - for (x=1; x < argc; x++){ - if ( (strncmp(argv[x], arg_string9, (sizeof(arg_string9)-1))) == 0 ){ - y=(sizeof(arg_string9)-1); - z=0; - while (1){ - buffer[z] = argv[x][y]; - if(buffer[z] != '\0'){ y++; z++; }else{ break; } - } - servo_acceleration = (char)atoi(buffer); - printf ("Servo acceleration set to %i \n", atoi(buffer)); - } - } - for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. - char arg_string10[] = "--pan_servo="; - for (x=1; x < argc; x++){ - if ( (strncmp(argv[x], arg_string10, (sizeof(arg_string10)-1))) == 0 ){ - y=(sizeof(arg_string10)-1); - z=0; - while (1){ - buffer[z] = argv[x][y]; - if(buffer[z] != '\0'){ y++; z++; }else{ break; } - } - theta_servo_address = (char)atoi(buffer); - printf ("Pan (Theta) servo number set to %i \n", atoi(buffer)); - } - } + }else{ + perror("ERROR: Pan mode can be either 180 or 360 degrees"); + ant_tracker_pan_mode = 180; + hfov = 180; + vfov = 180; + printf ("PAN servo set to %i %s \n", ant_tracker_pan_mode, "degrees"); + } + } + } - for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. - char arg_string11[] = "--tilt_servo="; - for (x=1; x < argc; x++){ - if ( (strncmp(argv[x], arg_string11, (sizeof(arg_string11)-1))) == 0 ){ - y=(sizeof(arg_string11)-1); - z=0; - while (1){ - buffer[z] = argv[x][y]; - if(buffer[z] != '\0'){ y++; z++; }else{ break; } - } - psi_servo_address = (char)atoi(buffer); - printf ("Tilt (Psi) servo number set to %i \n", atoi(buffer)); - } - } + for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. + char arg_string4[] = "--pan_epa="; + for (x=1; x < argc; x++){ + if ( (strncmp(argv[x], arg_string4, (sizeof(arg_string4)-1))) == 0 ){ + y=(sizeof(arg_string4)-1); + z=0; + while (1){ + buffer[z] = argv[x][y]; + if(buffer[z] != '\0'){ y++; z++; }else{ break; } + } + theta_servo_pw_span = atoi(buffer); + printf ("THETA servo EPA set to %i \n", atoi(buffer)); + if (abs(theta_servo_pw_span) > 1000){ + printf ("REMEMBER TO SET THE MIN/MAX SERVO LIMITS WITH THE POLOLU SETUP PROGRAM \n"); + printf ("OTHERWISE THE MAX SERVO MOVEMENT WILL BE RESTRAINED TO 1000 MICROSECONDS \n"); + } + } + } - for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. - char arg_string12[] = "--zero_angle="; - for (x=1; x < argc; x++){ - if ( (strncmp(argv[x], arg_string12, (sizeof(arg_string12)-1))) == 0 ){ - y=(sizeof(arg_string12)-1); - z=0; - while (1){ - buffer[z] = argv[x][y]; - if(buffer[z] != '\0'){ y++; z++; }else{ break; } - } - hnp = (double)atoi(buffer); - printf ("Zero angle is set to %i %s \n", atoi(buffer), "degrees"); - } - } - for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. - char arg_string13[] = "--tilt_servo_center_pw="; - for (x=1; x < argc; x++){ - if ( (strncmp(argv[x], arg_string13, (sizeof(arg_string13)-1))) == 0 ){ - y=(sizeof(arg_string13)-1); - z=0; - while (1){ - buffer[z] = argv[x][y]; - if(buffer[z] != '\0'){ y++; z++; }else{ break; } - } - psi_servo_center_pw = atoi(buffer); - printf ("PSI servo center pulse width set to %i \n", atoi(buffer)); - } - } - for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. - char arg_string14[] = "--pan_servo_center_pw="; - for (x=1; x < argc; x++){ - if ( (strncmp(argv[x], arg_string14, (sizeof(arg_string14)-1))) == 0 ){ - y=(sizeof(arg_string14)-1); - z=0; - while (1){ - buffer[z] = argv[x][y]; - if(buffer[z] != '\0'){ y++; z++; }else{ break; } - } - theta_servo_center_pw = atoi(buffer); - printf ("THETA servo center pulse width set to %i \n", atoi(buffer)); - } - } - for(z=0; z 1000){ + printf ("REMEMBER TO SET THE MIN/MAX SERVO LIMITS WITH THE POLOLU SETUP PROGRAM \n"); + printf ("OTHERWISE THE MAX SERVO MOVEMENT WILL BE RESTRAINED TO 1000 MICROSECONDS \n"); + } + } + } + for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. + char arg_string8[] = "--id="; + for (x=1; x < argc; x++){ + if ( (strncmp(argv[x], arg_string8, (sizeof(arg_string8)-1))) == 0 ){ + y=(sizeof(arg_string8)-1); + z=0; + while (1){ + buffer[z] = argv[x][y]; + if(buffer[z] != '\0'){ y++; z++; }else{ break; } + } + pololu_board_id = (char)atoi(buffer); + printf ("Pololu Board id set to %i \n", atoi(buffer)); + } + } + for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. + char arg_string9[] = "--servo_acc="; + for (x=1; x < argc; x++){ + if ( (strncmp(argv[x], arg_string9, (sizeof(arg_string9)-1))) == 0 ){ + y=(sizeof(arg_string9)-1); + z=0; + while (1){ + buffer[z] = argv[x][y]; + if(buffer[z] != '\0'){ y++; z++; }else{ break; } + } + servo_acceleration = (char)atoi(buffer); + printf ("Servo acceleration set to %i \n", atoi(buffer)); + } + } + for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. + char arg_string10[] = "--pan_servo="; + for (x=1; x < argc; x++){ + if ( (strncmp(argv[x], arg_string10, (sizeof(arg_string10)-1))) == 0 ){ + y=(sizeof(arg_string10)-1); + z=0; + while (1){ + buffer[z] = argv[x][y]; + if(buffer[z] != '\0'){ y++; z++; }else{ break; } + } + theta_servo_address = (char)atoi(buffer); + printf ("Pan (Theta) servo number set to %i \n", atoi(buffer)); + } + } - if(serial_open == 0){ printf ("Trying to open /dev/ttyACM0 \n"); open_port("/dev/ttyACM0"); } + for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. + char arg_string11[] = "--tilt_servo="; + for (x=1; x < argc; x++){ + if ( (strncmp(argv[x], arg_string11, (sizeof(arg_string11)-1))) == 0 ){ + y=(sizeof(arg_string11)-1); + z=0; + while (1){ + buffer[z] = argv[x][y]; + if(buffer[z] != '\0'){ y++; z++; }else{ break; } + } + psi_servo_address = (char)atoi(buffer); + printf ("Tilt (Psi) servo number set to %i \n", atoi(buffer)); + } + } + + for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. + char arg_string12[] = "--zero_angle="; + for (x=1; x < argc; x++){ + if ( (strncmp(argv[x], arg_string12, (sizeof(arg_string12)-1))) == 0 ){ + y=(sizeof(arg_string12)-1); + z=0; + while (1){ + buffer[z] = argv[x][y]; + if(buffer[z] != '\0'){ y++; z++; }else{ break; } + } + hnp = (double)atoi(buffer); + printf ("Zero angle is set to %i %s \n", atoi(buffer), "degrees"); + } + } + for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. + char arg_string13[] = "--tilt_servo_center_pw="; + for (x=1; x < argc; x++){ + if ( (strncmp(argv[x], arg_string13, (sizeof(arg_string13)-1))) == 0 ){ + y=(sizeof(arg_string13)-1); + z=0; + while (1){ + buffer[z] = argv[x][y]; + if(buffer[z] != '\0'){ y++; z++; }else{ break; } + } + psi_servo_center_pw = atoi(buffer); + printf ("PSI servo center pulse width set to %i \n", atoi(buffer)); + } + } + for(z=0; z < sizeof(buffer); z++){ buffer[z] = '\0'; } //Reset the buffer. + char arg_string14[] = "--pan_servo_center_pw="; + for (x=1; x < argc; x++){ + if ( (strncmp(argv[x], arg_string14, (sizeof(arg_string14)-1))) == 0 ){ + y=(sizeof(arg_string14)-1); + z=0; + while (1){ + buffer[z] = argv[x][y]; + if(buffer[z] != '\0'){ y++; z++; }else{ break; } + } + theta_servo_center_pw = atoi(buffer); + printf ("THETA servo center pulse width set to %i \n", atoi(buffer)); + } + } + for(z=0; z