TarzaNN
TarzaNN neural network simulator
C:/Users/albertlr/projects/TarzaNN/TarzaNN/ptu.h
Go to the documentation of this file.
00001 /*************************************************************************
00002 *****                PTU BINARY DRIVER INCLUDE FILE                  *****
00003 *****                                                                *****
00004 *****     (C)1992,2010 FLIR Commercial Systems, Inc.                 *****
00005 *****                     All Rights Reserved.                       *****
00006 *****                                                                *****
00007 *****   Licensed users may freely distribute compiled code including *****
00008 *****   this code and data. Source data and code may NOT be          *****
00009 *****   distributed without the prior written consent from FLIR      *****
00010 *****   Commercial Systems, Inc.                                     *****
00011 *****                                                                *****
00012 *****   FLIR Commercial Systems, Inc. reserves the right to make     *****
00013 *****   changes without further notice to any content herein to      *****
00014 *****   improve reliability, function or design. FLIR Commercial     *****
00015 *****   Systems, Inc. shall not assume any liability arising from    *****
00016 *****   the application or use of this code, data or function.       *****
00017 *****                                                                *****
00018 *****   FLIR Commercial Systems, Inc.                                *****
00019 *****   Motion Control Systems                                       *****
00020 *****   890C Cowan Rd, Burlingame, CA 94010                          *****
00021 *****   www.flir.com/mcs                                             *****
00022 *****   mcs-support@flir.com                                         *****
00023 **************************************************************************
00024 
00025 CHANGE HISTORY:
00026     3/19/07             v1.09.12   Added ISM support to ABS Pos Calls and made all variables signed
00027                                                    Allowed for baud rate changes.
00028    12/14/06     v2.13.0r3  Added ISM controls.
00029     2/16/06     v2.12.12r5 Added ISM support and OEM TTL controls 
00030     9/ 3/04     v2.12.10   Check for pending asynchronous event in get_current and get_desired
00031     5/28/04:    v2.12.09   Added set_PTU_motion and get_PTU_motion
00032    12/10/99:    v1.09.12   added a write and wait after open in open_host_port 
00033                            for networked operation
00034    11/10/99:    v1.09.11.  Added asynchronous event status handling functions.
00035 
00036     8/10/98:    v1.08.09.  In firmware_version_OK, removed addressing to string constant.
00037     7/15/97:    v1.08.00.  Compiles with MSVC v1.52. Unified with Win16/32
00038                            PTU interface calls.
00039     6/20/97:    #define of ALL misdefined. Fixed to equal PAN+TILT
00040     11/2/95:    v1.07.07d. Firmware version check bug fixed.
00041     7/11/95:    v1.07.06d. Updated opcode structure and added new support.
00042     2/19/95:    v1.07.04d. Generalized for Windows, DOS, & UNIX.
00043                            Added networking. 
00044     10/12/94:   v1.07.03d. Pre-release working version.
00045                            XON/XOFF removed from PTU firmware to allow for binary mode.
00046 
00047 
00048 **************************************************************************/
00049 
00050 
00051 /*** Conditionally include the required serial interface declarations. ***/
00052 /*** If your compiler doesn't have the macro symbol defined, you can   ***/
00053 /*** manually select the right include file yourself.                  ***/
00054 #if   defined(_WIN32)
00055 #include "w32seria.h"
00056 #elif defined(_WIN16)
00057 #include "w16seria.h"  
00058 #elif defined(_DOS)  
00059 #include "dosseria.h"
00060 #elif defined(_LINUX)
00061 #include "linuxser.h"
00062 #elif defined(_PIC24)
00063 #include "pic24serial.h"
00064 #endif
00065                       
00066 #include "opcodes.h"
00067 
00068 
00069 /* return status codes */
00070 #define PTU_OK                                          0
00071 #define PTU_ILLEGAL_COMMAND_ARGUMENT    1
00072 #define PTU_ILLEGAL_COMMAND                         2
00073 #define PTU_ILLEGAL_POSITION_ARGUMENT   3
00074 #define PTU_ILLEGAL_SPEED_ARGUMENT              4
00075 #define PTU_ACCEL_TABLE_EXCEEDED                5
00076 #define PTU_DEFAULTS_EEPROM_FAULT               6
00077 #define PTU_SAVED_DEFAULTS_CORRUPTED    7
00078 #define PTU_LIMIT_HIT                           8
00079 #define PTU_CABLE_DISCONNECTED                  9
00080 #define PTU_ILLEGAL_UNIT_ID                     10
00081 #define PTU_ILLEGAL_POWER_MODE                  11
00082 #define PTU_RESET_FAILED                        12
00083 #define PTU_NOT_RESPONDING                          13
00084 #define PTU_FIRMWARE_VERSION_TOO_LOW    14
00085 
00086 
00087 
00088 /********************************************************************
00089  *****                                                          *****
00090  *****          For all of these commands, a non-zero return status *****
00091  *****          indicates an error, and it returns that error code. *****
00092  *****                                                                                                                  *****
00093  ********************************************************************/
00094 
00095 
00096 /* open_host_port(<portname>) ==> <portstream> */
00097 extern portstream_fd open_host_port(char *);
00098 
00099 /* Set's the baud rate of the port prior to opening only */
00100 extern char set_baud_rate(int baudrate);
00101 
00102 /* close_host_port(<portstream>) ==> <status> */
00103 extern char close_host_port(portstream_fd);
00104 
00105 
00106 
00107 typedef short int PTU_PARM_PTR;
00108 
00109 /* reset_PTU_parser(<timeout_in_msec>) ==> [PTU_OK|PTU_NOT_RESPONDING] */
00110 extern char reset_PTU_parser(long);
00111 
00112 /* set_desired([PAN|TILT],
00113                                         [POSITION|SPEED|ACCELERATION|BASE|UPPER_SPEED_LIMIT|LOWER_SPEED_LIMIT],
00114                                         [<position>|<speed>|<acceleration>],
00115                                         [RELATIVE|ABSOLUTE]) ==> <status>
00116         set_desired([PAN|TILT],
00117                                         HOLD_POWER_LEVEL,
00118                                         <power mode>,
00119                                         NULL) ==> <status>
00120         set_desired([PAN|TILT],
00121                                         [HOLD_POWER_LEVEL,MOVE_POWER_LEVEL],
00122                                         [PTU_REG_POWER|PTU_LOW_POWER|PTU_OFF_POWER],
00123                                         ABSOLUTE) ==> <status>                              */
00124 extern char set_desired(char, char, PTU_PARM_PTR *, char);
00125 
00126 
00127 /* get_current([PAN|TILT],
00128                                         [POSITION|SPEED|ACCELERATION|BASE|UPPER_SPEED_LIMIT|LOWER_SPEED_LIMIT|
00129                                          HOLD_POWER_LEVEL|MOVE_POWER_LEVEL|RESOLUTION]) ==> <value> */
00130 extern long get_current(char, char);
00131 
00132 
00133 /* get_desired([PAN|TILT],
00134                                         [POSITION|SPEED|ACCELERATION|BASE|UPPER_SPEED_LIMIT|LOWER_SPEED_LIMIT|
00135                                          HOLD_POWER_LEVEL|MOVE_POWER_LEVEL|RESOLUTION]) ==> <value> */
00136 extern long get_desired(char, char);
00137 
00138 
00139 /* set_mode(COMMAND_EXECUTION_MODE,
00140                                 [EXECUTE_IMMEDIATELY|EXECUTE_UPON_IMMEDIATE_OR_AWAIT]) ==> <status>
00141    set_mode(ASCII_VERBOSE_MODE, [VERBOSE|TERSE|QUERY_MODE]) ==> <status>
00142    set_mode(ASCII_ECHO_MODE, [ON_MODE|OFF_MODE|QUERY_MODE]) ==> <status>
00143    set_mode(POSITION_LIMITS_MODE, [ON_MODE|OFF_MODE|QUERY_MODE]) ==> <status>
00144    set_mode(DEFAULTS,[SAVE_CURRENT_SETTINGS|RESTORE_SAVED_SETTINGS|
00145                  RESTORE_FACTORY_SETTINGS]) ==> <status> */
00146 extern char set_mode(char,char);
00147 
00148 
00149 /* halt([ALL|PAN|TILT]) ==> <status>    */
00150 extern char halt(char);
00151 
00152 
00153 /* await_completion() ==> <status> */
00154 extern char await_completion(void);
00155 
00156 
00157 /* reset_PTU() ==> <status> */
00158 extern char reset_ptu(void);
00159 extern char reset_ptu_pan(void);
00160 extern char reset_ptu_tilt(void);
00161 
00162 
00163 /* firmware_version() ==> <version ID string> */
00164 extern char* firmware_version(void);
00165 
00166 
00167 /*** multiple unit support ***/
00168 typedef unsigned short int UID_fd;
00169 
00170 /* in general, should not be used or required... */
00171 extern char select_host_port(portstream_fd);
00172 
00173 /* select_unit(<portstream>, <unit ID>) ==> <status> */
00174 extern char select_unit(UID_fd);
00175 
00176 extern char set_unit_id(UID_fd);   // This call should be made only
00177                                    // when one unit is on the current
00178                                    // host serial port
00179 
00180 /*** sets all pan-tilt dynamic motion parameters within a single command ***/
00181 extern char set_PTU_motion(short int, short int, unsigned short int, unsigned short int);
00182 extern char get_PTU_motion(short int *, short int *, short int *, short int *);
00183 
00184 
00185 /*** sample textual commands ***/
00186 extern char config_CHA(void);
00187 extern char talkto_CHA(void);
00188 extern char talkto_PTUcontroller(void);
00189 
00190 
00191 
00192 
00193 /*** asynchronous event status handling functions ***/
00194 
00195 typedef unsigned char (*event_handler_fn_ptr_type) (unsigned char);
00196 
00197 extern unsigned char default_async_event_handler(unsigned char);
00198 /* Call this function to set the function handler for asynchronous events.
00199    Defaults to a null function. Example call: 
00200              if ( set_async_event_handler( (unsigned char (*) (unsigned char)) default_async_event_handler ) )
00201                       printf("ASYNCH handler installed properly!");
00202                  else printf("ERROR: ASYNCH handler not installed properly!");
00203 */
00204 extern unsigned char set_async_event_handler( void (*) (unsigned char) );
00205 
00206 
00207 
00208 /********************* function call constants ***********************/
00209 
00210 #define PAN                         1
00211 #define TILT                2
00212 
00213 #define POSITION                    1
00214 #define SPEED                       2
00215 #define ACCELERATION        3
00216 #define BASE                        4
00217 #define UPPER_SPEED_LIMIT       5
00218 #define LOWER_SPEED_LIMIT       6
00219 #define MINIMUM_POSITION        7
00220 #define MAXIMUM_POSITION    8
00221 #define HOLD_POWER_LEVEL        9
00222 #define MOVE_POWER_LEVEL        10
00223 #define RESOLUTION                  11
00224 #define ISM_DRIFT           12
00225 
00226 /* specifies changes relative to current position */
00227 /* (Had to add conditional compilation since WIN32 already defines these values */
00228 #ifndef RELATIVE
00229 #define RELATIVE        1
00230 #endif
00231 #ifndef ABSOLUTE
00232 #define ABSOLUTE        2 
00233 #endif
00234 
00235 
00236 #define QUERY           NULL
00237 
00238 /* power modes */
00239 #define PTU_HI_POWER    1
00240 #define PTU_REG_POWER   2
00241 #define PTU_LOW_POWER   3
00242 #define PTU_OFF_POWER   4
00243 
00244 /* PTU mode types */
00245 #define COMMAND_EXECUTION_MODE               1
00246 #define ASCII_VERBOSE_MODE                   2
00247 #define ASCII_ECHO_MODE                      3
00248 #define POSITION_LIMITS_MODE                 4
00249 #define DEFAULTS                             5
00250 #define SPEED_CONTROL_MODE                   6 /* v1.9.7 and higher */
00251 
00252 #define EXECUTE_IMMEDIATELY                  1  /* default */
00253 #define EXECUTE_UPON_IMMEDIATE_OR_AWAIT      2
00254 
00255 #define VERBOSE                         1  /* default */
00256 #define TERSE                           0  
00257 
00258 #define ON_MODE                         1  /* default */
00259 #define OFF_MODE                        0
00260 
00261 #define SAVE_CURRENT_SETTINGS           0
00262 #define RESTORE_SAVED_SETTINGS          1
00263 #define RESTORE_FACTORY_SETTINGS        2
00264 
00265 #define QUERY_MODE                      3
00266 
00267 #define ALL             3
00268 
00269 
00270 /* OEM support for TTL controls */
00271 extern unsigned char set_TTL_outputs(unsigned char);
00272 extern unsigned char get_TTL_values(void);
00273 
00274 /* advanced calls for doubling pan and tilt position query rates by overlapping comms */
00275 extern char set_desired_abs_positions(signed short int*, signed short int*);
00276 extern char get_current_positions(signed short int*, signed short int*);
00277 
00278 /* OEM support for trigger controls */
00279 extern unsigned char TriggerOn(signed short int, signed short int, signed short int);
00280 extern unsigned char TriggerOff(void);
00281 extern signed short int TriggersPending(void);
00282 
00283 /* ISM controls */
00284 /* use only in pure velocity mode */
00285 /* <SET_DESIRED_VELOCITIES opcode><pvel signed 2B int><tvel signed 2B int><checksum: xor of int bytes> ==> <status byte> */
00286 unsigned char ptu_set_desired_velocities(signed short int, signed short int);
00287 unsigned char execute_set_desired_velocities(signed short int*, signed short int*);
00288 
00289 /* a way to set the pan tilt's positions while in ISM mode */
00290 /* this will command the ISM to slew to this pan tilt position and to begin stabilizing that angle */
00291 char set_ISM_desired_abs_positions(signed short int *Ppos, signed short int *Tpos);
00292 
00293 /* a way to get the pan and tilt's positions while in ISM mode */
00294 /* this will command the ISM to return the latest known positios of the pan-tilt head in pan tilt coordinates. */
00295 char get_ISM_desired_abs_positions(signed short int *Ppos, signed short int *Tpos);
00296 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines