INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
sickdefines.h00001 /* 00002 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics 00003 * http://gearbox.sf.net/ 00004 * Copyright (c) 2004-2010 Alex Brooks 00005 * 00006 * This distribution is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 #ifndef SICK_ACFR_DRIVER_SICKDEFINES_H 00011 #define SICK_ACFR_DRIVER_SICKDEFINES_H 00012 00013 #include <string> 00014 #include <stdint.h> 00015 00016 namespace gbxsickacfr { 00017 00018 typedef unsigned char uChar; 00019 00021 // 00022 // Random SICK crap 00023 // 00024 const uChar STX = 0x02; // Start of Text 00025 const uChar ACK = 0x06; 00026 const uChar NACK = 0x15; 00027 const uChar ADDRESS = 0x00; 00028 00029 const int MAX_SICK_TELEGRAM_LENGTH = 812; // bytes 00030 00031 const int MAX_RESPONSE_TIME_MS = 60; 00032 00034 // 00035 // Command Types 00036 // 00037 const uChar CMD_INIT_AND_RESET = 0x10; 00038 const uChar CMD_SWITCH_OPERATING_MODE = 0x20; 00039 const uChar CMD_REQUEST_MEASURED_VALUES = 0x30; 00040 const uChar CMD_REQUEST_LMS_STATUS = 0x31; 00041 const uChar CMD_REQUEST_ERROR_OR_TEST_MESSAGE = 0x32; 00042 const uChar CMD_REQUEST_OPERATING_DATA_COUNTER = 0x35; 00043 const uChar CMD_REQUEST_MEAN_MEASURED_VALUES = 0x36; 00044 const uChar CMD_REQUEST_MEASURED_VALUE_SUBRANGE = 0x37; 00045 const uChar CMD_REQUEST_LMS_TYPE = 0x3A; 00046 const uChar CMD_SWITCH_VARIANT = 0x3B; 00047 const uChar CMD_REQUEST_MEASURED_VALUE_WITH_FIELD_VALUES = 0x3E; 00048 const uChar CMD_REQUEST_MEAN_MEASURED_VALUE_SUBRANGE = 0x3F; 00049 const uChar CMD_CONFIGURE_FIELDS = 0x40; 00050 const uChar CMD_SWITCH_ACTIVE_FIELD_SET = 0x41; 00051 const uChar CMD_CHANGE_PASSWORD = 0x42; 00052 const uChar CMD_REQUEST_MEASURED_VALUES_AND_REFLECTIVITY_VALUE_SUBRANGE = 0x44; 00053 const uChar CMD_REQUEST_CONFIGURED_FIELDS = 0x45; 00054 const uChar CMD_START_TEACH_MODE_FOR_FIELD_CONFIGURATION = 0x46; 00055 const uChar CMD_REQUEST_STATUS_OF_FIELD_OUTPUTS = 0x4A; 00056 const uChar CMD_DEFINE_PERMANENT_BAUD_RATE_OR_LMS_TYPE = 0x66; 00057 const uChar CMD_DEFINE_ANGULAR_RANGE_FOR_POSITIONING_AID = 0x69; 00058 const uChar CMD_REQUEST_LMS_CONFIGURATION = 0x74; 00059 const uChar CMD_REQUEST_MEASURED_VALUE_WITH_REFLECTIVITY_DATA = 0x75; 00060 const uChar CMD_REQUEST_MEASURED_VALUES_IN_CARTESIAN_COORDINATES = 0x76; 00061 const uChar CMD_CONFIGURE_LMS = 0x77; 00062 const uChar CMD_CONFIGURE_LMS_CONTINUED = 0x7C; 00064 00066 // 00067 // Acknowledgement types 00068 // 00069 inline uChar ack( uChar command ) { return (uChar)(command + 0x80); } 00070 00071 // Need to do this so they can be used in constant expressions (eg in switch stmts) 00072 const uChar ACK_INIT_AND_RESET = CMD_INIT_AND_RESET + 0x80; 00073 const uChar ACK_SWITCH_OPERATING_MODE = CMD_SWITCH_OPERATING_MODE + 0x80; 00074 const uChar ACK_REQUEST_MEASURED_VALUES = CMD_REQUEST_MEASURED_VALUES + 0x80; 00075 const uChar ACK_REQUEST_LMS_STATUS = CMD_REQUEST_LMS_STATUS + 0x80; 00076 const uChar ACK_REQUEST_ERROR_OR_TEST_MESSAGE = CMD_REQUEST_ERROR_OR_TEST_MESSAGE + 0x80; 00077 const uChar ACK_REQUEST_OPERATING_DATA_COUNTER = CMD_REQUEST_OPERATING_DATA_COUNTER + 0x80; 00078 const uChar ACK_REQUEST_MEAN_MEASURED_VALUES = CMD_REQUEST_MEAN_MEASURED_VALUES + 0x80; 00079 const uChar ACK_REQUEST_MEASURED_VALUE_SUBRANGE = CMD_REQUEST_MEASURED_VALUE_SUBRANGE + 0x80; 00080 const uChar ACK_REQUEST_LMS_TYPE = CMD_REQUEST_LMS_TYPE + 0x80; 00081 const uChar ACK_SWITCH_VARIANT = CMD_SWITCH_VARIANT + 0x80; 00082 const uChar ACK_REQUEST_MEASURED_VALUE_WITH_FIELD_VALUES = 00083 CMD_REQUEST_MEASURED_VALUE_WITH_FIELD_VALUES + 0x80; 00084 const uChar ACK_REQUEST_MEAN_MEASURED_VALUE_SUBRANGE = 00085 CMD_REQUEST_MEAN_MEASURED_VALUE_SUBRANGE + 0x80; 00086 const uChar ACK_CONFIGURE_FIELDS = CMD_CONFIGURE_FIELDS + 0x80; 00087 const uChar ACK_SWITCH_ACTIVE_FIELD_SET = CMD_SWITCH_ACTIVE_FIELD_SET + 0x80; 00088 const uChar ACK_CHANGE_PASSWORD = CMD_CHANGE_PASSWORD + 0x80; 00089 const uChar ACK_REQUEST_MEASURED_VALUES_AND_REFLECTIVITY_VALUE_SUBRANGE = 00090 CMD_REQUEST_MEASURED_VALUES_AND_REFLECTIVITY_VALUE_SUBRANGE + 0x80; 00091 const uChar ACK_REQUEST_CONFIGURED_FIELDS = CMD_REQUEST_CONFIGURED_FIELDS + 0x80; 00092 const uChar ACK_START_TEACH_MODE_FOR_FIELD_CONFIGURATION = 00093 CMD_START_TEACH_MODE_FOR_FIELD_CONFIGURATION + 0x80; 00094 const uChar ACK_REQUEST_STATUS_OF_FIELD_OUTPUTS = CMD_REQUEST_STATUS_OF_FIELD_OUTPUTS + 0x80; 00095 const uChar ACK_DEFINE_PERMANENT_BAUD_RATE_OR_LMS_TYPE = 00096 CMD_DEFINE_PERMANENT_BAUD_RATE_OR_LMS_TYPE + 0x80; 00097 const uChar ACK_DEFINE_ANGULAR_RANGE_FOR_POSITIONING_AID = 00098 CMD_DEFINE_ANGULAR_RANGE_FOR_POSITIONING_AID + 0x80; 00099 const uChar ACK_REQUEST_LMS_CONFIGURATION = CMD_REQUEST_LMS_CONFIGURATION + 0x80; 00100 const uChar ACK_REQUEST_MEASURED_VALUE_WITH_REFLECTIVITY_DATA = 00101 CMD_REQUEST_MEASURED_VALUE_WITH_REFLECTIVITY_DATA + 0x80; 00102 const uChar ACK_REQUEST_MEASURED_VALUES_IN_CARTESIAN_COORDINATES = 00103 CMD_REQUEST_MEASURED_VALUES_IN_CARTESIAN_COORDINATES + 0x80; 00104 const uChar ACK_CONFIGURE_LMS = CMD_CONFIGURE_LMS + 0x80; 00105 const uChar ACK_CONFIGURE_LMS_CONTINUED = CMD_CONFIGURE_LMS_CONTINUED + 0x80; 00106 00107 // Response Types (in addition to acknowledgement types) 00108 const uChar RESP_SOFTWARE_RESET_CONFIRM = 0x91; 00109 const uChar RESP_INCORRECT_COMMAND = 0x92; 00110 00111 std::string cmdToString( uChar command ); 00112 00113 00115 // 00116 // Operating Modes 00117 // 00118 const uChar OPERATING_MODE_INSTALLATION = 0x00; 00119 00120 const uChar OPERATING_MODE_DIAGNOSIS = 0x10; 00121 00122 const uChar OPERATING_MODE_MIN_MEASURED_CONTINUOUS = 0x20; 00123 const uChar OPERATING_MODE_MIN_MEASURED_IN_FIELD = 0x21; 00124 const uChar OPERATING_MODE_MIN_VERTICAL_DISTANCE_CONTINUOUS = 0x22; 00125 const uChar OPERATING_MODE_MIN_VERTICAL_DISTANCE_IN_FIELD = 0x23; 00126 const uChar OPERATING_MODE_ALL_MEASURED_CONTINUOUS = 0x24; 00127 const uChar OPERATING_MODE_MEASURED_ON_REQUEST = 0x25; // (this is the default setting) 00128 const uChar OPERATING_MODE_MEAN_MEASURED_CONTINUOUS = 0x26; 00129 const uChar OPERATING_MODE_MEASURED_SUBRANGE_CONTINUOUS = 0x27; 00130 const uChar OPERATING_MODE_MEAN_MEASURED_SUBRANGE_CONTINUOUS = 0x28; 00131 const uChar OPERATING_MODE_MEASURED_WITH_FIELD_VALUES_CONTINUOUS = 0x29; 00132 const uChar OPERATING_MODE_MEASURED_PARTIAL_CONTINUOUS = 0x2A; 00133 const uChar OPERATING_MODE_MEASURED_N_PARTIAL_CONTINUOUS = 0x2B; 00134 const uChar OPERATING_MODE_MEASURED_PER_SEGMENT_CONTINUOUS = 0x2C; 00135 const uChar OPERATING_MODE_NAV_DATA_RECORDS = 0x2E; 00136 const uChar OPERATING_MODE_ALL_MEASURED_PLUS_REFLECTIVITY_SUBRANGE_CONTINUOUS = 0x50; 00137 00138 const uChar OPERATING_MODE_TEST_PASSWORD = 0x30; 00139 00140 const uChar OPERATING_MODE_SET_BAUDRATE_38400 = 0x40; 00141 const uChar OPERATING_MODE_SET_BAUDRATE_19200 = 0x41; 00142 const uChar OPERATING_MODE_SET_BAUDRATE_9600 = 0x42; 00143 const uChar OPERATING_MODE_SET_BAUDRATE_500000 = 0x48; 00144 00145 std::string operatingModeToString( uChar operatingMode ); 00146 00148 // 00149 // Operating Mode Response Data 00150 // 00151 const uChar OPERATING_MODE_RESPONSE_SUCCESS = 0x00; 00152 const uChar OPERATING_MODE_RESPONSE_FAIL = 0x01; 00153 00155 // 00156 // Status Response Data Stuff 00157 // 00158 const int VERSION_LENGTH = 6; 00159 const int SOFTWARE_VERSION_LENGTH = 6; 00160 const int MANUFACTURER_LENGTH = 8; 00161 const int POLLUTION_LENGTH = 8; 00162 const int REF_POLLUTION_LENGTH = 4; 00163 const int CALIB_POLLUTION_LENGTH = 8; 00164 const int CALIB_REF_POLLUTION_LENGTH = 4; 00165 00167 // 00168 // Measuring Modes 00169 // 00170 const uChar MEASURING_MODE_8m80m_FIELD_AB_DAZZLE = 0x00; // (default value) 00171 const uChar MEASURING_MODE_8m80m_REFLECTOR8LEVELS = 0x01; 00172 const uChar MEASURING_MODE_8m80m_FIELD_ABC = 0x02; 00173 const uChar MEASURING_MODE_16m_REFLECTOR4LEVELS = 0x03; 00174 const uChar MEASURING_MODE_16m_FIELD_AB = 0x04; 00175 const uChar MEASURING_MODE_32m_FIELD_AB = 0x05; 00176 const uChar MEASURING_MODE_32m_FIELD_A = 0x06; 00177 00178 std::string measuringModeToString( uChar mode ); 00179 00181 // 00182 // Status Codes 00183 // 00184 00185 const uChar STATUS_GENERAL_MASK = 0x07; 00186 // These apply to the lower 3 bits as masked by STATUS_GENERAL_MASK 00187 const uChar STATUS_OK = 0x00; 00188 const uChar STATUS_INFO = 0x01; 00189 const uChar STATUS_WARNING = 0x02; 00190 const uChar STATUS_ERROR = 0x03; 00191 const uChar STATUS_FATAL_ERROR = 0x04; 00192 00193 // one-bit masks 00194 const uChar STATUS_RESTART_MASK = 0x20; 00195 const uChar STATUS_IMPLAUSIBLE_MEASURED_VALUES_MASK = 0x30; 00196 const uChar STATUS_POLLUTION_MASK = 0x80; 00197 00198 std::string statusToString( uChar status ); 00199 bool generalStatusIsWarn( uChar generalStatus ); 00200 bool generalStatusIsError( uChar generalStatus ); 00201 00202 00204 // 00205 // Status Codes 00206 // 00207 00208 const uChar MODE_SWITCH_SUCCESS_OK = 0x00; 00209 const uChar MODE_SWITCH_FAIL_BAD_PASSWORD = 0x01; 00210 const uChar MODE_SWITCH_FAIL_LMS_FAULT = 0x02; 00211 00212 std::string modeSwitchSuccessToString( uChar success ); 00213 00215 // 00216 // Measurement units 00217 // 00218 00219 const uChar MEASURED_VALUE_UNIT_CM = 0x00; 00220 const uChar MEASURED_VALUE_UNIT_MM = 0x01; 00221 00222 std::string measuredValueUnitToString( uChar unit ); 00223 00225 // 00226 // Angular Resolution and scanning angle 00227 // 00228 const uint16_t ANGULAR_RESOLUTION_1_0_DEG = 100; 00229 const uint16_t ANGULAR_RESOLUTION_0_5_DEG = 50; 00230 const uint16_t ANGULAR_RESOLUTION_0_25_DEG = 25; 00231 00232 inline double angularResolutionToDoubleInDegrees( uint16_t angularResolution ) 00233 { return angularResolution/100.0; } 00234 00235 const uint16_t SCANNING_ANGLE_180 = 180; 00236 const uint16_t SCANNING_ANGLE_100 = 100; 00237 00238 const uChar SWITCH_VARIANT_SUCCESS = 0x01; 00239 const uChar SWITCH_VARIANT_FAIL = 0x00; 00240 00241 std::string switchVariantSuccessToString( uChar success ); 00242 00244 // 00245 // Sensitivity 00246 // 00247 00248 const uChar SENSITIVITY_STANDARD = 0x00; // between medium and high 00249 const uChar SENSITIVITY_MEDIUM = 0x01; 00250 const uChar SENSITIVITY_LOW = 0x02; 00251 const uChar SENSITIVITY_HIGH = 0x03; 00252 00253 std::string sensitivityToString( uChar sens ); 00254 00256 // 00257 // Configuration success 00258 // 00259 00260 const uChar CONFIGURATION_SUCCESS = 0x01; 00261 const uChar CONFIGURATION_FAIL = 0x00; 00262 00263 std::string configurationSuccessToString( uChar success ); 00264 00266 // 00267 // Baud rates 00268 // 00269 00270 // returns -1 on error 00271 int baudRateToInt( uint16_t baudRate ); 00272 uChar baudRateIntToOperatingMode( int baudRate ); 00273 00274 std::string permanentBaudRateToString( uChar permanentBaudRate ); 00275 00277 // 00278 // Error codes 00279 // 00280 00281 const uChar ERROR_TYPE_NO_LONGER_RELEVANT_MASK = 0x80; 00282 00283 const uChar ERROR_CODE_DAZZLE_TEST = 05; 00284 const uChar ERROR_CODE_PEAK_COMPARATOR_TEST = 06; 00285 const uChar ERROR_CODE_STOP_COMPARATOR_TEST = 07; 00286 const uChar ERROR_CODE_TDC_INIT_AND_GATE_FUNCTION_TEST = 15; 00287 const uChar ERROR_CODE_POLLUTION_EVALUATION_OIL_CHANNEL_1 = 17; 00288 const uChar ERROR_CODE_POLLUTION_EVALUATION_DIRT_CHANNEL_1 = 18; 00289 const uChar ERROR_CODE_POLLUTION_EVALUATION_DIRT_CHANNEL_2 = 19; 00290 const uChar ERROR_CODE_POLLUTION_EVALUATION_OIL_CHANNEL_2 = 20; 00291 const uChar ERROR_CODE_POLLUTION_EVALUATION_REF_CHANNEL_0 = 21; 00292 const uChar ERROR_CODE_POLLUTION_EVALUATION_REF_CHANNEL_1 = 22; 00293 const uChar ERROR_CODE_OUTPUT_A_DEFECTIVE = 27; 00294 const uChar ERROR_CODE_OUTPUT_B_DEFECTIVE = 28; 00295 const uChar ERROR_CODE_NUM_MOTOR_REVOLUTIONS = 29; 00296 const uChar ERROR_CODE_CALIBRATION_POLLUTION = 37; 00297 const uChar ERROR_CODE_TIMEOUT_ON_TDC_CALIBRATION = 39; 00298 const uChar ERROR_CODE_1_MEASUREMENT_VALUE_MISSING = 45; 00299 const uChar ERROR_CODE_1_SCAN_MISSING_SCAN_LASTS_TOO_LONG = 46; 00300 const uChar ERROR_CODE_REFERENCE_TARGET_LOAD_PULSE_WIDTH_IMPLAUSIBLE = 47; 00301 const uChar ERROR_CODE_CALIBRATION_OF_LASER_POWER = 48; 00302 const uChar ERROR_CODE_LASER_POWER_OUTSIDE_50_PCT_140_PCT = 49; 00303 const uChar ERROR_CODE_INITIALISATION_TDC_MO_CHANNEL_0_AND_1 = 50; 00304 const uChar ERROR_CODE_DA_AD_TEST_STOP_BRANCH = 51; 00305 const uChar ERROR_CODE_DA_AD_TEST_PEAK_BRANCH = 52; 00306 const uChar ERROR_CODE_FLASH_WRITTEN = 53; 00307 const uChar ERROR_CODE_POLLUTION_CHANNEL_MEASUREMENT_WITHOUT_ACTIVE_TRANSMITTER = 54; 00308 const uChar ERROR_CODE_NO_TWO_DIFFERENT_ANGLES_DETECTED_ON_LASER_POWER_CALIBRATION = 55; 00309 const uChar ERROR_CODE_HARDWARE_WATCHDOG_DEFECTIVE = 56; 00310 const uChar ERROR_CODE_NO_ZERO_INDEX_SIGNAL_AVAILABLE = 57; 00311 const uChar ERROR_CODE_SLAVE_CANNOT_SYNC_DURING_INIT = 58; 00312 const uChar ERROR_CODE_SYNC_LOST_IN_OPERATING_STATE = 59; 00313 const uChar ERROR_CODE_SYNC_CYCLE_FROM_MASTER_MISSING = 60; 00314 const uChar ERROR_CODE_HARDWARE_UNSUITABLE_FOR_SYNC_IN_SLAVE_OPERATING_MODE = 61; 00315 const uChar ERROR_CODE_WRONG_DIP_SWITCH_POSITION = 62; 00316 const uChar ERROR_CODE_REF_TARGET_SMALLEST_PULSE_WIDTH_TOO_SMALL = 86; 00317 const uChar ERROR_CODE_REF_TARGET_LARGEST_PULSE_WIDTH_TOO_LARGE = 87; 00318 const uChar ERROR_CODE_REF_TARGET_PULSE_WIDTH_SPECTRUM_TOO_LARGE = 88; 00319 const uChar ERROR_CODE_REF_TARGET_REF_TABLE_LESS_THAN_2_CYCLES_UPDATE = 89; 00320 const uChar ERROR_CODE_REF_TARGET_REFLECTIVITY_MEASUREMENT_CANNOT_BE_CALIBRATED = 91; 00321 const uChar ERROR_CODE_REF_TARGET_TEACH_IN_MODE_IS_NOT_COMPLETED = 92; 00322 const uChar ERROR_CODE_OUT_OF_MEMORY_IN_MEASUREMENT_ROUTINE = 124; 00323 const uChar ERROR_CODE_OUT_OF_MEMORY_IN_REFERENCE_TARGET_ROUTINE = 125; 00324 const uChar ERROR_CODE_OUT_OF_MEMORY_IN_REFERENCE_TARGET_ANGULAR_TABLE = 126; 00325 00326 std::string errorTypeToString( uChar errorType ); 00327 bool errorTypeIsWarn( uChar errorType ); 00328 bool errorTypeIsError( uChar errorType ); 00329 std::string errorCodeToString( uChar errorCode ); 00330 } 00331 00332 #endif |