orientus_packets.h
Go to the documentation of this file.
00001 /****************************************************************/
00002 /*                                                              */
00003 /*         Advanced Navigation Packet Protocol Library          */
00004 /*         C Language Dynamic Orientus SDK, Version 1.1         */
00005 /*   Copyright 2013, Xavier Orr, Advanced Navigation Pty Ltd    */
00006 /*                                                              */
00007 /****************************************************************/
00008 /*
00009  * Copyright (C) 2013 Advanced Navigation Pty Ltd
00010  *
00011  * Permission is hereby granted, free of charge, to any person obtaining
00012  * a copy of this software and associated documentation files (the "Software"),
00013  * to deal in the Software without restriction, including without limitation
00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00015  * and/or sell copies of the Software, and to permit persons to whom the
00016  * Software is furnished to do so, subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be included
00019  * in all copies or substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00022  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
00024  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00027  * DEALINGS IN THE SOFTWARE.
00028  */
00029  
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 #define MAXIMUM_PACKET_PERIODS 50
00035 
00036 #define START_SYSTEM_PACKETS 0
00037 #define START_STATE_PACKETS 20
00038 #define START_CONFIGURATION_PACKETS 180
00039 
00040 typedef enum
00041 {
00042     packet_id_acknowledge,
00043     packet_id_request,
00044     packet_id_boot_mode,
00045     packet_id_device_information,
00046     packet_id_restore_factory_settings,
00047     packet_id_reset,
00048     packet_id_print,
00049     packet_id_file_transfer_request,
00050     packet_id_file_transfer_acknowledge,
00051     packet_id_file_transfer,
00052     end_system_packets,
00053     
00054     packet_id_system_state = START_STATE_PACKETS,
00055     packet_id_unix_time,
00056     packet_id_formatted_time,
00057     packet_id_status,
00058     packet_id_position_standard_deviation,
00059     packet_id_velocity_standard_deviation,
00060     packet_id_euler_orientation_standard_deviation,
00061     packet_id_quaternion_orientation_standard_deviation,
00062     packet_id_raw_sensors,
00063     packet_id_raw_gnss,
00064     packet_id_satellites,
00065     packet_id_satellites_detailed,
00066     packet_id_geodetic_position,
00067     packet_id_ecef_position,
00068     packet_id_utm_position,
00069     packet_id_ned_velocity,
00070     packet_id_body_velocity,
00071     packet_id_acceleration,
00072     packet_id_body_acceleration,
00073     packet_id_euler_orientation,
00074     packet_id_quaternion_orientation,
00075     packet_id_dcm_orientation,
00076     packet_id_angular_velocity,
00077     packet_id_angular_acceleration,
00078     packet_id_external_position_velocity,
00079     packet_id_external_position,
00080     packet_id_external_velocity,
00081     packet_id_external_body_velocity,
00082     packet_id_external_heading,
00083     packet_id_running_time,
00084         packet_id_local_magnetics,
00085         packet_id_odometer_state,
00086         packet_id_external_time,
00087         packet_id_external_depth,
00088         packet_id_geoid_height,
00089         packet_id_rtcm_corrections,
00090         packet_id_external_pitot_pressure,
00091         packet_id_wind_estimation,
00092         packet_id_heave,
00093     end_state_packets,
00094     
00095     packet_id_packet_timer_period = START_CONFIGURATION_PACKETS,
00096     packet_id_packet_periods,
00097     packet_id_baud_rates,
00098     packet_id_bus_configuration,
00099     packet_id_sensor_ranges,
00100     packet_id_installation_alignment,
00101     packet_id_filter_options,
00102     packet_id_filter_advanced_parameters,
00103     packet_id_gpio_configuration,
00104     packet_id_magnetic_calibration_values,
00105     packet_id_magnetic_calibration_configuration,
00106     packet_id_magnetic_calibration_status,
00107     packet_id_odometer_configuration,
00108         packet_id_zero_alignment,
00109         packet_id_heave_offset,
00110     end_configuration_packets
00111 }packet_id_e;
00112 
00113 /* start of system packets typedef structs */
00114 
00115 typedef enum
00116 {
00117         acknowledge_success,
00118         acknowledge_failure_crc,
00119         acknowledge_failure_length,
00120         acknowledge_failure_range,
00121         acknowledge_failure_flash,
00122         acknowledge_failure_not_ready,
00123         acknowledge_failure_unknown_packet
00124 } acknowledge_result_e;
00125 
00126 typedef struct
00127 {
00128         uint8_t packet_id;
00129         uint16_t packet_crc;
00130         uint8_t acknowledge_result;
00131 } acknowledge_packet_t;
00132 
00133 typedef enum
00134 {
00135         boot_mode_bootloader,
00136         boot_mode_main_program
00137 } boot_mode_e;
00138 
00139 typedef struct
00140 {
00141         uint8_t boot_mode;
00142 } boot_mode_packet_t;
00143 
00144 typedef struct
00145 {
00146         uint32_t software_version;
00147         uint32_t device_id;
00148         uint32_t hardware_revision;
00149         uint32_t serial_number[3];
00150 } device_information_packet_t;
00151 
00152 /* start of state packets typedef structs */
00153 
00154 typedef struct
00155 {
00156         union
00157         {
00158                 uint16_t r;
00159                 struct
00160                 {
00161                         unsigned int system_failure :1;
00162                         unsigned int accelerometer_sensor_failure :1;
00163                         unsigned int gyroscope_sensor_failure :1;
00164                         unsigned int magnetometer_sensor_failure :1;
00165                         unsigned int reserved1 :1;
00166                         unsigned int reserved2 :1;
00167                         unsigned int accelerometer_over_range :1;
00168                         unsigned int gyroscope_over_range :1;
00169                         unsigned int magnetometer_over_range :1;
00170                         unsigned int reserved3 :1;
00171                         unsigned int minimum_temperature_alarm :1;
00172                         unsigned int maximum_temperature_alarm :1;
00173                         unsigned int low_voltage_alarm :1;
00174                         unsigned int high_voltage_alarm :1;
00175                         unsigned int reserved4 :1;
00176                         unsigned int serial_port_overflow_alarm :1;
00177                 } b;
00178         } system_status;
00179         union
00180         {
00181                 uint16_t r;
00182                 struct
00183                 {
00184                         unsigned int orientation_filter_initialised :1;
00185                         unsigned int reserved1 :1;
00186                         unsigned int heading_initialised :1;
00187                         unsigned int reserved2 :1;
00188                         unsigned int reserved3 :1;
00189                         unsigned int reserved4 :1;
00190                         unsigned int reserved5 :1;
00191                         unsigned int reserved6 :1;
00192                         unsigned int reserved7 :1;
00193                         unsigned int reserved8 :1;
00194                         unsigned int magnetometers_enabled :1;
00195                         unsigned int velocity_heading_enabled :1;
00196                         unsigned int reserved9 :1;
00197                         unsigned int external_position_active :1;
00198                         unsigned int external_velocity_active :1;
00199                         unsigned int external_heading_active :1;
00200                 } b;
00201         } filter_status;
00202         uint32_t unix_time_seconds;
00203         uint32_t microseconds;
00204         float orientation[3];
00205         float angular_velocity[3];
00206 } system_state_packet_t;
00207 
00208 typedef struct
00209 {
00210     uint32_t unix_time_seconds;
00211     uint32_t microseconds;
00212 } unix_time_packet_t;
00213 
00214 typedef struct
00215 {
00216     union
00217         {
00218                 uint16_t r;
00219                 struct
00220                 {
00221                         unsigned int system_failure :1;
00222                         unsigned int accelerometer_sensor_failure :1;
00223                         unsigned int gyroscope_sensor_failure :1;
00224                         unsigned int magnetometer_sensor_failure :1;
00225                         unsigned int reserved1 :1;
00226                         unsigned int reserved2 :1;
00227                         unsigned int accelerometer_over_range :1;
00228                         unsigned int gyroscope_over_range :1;
00229                         unsigned int magnetometer_over_range :1;
00230                         unsigned int reserved3 :1;
00231                         unsigned int minimum_temperature_alarm :1;
00232                         unsigned int maximum_temperature_alarm :1;
00233                         unsigned int low_voltage_alarm :1;
00234                         unsigned int high_voltage_alarm :1;
00235                         unsigned int reserved4 :1;
00236                         unsigned int serial_port_overflow_alarm :1;
00237                 } b;
00238         } system_status;
00239         union
00240         {
00241                 uint16_t r;
00242                 struct
00243                 {
00244                         unsigned int orientation_filter_initialised :1;
00245                         unsigned int reserved1 :1;
00246                         unsigned int heading_initialised :1;
00247                         unsigned int reserved2 :1;
00248                         unsigned int reserved3 :1;
00249                         unsigned int reserved4 :1;
00250                         unsigned int reserved5 :1;
00251                         unsigned int reserved6 :1;
00252                         unsigned int reserved7 :1;
00253                         unsigned int reserved8 :1;
00254                         unsigned int magnetometers_enabled :1;
00255                         unsigned int velocity_heading_enabled :1;
00256                         unsigned int reserved9 :1;
00257                         unsigned int external_position_active :1;
00258                         unsigned int external_velocity_active :1;
00259                         unsigned int external_heading_active :1;
00260                 } b;
00261         } filter_status;
00262 } status_packet_t;
00263 
00264 typedef struct
00265 {
00266     float standard_deviation[3];
00267 } euler_orientation_standard_deviation_packet_t;
00268 
00269 typedef struct
00270 {
00271     float standard_deviation[4];
00272 } quaternion_orientation_standard_deviation_packet_t;
00273 
00274 typedef struct
00275 {
00276         float accelerometers[3];
00277         float gyroscopes[3];
00278         float magnetometers[3];
00279         float imu_temperature;
00280 } raw_sensors_packet_t;
00281 
00282 typedef struct
00283 {
00284     float acceleration[3];
00285 } acceleration_packet_t;
00286 
00287 typedef struct
00288 {
00289     float orientation[3];
00290 } euler_orientation_packet_t;
00291 
00292 typedef struct
00293 {
00294     float orientation[4];
00295 } quaternion_orientation_packet_t;
00296 
00297 typedef struct
00298 {
00299     float orientation[3][3];
00300 } dcm_orientation_packet_t;
00301 
00302 typedef struct
00303 {
00304     float angular_velocity[3];
00305 } angular_velocity_packet_t;
00306 
00307 typedef struct
00308 {
00309     float angular_acceleration[3];
00310 } angular_acceleration_packet_t;
00311 
00312 typedef struct
00313 {
00314     double position[3];
00315     float velocity[3];
00316     float position_standard_deviation[3];
00317     float velocity_standard_deviation[3];
00318 } external_position_velocity_packet_t;
00319 
00320 typedef struct
00321 {
00322     double position[3];
00323     float standard_deviation[3];
00324 } external_position_packet_t;
00325 
00326 typedef struct
00327 {
00328     float velocity[3];
00329     float standard_deviation[3];
00330 } external_velocity_packet_t;
00331 
00332 typedef struct
00333 {
00334     float heading;
00335     float standard_deviation;
00336 } external_heading_packet_t;
00337 
00338 typedef struct
00339 {
00340         uint32_t seconds;
00341         uint32_t microseconds;
00342 } running_time_packet_t;
00343 
00344 typedef struct
00345 {
00346         float magnetic_field[3];
00347 } local_magnetics_packet_t;
00348 
00349 /* start of configuration packets typedef structs */
00350 
00351 typedef struct
00352 {
00353     uint8_t permanent;
00354     uint8_t utc_synchronisation;
00355     uint16_t packet_timer_period;
00356 } packet_timer_period_packet_t;
00357 
00358 typedef struct
00359 {
00360     uint8_t packet_id;
00361     uint32_t period;
00362 } packet_period_t;
00363 
00364 typedef struct
00365 {
00366     uint8_t permanent;
00367     uint8_t clear_existing_packets;
00368     packet_period_t packet_periods[MAXIMUM_PACKET_PERIODS];
00369 } packet_periods_packet_t;
00370 
00371 typedef struct
00372 {
00373     uint8_t permanent;
00374     uint32_t primary_baud_rate;
00375     uint32_t gpio_1_2_baud_rate;
00376     uint32_t gpio_3_4_baud_rate;
00377 } baud_rates_packet_t;
00378 
00379 typedef enum
00380 {
00381     accelerometer_range_2g,
00382     accelerometer_range_4g,
00383     accelerometer_range_16g
00384 } accelerometer_range_e;
00385 
00386 typedef enum
00387 {
00388     gyroscope_range_250dps,
00389     gyroscope_range_500dps,
00390     gyroscope_range_2000dps
00391 } gyroscope_range_e;
00392 
00393 typedef enum
00394 {
00395     magnetometer_range_2g,
00396     magnetometer_range_4g,
00397     magnetometer_range_8g
00398 } magnetometer_range_e;
00399 
00400 typedef struct
00401 {
00402     uint8_t permanent;
00403     uint8_t accelerometers_range;
00404     uint8_t gyroscopes_range;
00405     uint8_t magnetometers_range;
00406 } sensor_ranges_packet_t;
00407 
00408 typedef struct
00409 {
00410     uint8_t permanent;
00411     float alignment_dcm[3][3];
00412 } installation_alignment_packet_t;
00413 
00414 typedef enum
00415 {
00416     vehicle_type_unconstrained,
00417     vehicle_type_motorcycle,
00418     vehicle_type_car,
00419     vehicle_type_hovercraft,
00420     vehicle_type_submarine,
00421     vehicle_type_3d_underwater,
00422     vehicle_type_fixed_wing_plane,
00423     vehicle_type_3d_aircraft,
00424     vehicle_type_human
00425 } vehicle_type_e;
00426 
00427 typedef struct
00428 {
00429     uint8_t permanent;
00430     uint8_t vehicle_type;
00431     uint8_t magnetometers_enabled;
00432     uint8_t velocity_heading_enabled;
00433 } filter_options_packet_t;
00434 
00435 typedef enum
00436 {
00437         inactive,
00438         pps_output,
00439         gnss_fix_output,
00440         odometer_input,
00441         stationary_input,
00442         pitot_tube_input,
00443         nmea_input,
00444         nmea_output,
00445         novatel_gnss_input,
00446         topcon_gnss_input,
00447         motec_output,
00448         anpp_input,
00449         anpp_output,
00450         disable_magnetometers,
00451         disable_gnss,
00452         disable_pressure,
00453         set_zero_alignment,
00454         packet_trigger_system_state,
00455         packet_trigger_raw_sensors,
00456         rtcm_corrections_input,
00457         trimble_gnss_input,
00458         ublox_gnss_input,
00459         hemisphere_gnss_input,
00460         teledyne_dvl_input,
00461         tritech_usbl_input,
00462         linkquest_dvl_input,
00463         pressure_depth_sensor,
00464         left_wheel_speed_sensor,
00465         right_wheel_speed_sensor
00466 } gpio_function_e;
00467 
00468 typedef enum
00469 {
00470     gpio1,
00471     gpio2,
00472     gpio3,
00473     gpio4,
00474     gpio5,
00475     gpio6
00476 } gpio_index_e;
00477 
00478 typedef struct
00479 {
00480     uint8_t permanent;
00481     uint8_t gpio_function[4];
00482 } gpio_configuration_packet_t;
00483 
00484 typedef struct
00485 {
00486     uint8_t permanent;
00487     float hard_iron[3];
00488     float soft_iron[3][3];
00489 } magnetic_calibration_values_packet_t;
00490 
00491 typedef enum
00492 {
00493     magnetic_calibration_action_cancel,
00494     magnetic_calibration_action_stabilise,
00495     magnetic_calibration_action_start_2d,
00496     magnetic_calibration_action_start_3d
00497 } magnetic_calibration_action_e;
00498 
00499 typedef struct
00500 {
00501     uint8_t magnetic_calibration_action;
00502 } magnetic_calibration_configuration_packet_t;
00503 
00504 typedef enum
00505 {
00506         magnetic_calibration_status_not_completed,
00507         magnetic_calibration_status_completed_2d,
00508         magnetic_calibration_status_completed_3d,
00509         magnetic_calibration_status_completed_user,
00510         magnetic_calibration_status_stabilizing,
00511         magnetic_calibration_status_in_progress_2d,
00512         magnetic_calibration_status_in_progress_3d,
00513         magnetic_calibration_status_error_excessive_roll,
00514         magnetic_calibration_status_error_excessive_pitch,
00515         magnetic_calibration_status_error_overrange_event,
00516         magnetic_calibration_status_error_timeout,
00517         magnetic_calibration_status_error_system
00518 } magnetic_calibration_status_e;
00519 
00520 typedef struct
00521 {
00522     uint8_t magnetic_calibration_status;
00523     uint8_t magnetic_calibration_progress_percentage;
00524     uint8_t local_magnetic_error_percentage;
00525 } magnetic_calibration_status_packet_t;
00526 
00527 typedef struct
00528 {
00529         uint8_t permanent;
00530 } zero_alignment_packet_t;
00531 
00532 int decode_acknowledge_packet(acknowledge_packet_t *acknowledge_packet, an_packet_t *an_packet);
00533 an_packet_t *encode_request_packet(uint8_t requested_packet_id);
00534 int decode_boot_mode_packet(boot_mode_packet_t *boot_mode_packet, an_packet_t *an_packet);
00535 an_packet_t *encode_boot_mode_packet(boot_mode_packet_t *boot_mode_packet);
00536 int decode_device_information_packet(device_information_packet_t *device_information_packet, an_packet_t *an_packet);
00537 an_packet_t *encode_restore_factory_settings_packet();
00538 an_packet_t *encode_reset_packet();
00539 int decode_system_state_packet(system_state_packet_t *system_state_packet, an_packet_t *an_packet);
00540 int decode_unix_time_packet(unix_time_packet_t *unix_time_packet, an_packet_t *an_packet);
00541 int decode_status_packet(status_packet_t *status_packet, an_packet_t *an_packet);
00542 int decode_euler_orientation_standard_deviation_packet(euler_orientation_standard_deviation_packet_t *euler_orientation_standard_deviation, an_packet_t *an_packet);
00543 int decode_quaternion_orientation_standard_deviation_packet(quaternion_orientation_standard_deviation_packet_t *quaternion_orientation_standard_deviation_packet, an_packet_t *an_packet);
00544 int decode_raw_sensors_packet(raw_sensors_packet_t *raw_sensors_packet, an_packet_t *an_packet);
00545 int decode_euler_orientation_packet(euler_orientation_packet_t *euler_orientation_packet, an_packet_t *an_packet);
00546 int decode_quaternion_orientation_packet(quaternion_orientation_packet_t *quaternion_orientation_packet, an_packet_t *an_packet);
00547 int decode_dcm_orientation_packet(dcm_orientation_packet_t *dcm_orientation_packet, an_packet_t *an_packet);
00548 int decode_angular_velocity_packet(angular_velocity_packet_t *angular_velocity_packet, an_packet_t *an_packet);
00549 int decode_angular_acceleration_packet(angular_acceleration_packet_t *angular_acceleration_packet, an_packet_t *an_packet);
00550 int decode_external_position_velocity_packet(external_position_velocity_packet_t *external_position_velocity_packet, an_packet_t *an_packet);
00551 an_packet_t *encode_external_position_velocity_packet(external_position_velocity_packet_t *external_position_velocity_packet);
00552 int decode_external_position_packet(external_position_packet_t *external_position_packet, an_packet_t *an_packet);
00553 an_packet_t *encode_external_position_packet(external_position_packet_t *external_position_packet);
00554 int decode_external_velocity_packet(external_velocity_packet_t *external_velocity_packet, an_packet_t *an_packet);
00555 an_packet_t *encode_external_velocity_packet(external_velocity_packet_t *external_velocity_packet);
00556 int decode_external_heading_packet(external_heading_packet_t *external_heading_packet, an_packet_t *an_packet);
00557 an_packet_t *encode_external_heading_packet(external_heading_packet_t *external_heading_packet);
00558 int decode_running_time_packet(running_time_packet_t *running_time_packet, an_packet_t *an_packet);
00559 int decode_local_magnetics_packet(local_magnetics_packet_t *local_magnetics_packet, an_packet_t *an_packet);
00560 int decode_packet_timer_period_packet(packet_timer_period_packet_t *packet_timer_period_packet, an_packet_t *an_packet);
00561 an_packet_t *encode_packet_timer_period_packet(packet_timer_period_packet_t *packet_timer_period_packet);
00562 int decode_packet_periods_packet(packet_periods_packet_t *packet_periods_packet, an_packet_t *an_packet);
00563 an_packet_t *encode_packet_periods_packet(packet_periods_packet_t *packet_periods_packet);
00564 int decode_baud_rates_packet(baud_rates_packet_t *baud_rates_packet, an_packet_t *an_packet);
00565 an_packet_t *encode_baud_rates_packet(baud_rates_packet_t *baud_rates_packet);
00566 int decode_sensor_ranges_packet(sensor_ranges_packet_t *sensor_ranges_packet, an_packet_t *an_packet);
00567 an_packet_t *encode_sensor_ranges_packet(sensor_ranges_packet_t *sensor_ranges_packet);
00568 int decode_installation_alignment_packet(installation_alignment_packet_t *installation_alignment_packet, an_packet_t *an_packet);
00569 an_packet_t *encode_installation_alignment_packet(installation_alignment_packet_t *installation_alignment_packet);
00570 int decode_filter_options_packet(filter_options_packet_t *filter_options_packet, an_packet_t *an_packet);
00571 an_packet_t *encode_filter_options_packet(filter_options_packet_t *filter_options_packet);
00572 int decode_gpio_configuration_packet(gpio_configuration_packet_t *gpio_configuration_packet, an_packet_t *an_packet);
00573 an_packet_t *encode_gpio_configuration_packet(gpio_configuration_packet_t *gpio_configuration_packet);
00574 int decode_magnetic_calibration_values_packet(magnetic_calibration_values_packet_t *magnetic_calibration_values_packet, an_packet_t *an_packet);
00575 an_packet_t *encode_magnetic_calibration_values_packet(magnetic_calibration_values_packet_t *magnetic_calibration_values_packet);
00576 an_packet_t *encode_magnetic_calibration_configuration_packet(magnetic_calibration_configuration_packet_t *magnetic_calibration_configuration_packet);
00577 int decode_magnetic_calibration_status_packet(magnetic_calibration_status_packet_t *magnetic_calibration_status_packet, an_packet_t *an_packet);
00578 an_packet_t *encode_zero_alignment_packet(zero_alignment_packet_t *zero_alignment_packet);
00579 
00580 
00581 int decode_acceleration_packet(acceleration_packet_t *acceleration_packet, an_packet_t *an_packet);
00582 
00583 #ifdef __cplusplus
00584 }
00585 #endif


orientus_sdk_c
Author(s): Advanced Navigation, Nick Otero
autogenerated on Thu Jun 6 2019 20:17:59