GX4-45_Test.cpp
Go to the documentation of this file.
1 //
3 // GX4-45_Test.c
4 //
5 // Test program for the GX4-45
6 //
7 // Notes: This program runs through most of the sdk functions supported
8 // by the GX4-45. It does not permanently alter any of the device
9 // settings.
10 //
11 //
12 // External dependencies:
13 //
14 // mip_sdk.h
15 // GX4-45_Test.h
16 //
17 // Written By: Nathan Miller and Gregg Carpenter
18 //
20 //
23 //
33 //
35 
36 
38 //
39 //Include Files
40 //
42 
43 #include "microstrain_3dm_gx5_45/GX4-45_Test.h"
44 
46 //
47 // Defines
48 //
50 
52 //
53 // Globals
54 //
56 
58 
59 //The primary device interface structure
60 mip_interface device_interface;
61 
62 //Packet Counters (valid, timeout, and checksum errors)
66 
70 
74 
75 //Example data field storage
76 
77 //AHRS
78 mip_ahrs_scaled_gyro curr_ahrs_gyro;
79 mip_ahrs_scaled_accel curr_ahrs_accel;
80 mip_ahrs_scaled_mag curr_ahrs_mag;
81 
82 //GPS
83 mip_gps_llh_pos curr_llh_pos;
84 mip_gps_ned_vel curr_ned_vel;
85 mip_gps_time curr_gps_time;
86 
87 //FILTER
88 mip_filter_llh_pos curr_filter_pos;
89 mip_filter_ned_velocity curr_filter_vel;
90 mip_filter_attitude_euler_angles curr_filter_angles;
91 
92 
94 //
95 // Main Function
96 //
98 
99 int main(int argc, char* argv[])
100 {
101  u32 com_port, baudrate;
102  base_device_info_field device_info;
103  u8 temp_string[20] = {0};
104  u32 bit_result;
105  u8 enable = 1;
106  u8 data_stream_format_descriptors[10];
107  u16 data_stream_format_decimation[10];
108  u8 data_stream_format_num_entries = 0;
109  u8 readback_data_stream_format_descriptors[10] = {0};
110  u16 readback_data_stream_format_decimation[10] = {0};
111  u8 readback_data_stream_format_num_entries = 0;
112  u16 base_rate = 0;
113  u16 device_descriptors[128] = {0};
114  u16 device_descriptors_size = 128*2;
115  s16 i;
116  u16 j;
117  u8 com_mode = 0;
118  u8 readback_com_mode = 0;
119  float angles[3] = {0};
120  float readback_angles[3] = {0};
121  float offset[3] = {0};
122  float readback_offset[3] = {0};
123  float hard_iron[3] = {0};
124  float hard_iron_readback[3] = {0};
125  float soft_iron[9] = {0};
126  float soft_iron_readback[9] = {0};
127  u8 dynamics_mode = 0;
128  u8 readback_dynamics_mode = 0;
129  u16 estimation_control = 0, estimation_control_readback = 0;
130  u8 gps_source = 0;
131  u8 heading_source = 0;
132  u8 auto_init = 0;
133  float noise[3] = {0};
134  float readback_noise[3] = {0};
135  float beta[3] = {0};
136  float readback_beta[3] = {0};
137  mip_low_pass_filter_settings filter_settings;
138  float bias_vector[3] = {0};
139  u16 duration = 0;
140  gx4_imu_diagnostic_device_status_field imu_diagnostic_field;
141  gx4_imu_basic_status_field imu_basic_field;
142  gx4_45_diagnostic_device_status_field diagnostic_field;
143  gx4_45_basic_status_field basic_field;
144  mip_filter_external_gps_update_command external_gps_update;
145  mip_filter_external_heading_update_command external_heading_update;
146  mip_filter_zero_update_command zero_update_control, zero_update_readback;
147  mip_filter_external_heading_with_time_command external_heading_with_time;
148  mip_complementary_filter_settings comp_filter_command, comp_filter_readback;
149 
150  u8 declination_source_command, declination_source_readback;
151 
152  mip_filter_accel_magnitude_error_adaptive_measurement_command accel_magnitude_error_command, accel_magnitude_error_readback;
153  mip_filter_magnetometer_magnitude_error_adaptive_measurement_command mag_magnitude_error_command, mag_magnitude_error_readback;
154  mip_filter_magnetometer_dip_angle_error_adaptive_measurement_command mag_dip_angle_error_command, mag_dip_angle_error_readback;
155 
156 
157 
159  //Verify the command line arguments
161 
162  if(argc != NUM_COMMAND_LINE_ARGUMENTS)
163  {
165  return -1;
166  }
167 
168  //Convert the arguments
169  com_port = atoi(argv[1]);
170  baudrate = atoi(argv[2]);
171 
173  //Initialize the interface to the device
175  printf("Attempting to open interface on COM port %d \n",com_port);
176  if(mip_interface_init(com_port, baudrate, &device_interface, DEFAULT_PACKET_TIMEOUT_MS) != MIP_INTERFACE_OK)
177  return -1;
178 
179 
181  //jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
182  // IMU-Direct Mode Testing
183  //
185 
187 
189  //Set communication mode
191 
192  printf("----------------------------------------------------------------------\n");
193  printf("Attempting to set communications mode to IMU Direct mode\n");
194  printf("----------------------------------------------------------------------\n\n");
195 
196  while(mip_system_com_mode(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &com_mode) != MIP_INTERFACE_OK){}
197 
199  //Verify device mode setting
201 
202  while(mip_system_com_mode(&device_interface, MIP_FUNCTION_SELECTOR_READ, &com_mode) != MIP_INTERFACE_OK){}
203 
204  if(com_mode == MIP_SDK_GX4_45_IMU_DIRECT_MODE)
205  {
206 
207  printf("Communications mode IMU Direct.\n");
208 
209  printf("\n\n");
210  Sleep(1500);
211 
213  //
214  //Base Command Tests
215  //
217 
219  //Put the GX4-45 into idle mode
221 
222  printf("----------------------------------------------------------------------\n");
223  printf("Idling Device\n");
224  printf("----------------------------------------------------------------------\n\n");
225 
226  while(mip_base_cmd_idle(&device_interface) != MIP_INTERFACE_OK){}
227 
228  printf("\n\n");
229  Sleep(1500);
230 
232  //Try to ping the GX4-45
234 
235  printf("----------------------------------------------------------------------\n");
236  printf("Pinging Device\n");
237  printf("----------------------------------------------------------------------\n\n");
238 
239  while(mip_base_cmd_ping(&device_interface) != MIP_INTERFACE_OK){}
240 
241  printf("\n\n");
242  Sleep(1500);
243 
245  //Get the device information
247 
248  printf("----------------------------------------------------------------------\n");
249  printf("Getting Device Information\n");
250  printf("----------------------------------------------------------------------\n\n");
251 
252  while(mip_base_cmd_get_device_info(&device_interface, &device_info) != MIP_INTERFACE_OK){}
253 
254  printf("\n\nDevice Info:\n");
255  printf("---------------------------------------------\n");
256 
257  memcpy(temp_string, device_info.model_name, BASE_DEVICE_INFO_PARAM_LENGTH*2);
258  printf("Model Name => %s\n", temp_string);
259 
260  memcpy(temp_string, device_info.model_number, BASE_DEVICE_INFO_PARAM_LENGTH*2);
261  printf("Model Number => %s\n", temp_string);
262 
263  memcpy(temp_string, device_info.serial_number, BASE_DEVICE_INFO_PARAM_LENGTH*2);
264  printf("Serial Number => %s\n", temp_string);
265 
266  memcpy(temp_string, device_info.lotnumber, BASE_DEVICE_INFO_PARAM_LENGTH*2);
267  printf("Lot Number => %s\n", temp_string);
268 
269  memcpy(temp_string, device_info.device_options, BASE_DEVICE_INFO_PARAM_LENGTH*2);
270  printf("Options => %s\n", temp_string);
271 
272  printf("Firmware Version => %d.%d.%.2d\n\n", (device_info.firmware_version)/1000,
273  (device_info.firmware_version)%1000/100,
274  (device_info.firmware_version)%100);
275 
276  printf("\n\n");
277  Sleep(1500);
278 
280  //Get the supported descriptors
282 
283  printf("----------------------------------------------------------------------\n");
284  printf("Getting Supported descriptors\n");
285  printf("----------------------------------------------------------------------\n\n");
286 
287  while(mip_base_cmd_get_device_supported_descriptors(&device_interface, (u8*)device_descriptors, &device_descriptors_size) != MIP_INTERFACE_OK){}
288 
289  printf("\n\nSupported descriptors:\n\n");
290 
291  for(i=0; i< device_descriptors_size/2; i++)
292  {
293  printf("Descriptor Set: %02x, Descriptor: %02x\n", device_descriptors[i] >> 8, device_descriptors[i]&0xFF);
294  Sleep(100);
295  }
296 
297  printf("\n\n");
298  Sleep(1500);
299 
301  //Peform a built-in-test
303 
304  printf("----------------------------------------------------------------------\n");
305  printf("Running Built In Test\n");
306  printf("----------------------------------------------------------------------\n\n");
307 
308  while(mip_base_cmd_built_in_test(&device_interface, &bit_result) != MIP_INTERFACE_OK){}
309 
310  printf("\nBIT Result (should be 0x00000000) => 0x%08x\n\n", bit_result);
311 
312  printf("\n\n");
313  Sleep(1500);
314 
316  //
317  // 3DM Command Tests
318  //
320 
322  //Get AHRS Base Rate
324 
325  printf("----------------------------------------------------------------------\n");
326  printf("Getting the AHRS datastream base rate\n");
327  printf("----------------------------------------------------------------------\n\n");
328 
329  while(mip_3dm_cmd_get_ahrs_base_rate(&device_interface, &base_rate) != MIP_INTERFACE_OK){}
330 
331  printf("\nAHRS Base Rate => %d Hz\n\n", base_rate);
332 
333  printf("\n\n");
334  Sleep(1500);
335 
337  //Get Device Status
339 
340 
341  printf("----------------------------------------------------------------------\n");
342  printf("Requesting BASIC Status Report:\n");
343  printf("----------------------------------------------------------------------\n\n");
344 
345  //Request basic status report
346  while(mip_3dm_cmd_hw_specific_imu_device_status(&device_interface, GX4_IMU_MODEL_NUMBER, GX4_IMU_BASIC_STATUS_SEL, &imu_basic_field) != MIP_INTERFACE_OK){}
347 
348  printf("Model Number: \t\t\t\t\t%04u\n", imu_basic_field.device_model);
349  printf("Status Selector: \t\t\t\t%s\n", imu_basic_field.status_selector == GX4_IMU_BASIC_STATUS_SEL ? "Basic Status Report" : "Diagnostic Status Report");
350  printf("Status Flags: \t\t\t\t\t0x%08x\n", imu_basic_field.status_flags);
351  printf("System Millisecond Timer Count: \t\t%llu ms\n\n", imu_basic_field.system_timer_ms);
352 
353  printf("Requesting DIAGNOSTIC Status Report:\n");
354 
355  //Request diagnostic status report
356  while(mip_3dm_cmd_hw_specific_imu_device_status(&device_interface, GX4_IMU_MODEL_NUMBER, GX4_IMU_DIAGNOSTICS_STATUS_SEL, &imu_diagnostic_field) != MIP_INTERFACE_OK){}
357 
358  printf("Model Number: \t\t\t\t\t%04u\n", imu_diagnostic_field.device_model);
359  printf("Status Selector: \t\t\t\t%s\n", imu_diagnostic_field.status_selector == GX4_IMU_BASIC_STATUS_SEL ? "Basic Status Report" : "Diagnostic Status Report");
360  printf("Status Flags: \t\t\t\t\t0x%08x\n", imu_diagnostic_field.status_flags);
361  printf("System Millisecond Timer Count: \t\t%llu ms\n", imu_diagnostic_field.system_timer_ms);
362  printf("Magnetometer: \t\t\t\t\t%s\n", imu_diagnostic_field.has_mag == 1 ? "DETECTED" : "NOT-DETECTED");
363  printf("Pressure Sensor: \t\t\t\t%s\n", imu_diagnostic_field.has_pressure == 1 ? "DETECTED" : "NOT-DETECTED");
364  printf("Gyro Range Reported: \t\t\t\t%u deg/s\n", imu_diagnostic_field.gyro_range);
365  printf("Accel Range Reported: \t\t\t\t%u G\n", imu_diagnostic_field.accel_range);
366  printf("Magnetometer Range Reported: \t\t\t%f Gs\n", imu_diagnostic_field.mag_range);
367  printf("Pressure Range Reported: \t\t\t%f hPa\n", imu_diagnostic_field.pressure_range);
368  printf("Measured Internal Temperature: \t\t\t%f degrees C\n", imu_diagnostic_field.temp_degc);
369  printf("Last Temperature Measured: \t\t\t%u ms\n", imu_diagnostic_field.last_temp_read_ms);
370  printf("Bad Temperature Sensor Detected: \t\t%s\n", imu_diagnostic_field.temp_sensor_error == 1 ? "TRUE" : "FALSE");
371  printf("Number Received GPS Pulse-Per-Second Pulses: \t%u Pulses\n", imu_diagnostic_field.num_gps_pps_triggers);
372  printf("Time of Last GPS Pulse-Per-Second Pulse: \t%u ms\n", imu_diagnostic_field.last_gps_pps_trigger_ms);
373  printf("Data Streaming Enabled: \t\t\t%s\n", imu_diagnostic_field.stream_enabled == 1 ? "TRUE" : "FALSE");
374  printf("Number of Dropped Communication Packets: \t%u packets\n", imu_diagnostic_field.dropped_packets);
375  printf("Communications Port Bytes Written: \t\t%u Bytes\n", imu_diagnostic_field.com_port_bytes_written);
376  printf("Communications Port Bytes Read: \t\t%u Bytes\n", imu_diagnostic_field.com_port_bytes_read);
377  printf("Communications Port Write Overruns: \t\t%u Bytes\n", imu_diagnostic_field.com_port_write_overruns);
378  printf("Communications Port Read Overruns: \t\t%u Bytes\n", imu_diagnostic_field.com_port_read_overruns);
379 
380  printf("\n\n");
381  Sleep(1500);
382 
384  //Set/Read Coning and Sculling Compensation
386 
387  printf("----------------------------------------------------------------------\n");
388  printf("Disabling Coning and Sculling compensation\n");
389  printf("----------------------------------------------------------------------\n\n");
390 
391  enable = MIP_3DM_CONING_AND_SCULLING_DISABLE;
392 
393  while(mip_3dm_cmd_coning_sculling_compensation(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &enable) != MIP_INTERFACE_OK){}
394 
395  printf("Reading Coning and Sculling compensation enabled state:\n");
396 
397  while(mip_3dm_cmd_coning_sculling_compensation(&device_interface, MIP_FUNCTION_SELECTOR_READ, &enable) != MIP_INTERFACE_OK){}
398 
399  printf("%s\n\n", enable == MIP_3DM_CONING_AND_SCULLING_DISABLE ? "DISABLED" : "ENABLED");
400 
401  printf("Enabling Coning and Sculling compensation.\n");
402 
403  enable = MIP_3DM_CONING_AND_SCULLING_ENABLE;
404 
405  while(mip_3dm_cmd_coning_sculling_compensation(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &enable) != MIP_INTERFACE_OK){}
406 
407  printf("Reading Coning and Sculling compensation enabled state:\n");
408 
409  while(mip_3dm_cmd_coning_sculling_compensation(&device_interface, MIP_FUNCTION_SELECTOR_READ, &enable) != MIP_INTERFACE_OK){}
410 
411  printf("%s\n\n", enable == MIP_3DM_CONING_AND_SCULLING_DISABLE ? "DISABLED" : "ENABLED");
412 
413  printf("\n\n");
414  Sleep(1500);
415 
417  //Set/Read Accel Bias
419 
420  bias_vector[0] = 1.0f;
421  bias_vector[1] = 2.0f;
422  bias_vector[2] = 3.0f;
423 
424  printf("----------------------------------------------------------------------\n");
425  printf("Accel Bias Vector\n");
426  printf("----------------------------------------------------------------------\n\n");
427 
428  printf("Setting Accel Bias Vector:\n");
429  printf("bias_vector[0] = %f\nbias_vector[1] = %f\nbias_vector[2] = %f\n\n", bias_vector[0], bias_vector[1], bias_vector[2]);
430 
431  while(mip_3dm_cmd_accel_bias(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, bias_vector) != MIP_INTERFACE_OK){}
432 
433  memset(bias_vector, 0, 3*sizeof(float));
434 
435  printf("Reading current Accel Bias Vector:\n");
436 
437  while(mip_3dm_cmd_accel_bias(&device_interface, MIP_FUNCTION_SELECTOR_READ, bias_vector) != MIP_INTERFACE_OK){}
438 
439  printf("bias_vector[0] = %f\nbias_vector[1] = %f\nbias_vector[2] = %f\n\n", bias_vector[0], bias_vector[1], bias_vector[2]);
440 
441  printf("Resetting Accel Bias to default state.\n\n");
442 
443  while(mip_3dm_cmd_accel_bias(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
444 
445  printf("\n\n");
446  Sleep(1500);
447 
449  //Set/Read Gyro Bias
451 
452  bias_vector[0] = 4.0f;
453  bias_vector[1] = 5.0f;
454  bias_vector[2] = 6.0f;
455 
456  printf("----------------------------------------------------------------------\n");
457  printf("Gyro Bias Vector\n");
458  printf("----------------------------------------------------------------------\n\n");
459 
460  printf("Setting Gyro Bias Vector:\n");
461  printf("bias_vector[0] = %f\nbias_vector[1] = %f\nbias_vector[2] = %f\n\n", bias_vector[0], bias_vector[1], bias_vector[2]);
462 
463  while(mip_3dm_cmd_gyro_bias(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, bias_vector) != MIP_INTERFACE_OK){}
464 
465  memset(bias_vector, 0, 3*sizeof(float));
466 
467  printf("Reading current Gyro Bias Vector:\n");
468 
469  while(mip_3dm_cmd_gyro_bias(&device_interface, MIP_FUNCTION_SELECTOR_READ, bias_vector) != MIP_INTERFACE_OK){}
470 
471  printf("bias_vector[0] = %f\nbias_vector[1] = %f\nbias_vector[2] = %f\n\n", bias_vector[0], bias_vector[1], bias_vector[2]);
472 
473  printf("Resetting Gyro Bias to default state.\n\n");
474 
475  while(mip_3dm_cmd_gyro_bias(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
476 
477  printf("\n\n");
478  Sleep(1500);
479 
480 
482  //Capture Gyro Bias
484 
485  printf("----------------------------------------------------------------------\n");
486  printf("Performing Gyro Bias capture.\nPlease keep device stationary during the 5 second gyro bias capture interval\n");
487  printf("----------------------------------------------------------------------\n\n");
488 
489  duration = 5000; //milliseconds
490 
491  while(mip_3dm_cmd_capture_gyro_bias(&device_interface, duration, bias_vector) != MIP_INTERFACE_OK){}
492 
493  printf("Gyro Bias Captured:\nbias_vector[0] = %f\nbias_vector[1] = %f\nbias_vector[2] = %f\n\n", bias_vector[0], bias_vector[1], bias_vector[2]);
494 
495  printf("\n\n");
496  Sleep(1500);
497 
498 
500  //Set/Read the hard iron offset values
502 
503  printf("----------------------------------------------------------------------\n");
504  printf("Setting the hard iron offset values\n");
505  printf("----------------------------------------------------------------------\n\n");
506 
507  hard_iron[0] = 1.0;
508  hard_iron[1] = 2.0;
509  hard_iron[2] = 3.0;
510 
511  while(mip_3dm_cmd_hard_iron(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, hard_iron) != MIP_INTERFACE_OK){}
512 
513  //Read back the hard iron offset values
514  while(mip_3dm_cmd_hard_iron(&device_interface, MIP_FUNCTION_SELECTOR_READ, hard_iron_readback) != MIP_INTERFACE_OK){}
515 
516  if((abs(hard_iron_readback[0] - hard_iron[0]) < 0.001) &&
517  (abs(hard_iron_readback[1] - hard_iron[1]) < 0.001) &&
518  (abs(hard_iron_readback[2] - hard_iron[2]) < 0.001))
519  {
520  printf("Hard iron offset values successfully set.\n");
521  }
522  else
523  {
524  printf("ERROR: Failed to set hard iron offset values!!!\n");
525  printf("Sent values: %f X %f Y %f Z\n", hard_iron[0], hard_iron[1], hard_iron[2]);
526  printf("Returned values: %f X %f Y %f Z\n", hard_iron_readback[0], hard_iron_readback[1], hard_iron_readback[2]);
527  }
528 
529  printf("\n\nLoading the default hard iron offset values.\n\n");
530 
531  while(mip_3dm_cmd_hard_iron(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
532 
533  printf("\n\n");
534  Sleep(1500);
535 
536 
538  //Set/Read the soft iron matrix values
540 
541  printf("----------------------------------------------------------------------\n");
542  printf("Setting the soft iron matrix values\n");
543  printf("----------------------------------------------------------------------\n\n");
544 
545  for(i=0; i<9; i++)
546  soft_iron[i] = i;
547 
548  while(mip_3dm_cmd_soft_iron(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, soft_iron) != MIP_INTERFACE_OK){}
549 
550  //Read back the soft iron matrix values
551  while(mip_3dm_cmd_soft_iron(&device_interface, MIP_FUNCTION_SELECTOR_READ, soft_iron_readback) != MIP_INTERFACE_OK){}
552 
553  if((abs(soft_iron_readback[0] - soft_iron[0]) < 0.001) &&
554  (abs(soft_iron_readback[1] - soft_iron[1]) < 0.001) &&
555  (abs(soft_iron_readback[2] - soft_iron[2]) < 0.001) &&
556  (abs(soft_iron_readback[3] - soft_iron[3]) < 0.001) &&
557  (abs(soft_iron_readback[4] - soft_iron[4]) < 0.001) &&
558  (abs(soft_iron_readback[5] - soft_iron[5]) < 0.001) &&
559  (abs(soft_iron_readback[6] - soft_iron[6]) < 0.001) &&
560  (abs(soft_iron_readback[7] - soft_iron[7]) < 0.001) &&
561  (abs(soft_iron_readback[8] - soft_iron[8]) < 0.001))
562  {
563  printf("Soft iron matrix values successfully set.\n");
564  }
565  else
566  {
567  printf("ERROR: Failed to set hard iron values!!!\n");
568  printf("Sent values: [%f %f %f][%f %f %f][%f %f %f]\n", soft_iron[0], soft_iron[1], soft_iron[2], soft_iron[3], soft_iron[4], soft_iron[5], soft_iron[6], soft_iron[7], soft_iron[8]);
569  printf("Returned values: [%f %f %f][%f %f %f][%f %f %f]\n", soft_iron_readback[0], soft_iron_readback[1], soft_iron_readback[2], soft_iron_readback[3], soft_iron_readback[4],
570  soft_iron_readback[5], soft_iron_readback[6], soft_iron_readback[7], soft_iron_readback[8]);
571  }
572 
573  printf("\n\nLoading the default soft iron matrix values.\n\n");
574 
575  while(mip_3dm_cmd_soft_iron(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
576 
577  printf("\n\n");
578  Sleep(1500);
579 
580 
581 
583  //Setup the AHRS datastream format
585 
586  printf("----------------------------------------------------------------------\n");
587  printf("Setting the AHRS message format\n");
588  printf("----------------------------------------------------------------------\n\n");
589 
590  data_stream_format_descriptors[0] = MIP_AHRS_DATA_ACCEL_SCALED;
591  data_stream_format_descriptors[1] = MIP_AHRS_DATA_GYRO_SCALED;
592 
593  data_stream_format_decimation[0] = 0x64;
594  data_stream_format_decimation[1] = 0x64;
595 
596  data_stream_format_num_entries = 2;
597 
598  while(mip_3dm_cmd_ahrs_message_format(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &data_stream_format_num_entries, data_stream_format_descriptors, data_stream_format_decimation) != MIP_INTERFACE_OK){}
599 
600  printf("\n\n");
601  Sleep(1500);
602 
603 
605  //Poll the AHRS data
607 
608  printf("----------------------------------------------------------------------\n");
609  printf("Polling AHRS Data.\n");
610  printf("----------------------------------------------------------------------\n\n");
611 
612  while(mip_3dm_cmd_poll_ahrs(&device_interface, MIP_3DM_POLLING_ENABLE_ACK_NACK, data_stream_format_num_entries, data_stream_format_descriptors) != MIP_INTERFACE_OK){}
613 
614  }
615  else
616  {
617  printf("ERROR: IMU_Direct mode not established\n\n");
618  }
619 
620  printf("\n\n");
621  Sleep(1500);
622 
623 
625  //
626  // Standard Mode Tests
627  //
629 
630  device_descriptors_size = 128*2;
632 
633  printf("----------------------------------------------------------------------\n");
634  printf("Putting Device Into Standard Mode\n");
635  printf("----------------------------------------------------------------------\n\n");
636 
637  //Set communication mode
638  while(mip_system_com_mode(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &com_mode) != MIP_INTERFACE_OK){}
639 
640  //Verify device mode setting
641  while(mip_system_com_mode(&device_interface, MIP_FUNCTION_SELECTOR_READ, &com_mode) != MIP_INTERFACE_OK){}
642 
643  printf("\n\n");
644  Sleep(1500);
645 
646 
647  if(com_mode == MIP_SDK_GX4_45_IMU_STANDARD_MODE)
648  {
649 
651  //
652  //Base Command Tests
653  //
655 
657  //Put the GX4-45 into idle mode
659 
660  printf("----------------------------------------------------------------------\n");
661  printf("Idling Device\n");
662  printf("----------------------------------------------------------------------\n\n");
663 
664  while(mip_base_cmd_idle(&device_interface) != MIP_INTERFACE_OK){}
665 
666  printf("\n\n");
667  Sleep(1500);
668 
670  //Try to ping the GX4-45
672 
673  printf("----------------------------------------------------------------------\n");
674  printf("Pinging Device\n");
675  printf("----------------------------------------------------------------------\n\n");
676 
677  while(mip_base_cmd_ping(&device_interface) != MIP_INTERFACE_OK){}
678 
679  printf("\n\n");
680  Sleep(1500);
681 
683  //Get the device information
685 
686  printf("----------------------------------------------------------------------\n");
687  printf("Getting Device Information\n");
688  printf("----------------------------------------------------------------------\n\n");
689 
690  while(mip_base_cmd_get_device_info(&device_interface, &device_info) != MIP_INTERFACE_OK){}
691 
692  printf("Device Info:\n");
693  printf("---------------------------------------------\n");
694 
695  memcpy(temp_string, device_info.model_name, BASE_DEVICE_INFO_PARAM_LENGTH*2);
696  printf("Model Name => %s\n", temp_string);
697 
698  memcpy(temp_string, device_info.model_number, BASE_DEVICE_INFO_PARAM_LENGTH*2);
699  printf("Model Number => %s\n", temp_string);
700 
701  memcpy(temp_string, device_info.serial_number, BASE_DEVICE_INFO_PARAM_LENGTH*2);
702  printf("Serial Number => %s\n", temp_string);
703 
704  memcpy(temp_string, device_info.lotnumber, BASE_DEVICE_INFO_PARAM_LENGTH*2);
705  printf("Lot Number => %s\n", temp_string);
706 
707  memcpy(temp_string, device_info.device_options, BASE_DEVICE_INFO_PARAM_LENGTH*2);
708  printf("Options => %s\n", temp_string);
709 
710  printf("Firmware Version => %d.%d.%.2d\n\n", (device_info.firmware_version)/1000,
711  (device_info.firmware_version)%1000/100,
712  (device_info.firmware_version)%100);
713 
714  printf("\n\n");
715  Sleep(1500);
716 
718  //Get the supported descriptors
720 
721  printf("----------------------------------------------------------------------\n");
722  printf("Getting Supported descriptors\n");
723  printf("----------------------------------------------------------------------\n\n");
724 
725  while(mip_base_cmd_get_device_supported_descriptors(&device_interface, (u8*)device_descriptors, &device_descriptors_size) != MIP_INTERFACE_OK){}
726 
727  printf("\n\nSupported descriptors:\n\n");
728 
729  for(i=0; i< device_descriptors_size/2; i++)
730  {
731  printf("Descriptor Set: %02x, Descriptor: %02x\n", device_descriptors[i] >> 8, device_descriptors[i]&0xFF);
732  Sleep(100);
733  }
734 
735  printf("\n\n");
736  Sleep(1500);
737 
738 
740  //Peform a built-in-test
742 
743  printf("----------------------------------------------------------------------\n");
744  printf("Running Built In Test\n");
745  printf("----------------------------------------------------------------------\n\n");
746 
747  while(mip_base_cmd_built_in_test(&device_interface, &bit_result) != MIP_INTERFACE_OK){}
748 
749  printf("\nBIT Result (should be 0x00000000) => 0x%08x\n\n", bit_result);
750 
751 
752  printf("\n\n");
753  Sleep(1500);
754 
756  //
757  // 3DM Command Tests
758  //
760 
762  //Get AHRS Base Rate
764 
765  printf("----------------------------------------------------------------------\n");
766  printf("Getting the AHRS datastream base rate\n");
767  printf("----------------------------------------------------------------------\n\n");
768 
769  while(mip_3dm_cmd_get_ahrs_base_rate(&device_interface, &base_rate) != MIP_INTERFACE_OK){}
770 
771  printf("\nAHRS Base Rate => %d Hz\n", base_rate);
772 
773  printf("\n\n");
774  Sleep(1500);
775 
777  //Get GPS Base Rate
779 
780  printf("----------------------------------------------------------------------\n");
781  printf("Getting the GPS datastream base rate\n");
782  printf("----------------------------------------------------------------------\n\n");
783 
784  while(mip_3dm_cmd_get_gps_base_rate(&device_interface, &base_rate) != MIP_INTERFACE_OK){}
785 
786  printf("\nGPS Base Rate => %d Hz\n", base_rate);
787 
788  printf("\n\n");
789  Sleep(1500);
790 
792  //Get Estimation Filter Base Rate
794 
795  printf("----------------------------------------------------------------------\n");
796  printf("Getting the Estimation Filter datastream base rate\n");
797  printf("----------------------------------------------------------------------\n\n");
798 
799  while(mip_3dm_cmd_get_filter_base_rate(&device_interface, &base_rate) != MIP_INTERFACE_OK){}
800 
801  printf("\nFILTER Base Rate => %d Hz\n", base_rate);
802 
803  printf("\n\n");
804  Sleep(1500);
805 
807  //Set/Read Coning and Sculling Compensation
809 
810  printf("----------------------------------------------------------------------\n");
811  printf("Toggling Coning and Sculling compensation\n");
812  printf("----------------------------------------------------------------------\n\n");
813 
814  enable = MIP_3DM_CONING_AND_SCULLING_DISABLE;
815 
816  while(mip_3dm_cmd_coning_sculling_compensation(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &enable) != MIP_INTERFACE_OK){}
817 
818  printf("Reading Coning and Sculling compensation enabled state:\n");
819 
820  while(mip_3dm_cmd_coning_sculling_compensation(&device_interface, MIP_FUNCTION_SELECTOR_READ, &enable) != MIP_INTERFACE_OK){}
821 
822  printf("%s\n\n", enable == MIP_3DM_CONING_AND_SCULLING_DISABLE ? "DISABLED" : "ENABLED");
823 
824  printf("Enabling Coning and Sculling compensation.\n");
825 
826  enable = MIP_3DM_CONING_AND_SCULLING_ENABLE;
827 
828  while(mip_3dm_cmd_coning_sculling_compensation(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &enable) != MIP_INTERFACE_OK){}
829 
830  printf("Reading Coning and Sculling compensation enabled state:\n");
831 
832  while(mip_3dm_cmd_coning_sculling_compensation(&device_interface, MIP_FUNCTION_SELECTOR_READ, &enable) != MIP_INTERFACE_OK){}
833 
834  printf("%s\n\n", enable == MIP_3DM_CONING_AND_SCULLING_DISABLE ? "DISABLED" : "ENABLED");
835 
836  printf("\n\n");
837  Sleep(1500);
838 
839 
841  //Set/Read Accel Bias
843 
844  bias_vector[0] = 1.0f;
845  bias_vector[1] = 2.0f;
846  bias_vector[2] = 3.0f;
847 
848  printf("----------------------------------------------------------------------\n");
849  printf("Accel Bias Vector\n");
850  printf("----------------------------------------------------------------------\n\n");
851 
852  printf("Setting Accel Bias Vector:\n");
853  printf("bias_vector[0] = %f\nbias_vector[1] = %f\nbias_vector[2] = %f\n\n", bias_vector[0], bias_vector[1], bias_vector[2]);
854 
855  while(mip_3dm_cmd_accel_bias(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, bias_vector) != MIP_INTERFACE_OK){}
856 
857  memset(bias_vector, 0, 3*sizeof(float));
858 
859  printf("Reading current Accel Bias Vector:\n");
860 
861  while(mip_3dm_cmd_accel_bias(&device_interface, MIP_FUNCTION_SELECTOR_READ, bias_vector) != MIP_INTERFACE_OK){}
862 
863  printf("bias_vector[0] = %f\nbias_vector[1] = %f\nbias_vector[2] = %f\n\n", bias_vector[0], bias_vector[1], bias_vector[2]);
864 
865  printf("Resetting Accel Bias to default state.\n\n");
866 
867  while(mip_3dm_cmd_accel_bias(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
868 
869  printf("\n\n");
870  Sleep(1500);
871 
872 
874  //Set/Read Gyro Bias
876 
877  bias_vector[0] = 4.0f;
878  bias_vector[1] = 5.0f;
879  bias_vector[2] = 6.0f;
880 
881  printf("----------------------------------------------------------------------\n");
882  printf("Gyro Bias Vector\n");
883  printf("----------------------------------------------------------------------\n\n");
884 
885  printf("Setting Gyro Bias Vector:\n");
886  printf("bias_vector[0] = %f\nbias_vector[1] = %f\nbias_vector[2] = %f\n\n", bias_vector[0], bias_vector[1], bias_vector[2]);
887 
888  while(mip_3dm_cmd_gyro_bias(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, bias_vector) != MIP_INTERFACE_OK){}
889 
890  memset(bias_vector, 0, 3*sizeof(float));
891 
892  printf("Reading current Gyro Bias Vector:\n");
893 
894  while(mip_3dm_cmd_gyro_bias(&device_interface, MIP_FUNCTION_SELECTOR_READ, bias_vector) != MIP_INTERFACE_OK){}
895 
896  printf("bias_vector[0] = %f\nbias_vector[1] = %f\nbias_vector[2] = %f\n\n", bias_vector[0], bias_vector[1], bias_vector[2]);
897 
898  printf("Resetting Gyro Bias to default state.\n\n");
899 
900  while(mip_3dm_cmd_gyro_bias(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
901 
902  printf("\n\n");
903  Sleep(1500);
904 
905 
907  //Capture Gyro Bias
909 
910  printf("----------------------------------------------------------------------\n");
911  printf("Performing Gyro Bias capture.\nPlease keep device stationary during the 5 second gyro bias capture interval\n");
912  printf("----------------------------------------------------------------------\n\n");
913 
914  duration = 5000; //milliseconds
915 
916  while(mip_3dm_cmd_capture_gyro_bias(&device_interface, duration, bias_vector) != MIP_INTERFACE_OK){}
917 
918  printf("Gyro Bias Captured:\nbias_vector[0] = %f\nbias_vector[1] = %f\nbias_vector[2] = %f\n\n", bias_vector[0], bias_vector[1], bias_vector[2]);
919 
920  printf("\n\n");
921  Sleep(1500);
922 
923 
925  //Set/Read the hard iron offset values
927 
928  printf("----------------------------------------------------------------------\n");
929  printf("Setting the hard iron offset values\n");
930  printf("----------------------------------------------------------------------\n\n");
931 
932  hard_iron[0] = 1.0;
933  hard_iron[1] = 2.0;
934  hard_iron[2] = 3.0;
935 
936  while(mip_3dm_cmd_hard_iron(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, hard_iron) != MIP_INTERFACE_OK){}
937 
938  //Read back the hard iron offset values
939  while(mip_3dm_cmd_hard_iron(&device_interface, MIP_FUNCTION_SELECTOR_READ, hard_iron_readback) != MIP_INTERFACE_OK){}
940 
941  if((abs(hard_iron_readback[0] - hard_iron[0]) < 0.001) &&
942  (abs(hard_iron_readback[1] - hard_iron[1]) < 0.001) &&
943  (abs(hard_iron_readback[2] - hard_iron[2]) < 0.001))
944  {
945  printf("Hard iron offset values successfully set.\n");
946  }
947  else
948  {
949  printf("ERROR: Failed to set hard iron offset values!!!\n");
950  printf("Sent values: %f X %f Y %f Z\n", hard_iron[0], hard_iron[1], hard_iron[2]);
951  printf("Returned values: %f X %f Y %f Z\n", hard_iron_readback[0], hard_iron_readback[1], hard_iron_readback[2]);
952  }
953 
954  printf("\n\nLoading the default hard iron offset values.\n\n");
955 
956  while(mip_3dm_cmd_hard_iron(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
957 
958  printf("\n\n");
959  Sleep(1500);
960 
961 
963  //Set/Read the soft iron matrix values
965 
966  printf("----------------------------------------------------------------------\n");
967  printf("Setting the soft iron matrix values\n");
968  printf("----------------------------------------------------------------------\n\n");
969 
970  for(i=0; i<9; i++)
971  soft_iron[i] = i;
972 
973  while(mip_3dm_cmd_soft_iron(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, soft_iron) != MIP_INTERFACE_OK){}
974 
975  //Read back the soft iron matrix values
976  while(mip_3dm_cmd_soft_iron(&device_interface, MIP_FUNCTION_SELECTOR_READ, soft_iron_readback) != MIP_INTERFACE_OK){}
977 
978  if((abs(soft_iron_readback[0] - soft_iron[0]) < 0.001) &&
979  (abs(soft_iron_readback[1] - soft_iron[1]) < 0.001) &&
980  (abs(soft_iron_readback[2] - soft_iron[2]) < 0.001) &&
981  (abs(soft_iron_readback[3] - soft_iron[3]) < 0.001) &&
982  (abs(soft_iron_readback[4] - soft_iron[4]) < 0.001) &&
983  (abs(soft_iron_readback[5] - soft_iron[5]) < 0.001) &&
984  (abs(soft_iron_readback[6] - soft_iron[6]) < 0.001) &&
985  (abs(soft_iron_readback[7] - soft_iron[7]) < 0.001) &&
986  (abs(soft_iron_readback[8] - soft_iron[8]) < 0.001))
987  {
988  printf("Soft iron matrix values successfully set.\n");
989  }
990  else
991  {
992  printf("ERROR: Failed to set hard iron values!!!\n");
993  printf("Sent values: [%f %f %f][%f %f %f][%f %f %f]\n", soft_iron[0], soft_iron[1], soft_iron[2], soft_iron[3], soft_iron[4], soft_iron[5], soft_iron[6], soft_iron[7], soft_iron[8]);
994  printf("Returned values: [%f %f %f][%f %f %f][%f %f %f]\n", soft_iron_readback[0], soft_iron_readback[1], soft_iron_readback[2], soft_iron_readback[3], soft_iron_readback[4],
995  soft_iron_readback[5], soft_iron_readback[6], soft_iron_readback[7], soft_iron_readback[8]);
996  }
997 
998  printf("\n\nLoading the default soft iron matrix values.\n\n");
999 
1000  while(mip_3dm_cmd_soft_iron(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1001 
1002  printf("\n\n");
1003  Sleep(1500);
1004 
1005 
1006 
1008  //Set/Read the complementary filter values
1010 
1011  printf("----------------------------------------------------------------------\n");
1012  printf("Setting the complementary filter values\n");
1013  printf("----------------------------------------------------------------------\n\n");
1014 
1015 
1016  comp_filter_command.north_compensation_enable = 0;
1017  comp_filter_command.up_compensation_enable = 0;
1018 
1019  comp_filter_command.north_compensation_time_constant = 30;
1020  comp_filter_command.up_compensation_time_constant = 30;
1021 
1022  while(mip_3dm_cmd_complementary_filter_settings(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &comp_filter_command) != MIP_INTERFACE_OK){}
1023 
1024  //Read back the complementary filter values
1025  while(mip_3dm_cmd_complementary_filter_settings(&device_interface, MIP_FUNCTION_SELECTOR_READ, &comp_filter_readback) != MIP_INTERFACE_OK){}
1026 
1027  if((comp_filter_command.north_compensation_enable == comp_filter_readback.north_compensation_enable) &&
1028  (comp_filter_command.up_compensation_enable == comp_filter_readback.up_compensation_enable) &&
1029  (abs(comp_filter_command.north_compensation_time_constant - comp_filter_readback.north_compensation_time_constant) < 0.001) &&
1030  (abs(comp_filter_command.up_compensation_time_constant - comp_filter_readback.up_compensation_time_constant) < 0.001))
1031  {
1032  printf("Complementary filter values successfully set.\n");
1033  }
1034  else
1035  {
1036  printf("ERROR: Failed to set complementary filter values!!!\n");
1037  printf("Sent values: Up Enable: %d North Enable: %d Up Time Constant: %f North Time Constant: %f \n", comp_filter_command.up_compensation_enable, comp_filter_command.north_compensation_enable,
1038  comp_filter_command.up_compensation_time_constant, comp_filter_command.north_compensation_time_constant);
1039  printf("Returned values: Up Enable: %d North Enable: %d Up Time Constant: %f North Time Constant: %f \n", comp_filter_readback.up_compensation_enable, comp_filter_readback.north_compensation_enable,
1040  comp_filter_readback.up_compensation_time_constant, comp_filter_readback.north_compensation_time_constant);
1041  }
1042 
1043  printf("\n\nLoading the default complementary filter values.\n\n");
1044 
1045  while(mip_3dm_cmd_complementary_filter_settings(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1046 
1047  printf("\n\n");
1048  Sleep(1500);
1049 
1050 
1052  //Get Device Status
1054 
1055  printf("----------------------------------------------------------------------\n");
1056  printf("Requesting BASIC Status Report\n");
1057  printf("----------------------------------------------------------------------\n\n");
1058 
1059  //Request basic status report
1060  while(mip_3dm_cmd_hw_specific_device_status(&device_interface, GX4_45_MODEL_NUMBER, GX4_45_BASIC_STATUS_SEL, &basic_field) != MIP_INTERFACE_OK){}
1061 
1062  printf("Model Number: \t\t\t\t\t%04u\n", basic_field.device_model);
1063  printf("Status Selector: \t\t\t\t%s\n", basic_field.status_selector == GX4_45_BASIC_STATUS_SEL ? "Basic Status Report" : "Diagnostic Status Report");
1064  printf("Status Flags: \t\t\t\t\t0x%08x\n", basic_field.status_flags);
1065 
1066  if(basic_field.system_state == GX4_45_SYSTEM_STATE_INIT)
1067  {
1068  strcpy(temp_string,"System Initialization");
1069  }
1070  else if(basic_field.system_state == GX4_45_SYSTEM_STATE_SENSOR_STARTUP)
1071  {
1072  strcpy(temp_string,"Sensor Start-up");
1073  }
1074  else if(basic_field.system_state == GX4_45_SYSTEM_STATE_RUNNING)
1075  {
1076  strcpy(temp_string,"System Running");
1077  }
1078 
1079  printf("System State: \t\t\t\t\t%s\n",temp_string);
1080  printf("System Microsecond Timer Count: \t\t%llu ms\n\n", basic_field.system_timer_ms);
1081 
1082  printf("Requesting DIAGNOSTIC Status Report:\n");
1083 
1084  //Request diagnostic status report
1085  while(mip_3dm_cmd_hw_specific_device_status(&device_interface, GX4_45_MODEL_NUMBER, GX4_45_DIAGNOSTICS_STATUS_SEL, &diagnostic_field) != MIP_INTERFACE_OK){}
1086 
1087  printf("Model Number: \t\t\t\t\t%04u\n", diagnostic_field.device_model);
1088  printf("Status Selector: \t\t\t\t%s\n", diagnostic_field.status_selector == GX4_45_BASIC_STATUS_SEL ? "Basic Status Report" : "Diagnostic Status Report");
1089  printf("Status Flags: \t\t\t\t\t0x%08x\n", diagnostic_field.status_flags);
1090  printf("System Millisecond Timer Count: \t\t%llu ms\n", diagnostic_field.system_timer_ms);
1091  printf("Number Received GPS Pulse-Per-Second Pulses: \t%u Pulses\n", diagnostic_field.num_gps_pps_triggers);
1092  printf("Time of Last GPS Pulse-Per-Second Pulse: \t%u ms\n", diagnostic_field.last_gps_pps_trigger_ms);
1093  printf("IMU Streaming Enabled: \t\t\t\t%s\n", diagnostic_field.imu_stream_enabled == 1 ? "TRUE" : "FALSE");
1094  printf("GPS Streaming Enabled: \t\t\t\t%s\n", diagnostic_field.gps_stream_enabled == 1 ? "TRUE" : "FALSE");
1095  printf("FILTER Streaming Enabled: \t\t\t\t%s\n", diagnostic_field.filter_stream_enabled == 1 ? "TRUE" : "FALSE");
1096  printf("Number of Dropped IMU Packets: \t\t\t%u packets\n", diagnostic_field.imu_dropped_packets);
1097  printf("Number of Dropped GPS Packets: \t\t\t%u packets\n", diagnostic_field.gps_dropped_packets);
1098  printf("Number of Dropped FILTER Packets: \t\t\t%u packets\n", diagnostic_field.filter_dropped_packets);
1099  printf("Communications Port Bytes Written: \t\t%u Bytes\n", diagnostic_field.com1_port_bytes_written);
1100  printf("Communications Port Bytes Read: \t\t%u Bytes\n", diagnostic_field.com1_port_bytes_read);
1101  printf("Communications Port Write Overruns: \t\t%u Bytes\n", diagnostic_field.com1_port_write_overruns);
1102  printf("Communications Port Read Overruns: \t\t%u Bytes\n", diagnostic_field.com1_port_read_overruns);
1103  printf("IMU Parser Errors: \t\t\t\t%u Errors\n", diagnostic_field.imu_parser_errors);
1104  printf("IMU Message Count: \t\t\t\t%u Messages\n", diagnostic_field.imu_message_count);
1105  printf("IMU Last Message Received: \t\t\t%u ms\n", diagnostic_field.imu_last_message_ms);
1106  printf("GPS Parser Errors: \t\t\t\t%u Errors\n", diagnostic_field.gps_parser_errors);
1107  printf("GPS Message Count: \t\t\t\t%u Messages\n", diagnostic_field.gps_message_count);
1108  printf("GPS Last Message Received: \t\t\t%u ms\n", diagnostic_field.gps_last_message_ms);
1109 
1110  printf("\n\n");
1111  Sleep(1500);
1112 
1114  //
1115  // Filter Command Tests
1116  //
1118 
1119 
1121  //Reset the filter
1123 
1124  printf("----------------------------------------------------------------------\n");
1125  printf("Resetting the Filter\n");
1126  printf("----------------------------------------------------------------------\n\n");
1127 
1128  while(mip_filter_reset_filter(&device_interface) != MIP_INTERFACE_OK){}
1129 
1130  printf("\n\n");
1131  Sleep(1500);
1132 
1134  //Initialize the filter with Euler Angles
1136 
1137  printf("----------------------------------------------------------------------\n");
1138  printf("Initializing the Filter with Euler angles\n");
1139  printf("----------------------------------------------------------------------\n\n");
1140 
1141  angles[0] = angles[1] = angles[2] = 0;
1142 
1143  while(mip_filter_set_init_attitude(&device_interface, angles) != MIP_INTERFACE_OK){}
1144 
1145  printf("\n\n");
1146  Sleep(1500);
1147 
1149  //Reset the filter
1151 
1152  printf("----------------------------------------------------------------------\n");
1153  printf("Resetting the Filter\n");
1154  printf("----------------------------------------------------------------------\n\n");
1155 
1156  while(mip_filter_reset_filter(&device_interface) != MIP_INTERFACE_OK){}
1157 
1158  printf("\n\n");
1159  Sleep(1500);
1160 
1162  //Initialize the filter with a heading
1164 
1165  printf("----------------------------------------------------------------------\n");
1166  printf("Initializing the Filter with a heading angle\n");
1167  printf("----------------------------------------------------------------------\n\n");
1168 
1169  while(mip_filter_set_init_heading(&device_interface, angles[0]) != MIP_INTERFACE_OK){}
1170 
1171  printf("\n\n");
1172  Sleep(1500);
1173 
1175  //Reset the filter
1177 
1178  printf("----------------------------------------------------------------------\n");
1179  printf("Resetting the Filter\n");
1180  printf("----------------------------------------------------------------------\n\n");
1181 
1182  while(mip_filter_reset_filter(&device_interface) != MIP_INTERFACE_OK){}
1183 
1184  printf("\n\n");
1185  Sleep(1500);
1186 
1188  //Set/Read the Vehicle dynamics mode
1190 
1191  printf("----------------------------------------------------------------------\n");
1192  printf("Cycle through available Vehicle Dynamics Modes\n");
1193  printf("----------------------------------------------------------------------\n\n");
1194 
1195  //Loop through valid modes and set/read current come mode
1196  for(i=3; i>=1; i--)
1197  {
1198  //Set the dynamics mode
1199  dynamics_mode = i;
1200 
1201  while(mip_filter_vehicle_dynamics_mode(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &dynamics_mode) != MIP_INTERFACE_OK){}
1202 
1203  //Reset the readback_dynamics_mode variable
1204  readback_dynamics_mode = 0;
1205 
1206  //Read back the com mode
1207  while(mip_filter_vehicle_dynamics_mode(&device_interface, MIP_FUNCTION_SELECTOR_READ, &readback_dynamics_mode) != MIP_INTERFACE_OK){}
1208 
1209  if(dynamics_mode == readback_dynamics_mode)
1210  {
1211  printf("Vehicle dynamics mode successfully set to %d\n", dynamics_mode);
1212  }
1213  else
1214  {
1215  printf("ERROR: Failed to set vehicle dynamics mode to %d!!!\n", dynamics_mode);
1216  }
1217  }
1218 
1219  printf("\nLoading the default vehicle dynamics mode\n\n");
1220 
1221  while(mip_filter_vehicle_dynamics_mode(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1222 
1223  printf("\n\n");
1224  Sleep(1500);
1225 
1226 
1228  //Set/Read the Sensor to Vehicle Frame transformation
1230 
1231  printf("----------------------------------------------------------------------\n");
1232  printf("Setting the sensor to vehicle frame transformation\n");
1233  printf("----------------------------------------------------------------------\n\n");
1234 
1235  angles[0] = 3.14/4.0;
1236  angles[1] = 3.14/8.0;
1237  angles[2] = 3.14/12.0;
1238 
1239  while(mip_filter_sensor2vehicle_tranformation(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, angles) != MIP_INTERFACE_OK){}
1240 
1241  //Read back the transformation
1242  while(mip_filter_sensor2vehicle_tranformation(&device_interface, MIP_FUNCTION_SELECTOR_READ, readback_angles) != MIP_INTERFACE_OK){}
1243 
1244  if((abs(readback_angles[0]-angles[0]) < 0.001) &&
1245  (abs(readback_angles[1]-angles[1]) < 0.001) &&
1246  (abs(readback_angles[2]-angles[2]) < 0.001))
1247  {
1248  printf("Transformation successfully set.\n");
1249  }
1250  else
1251  {
1252  printf("ERROR: Failed to set transformation!!!\n");
1253  printf("Sent angles: %f roll %f pitch %f yaw\n", angles[0], angles[1], angles[2]);
1254  printf("Returned angles: %f roll %f pitch %f yaw\n", readback_angles[0], readback_angles[1], readback_angles[2]);
1255  }
1256 
1257  printf("\n\nLoading the default sensor to vehicle transformation.\n\n");
1258 
1259  while(mip_filter_sensor2vehicle_tranformation(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1260 
1261  printf("\n\n");
1262  Sleep(1500);
1263 
1265  //Set/Read the Sensor to Vehicle Frame offset
1267 
1268  printf("----------------------------------------------------------------------\n");
1269  printf("Setting the sensor to vehicle frame offset\n");
1270  printf("----------------------------------------------------------------------\n\n");
1271 
1272  offset[0] = 1.0;
1273  offset[1] = 2.0;
1274  offset[2] = 3.0;
1275 
1276  while(mip_filter_sensor2vehicle_offset(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, offset) != MIP_INTERFACE_OK){}
1277 
1278  //Read back the transformation
1279  while(mip_filter_sensor2vehicle_offset(&device_interface, MIP_FUNCTION_SELECTOR_READ, readback_offset) != MIP_INTERFACE_OK){}
1280 
1281  if((abs(readback_offset[0]-offset[0]) < 0.001) &&
1282  (abs(readback_offset[1]-offset[1]) < 0.001) &&
1283  (abs(readback_offset[2]-offset[2]) < 0.001))
1284  {
1285  printf("Offset successfully set.\n");
1286  }
1287  else
1288  {
1289  printf("ERROR: Failed to set offset!!!\n");
1290  printf("Sent offset: %f X %f Y %f Z\n", offset[0], offset[1], offset[2]);
1291  printf("Returned offset: %f X %f Y %f Z\n", readback_offset[0], readback_offset[1], readback_offset[2]);
1292  }
1293 
1294  printf("\n\nLoading the default sensor to vehicle offset.\n\n");
1295 
1296  while(mip_filter_sensor2vehicle_offset(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1297 
1298  printf("\n\n");
1299  Sleep(1500);
1300 
1302  //Set/Read the GPS antenna offset
1304 
1305  printf("----------------------------------------------------------------------\n");
1306  printf("Setting the GPS antenna offset\n");
1307  printf("----------------------------------------------------------------------\n\n");
1308 
1309  offset[0] = 1.0;
1310  offset[1] = 2.0;
1311  offset[2] = 3.0;
1312 
1313  while(mip_filter_antenna_offset(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, offset) != MIP_INTERFACE_OK){}
1314 
1315  //Read back the transformation
1316  while(mip_filter_antenna_offset(&device_interface, MIP_FUNCTION_SELECTOR_READ, readback_offset) != MIP_INTERFACE_OK){}
1317 
1318  if((abs(readback_offset[0]-offset[0]) < 0.001) &&
1319  (abs(readback_offset[1]-offset[1]) < 0.001) &&
1320  (abs(readback_offset[2]-offset[2]) < 0.001))
1321  {
1322  printf("Offset successfully set.\n");
1323  }
1324  else
1325  {
1326  printf("ERROR: Failed to set offset!!!\n");
1327  printf("Sent offset: %f X %f Y %f Z\n", offset[0], offset[1], offset[2]);
1328  printf("Returned offset: %f X %f Y %f Z\n", readback_offset[0], readback_offset[1], readback_offset[2]);
1329  }
1330 
1331  printf("\n\nLoading the default antenna offset.\n\n");
1332 
1333  while(mip_filter_antenna_offset(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1334 
1335  printf("\n\n");
1336  Sleep(1500);
1337 
1339  //Set/Read Estimation control bits
1341 
1342  printf("----------------------------------------------------------------------\n");
1343  printf("Cycling through Estimation Control Flags\n");
1344  printf("----------------------------------------------------------------------\n\n");
1345 
1346  //negate successive bitfields
1347  for(j=0; j < 0x0020 ; j++)
1348  {
1349 
1350  estimation_control = (0xFFFF & ~j);
1351 
1352  //Set control bits
1353  while(mip_filter_estimation_control(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &estimation_control) != MIP_INTERFACE_OK){}
1354 
1355  //Readback set control bits
1356  while(mip_filter_estimation_control(&device_interface, MIP_FUNCTION_SELECTOR_READ, &estimation_control_readback) != MIP_INTERFACE_OK){}
1357 
1358  if(estimation_control != estimation_control_readback)
1359  {
1360  printf("ERROR:\n");
1361 
1362  if((estimation_control_readback & FILTER_ESTIMATION_CONTROL_GYRO_BIAS) != 0 && (estimation_control & FILTER_ESTIMATION_CONTROL_GYRO_BIAS) == 0)
1363  printf("Gyroscope Bias Estimation NOT DISABLED\n");
1364 
1365  if((estimation_control_readback & FILTER_ESTIMATION_CONTROL_ACCEL_BIAS) != 0 && (estimation_control & FILTER_ESTIMATION_CONTROL_ACCEL_BIAS) == 0)
1366  printf("Accelerometer Bias Estimation NOT DISABLED\n");
1367 
1368  if((estimation_control_readback & FILTER_ESTIMATION_CONTROL_GYRO_SCALE_FACTOR) != 0 && (estimation_control & FILTER_ESTIMATION_CONTROL_GYRO_SCALE_FACTOR) == 0)
1369  printf("Gyroscope Scale Factor Estimation NOT DISABLED\n");
1370 
1371  if((estimation_control_readback & FILTER_ESTIMATION_CONTROL_ACCEL_SCALE_FACTOR) != 0 && (estimation_control & FILTER_ESTIMATION_CONTROL_ACCEL_SCALE_FACTOR) == 0)
1372  printf("Accelerometer Scale Factor Estimation NOT DISABLED\n");
1373 
1374  if((estimation_control_readback & FILTER_ESTIMATION_CONTROL_GPS_ANTENNA_OFFSET) != 0 && (estimation_control & FILTER_ESTIMATION_CONTROL_GPS_ANTENNA_OFFSET) == 0)
1375  printf("GPS Antenna Offset Estimation NOT DISABLED\n");
1376  }
1377  }
1378 
1379  printf("\n\nResetting Estimation Control Flags to default state.\n\n");
1380 
1381  while(mip_filter_estimation_control(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, &estimation_control) != MIP_INTERFACE_OK){}
1382 
1383  printf("\n\n");
1384  Sleep(1500);
1385 
1387  //Set/Read the gps source
1389 
1390  printf("----------------------------------------------------------------------\n");
1391  printf("Cycle through available GPS sources\n");
1392  printf("----------------------------------------------------------------------\n\n");
1393 
1394  //Loop through valid modes and set/read current come mode
1395  for(i=2; i>=1; i--)
1396  {
1397  //Set the GPS source
1398  gps_source = i;
1399 
1400  while(mip_filter_gps_source(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &gps_source) != MIP_INTERFACE_OK){}
1401 
1402  //Read back the GPS source
1403  while(mip_filter_gps_source(&device_interface, MIP_FUNCTION_SELECTOR_READ, &gps_source) != MIP_INTERFACE_OK){}
1404 
1405  if(gps_source == i)
1406  {
1407  printf("GPS source successfully set to %d\n", i);
1408  }
1409  else
1410  {
1411  printf("ERROR: Failed to set GPS source to %d!!!\n", i);
1412  }
1413  }
1414 
1415  printf("\n\nLoading the default gps source.\n\n");
1416 
1417  while(mip_filter_gps_source(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1418 
1419  printf("\n\n");
1420  Sleep(1500);
1421 
1423  //External GPS Update
1425 
1426  //Set the GPS source to external GPS
1427  printf("----------------------------------------------------------------------\n");
1428  printf("Performing External GPS Update with externally supplied GPS information\n");
1429  printf("----------------------------------------------------------------------\n\n");
1430 
1431  gps_source = 0x2;
1432 
1433  while(mip_filter_gps_source(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &gps_source) != MIP_INTERFACE_OK){}
1434 
1435  //Set GPS External Update parameters
1436  external_gps_update.tow = 0;
1437  external_gps_update.week_number = 0;
1438  external_gps_update.pos[0] = 44.43753433; //Latitude of LORD Microstrain Sensing Systems
1439  external_gps_update.pos[1] = -73.10612488; //Longitude of LORD Microstrain Sensing Systems
1440  external_gps_update.pos[2] = 134.029999; //Height Above Ellipsoid of LORD Microstrain Sensing Systems
1441  external_gps_update.vel[0] = 0.0; //North Velocity
1442  external_gps_update.vel[1] = 0.0; //East Velocity
1443  external_gps_update.vel[2] = 0.0; //Down Velocity
1444  external_gps_update.pos_1sigma[0] = 0.1; //North Position Standard Deviation
1445  external_gps_update.pos_1sigma[1] = 0.1; //East Position Standard Deviation
1446  external_gps_update.pos_1sigma[2] = 0.1; //Down Position Standard Deviation
1447  external_gps_update.vel_1sigma[0] = 0.1; //North Velocity Standard Deviation
1448  external_gps_update.vel_1sigma[1] = 0.1; //East Velocity Standard Deviation
1449  external_gps_update.vel_1sigma[2] = 0.1; //Down Velocity Standard Deviation
1450 
1451  while(mip_filter_external_gps_update(&device_interface, &external_gps_update) != MIP_INTERFACE_OK){}
1452 
1453  //Reset GPS source to internal GPS
1454  gps_source = 0x01;
1455 
1456  while(mip_filter_gps_source(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &gps_source) != MIP_INTERFACE_OK){}
1457 
1458  printf("\n\n");
1459  Sleep(1500);
1460 
1462  //External Heading Update
1464 
1465  printf("----------------------------------------------------------------------\n");
1466  printf("Performing External Heading Update with externally supplied heading information\n");
1467  printf("----------------------------------------------------------------------\n\n");
1468 
1469  //Set device to external heading update mode
1470  heading_source = 0x3;
1471 
1472  while(mip_filter_heading_source(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &heading_source) != MIP_INTERFACE_OK){}
1473 
1474  external_heading_update.heading_angle = 0.0; //0 Radians
1475  external_heading_update.heading_angle_1sigma = 0.01; //Radian Standard Deviation in heading estimate
1476  external_heading_update.type = 0x1; //True Heading
1477 
1478  while(mip_filter_external_heading_update(&device_interface, &external_heading_update) != MIP_INTERFACE_OK){}
1479 
1480  //Set device to default heading update mode
1481 
1482  while(mip_filter_heading_source(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, &heading_source) != MIP_INTERFACE_OK){}
1483 
1484  printf("\n\n");
1485  Sleep(1500);
1486 
1488  //Cycle through the available heading sources
1490 
1491  printf("----------------------------------------------------------------------\n");
1492  printf("Cycle through available Heading sources\n");
1493  printf("----------------------------------------------------------------------\n\n");
1494 
1495  //Loop through valid heading sources and set/read
1496  for(i=3; i>=0; i--)
1497  {
1498  //Set the heading source
1499  heading_source = i;
1500 
1501  mip_filter_heading_source(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &heading_source);
1502 
1503  //Read back the heading source
1504  while(mip_filter_heading_source(&device_interface, MIP_FUNCTION_SELECTOR_READ, &heading_source) != MIP_INTERFACE_OK){}
1505 
1506  if(heading_source == i)
1507  {
1508  printf("Heading source successfully set to %d\n", i);
1509  }
1510  else
1511  {
1512  printf("ERROR: Failed to set heading source to %d!!!\n", i);
1513  }
1514  }
1515 
1516  printf("\n\nLoading the default heading source.\n\n");
1517 
1518  while(mip_filter_heading_source(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1519 
1520  printf("\n\n");
1521  Sleep(1500);
1522 
1524  //Cycle through the available auto-init values
1526 
1527  printf("----------------------------------------------------------------------\n");
1528  printf("Cycle through available auto-init values\n");
1529  printf("----------------------------------------------------------------------\n\n");
1530 
1531  //Loop through valid heading sources and set/read
1532  for(i=1; i>=0; i--)
1533  {
1534  //Set the auto-init value
1535  auto_init = i;
1536 
1537  while(mip_filter_auto_initialization(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &auto_init) != MIP_INTERFACE_OK){}
1538 
1539  //Read back the auto-init value
1540  while(mip_filter_auto_initialization(&device_interface, MIP_FUNCTION_SELECTOR_READ, &auto_init) != MIP_INTERFACE_OK){}
1541 
1542  if(auto_init == i)
1543  {
1544  printf("Auto-init successfully set to %d\n", i);
1545  }
1546  else
1547  {
1548  printf("ERROR: Failed to set auto-init to %d!!!\n", i);
1549  }
1550  }
1551 
1552  printf("\n\nLoading the default auto-init value.\n\n");
1553 
1554  while(mip_filter_auto_initialization(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1555 
1556  printf("\n\n");
1557  Sleep(1500);
1558 
1560  //Set/Read the accel noise values
1562 
1563  printf("----------------------------------------------------------------------\n");
1564  printf("Setting the accel noise values\n");
1565  printf("----------------------------------------------------------------------\n\n");
1566 
1567  noise[0] = 0.1;
1568  noise[1] = 0.2;
1569  noise[2] = 0.3;
1570 
1571  while(mip_filter_accel_noise(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, noise) != MIP_INTERFACE_OK){}
1572 
1573  //Read back the accel noise values
1574  while(mip_filter_accel_noise(&device_interface, MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK){}
1575 
1576  if((abs(readback_noise[0]-noise[0]) < 0.001) &&
1577  (abs(readback_noise[1]-noise[1]) < 0.001) &&
1578  (abs(readback_noise[2]-noise[2]) < 0.001))
1579  {
1580  printf("Accel noise values successfully set.\n");
1581  }
1582  else
1583  {
1584  printf("ERROR: Failed to set accel noise values!!!\n");
1585  printf("Sent values: %f X %f Y %f Z\n", noise[0], noise[1], noise[2]);
1586  printf("Returned values: %f X %f Y %f Z\n", readback_noise[0], readback_noise[1], readback_noise[2]);
1587  }
1588 
1589  printf("\n\nLoading the default accel noise values.\n\n");
1590 
1591  while(mip_filter_accel_noise(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1592 
1593  printf("\n\n");
1594  Sleep(1500);
1595 
1597  //Set/Read the gyro noise values
1599 
1600  printf("----------------------------------------------------------------------\n");
1601  printf("Setting the gyro noise values\n");
1602  printf("----------------------------------------------------------------------\n\n");
1603 
1604  noise[0] = 0.1;
1605  noise[1] = 0.2;
1606  noise[2] = 0.3;
1607 
1608  while(mip_filter_gyro_noise(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, noise) != MIP_INTERFACE_OK){}
1609 
1610  //Read back the gyro noise values
1611  while(mip_filter_gyro_noise(&device_interface, MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK){}
1612 
1613  if((abs(readback_noise[0]-noise[0]) < 0.001) &&
1614  (abs(readback_noise[1]-noise[1]) < 0.001) &&
1615  (abs(readback_noise[2]-noise[2]) < 0.001))
1616  {
1617  printf("Gyro noise values successfully set.\n");
1618  }
1619  else
1620  {
1621  printf("ERROR: Failed to set gyro noise values!!!\n");
1622  printf("Sent values: %f X %f Y %f Z\n", noise[0], noise[1], noise[2]);
1623  printf("Returned values: %f X %f Y %f Z\n", readback_noise[0], readback_noise[1], readback_noise[2]);
1624  }
1625 
1626  printf("\n\nLoading the default gyro noise values.\n\n");
1627 
1628  while(mip_filter_gyro_noise(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1629 
1630  printf("\n\n");
1631  Sleep(1500);
1632 
1633 
1635  //Set/Read the mag noise values
1637 
1638  printf("----------------------------------------------------------------------\n");
1639  printf("Setting the mag noise values\n");
1640  printf("----------------------------------------------------------------------\n\n");
1641 
1642  noise[0] = 0.1;
1643  noise[1] = 0.2;
1644  noise[2] = 0.3;
1645 
1646  while(mip_filter_mag_noise(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, noise) != MIP_INTERFACE_OK){}
1647 
1648  //Read back the mag white noise values
1649  while(mip_filter_mag_noise(&device_interface, MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK){}
1650 
1651  if((abs(readback_noise[0] - noise[0]) < 0.001) &&
1652  (abs(readback_noise[1] - noise[1]) < 0.001) &&
1653  (abs(readback_noise[2] - noise[2]) < 0.001))
1654  {
1655  printf("Mag noise values successfully set.\n");
1656  }
1657  else
1658  {
1659  printf("ERROR: Failed to set mag noise values!!!\n");
1660  printf("Sent values: %f X %f Y %f Z\n", noise[0], noise[1], noise[2]);
1661  printf("Returned values: %f X %f Y %f Z\n", readback_noise[0], readback_noise[1], readback_noise[2]);
1662  }
1663 
1664  printf("\n\nLoading the default mag noise values.\n\n");
1665 
1666  while(mip_filter_mag_noise(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1667 
1668  printf("\n\n");
1669  Sleep(1500);
1670 
1672  //Set/Read the accel bias model values
1674 
1675  printf("----------------------------------------------------------------------\n");
1676  printf("Setting the accel bias model values\n");
1677  printf("----------------------------------------------------------------------\n\n");
1678 
1679  noise[0] = 0.1;
1680  noise[1] = 0.2;
1681  noise[2] = 0.3;
1682 
1683  beta[0] = 0.1;
1684  beta[1] = 0.2;
1685  beta[2] = 0.3;
1686 
1687  while(mip_filter_accel_bias_model(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, beta, noise) != MIP_INTERFACE_OK){}
1688 
1689  //Read back the accel bias model values
1690  while(mip_filter_accel_bias_model(&device_interface, MIP_FUNCTION_SELECTOR_READ, readback_beta, readback_noise) != MIP_INTERFACE_OK){}
1691 
1692  if((abs(readback_noise[0]-noise[0]) < 0.001) &&
1693  (abs(readback_noise[1]-noise[1]) < 0.001) &&
1694  (abs(readback_noise[2]-noise[2]) < 0.001) &&
1695  (abs(readback_beta[0]-beta[0]) < 0.001) &&
1696  (abs(readback_beta[1]-beta[1]) < 0.001) &&
1697  (abs(readback_beta[2]-beta[2]) < 0.001))
1698  {
1699  printf("Accel bias model values successfully set.\n");
1700  }
1701  else
1702  {
1703  printf("ERROR: Failed to set accel bias model values!!!\n");
1704  printf("Sent values: Beta: %f X %f Y %f Z, White Noise: %f X %f Y %f Z\n", beta[0], beta[1], beta[2], noise[0], noise[1], noise[2]);
1705  printf("Returned values: Beta: %f X %f Y %f Z, White Noise: %f X %f Y %f Z\n", readback_beta[0], readback_beta[1], readback_beta[2],
1706  readback_noise[0], readback_noise[1], readback_noise[2]);
1707  }
1708 
1709  printf("\n\nLoading the default accel bias model values.\n\n");
1710 
1711  while(mip_filter_accel_bias_model(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL, NULL) != MIP_INTERFACE_OK){}
1712 
1713  printf("\n\n");
1714  Sleep(1500);
1715 
1717  //Set/Read the gyro bias model values
1719 
1720  printf("----------------------------------------------------------------------\n");
1721  printf("Setting the gyro bias model values\n");
1722  printf("----------------------------------------------------------------------\n\n");
1723 
1724  noise[0] = 0.1;
1725  noise[1] = 0.2;
1726  noise[2] = 0.3;
1727 
1728  beta[0] = 0.1;
1729  beta[1] = 0.2;
1730  beta[2] = 0.3;
1731 
1732  while(mip_filter_gyro_bias_model(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, beta, noise) != MIP_INTERFACE_OK){}
1733 
1734  //Read back the gyro bias model values
1735  while(mip_filter_gyro_bias_model(&device_interface, MIP_FUNCTION_SELECTOR_READ, readback_beta, readback_noise) != MIP_INTERFACE_OK){}
1736 
1737  if((abs(readback_noise[0]-noise[0]) < 0.001) &&
1738  (abs(readback_noise[1]-noise[1]) < 0.001) &&
1739  (abs(readback_noise[2]-noise[2]) < 0.001) &&
1740  (abs(readback_beta[0]-beta[0]) < 0.001) &&
1741  (abs(readback_beta[1]-beta[1]) < 0.001) &&
1742  (abs(readback_beta[2]-beta[2]) < 0.001))
1743  {
1744  printf("Gyro bias model values successfully set.\n");
1745  }
1746  else
1747  {
1748  printf("ERROR: Failed to set gyro bias model values!!!\n");
1749  printf("Sent values: Beta: %f X %f Y %f Z, White Noise: %f X %f Y %f Z\n", beta[0], beta[1], beta[2], noise[0], noise[1], noise[2]);
1750  printf("Returned values: Beta: %f X %f Y %f Z, White Noise: %f X %f Y %f Z\n", readback_beta[0], readback_beta[1], readback_beta[2],
1751  readback_noise[0], readback_noise[1], readback_noise[2]);
1752  }
1753 
1754  printf("\n\nLoading the default gyro bias model values.\n\n");
1755 
1756  while(mip_filter_gyro_bias_model(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL, NULL) != MIP_INTERFACE_OK){}
1757 
1758  printf("\n\n");
1759  Sleep(1500);
1760 
1762  //Zero-Velocity Update Control
1764 
1765  printf("----------------------------------------------------------------------\n");
1766  printf("Setting Zero Velocity-Update threshold\n");
1767  printf("----------------------------------------------------------------------\n\n");
1768 
1769  zero_update_control.threshold = 0.1; // m/s
1770  zero_update_control.enable = 1; //enable zero-velocity update
1771 
1772  //Set ZUPT parameters
1773  while(mip_filter_zero_velocity_update_control(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &zero_update_control) != MIP_INTERFACE_OK){}
1774 
1775  //Read back parameter settings
1776  while(mip_filter_zero_velocity_update_control(&device_interface, MIP_FUNCTION_SELECTOR_READ, &zero_update_readback) != MIP_INTERFACE_OK){}
1777 
1778  if(zero_update_control.enable != zero_update_readback.enable || zero_update_control.threshold != zero_update_readback.threshold)
1779  printf("ERROR configuring Zero Velocity Update.\n");
1780 
1781  printf("\n\nResetting Zero Velocity Update Control to default parameters.\n\n");
1782 
1783  //Reset to default value
1784  while(mip_filter_zero_velocity_update_control(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1785 
1786  printf("\n\n");
1787  Sleep(1500);
1788 
1790  //External Heading Update with Timestamp
1792 
1793  printf("----------------------------------------------------------------------\n");
1794  printf("Applying External Heading Update with Timestamp\n");
1795  printf("----------------------------------------------------------------------\n\n");
1796 
1797  //Set device to external heading update mode
1798  heading_source = 0x3;
1799 
1800  while(mip_filter_heading_source(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &heading_source) != MIP_INTERFACE_OK){}
1801 
1802  external_heading_with_time.gps_tow = 0.0;
1803  external_heading_with_time.gps_week_number = 0;
1804  external_heading_with_time.heading_angle_rads = 0.0;
1805  external_heading_with_time.heading_angle_sigma_rads = 0.05;
1806  external_heading_with_time.heading_type = 0x01;
1807 
1808  while(mip_filter_external_heading_update_with_time(&device_interface, &external_heading_with_time) != MIP_INTERFACE_OK){}
1809 
1810  //Resetting default heading update
1811  printf("\n\nResetting default heading update.\n\n");
1812 
1813  while(mip_filter_heading_source(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1814 
1815  printf("\n\n");
1816  Sleep(1500);
1817 
1819  //Angular Rate Zero Update Control
1821 
1822  printf("----------------------------------------------------------------------\n");
1823  printf("Setting Zero Angular-Rate-Update threshold\n");
1824  printf("----------------------------------------------------------------------\n\n");
1825 
1826  zero_update_control.threshold = 0.05; // rads/s
1827  zero_update_control.enable = 1; //enable zero-angular-rate update
1828 
1829  //Set ZUPT parameters
1830  while(mip_filter_zero_angular_rate_update_control(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &zero_update_control) != MIP_INTERFACE_OK){}
1831 
1832  //Read back parameter settings
1833  while(mip_filter_zero_angular_rate_update_control(&device_interface, MIP_FUNCTION_SELECTOR_READ, &zero_update_readback) != MIP_INTERFACE_OK){}
1834 
1835  if(zero_update_control.enable != zero_update_readback.enable || zero_update_control.threshold != zero_update_readback.threshold)
1836  printf("ERROR configuring Zero Angular Rate Update.\n");
1837 
1838  printf("\n\nResetting Zero Angular Rate Update Control to default parameters.\n\n");
1839 
1840  //Reset to default value
1841  while(mip_filter_zero_angular_rate_update_control(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1842 
1843 
1844  printf("\n\n");
1845  Sleep(1500);
1846 
1847 
1849  //Tare Orientation
1851 
1852  printf("----------------------------------------------------------------------\n");
1853  printf("Performing Tare Orientation Command\n");
1854  printf("(This will only pass if the internal GPS solution is valid)\n");
1855  printf("----------------------------------------------------------------------\n\n");
1856 
1857 
1858  printf("Re-initializing filter (required for tare)\n\n");
1859 
1860  //Re-initialize the filter
1861  angles[0] = angles[1] = angles[2] = 0;
1862 
1863  while(mip_filter_set_init_attitude(&device_interface, angles) != MIP_INTERFACE_OK){}
1864 
1865  //Wait for Filter to re-establish running state
1866  Sleep(5000);
1867 
1868 
1869  //Cycle through axes combinations
1870  for(i=1; i<8; i++)
1871  {
1872 
1873  if(mip_filter_tare_orientation(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, i) != MIP_INTERFACE_OK)
1874  {
1875  printf("ERROR: Failed Axis - ");
1876 
1877  if(i & FILTER_TARE_ROLL_AXIS)
1878  printf(" Roll Axis ");
1879 
1880  if(i & FILTER_TARE_PITCH_AXIS)
1881  printf(" Pitch Axis ");
1882 
1883  if(i & FILTER_TARE_YAW_AXIS)
1884  printf(" Yaw Axis ");
1885  }
1886  else
1887  {
1888  printf("Tare Configuration = %d\n", i);
1889 
1890  printf("Tared -");
1891 
1892  if(i & FILTER_TARE_ROLL_AXIS)
1893  printf(" Roll Axis ");
1894 
1895  if(i & FILTER_TARE_PITCH_AXIS)
1896  printf(" Pitch Axis ");
1897 
1898  if(i & FILTER_TARE_YAW_AXIS)
1899  printf(" Yaw Axis ");
1900 
1901  printf("\n\n");
1902  }
1903 
1904  Sleep(1000);
1905  }
1906 
1907  printf("\n\nRestoring Orientation to default value.\n\n");
1908 
1909  //Restore to default value
1910  while(mip_filter_tare_orientation(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, 0) != MIP_INTERFACE_OK){}
1911 
1912  printf("\n\n");
1913  Sleep(1500);
1914 
1916  //Commanded ZUPT
1918 
1919  printf("----------------------------------------------------------------------\n");
1920  printf("Performing Commanded Zero-Velocity Update\n");
1921  printf("----------------------------------------------------------------------\n\n");
1922 
1923  while(mip_filter_commanded_zero_velocity_update(&device_interface) != MIP_INTERFACE_OK){}
1924 
1925  printf("\n\n");
1926  Sleep(1500);
1927 
1929  //Commanded Zero Angular-Rate Update
1931 
1932  printf("----------------------------------------------------------------------\n");
1933  printf("Performing Commanded Zero-Angular-Rate Update\n");
1934  printf("----------------------------------------------------------------------\n\n");
1935 
1936  while(mip_filter_commanded_zero_angular_rate_update(&device_interface) != MIP_INTERFACE_OK){}
1937 
1938  printf("\n\n");
1939  Sleep(1500);
1940 
1942  //Set/Read the declination source
1944 
1945  printf("----------------------------------------------------------------------\n");
1946  printf("Cycle through available declination sources\n");
1947  printf("----------------------------------------------------------------------\n\n");
1948 
1949  //Loop through declination sources and set/read current source
1950  for(i=3; i>=1; i--)
1951  {
1952  //Set the source
1953  declination_source_command = i;
1954 
1955  while(mip_filter_declination_source(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &declination_source_command) != MIP_INTERFACE_OK){}
1956 
1957  //Read back the declination source
1958  while(mip_filter_declination_source(&device_interface, MIP_FUNCTION_SELECTOR_READ, &declination_source_readback) != MIP_INTERFACE_OK){}
1959 
1960  if(declination_source_command == declination_source_readback)
1961  {
1962  printf("Declination source successfully set to %d\n", i);
1963  }
1964  else
1965  {
1966  printf("ERROR: Failed to set the declination source to %d!!!\n", i);
1967  }
1968  }
1969 
1970  printf("\n\nLoading the default declination source.\n\n");
1971 
1972  while(mip_filter_declination_source(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1973 
1974  printf("\n\n");
1975  Sleep(1500);
1976 
1977 
1979  //Set/Read the accel magnitude error adaptive measurement values
1981 
1982  printf("----------------------------------------------------------------------\n");
1983  printf("Setting the accel magnitude error adaptive measurement values\n");
1984  printf("----------------------------------------------------------------------\n\n");
1985 
1986  accel_magnitude_error_command.enable = 0;
1987  accel_magnitude_error_command.low_pass_cutoff = 10;
1988  accel_magnitude_error_command.min_1sigma = 2.0;
1989  accel_magnitude_error_command.low_limit = -2.0;
1990  accel_magnitude_error_command.high_limit = 2.0;
1991  accel_magnitude_error_command.low_limit_1sigma = 4.0;
1992  accel_magnitude_error_command.high_limit_1sigma = 4.0;
1993 
1994  while(mip_filter_accel_magnitude_error_adaptive_measurement(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &accel_magnitude_error_command) != MIP_INTERFACE_OK){}
1995 
1996  //Read back the accel magnitude error adaptive measurement values
1997  while(mip_filter_accel_magnitude_error_adaptive_measurement(&device_interface, MIP_FUNCTION_SELECTOR_READ, &accel_magnitude_error_readback) != MIP_INTERFACE_OK){}
1998 
1999  if((accel_magnitude_error_command.enable == accel_magnitude_error_readback.enable) &&
2000  (abs(accel_magnitude_error_command.low_pass_cutoff - accel_magnitude_error_readback.low_pass_cutoff) < 0.001) &&
2001  (abs(accel_magnitude_error_command.min_1sigma - accel_magnitude_error_readback.min_1sigma) < 0.001) &&
2002  (abs(accel_magnitude_error_command.low_limit - accel_magnitude_error_readback.low_limit) < 0.001) &&
2003  (abs(accel_magnitude_error_command.high_limit - accel_magnitude_error_readback.high_limit) < 0.001) &&
2004  (abs(accel_magnitude_error_command.low_limit_1sigma - accel_magnitude_error_readback.low_limit_1sigma) < 0.001) &&
2005  (abs(accel_magnitude_error_command.high_limit_1sigma - accel_magnitude_error_readback.high_limit_1sigma) < 0.001))
2006  {
2007  printf("accel magnitude error adaptive measurement values successfully set.\n");
2008  }
2009  else
2010  {
2011  printf("ERROR: Failed to set accel magnitude error adaptive measurement values!!!\n");
2012  printf("Sent values: Enable: %i, Parameters: %f %f %f %f %f %f\n", accel_magnitude_error_command.enable,
2013  accel_magnitude_error_command.low_pass_cutoff,
2014  accel_magnitude_error_command.min_1sigma,
2015  accel_magnitude_error_command.low_limit,
2016  accel_magnitude_error_command.high_limit,
2017  accel_magnitude_error_command.low_limit_1sigma,
2018  accel_magnitude_error_command.high_limit_1sigma);
2019 
2020  printf("Returned values: Enable: %i, Parameters: %f %f %f %f %f %f\n", accel_magnitude_error_readback.enable,
2021  accel_magnitude_error_readback.low_pass_cutoff,
2022  accel_magnitude_error_readback.min_1sigma,
2023  accel_magnitude_error_readback.low_limit,
2024  accel_magnitude_error_readback.high_limit,
2025  accel_magnitude_error_readback.low_limit_1sigma,
2026  accel_magnitude_error_readback.high_limit_1sigma);
2027  }
2028 
2029  printf("\n\nLoading the default accel magnitude error adaptive measurement values.\n\n");
2030 
2031  while(mip_filter_accel_magnitude_error_adaptive_measurement(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
2032 
2033  printf("\n\n");
2034  Sleep(1500);
2035 
2036 
2037 
2039  //Set/Read the mag magnitude error adaptive measurement values
2041 
2042  printf("----------------------------------------------------------------------\n");
2043  printf("Setting the mag magnitude error adaptive measurement values\n");
2044  printf("----------------------------------------------------------------------\n\n");
2045 
2046  mag_magnitude_error_command.enable = 0;
2047  mag_magnitude_error_command.low_pass_cutoff = 10;
2048  mag_magnitude_error_command.min_1sigma = 0.1;
2049  mag_magnitude_error_command.low_limit = -1.0;
2050  mag_magnitude_error_command.high_limit = 1.0;
2051  mag_magnitude_error_command.low_limit_1sigma = 1.0;
2052  mag_magnitude_error_command.high_limit_1sigma = 1.0;
2053 
2054  while(mip_filter_mag_magnitude_error_adaptive_measurement(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &mag_magnitude_error_command) != MIP_INTERFACE_OK){}
2055 
2056  //Read back the mag magnitude error adaptive measurement values
2057  while(mip_filter_mag_magnitude_error_adaptive_measurement(&device_interface, MIP_FUNCTION_SELECTOR_READ, &mag_magnitude_error_readback) != MIP_INTERFACE_OK){}
2058 
2059  if((mag_magnitude_error_command.enable == mag_magnitude_error_readback.enable) &&
2060  (abs(mag_magnitude_error_command.low_pass_cutoff - mag_magnitude_error_readback.low_pass_cutoff) < 0.001) &&
2061  (abs(mag_magnitude_error_command.min_1sigma - mag_magnitude_error_readback.min_1sigma) < 0.001) &&
2062  (abs(mag_magnitude_error_command.low_limit - mag_magnitude_error_readback.low_limit) < 0.001) &&
2063  (abs(mag_magnitude_error_command.high_limit - mag_magnitude_error_readback.high_limit) < 0.001) &&
2064  (abs(mag_magnitude_error_command.low_limit_1sigma - mag_magnitude_error_readback.low_limit_1sigma) < 0.001) &&
2065  (abs(mag_magnitude_error_command.high_limit_1sigma - mag_magnitude_error_readback.high_limit_1sigma) < 0.001))
2066  {
2067  printf("mag magnitude error adaptive measurement values successfully set.\n");
2068  }
2069  else
2070  {
2071  printf("ERROR: Failed to set mag magnitude error adaptive measurement values!!!\n");
2072  printf("Sent values: Enable: %i, Parameters: %f %f %f %f %f %f\n", mag_magnitude_error_command.enable,
2073  mag_magnitude_error_command.low_pass_cutoff,
2074  mag_magnitude_error_command.min_1sigma,
2075  mag_magnitude_error_command.low_limit,
2076  mag_magnitude_error_command.high_limit,
2077  mag_magnitude_error_command.low_limit_1sigma,
2078  mag_magnitude_error_command.high_limit_1sigma);
2079 
2080  printf("Returned values: Enable: %i, Parameters: %f %f %f %f %f %f\n", mag_magnitude_error_readback.enable,
2081  mag_magnitude_error_readback.low_pass_cutoff,
2082  mag_magnitude_error_readback.min_1sigma,
2083  mag_magnitude_error_readback.low_limit,
2084  mag_magnitude_error_readback.high_limit,
2085  mag_magnitude_error_readback.low_limit_1sigma,
2086  mag_magnitude_error_readback.high_limit_1sigma);
2087  }
2088 
2089  printf("\n\nLoading the default mag magnitude error adaptive measurement values.\n\n");
2090 
2091  while(mip_filter_mag_magnitude_error_adaptive_measurement(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
2092 
2093  printf("\n\n");
2094  Sleep(1500);
2095 
2096 
2097 
2098 
2100  //Set/Read the mag dip angle error adaptive measurement values
2102 
2103  printf("----------------------------------------------------------------------\n");
2104  printf("Setting the mag dip angle error adaptive measurement values\n");
2105  printf("----------------------------------------------------------------------\n\n");
2106 
2107  mag_dip_angle_error_command.enable = 0;
2108  mag_dip_angle_error_command.low_pass_cutoff = 10;
2109  mag_dip_angle_error_command.min_1sigma = 0.1;
2110  mag_dip_angle_error_command.high_limit = 90.0*3.14/180.0;
2111  mag_dip_angle_error_command.high_limit_1sigma = 2.0;
2112 
2113  while(mip_filter_mag_dip_angle_error_adaptive_measurement(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &mag_dip_angle_error_command) != MIP_INTERFACE_OK){}
2114 
2115  //Read back the mag magnitude error adaptive measurement values
2116  while(mip_filter_mag_dip_angle_error_adaptive_measurement(&device_interface, MIP_FUNCTION_SELECTOR_READ, &mag_dip_angle_error_readback) != MIP_INTERFACE_OK){}
2117 
2118  if((mag_dip_angle_error_command.enable == mag_magnitude_error_readback.enable) &&
2119  (abs(mag_dip_angle_error_command.low_pass_cutoff - mag_dip_angle_error_readback.low_pass_cutoff) < 0.001) &&
2120  (abs(mag_dip_angle_error_command.min_1sigma - mag_dip_angle_error_readback.min_1sigma) < 0.001) &&
2121  (abs(mag_dip_angle_error_command.high_limit - mag_dip_angle_error_readback.high_limit) < 0.001) &&
2122  (abs(mag_dip_angle_error_command.high_limit_1sigma - mag_dip_angle_error_readback.high_limit_1sigma) < 0.001))
2123  {
2124  printf("mag dip angle error adaptive measurement values successfully set.\n");
2125  }
2126  else
2127  {
2128  printf("ERROR: Failed to set mag dip angle error adaptive measurement values!!!\n");
2129  printf("Sent values: Enable: %i, Parameters: %f %f %f %f\n", mag_dip_angle_error_command.enable,
2130  mag_dip_angle_error_command.low_pass_cutoff,
2131  mag_dip_angle_error_command.min_1sigma,
2132  mag_dip_angle_error_command.high_limit,
2133  mag_dip_angle_error_command.high_limit_1sigma);
2134 
2135  printf("Returned values: Enable: %i, Parameters: %f %f %f %f\n", mag_dip_angle_error_readback.enable,
2136  mag_dip_angle_error_readback.low_pass_cutoff,
2137  mag_dip_angle_error_readback.min_1sigma,
2138  mag_dip_angle_error_readback.high_limit,
2139  mag_dip_angle_error_readback.high_limit_1sigma);
2140  }
2141 
2142  printf("\n\nLoading the default mag magnitude error adaptive measurement values.\n\n");
2143 
2144  while(mip_filter_mag_dip_angle_error_adaptive_measurement(&device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
2145 
2146  printf("\n\n");
2147  Sleep(1500);
2148 
2149 
2150 
2151 
2153  //
2154  // Streaming Data Tests
2155  //
2157 
2158 
2159 
2161  //Setup the GX4-45 dataset callbacks
2163 
2164  if(mip_interface_add_descriptor_set_callback(&device_interface, MIP_FILTER_DATA_SET, NULL, &filter_packet_callback) != MIP_INTERFACE_OK)
2165  return -1;
2166 
2167  if(mip_interface_add_descriptor_set_callback(&device_interface, MIP_AHRS_DATA_SET, NULL, &ahrs_packet_callback) != MIP_INTERFACE_OK)
2168  return -1;
2169 
2170  if(mip_interface_add_descriptor_set_callback(&device_interface, MIP_GPS_DATA_SET, NULL, &gps_packet_callback) != MIP_INTERFACE_OK)
2171  return -1;
2172 
2173  //Enable the output of data statistics
2175 
2177  //Setup the AHRS datastream format
2179 
2180  printf("----------------------------------------------------------------------\n");
2181  printf("Setting the AHRS message format\n");
2182  printf("----------------------------------------------------------------------\n\n");
2183 
2184  data_stream_format_descriptors[0] = MIP_AHRS_DATA_ACCEL_SCALED;
2185  data_stream_format_descriptors[1] = MIP_AHRS_DATA_GYRO_SCALED;
2186 
2187  data_stream_format_decimation[0] = 0x32;
2188  data_stream_format_decimation[1] = 0x32;
2189 
2190  data_stream_format_num_entries = 2;
2191 
2192  while(mip_3dm_cmd_ahrs_message_format(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &data_stream_format_num_entries, data_stream_format_descriptors, data_stream_format_decimation) != MIP_INTERFACE_OK){}
2193 
2194  printf("\n\n");
2195  Sleep(1500);
2196 
2198  //Poll the AHRS data
2200 
2201  printf("----------------------------------------------------------------------\n");
2202  printf("Polling AHRS Data.\n");
2203  printf("----------------------------------------------------------------------\n\n");
2204 
2205  while(mip_3dm_cmd_poll_ahrs(&device_interface, MIP_3DM_POLLING_ENABLE_ACK_NACK, data_stream_format_num_entries, data_stream_format_descriptors) != MIP_INTERFACE_OK){}
2206 
2207  printf("\n\n");
2208  Sleep(1500);
2209 
2211  //Setup the GPS datastream format
2213 
2214  printf("----------------------------------------------------------------------\n");
2215  printf("Setting the GPS datastream format\n");
2216  printf("----------------------------------------------------------------------\n\n");
2217 
2218  data_stream_format_descriptors[0] = MIP_GPS_DATA_LLH_POS;
2219  data_stream_format_descriptors[1] = MIP_GPS_DATA_NED_VELOCITY;
2220  data_stream_format_descriptors[2] = MIP_GPS_DATA_GPS_TIME;
2221 
2222  data_stream_format_decimation[0] = 0x04;
2223  data_stream_format_decimation[1] = 0x04;
2224  data_stream_format_decimation[2] = 0x04;
2225 
2226  data_stream_format_num_entries = 3;
2227 
2228  while(mip_3dm_cmd_gps_message_format(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &data_stream_format_num_entries,
2229  data_stream_format_descriptors, data_stream_format_decimation) != MIP_INTERFACE_OK){}
2230 
2231  printf("\n\n");
2232  Sleep(1500);
2233 
2235  //Poll the GPS data
2237 
2238  printf("----------------------------------------------------------------------\n");
2239  printf("Polling GPS Data.\n");
2240  printf("----------------------------------------------------------------------\n\n");
2241 
2242  while(mip_3dm_cmd_poll_gps(&device_interface, MIP_3DM_POLLING_ENABLE_ACK_NACK, data_stream_format_num_entries, data_stream_format_descriptors) != MIP_INTERFACE_OK){}
2243 
2244  printf("\n\n");
2245  Sleep(1500);
2246 
2248  //Setup the FILTER datastream format
2250 
2251  printf("----------------------------------------------------------------------\n");
2252  printf("Setting the Estimation Filter datastream format\n");
2253  printf("----------------------------------------------------------------------\n\n");
2254 
2255  data_stream_format_descriptors[0] = MIP_FILTER_DATA_LLH_POS;
2256  data_stream_format_descriptors[1] = MIP_FILTER_DATA_NED_VEL;
2257  data_stream_format_descriptors[2] = MIP_FILTER_DATA_ATT_EULER_ANGLES;
2258 
2259  data_stream_format_decimation[0] = 0x32;
2260  data_stream_format_decimation[1] = 0x32;
2261  data_stream_format_decimation[2] = 0x32;
2262 
2263  data_stream_format_num_entries = 3;
2264 
2265  while(mip_3dm_cmd_filter_message_format(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, &data_stream_format_num_entries,
2266  data_stream_format_descriptors, data_stream_format_decimation) != MIP_INTERFACE_OK){}
2267 
2268  printf("\n\n");
2269  Sleep(1500);
2270 
2272  //Poll the Estimation Filter data
2274 
2275  printf("----------------------------------------------------------------------\n");
2276  printf("Polling Estimation Filter Data.\n");
2277  printf("----------------------------------------------------------------------\n\n");
2278 
2279  while(mip_3dm_cmd_poll_filter(&device_interface, MIP_3DM_POLLING_ENABLE_ACK_NACK, data_stream_format_num_entries, data_stream_format_descriptors) != MIP_INTERFACE_OK){}
2280 
2281  printf("\n\n");
2282  Sleep(1500);
2283  }
2284  else
2285  {
2286  printf("ERROR: Standard mode not established\n\n");
2287  }
2288 
2289 
2290  //Disable the output of data statistics
2292 
2294  //Enable the AHRS datastream
2296 
2297  printf("\n----------------------------------------------------------------------\n");
2298  printf("Enable the AHRS datastream\n");
2299  printf("----------------------------------------------------------------------\n\n");
2300 
2301  enable = 0x01;
2302 
2303  while(mip_3dm_cmd_continuous_data_stream(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, MIP_3DM_AHRS_DATASTREAM, &enable) != MIP_INTERFACE_OK){}
2304 
2305  printf("\n\n");
2306  Sleep(1500);
2307 
2309  //Enable the FILTER datastream
2311 
2312  printf("----------------------------------------------------------------------\n");
2313  printf("Enable the FILTER datastream\n");
2314  printf("----------------------------------------------------------------------\n\n");
2315 
2316  enable = 0x01;
2317 
2318  while(mip_3dm_cmd_continuous_data_stream(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, MIP_3DM_INS_DATASTREAM, &enable) != MIP_INTERFACE_OK){}
2319 
2320  printf("\n\n");
2321  Sleep(1500);
2322 
2324  //Enable the GPS datastream
2326 
2327  printf("----------------------------------------------------------------------\n");
2328  printf("Enable the GPS datastream\n");
2329  printf("----------------------------------------------------------------------\n");
2330 
2331  enable = 0x01;
2332 
2333  while(mip_3dm_cmd_continuous_data_stream(&device_interface, MIP_FUNCTION_SELECTOR_WRITE, MIP_3DM_GPS_DATASTREAM, &enable) != MIP_INTERFACE_OK){}
2334 
2335  printf("\n\n");
2336  Sleep(1500);
2337 
2339  //Wait for packets to arrive
2341 
2342  printf("----------------------------------------------------------------------\n");
2343  printf("Processing incoming packets\n");
2344  printf("----------------------------------------------------------------------\n\n\n");
2345 
2346  //Enable the output of data statistics
2348 
2349  while(1)
2350  {
2351  //Update the parser (this function reads the port and parses the bytes
2352  mip_interface_update(&device_interface);
2353 
2354  //Be nice to other programs
2355  Sleep(1);
2356  }
2357 }
2358 
2359 
2360 
2362 //
2363 // FILTER Packet Callback
2364 //
2366 
2367 void filter_packet_callback(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
2368 {
2369  mip_field_header *field_header;
2370  u8 *field_data;
2371  u16 field_offset = 0;
2372 
2373  //The packet callback can have several types, process them all
2374  switch(callback_type)
2375  {
2377  //Handle valid packets
2379 
2380  case MIP_INTERFACE_CALLBACK_VALID_PACKET:
2381  {
2383 
2385  //Loop through all of the data fields
2387 
2388  while(mip_get_next_field(packet, &field_header, &field_data, &field_offset) == MIP_OK)
2389  {
2390 
2392  // Decode the field
2394 
2395  switch(field_header->descriptor)
2396  {
2398  // Estimated LLH Position
2400 
2401  case MIP_FILTER_DATA_LLH_POS:
2402  {
2403  memcpy(&curr_filter_pos, field_data, sizeof(mip_filter_llh_pos));
2404 
2405  //For little-endian targets, byteswap the data field
2406  mip_filter_llh_pos_byteswap(&curr_filter_pos);
2407 
2408  }break;
2409 
2411  // Estimated NED Velocity
2413 
2414  case MIP_FILTER_DATA_NED_VEL:
2415  {
2416  memcpy(&curr_filter_vel, field_data, sizeof(mip_filter_ned_velocity));
2417 
2418  //For little-endian targets, byteswap the data field
2419  mip_filter_ned_velocity_byteswap(&curr_filter_vel);
2420 
2421  }break;
2422 
2424  // Estimated Attitude, Euler Angles
2426 
2427  case MIP_FILTER_DATA_ATT_EULER_ANGLES:
2428  {
2429  memcpy(&curr_filter_angles, field_data, sizeof(mip_filter_attitude_euler_angles));
2430 
2431  //For little-endian targets, byteswap the data field
2432  mip_filter_attitude_euler_angles_byteswap(&curr_filter_angles);
2433 
2434  }break;
2435 
2436  default: break;
2437  }
2438  }
2439  }break;
2440 
2441 
2443  //Handle checksum error packets
2445 
2446  case MIP_INTERFACE_CALLBACK_CHECKSUM_ERROR:
2447  {
2449  }break;
2450 
2452  //Handle timeout packets
2454 
2455  case MIP_INTERFACE_CALLBACK_TIMEOUT:
2456  {
2458  }break;
2459  default: break;
2460  }
2461 
2463 }
2464 
2465 
2467 //
2468 // AHRS Packet Callback
2469 //
2471 
2472 void ahrs_packet_callback(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
2473 {
2474  mip_field_header *field_header;
2475  u8 *field_data;
2476  u16 field_offset = 0;
2477 
2478  //The packet callback can have several types, process them all
2479  switch(callback_type)
2480  {
2482  //Handle valid packets
2484 
2485  case MIP_INTERFACE_CALLBACK_VALID_PACKET:
2486  {
2488 
2490  //Loop through all of the data fields
2492 
2493  while(mip_get_next_field(packet, &field_header, &field_data, &field_offset) == MIP_OK)
2494  {
2495 
2497  // Decode the field
2499 
2500  switch(field_header->descriptor)
2501  {
2503  // Scaled Accelerometer
2505 
2506  case MIP_AHRS_DATA_ACCEL_SCALED:
2507  {
2508  memcpy(&curr_ahrs_accel, field_data, sizeof(mip_ahrs_scaled_accel));
2509 
2510  //For little-endian targets, byteswap the data field
2511  mip_ahrs_scaled_accel_byteswap(&curr_ahrs_accel);
2512 
2513  }break;
2514 
2516  // Scaled Gyro
2518 
2519  case MIP_AHRS_DATA_GYRO_SCALED:
2520  {
2521  memcpy(&curr_ahrs_gyro, field_data, sizeof(mip_ahrs_scaled_gyro));
2522 
2523  //For little-endian targets, byteswap the data field
2524  mip_ahrs_scaled_gyro_byteswap(&curr_ahrs_gyro);
2525 
2526  }break;
2527 
2529  // Scaled Magnetometer
2531 
2532  case MIP_AHRS_DATA_MAG_SCALED:
2533  {
2534  memcpy(&curr_ahrs_mag, field_data, sizeof(mip_ahrs_scaled_mag));
2535 
2536  //For little-endian targets, byteswap the data field
2537  mip_ahrs_scaled_mag_byteswap(&curr_ahrs_mag);
2538 
2539  }break;
2540 
2541  default: break;
2542  }
2543  }
2544  }break;
2545 
2547  //Handle checksum error packets
2549 
2550  case MIP_INTERFACE_CALLBACK_CHECKSUM_ERROR:
2551  {
2553  }break;
2554 
2556  //Handle timeout packets
2558 
2559  case MIP_INTERFACE_CALLBACK_TIMEOUT:
2560  {
2562  }break;
2563  default: break;
2564  }
2565 
2567 }
2568 
2569 
2571 //
2572 // GPS Packet Callback
2573 //
2575 
2576 void gps_packet_callback(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
2577 {
2578  mip_field_header *field_header;
2579  u8 *field_data;
2580  u16 field_offset = 0;
2581 
2582  //The packet callback can have several types, process them all
2583  switch(callback_type)
2584  {
2586  //Handle valid packets
2588 
2589  case MIP_INTERFACE_CALLBACK_VALID_PACKET:
2590  {
2592 
2594  //Loop through all of the data fields
2596 
2597  while(mip_get_next_field(packet, &field_header, &field_data, &field_offset) == MIP_OK)
2598  {
2599 
2601  // Decode the field
2603 
2604  switch(field_header->descriptor)
2605  {
2607  // LLH Position
2609 
2610  case MIP_GPS_DATA_LLH_POS:
2611  {
2612  memcpy(&curr_llh_pos, field_data, sizeof(mip_gps_llh_pos));
2613 
2614  //For little-endian targets, byteswap the data field
2615  mip_gps_llh_pos_byteswap(&curr_llh_pos);
2616 
2617  }break;
2618 
2620  // NED Velocity
2622 
2623  case MIP_GPS_DATA_NED_VELOCITY:
2624  {
2625  memcpy(&curr_ned_vel, field_data, sizeof(mip_gps_ned_vel));
2626 
2627  //For little-endian targets, byteswap the data field
2628  mip_gps_ned_vel_byteswap(&curr_ned_vel);
2629 
2630  }break;
2631 
2633  // GPS Time
2635 
2636  case MIP_GPS_DATA_GPS_TIME:
2637  {
2638  memcpy(&curr_gps_time, field_data, sizeof(mip_gps_time));
2639 
2640  //For little-endian targets, byteswap the data field
2641  mip_gps_time_byteswap(&curr_gps_time);
2642 
2643  }break;
2644 
2645  default: break;
2646  }
2647  }
2648  }break;
2649 
2650 
2652  //Handle checksum error packets
2654 
2655  case MIP_INTERFACE_CALLBACK_CHECKSUM_ERROR:
2656  {
2658  }break;
2659 
2661  //Handle timeout packets
2663 
2664  case MIP_INTERFACE_CALLBACK_TIMEOUT:
2665  {
2667  }break;
2668  default: break;
2669  }
2670 
2672 }
2673 
2674 
2676 //
2677 // Print Command-Line Help
2678 //
2680 
2682 {
2683  printf("\n\n");
2684  printf("Usage:\n");
2685  printf("-----------------------------------------------------------------------\n\n");
2686 
2687  printf(" GX4-45_Test [com_port_num] [baudrate]\n");
2688  printf("\n\n");
2689  printf(" Example: \"GX4-45_Test 1 115200\", Opens a connection to the \n");
2690  printf(" GX4-45 on COM1, with a baudrate of 115200.\n");
2691  printf("\n\n");
2692  printf(" [ ] - required command input.\n");
2693  printf("\n-----------------------------------------------------------------------\n");
2694  printf("\n\n");
2695 }
2696 
2697 
2699 //
2700 // Print Header
2701 //
2703 
2705 {
2706  printf("\n");
2707  printf("GX4-45 Test Program\n");
2708  printf("Copyright 2013. LORD Microstrain\n\n");
2709 }
2710 
2711 
2713 //
2714 // Print Packet Statistics
2715 //
2717 
2719 {
2721  {
2722  printf("\r%u FILTER (%u errors) %u AHRS (%u errors) %u GPS (%u errors) Packets", filter_valid_packet_count, filter_timeout_packet_count + filter_checksum_error_packet_count,
2725  }
2726 }
2727 
2729 //
2730 // Device specific Status Acquisition Routines
2731 //
2733 
2735 //
2738 //
2741 //
2748 //
2751 //
2756 
2757 u16 mip_3dm_cmd_hw_specific_imu_device_status(mip_interface *device_interface, u16 model_number, u8 status_selector, u8 *response_buffer)
2758 {
2759 
2760  gx4_imu_basic_status_field *basic_ptr;
2761  gx4_imu_diagnostic_device_status_field *diagnostic_ptr;
2762  u16 response_size = MIP_FIELD_HEADER_SIZE;
2763 
2764  if(status_selector == GX4_IMU_BASIC_STATUS_SEL)
2765  response_size += sizeof(gx4_imu_basic_status_field);
2766  else if(status_selector == GX4_IMU_DIAGNOSTICS_STATUS_SEL)
2767  response_size += sizeof(gx4_imu_diagnostic_device_status_field);
2768 
2769  while(mip_3dm_cmd_device_status(device_interface, model_number, status_selector, response_buffer, &response_size) != MIP_INTERFACE_OK){}
2770 
2771  if(status_selector == GX4_IMU_BASIC_STATUS_SEL){
2772 
2773  if(response_size != sizeof(gx4_imu_basic_status_field))
2774  return MIP_INTERFACE_ERROR;
2775  else if(MIP_SDK_CONFIG_BYTESWAP){
2776 
2777  basic_ptr = (gx4_imu_basic_status_field *)response_buffer;
2778 
2779  byteswap_inplace(&basic_ptr->device_model, sizeof(basic_ptr->device_model));
2780  byteswap_inplace(&basic_ptr->status_flags, sizeof(basic_ptr->status_flags));
2781  byteswap_inplace(&basic_ptr->system_timer_ms, sizeof(basic_ptr->system_timer_ms));
2782 
2783  }
2784 
2785  }else if(status_selector == GX4_IMU_DIAGNOSTICS_STATUS_SEL){
2786 
2787  if(response_size != sizeof(gx4_imu_diagnostic_device_status_field))
2788  return MIP_INTERFACE_ERROR;
2789  else if(MIP_SDK_CONFIG_BYTESWAP){
2790 
2791  diagnostic_ptr = (gx4_imu_diagnostic_device_status_field *)response_buffer;
2792 
2793  byteswap_inplace(&diagnostic_ptr->device_model, sizeof(diagnostic_ptr->device_model));
2794  byteswap_inplace(&diagnostic_ptr->status_flags, sizeof(diagnostic_ptr->status_flags));
2795  byteswap_inplace(&diagnostic_ptr->system_timer_ms, sizeof(diagnostic_ptr->system_timer_ms));
2796  byteswap_inplace(&diagnostic_ptr->gyro_range, sizeof(diagnostic_ptr->gyro_range));
2797  byteswap_inplace(&diagnostic_ptr->mag_range, sizeof(diagnostic_ptr->mag_range));
2798  byteswap_inplace(&diagnostic_ptr->pressure_range, sizeof(diagnostic_ptr->pressure_range));
2799  byteswap_inplace(&diagnostic_ptr->temp_degc, sizeof(diagnostic_ptr->temp_degc));
2800  byteswap_inplace(&diagnostic_ptr->last_temp_read_ms, sizeof(diagnostic_ptr->last_temp_read_ms));
2801  byteswap_inplace(&diagnostic_ptr->num_gps_pps_triggers, sizeof(diagnostic_ptr->num_gps_pps_triggers));
2802  byteswap_inplace(&diagnostic_ptr->last_gps_pps_trigger_ms, sizeof(diagnostic_ptr->last_gps_pps_trigger_ms));
2803  byteswap_inplace(&diagnostic_ptr->dropped_packets, sizeof(diagnostic_ptr->dropped_packets));
2804  byteswap_inplace(&diagnostic_ptr->com_port_bytes_written, sizeof(diagnostic_ptr->com_port_bytes_written));
2805  byteswap_inplace(&diagnostic_ptr->com_port_bytes_read, sizeof(diagnostic_ptr->com_port_bytes_read));
2806  byteswap_inplace(&diagnostic_ptr->com_port_write_overruns, sizeof(diagnostic_ptr->com_port_write_overruns));
2807  byteswap_inplace(&diagnostic_ptr->com_port_read_overruns, sizeof(diagnostic_ptr->com_port_read_overruns));
2808 
2809  }
2810 
2811  }
2812  else
2813  return MIP_INTERFACE_ERROR;
2814 
2815  return MIP_INTERFACE_OK;
2816 
2817 }
2818 
2819 
2821 //
2824 //
2827 //
2834 //
2837 //
2841 
2842 u16 mip_3dm_cmd_hw_specific_device_status(mip_interface *device_interface, u16 model_number, u8 status_selector, u8 *response_buffer)
2843 {
2844 
2845  gx4_45_basic_status_field *basic_ptr;
2846  gx4_45_diagnostic_device_status_field *diagnostic_ptr;
2847  u16 response_size = MIP_FIELD_HEADER_SIZE;
2848 
2849  if(status_selector == GX4_45_BASIC_STATUS_SEL)
2850  response_size += sizeof(gx4_45_basic_status_field);
2851  else if(status_selector == GX4_45_DIAGNOSTICS_STATUS_SEL)
2852  response_size += sizeof(gx4_45_diagnostic_device_status_field);
2853 
2854  while(mip_3dm_cmd_device_status(device_interface, model_number, status_selector, response_buffer, &response_size) != MIP_INTERFACE_OK){}
2855 
2856  if(status_selector == GX4_45_BASIC_STATUS_SEL)
2857  {
2858 
2859  if(response_size != sizeof(gx4_45_basic_status_field))
2860  return MIP_INTERFACE_ERROR;
2861  else if(MIP_SDK_CONFIG_BYTESWAP){
2862 
2863  basic_ptr = (gx4_45_basic_status_field *)response_buffer;
2864 
2865  byteswap_inplace(&basic_ptr->device_model, sizeof(basic_ptr->device_model));
2866  byteswap_inplace(&basic_ptr->status_flags, sizeof(basic_ptr->status_flags));
2867  byteswap_inplace(&basic_ptr->system_state, sizeof(basic_ptr->system_state));
2868  byteswap_inplace(&basic_ptr->system_timer_ms, sizeof(basic_ptr->system_timer_ms));
2869 
2870  }
2871 
2872  }
2873  else if(status_selector == GX4_45_DIAGNOSTICS_STATUS_SEL)
2874  {
2875 
2876  if(response_size != sizeof(gx4_45_diagnostic_device_status_field))
2877  return MIP_INTERFACE_ERROR;
2878  else if(MIP_SDK_CONFIG_BYTESWAP){
2879 
2880  diagnostic_ptr = (gx4_45_diagnostic_device_status_field *)response_buffer;
2881 
2882  byteswap_inplace(&diagnostic_ptr->device_model, sizeof(diagnostic_ptr->device_model));
2883  byteswap_inplace(&diagnostic_ptr->status_flags, sizeof(diagnostic_ptr->status_flags));
2884  byteswap_inplace(&diagnostic_ptr->system_state, sizeof(diagnostic_ptr->system_state));
2885  byteswap_inplace(&diagnostic_ptr->system_timer_ms, sizeof(diagnostic_ptr->system_timer_ms));
2886  byteswap_inplace(&diagnostic_ptr->num_gps_pps_triggers, sizeof(diagnostic_ptr->num_gps_pps_triggers));
2887  byteswap_inplace(&diagnostic_ptr->last_gps_pps_trigger_ms, sizeof(diagnostic_ptr->last_gps_pps_trigger_ms));
2888  byteswap_inplace(&diagnostic_ptr->imu_dropped_packets, sizeof(diagnostic_ptr->imu_dropped_packets));
2889  byteswap_inplace(&diagnostic_ptr->gps_dropped_packets, sizeof(diagnostic_ptr->gps_dropped_packets));
2890  byteswap_inplace(&diagnostic_ptr->filter_dropped_packets, sizeof(diagnostic_ptr->filter_dropped_packets));
2891  byteswap_inplace(&diagnostic_ptr->com1_port_bytes_written, sizeof(diagnostic_ptr->com1_port_bytes_written));
2892  byteswap_inplace(&diagnostic_ptr->com1_port_bytes_read, sizeof(diagnostic_ptr->com1_port_bytes_read));
2893  byteswap_inplace(&diagnostic_ptr->com1_port_write_overruns, sizeof(diagnostic_ptr->com1_port_write_overruns));
2894  byteswap_inplace(&diagnostic_ptr->com1_port_read_overruns, sizeof(diagnostic_ptr->com1_port_read_overruns));
2895  byteswap_inplace(&diagnostic_ptr->imu_parser_errors, sizeof(diagnostic_ptr->imu_parser_errors));
2896  byteswap_inplace(&diagnostic_ptr->imu_message_count, sizeof(diagnostic_ptr->imu_message_count));
2897  byteswap_inplace(&diagnostic_ptr->imu_last_message_ms, sizeof(diagnostic_ptr->imu_last_message_ms));
2898  byteswap_inplace(&diagnostic_ptr->gps_parser_errors, sizeof(diagnostic_ptr->gps_parser_errors));
2899  byteswap_inplace(&diagnostic_ptr->gps_message_count, sizeof(diagnostic_ptr->gps_message_count));
2900  byteswap_inplace(&diagnostic_ptr->gps_last_message_ms, sizeof(diagnostic_ptr->gps_last_message_ms));
2901  }
2902  }
2903  else
2904  return MIP_INTERFACE_ERROR;
2905 
2906  return MIP_INTERFACE_OK;
2907 
2908 }
mip_filter_ned_velocity curr_filter_vel
Definition: GX4-45_Test.cpp:89
#define MIP_SDK_GX4_45_IMU_DIRECT_MODE
Definition: GX4-45_Test.h:56
void gps_packet_callback(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
u16 mip_3dm_cmd_hw_specific_device_status(mip_interface *device_interface, u16 model_number, u8 status_selector, u8 *response_buffer)
u32 gps_checksum_error_packet_count
Definition: GX4-45_Test.cpp:73
mip_ahrs_scaled_gyro curr_ahrs_gyro
Definition: GX4-45_Test.cpp:78
mip_gps_time curr_gps_time
Definition: GX4-45_Test.cpp:85
#define NUM_COMMAND_LINE_ARGUMENTS
Definition: GX4-25_Test.h:58
mip_interface device_interface
Definition: GX4-45_Test.cpp:60
mip_filter_llh_pos curr_filter_pos
Definition: GX4-45_Test.cpp:88
u16 mip_3dm_cmd_hw_specific_imu_device_status(mip_interface *device_interface, u16 model_number, u8 status_selector, u8 *response_buffer)
u32 ahrs_valid_packet_count
Definition: GX4-45_Test.cpp:64
u32 filter_valid_packet_count
Definition: GX4-45_Test.cpp:63
mip_ahrs_scaled_accel curr_ahrs_accel
Definition: GX4-45_Test.cpp:79
int main(int argc, char *argv[])
Definition: GX4-45_Test.cpp:99
mip_gps_ned_vel curr_ned_vel
Definition: GX4-45_Test.cpp:84
u32 gps_valid_packet_count
Definition: GX4-45_Test.cpp:65
mip_gps_llh_pos curr_llh_pos
Definition: GX4-45_Test.cpp:83
void print_packet_stats()
void print_header()
#define Sleep(x)
Definition: GX4-25_Test.h:62
u32 filter_checksum_error_packet_count
Definition: GX4-45_Test.cpp:71
#define MIP_SDK_GX4_45_IMU_STANDARD_MODE
Definition: GX4-45_Test.h:55
void ahrs_packet_callback(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
u32 ahrs_checksum_error_packet_count
Definition: GX4-45_Test.cpp:72
u32 gps_timeout_packet_count
Definition: GX4-45_Test.cpp:69
u32 filter_timeout_packet_count
Definition: GX4-45_Test.cpp:67
u32 ahrs_timeout_packet_count
Definition: GX4-45_Test.cpp:68
mip_ahrs_scaled_mag curr_ahrs_mag
Definition: GX4-45_Test.cpp:80
mip_filter_attitude_euler_angles curr_filter_angles
Definition: GX4-45_Test.cpp:90
u8 enable_data_stats_output
Definition: GX4-45_Test.cpp:57
void print_command_line_usage()
void filter_packet_callback(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
#define DEFAULT_PACKET_TIMEOUT_MS
Definition: GX4-25_Test.h:60


microstrain_mips
Author(s): Brian Bingham
autogenerated on Sun Dec 22 2019 03:54:45