43 #include "microstrain_3dm_gx5_45/GX4-45_Test.h" 99 int main(
int argc,
char* argv[])
101 u32 com_port, baudrate;
102 base_device_info_field device_info;
103 u8 temp_string[20] = {0};
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;
113 u16 device_descriptors[128] = {0};
114 u16 device_descriptors_size = 128*2;
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;
131 u8 heading_source = 0;
133 float noise[3] = {0};
134 float readback_noise[3] = {0};
136 float readback_beta[3] = {0};
137 mip_low_pass_filter_settings filter_settings;
138 float bias_vector[3] = {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;
150 u8 declination_source_command, declination_source_readback;
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;
169 com_port = atoi(argv[1]);
170 baudrate = atoi(argv[2]);
175 printf(
"Attempting to open interface on COM port %d \n",com_port);
192 printf(
"----------------------------------------------------------------------\n");
193 printf(
"Attempting to set communications mode to IMU Direct mode\n");
194 printf(
"----------------------------------------------------------------------\n\n");
196 while(mip_system_com_mode(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &com_mode) != MIP_INTERFACE_OK){}
202 while(mip_system_com_mode(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &com_mode) != MIP_INTERFACE_OK){}
207 printf(
"Communications mode IMU Direct.\n");
222 printf(
"----------------------------------------------------------------------\n");
223 printf(
"Idling Device\n");
224 printf(
"----------------------------------------------------------------------\n\n");
235 printf(
"----------------------------------------------------------------------\n");
236 printf(
"Pinging Device\n");
237 printf(
"----------------------------------------------------------------------\n\n");
248 printf(
"----------------------------------------------------------------------\n");
249 printf(
"Getting Device Information\n");
250 printf(
"----------------------------------------------------------------------\n\n");
252 while(mip_base_cmd_get_device_info(&
device_interface, &device_info) != MIP_INTERFACE_OK){}
254 printf(
"\n\nDevice Info:\n");
255 printf(
"---------------------------------------------\n");
257 memcpy(temp_string, device_info.model_name, BASE_DEVICE_INFO_PARAM_LENGTH*2);
258 printf(
"Model Name => %s\n", temp_string);
260 memcpy(temp_string, device_info.model_number, BASE_DEVICE_INFO_PARAM_LENGTH*2);
261 printf(
"Model Number => %s\n", temp_string);
263 memcpy(temp_string, device_info.serial_number, BASE_DEVICE_INFO_PARAM_LENGTH*2);
264 printf(
"Serial Number => %s\n", temp_string);
266 memcpy(temp_string, device_info.lotnumber, BASE_DEVICE_INFO_PARAM_LENGTH*2);
267 printf(
"Lot Number => %s\n", temp_string);
269 memcpy(temp_string, device_info.device_options, BASE_DEVICE_INFO_PARAM_LENGTH*2);
270 printf(
"Options => %s\n", temp_string);
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);
283 printf(
"----------------------------------------------------------------------\n");
284 printf(
"Getting Supported descriptors\n");
285 printf(
"----------------------------------------------------------------------\n\n");
287 while(mip_base_cmd_get_device_supported_descriptors(&
device_interface, (u8*)device_descriptors, &device_descriptors_size) != MIP_INTERFACE_OK){}
289 printf(
"\n\nSupported descriptors:\n\n");
291 for(i=0; i< device_descriptors_size/2; i++)
293 printf(
"Descriptor Set: %02x, Descriptor: %02x\n", device_descriptors[i] >> 8, device_descriptors[i]&0xFF);
304 printf(
"----------------------------------------------------------------------\n");
305 printf(
"Running Built In Test\n");
306 printf(
"----------------------------------------------------------------------\n\n");
308 while(mip_base_cmd_built_in_test(&
device_interface, &bit_result) != MIP_INTERFACE_OK){}
310 printf(
"\nBIT Result (should be 0x00000000) => 0x%08x\n\n", bit_result);
325 printf(
"----------------------------------------------------------------------\n");
326 printf(
"Getting the AHRS datastream base rate\n");
327 printf(
"----------------------------------------------------------------------\n\n");
329 while(mip_3dm_cmd_get_ahrs_base_rate(&
device_interface, &base_rate) != MIP_INTERFACE_OK){}
331 printf(
"\nAHRS Base Rate => %d Hz\n\n", base_rate);
341 printf(
"----------------------------------------------------------------------\n");
342 printf(
"Requesting BASIC Status Report:\n");
343 printf(
"----------------------------------------------------------------------\n\n");
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);
353 printf(
"Requesting DIAGNOSTIC Status Report:\n");
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);
387 printf(
"----------------------------------------------------------------------\n");
388 printf(
"Disabling Coning and Sculling compensation\n");
389 printf(
"----------------------------------------------------------------------\n\n");
391 enable = MIP_3DM_CONING_AND_SCULLING_DISABLE;
393 while(mip_3dm_cmd_coning_sculling_compensation(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &enable) != MIP_INTERFACE_OK){}
395 printf(
"Reading Coning and Sculling compensation enabled state:\n");
397 while(mip_3dm_cmd_coning_sculling_compensation(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &enable) != MIP_INTERFACE_OK){}
399 printf(
"%s\n\n", enable == MIP_3DM_CONING_AND_SCULLING_DISABLE ?
"DISABLED" :
"ENABLED");
401 printf(
"Enabling Coning and Sculling compensation.\n");
403 enable = MIP_3DM_CONING_AND_SCULLING_ENABLE;
405 while(mip_3dm_cmd_coning_sculling_compensation(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &enable) != MIP_INTERFACE_OK){}
407 printf(
"Reading Coning and Sculling compensation enabled state:\n");
409 while(mip_3dm_cmd_coning_sculling_compensation(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &enable) != MIP_INTERFACE_OK){}
411 printf(
"%s\n\n", enable == MIP_3DM_CONING_AND_SCULLING_DISABLE ?
"DISABLED" :
"ENABLED");
420 bias_vector[0] = 1.0f;
421 bias_vector[1] = 2.0f;
422 bias_vector[2] = 3.0f;
424 printf(
"----------------------------------------------------------------------\n");
425 printf(
"Accel Bias Vector\n");
426 printf(
"----------------------------------------------------------------------\n\n");
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]);
431 while(mip_3dm_cmd_accel_bias(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, bias_vector) != MIP_INTERFACE_OK){}
433 memset(bias_vector, 0, 3*
sizeof(
float));
435 printf(
"Reading current Accel Bias Vector:\n");
437 while(mip_3dm_cmd_accel_bias(&
device_interface, MIP_FUNCTION_SELECTOR_READ, bias_vector) != MIP_INTERFACE_OK){}
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]);
441 printf(
"Resetting Accel Bias to default state.\n\n");
443 while(mip_3dm_cmd_accel_bias(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
452 bias_vector[0] = 4.0f;
453 bias_vector[1] = 5.0f;
454 bias_vector[2] = 6.0f;
456 printf(
"----------------------------------------------------------------------\n");
457 printf(
"Gyro Bias Vector\n");
458 printf(
"----------------------------------------------------------------------\n\n");
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]);
463 while(mip_3dm_cmd_gyro_bias(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, bias_vector) != MIP_INTERFACE_OK){}
465 memset(bias_vector, 0, 3*
sizeof(
float));
467 printf(
"Reading current Gyro Bias Vector:\n");
469 while(mip_3dm_cmd_gyro_bias(&
device_interface, MIP_FUNCTION_SELECTOR_READ, bias_vector) != MIP_INTERFACE_OK){}
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]);
473 printf(
"Resetting Gyro Bias to default state.\n\n");
475 while(mip_3dm_cmd_gyro_bias(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
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");
491 while(mip_3dm_cmd_capture_gyro_bias(&
device_interface, duration, bias_vector) != MIP_INTERFACE_OK){}
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]);
503 printf(
"----------------------------------------------------------------------\n");
504 printf(
"Setting the hard iron offset values\n");
505 printf(
"----------------------------------------------------------------------\n\n");
511 while(mip_3dm_cmd_hard_iron(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, hard_iron) != MIP_INTERFACE_OK){}
514 while(mip_3dm_cmd_hard_iron(&
device_interface, MIP_FUNCTION_SELECTOR_READ, hard_iron_readback) != MIP_INTERFACE_OK){}
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))
520 printf(
"Hard iron offset values successfully set.\n");
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]);
529 printf(
"\n\nLoading the default hard iron offset values.\n\n");
531 while(mip_3dm_cmd_hard_iron(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
541 printf(
"----------------------------------------------------------------------\n");
542 printf(
"Setting the soft iron matrix values\n");
543 printf(
"----------------------------------------------------------------------\n\n");
548 while(mip_3dm_cmd_soft_iron(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, soft_iron) != MIP_INTERFACE_OK){}
551 while(mip_3dm_cmd_soft_iron(&
device_interface, MIP_FUNCTION_SELECTOR_READ, soft_iron_readback) != MIP_INTERFACE_OK){}
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))
563 printf(
"Soft iron matrix values successfully set.\n");
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]);
573 printf(
"\n\nLoading the default soft iron matrix values.\n\n");
575 while(mip_3dm_cmd_soft_iron(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
586 printf(
"----------------------------------------------------------------------\n");
587 printf(
"Setting the AHRS message format\n");
588 printf(
"----------------------------------------------------------------------\n\n");
590 data_stream_format_descriptors[0] = MIP_AHRS_DATA_ACCEL_SCALED;
591 data_stream_format_descriptors[1] = MIP_AHRS_DATA_GYRO_SCALED;
593 data_stream_format_decimation[0] = 0x64;
594 data_stream_format_decimation[1] = 0x64;
596 data_stream_format_num_entries = 2;
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){}
608 printf(
"----------------------------------------------------------------------\n");
609 printf(
"Polling AHRS Data.\n");
610 printf(
"----------------------------------------------------------------------\n\n");
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){}
617 printf(
"ERROR: IMU_Direct mode not established\n\n");
630 device_descriptors_size = 128*2;
633 printf(
"----------------------------------------------------------------------\n");
634 printf(
"Putting Device Into Standard Mode\n");
635 printf(
"----------------------------------------------------------------------\n\n");
638 while(mip_system_com_mode(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &com_mode) != MIP_INTERFACE_OK){}
641 while(mip_system_com_mode(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &com_mode) != MIP_INTERFACE_OK){}
660 printf(
"----------------------------------------------------------------------\n");
661 printf(
"Idling Device\n");
662 printf(
"----------------------------------------------------------------------\n\n");
673 printf(
"----------------------------------------------------------------------\n");
674 printf(
"Pinging Device\n");
675 printf(
"----------------------------------------------------------------------\n\n");
686 printf(
"----------------------------------------------------------------------\n");
687 printf(
"Getting Device Information\n");
688 printf(
"----------------------------------------------------------------------\n\n");
690 while(mip_base_cmd_get_device_info(&
device_interface, &device_info) != MIP_INTERFACE_OK){}
692 printf(
"Device Info:\n");
693 printf(
"---------------------------------------------\n");
695 memcpy(temp_string, device_info.model_name, BASE_DEVICE_INFO_PARAM_LENGTH*2);
696 printf(
"Model Name => %s\n", temp_string);
698 memcpy(temp_string, device_info.model_number, BASE_DEVICE_INFO_PARAM_LENGTH*2);
699 printf(
"Model Number => %s\n", temp_string);
701 memcpy(temp_string, device_info.serial_number, BASE_DEVICE_INFO_PARAM_LENGTH*2);
702 printf(
"Serial Number => %s\n", temp_string);
704 memcpy(temp_string, device_info.lotnumber, BASE_DEVICE_INFO_PARAM_LENGTH*2);
705 printf(
"Lot Number => %s\n", temp_string);
707 memcpy(temp_string, device_info.device_options, BASE_DEVICE_INFO_PARAM_LENGTH*2);
708 printf(
"Options => %s\n", temp_string);
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);
721 printf(
"----------------------------------------------------------------------\n");
722 printf(
"Getting Supported descriptors\n");
723 printf(
"----------------------------------------------------------------------\n\n");
725 while(mip_base_cmd_get_device_supported_descriptors(&
device_interface, (u8*)device_descriptors, &device_descriptors_size) != MIP_INTERFACE_OK){}
727 printf(
"\n\nSupported descriptors:\n\n");
729 for(i=0; i< device_descriptors_size/2; i++)
731 printf(
"Descriptor Set: %02x, Descriptor: %02x\n", device_descriptors[i] >> 8, device_descriptors[i]&0xFF);
743 printf(
"----------------------------------------------------------------------\n");
744 printf(
"Running Built In Test\n");
745 printf(
"----------------------------------------------------------------------\n\n");
747 while(mip_base_cmd_built_in_test(&
device_interface, &bit_result) != MIP_INTERFACE_OK){}
749 printf(
"\nBIT Result (should be 0x00000000) => 0x%08x\n\n", bit_result);
765 printf(
"----------------------------------------------------------------------\n");
766 printf(
"Getting the AHRS datastream base rate\n");
767 printf(
"----------------------------------------------------------------------\n\n");
769 while(mip_3dm_cmd_get_ahrs_base_rate(&
device_interface, &base_rate) != MIP_INTERFACE_OK){}
771 printf(
"\nAHRS Base Rate => %d Hz\n", base_rate);
780 printf(
"----------------------------------------------------------------------\n");
781 printf(
"Getting the GPS datastream base rate\n");
782 printf(
"----------------------------------------------------------------------\n\n");
784 while(mip_3dm_cmd_get_gps_base_rate(&
device_interface, &base_rate) != MIP_INTERFACE_OK){}
786 printf(
"\nGPS Base Rate => %d Hz\n", base_rate);
795 printf(
"----------------------------------------------------------------------\n");
796 printf(
"Getting the Estimation Filter datastream base rate\n");
797 printf(
"----------------------------------------------------------------------\n\n");
799 while(mip_3dm_cmd_get_filter_base_rate(&
device_interface, &base_rate) != MIP_INTERFACE_OK){}
801 printf(
"\nFILTER Base Rate => %d Hz\n", base_rate);
810 printf(
"----------------------------------------------------------------------\n");
811 printf(
"Toggling Coning and Sculling compensation\n");
812 printf(
"----------------------------------------------------------------------\n\n");
814 enable = MIP_3DM_CONING_AND_SCULLING_DISABLE;
816 while(mip_3dm_cmd_coning_sculling_compensation(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &enable) != MIP_INTERFACE_OK){}
818 printf(
"Reading Coning and Sculling compensation enabled state:\n");
820 while(mip_3dm_cmd_coning_sculling_compensation(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &enable) != MIP_INTERFACE_OK){}
822 printf(
"%s\n\n", enable == MIP_3DM_CONING_AND_SCULLING_DISABLE ?
"DISABLED" :
"ENABLED");
824 printf(
"Enabling Coning and Sculling compensation.\n");
826 enable = MIP_3DM_CONING_AND_SCULLING_ENABLE;
828 while(mip_3dm_cmd_coning_sculling_compensation(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &enable) != MIP_INTERFACE_OK){}
830 printf(
"Reading Coning and Sculling compensation enabled state:\n");
832 while(mip_3dm_cmd_coning_sculling_compensation(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &enable) != MIP_INTERFACE_OK){}
834 printf(
"%s\n\n", enable == MIP_3DM_CONING_AND_SCULLING_DISABLE ?
"DISABLED" :
"ENABLED");
844 bias_vector[0] = 1.0f;
845 bias_vector[1] = 2.0f;
846 bias_vector[2] = 3.0f;
848 printf(
"----------------------------------------------------------------------\n");
849 printf(
"Accel Bias Vector\n");
850 printf(
"----------------------------------------------------------------------\n\n");
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]);
855 while(mip_3dm_cmd_accel_bias(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, bias_vector) != MIP_INTERFACE_OK){}
857 memset(bias_vector, 0, 3*
sizeof(
float));
859 printf(
"Reading current Accel Bias Vector:\n");
861 while(mip_3dm_cmd_accel_bias(&
device_interface, MIP_FUNCTION_SELECTOR_READ, bias_vector) != MIP_INTERFACE_OK){}
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]);
865 printf(
"Resetting Accel Bias to default state.\n\n");
867 while(mip_3dm_cmd_accel_bias(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
877 bias_vector[0] = 4.0f;
878 bias_vector[1] = 5.0f;
879 bias_vector[2] = 6.0f;
881 printf(
"----------------------------------------------------------------------\n");
882 printf(
"Gyro Bias Vector\n");
883 printf(
"----------------------------------------------------------------------\n\n");
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]);
888 while(mip_3dm_cmd_gyro_bias(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, bias_vector) != MIP_INTERFACE_OK){}
890 memset(bias_vector, 0, 3*
sizeof(
float));
892 printf(
"Reading current Gyro Bias Vector:\n");
894 while(mip_3dm_cmd_gyro_bias(&
device_interface, MIP_FUNCTION_SELECTOR_READ, bias_vector) != MIP_INTERFACE_OK){}
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]);
898 printf(
"Resetting Gyro Bias to default state.\n\n");
900 while(mip_3dm_cmd_gyro_bias(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
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");
916 while(mip_3dm_cmd_capture_gyro_bias(&
device_interface, duration, bias_vector) != MIP_INTERFACE_OK){}
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]);
928 printf(
"----------------------------------------------------------------------\n");
929 printf(
"Setting the hard iron offset values\n");
930 printf(
"----------------------------------------------------------------------\n\n");
936 while(mip_3dm_cmd_hard_iron(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, hard_iron) != MIP_INTERFACE_OK){}
939 while(mip_3dm_cmd_hard_iron(&
device_interface, MIP_FUNCTION_SELECTOR_READ, hard_iron_readback) != MIP_INTERFACE_OK){}
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))
945 printf(
"Hard iron offset values successfully set.\n");
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]);
954 printf(
"\n\nLoading the default hard iron offset values.\n\n");
956 while(mip_3dm_cmd_hard_iron(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
966 printf(
"----------------------------------------------------------------------\n");
967 printf(
"Setting the soft iron matrix values\n");
968 printf(
"----------------------------------------------------------------------\n\n");
973 while(mip_3dm_cmd_soft_iron(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, soft_iron) != MIP_INTERFACE_OK){}
976 while(mip_3dm_cmd_soft_iron(&
device_interface, MIP_FUNCTION_SELECTOR_READ, soft_iron_readback) != MIP_INTERFACE_OK){}
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))
988 printf(
"Soft iron matrix values successfully set.\n");
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]);
998 printf(
"\n\nLoading the default soft iron matrix values.\n\n");
1000 while(mip_3dm_cmd_soft_iron(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1011 printf(
"----------------------------------------------------------------------\n");
1012 printf(
"Setting the complementary filter values\n");
1013 printf(
"----------------------------------------------------------------------\n\n");
1016 comp_filter_command.north_compensation_enable = 0;
1017 comp_filter_command.up_compensation_enable = 0;
1019 comp_filter_command.north_compensation_time_constant = 30;
1020 comp_filter_command.up_compensation_time_constant = 30;
1022 while(mip_3dm_cmd_complementary_filter_settings(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &comp_filter_command) != MIP_INTERFACE_OK){}
1025 while(mip_3dm_cmd_complementary_filter_settings(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &comp_filter_readback) != MIP_INTERFACE_OK){}
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))
1032 printf(
"Complementary filter values successfully set.\n");
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);
1043 printf(
"\n\nLoading the default complementary filter values.\n\n");
1045 while(mip_3dm_cmd_complementary_filter_settings(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1055 printf(
"----------------------------------------------------------------------\n");
1056 printf(
"Requesting BASIC Status Report\n");
1057 printf(
"----------------------------------------------------------------------\n\n");
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);
1066 if(basic_field.system_state == GX4_45_SYSTEM_STATE_INIT)
1068 strcpy(temp_string,
"System Initialization");
1070 else if(basic_field.system_state == GX4_45_SYSTEM_STATE_SENSOR_STARTUP)
1072 strcpy(temp_string,
"Sensor Start-up");
1074 else if(basic_field.system_state == GX4_45_SYSTEM_STATE_RUNNING)
1076 strcpy(temp_string,
"System Running");
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);
1082 printf(
"Requesting DIAGNOSTIC Status Report:\n");
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);
1124 printf(
"----------------------------------------------------------------------\n");
1125 printf(
"Resetting the Filter\n");
1126 printf(
"----------------------------------------------------------------------\n\n");
1137 printf(
"----------------------------------------------------------------------\n");
1138 printf(
"Initializing the Filter with Euler angles\n");
1139 printf(
"----------------------------------------------------------------------\n\n");
1141 angles[0] = angles[1] = angles[2] = 0;
1143 while(mip_filter_set_init_attitude(&
device_interface, angles) != MIP_INTERFACE_OK){}
1152 printf(
"----------------------------------------------------------------------\n");
1153 printf(
"Resetting the Filter\n");
1154 printf(
"----------------------------------------------------------------------\n\n");
1165 printf(
"----------------------------------------------------------------------\n");
1166 printf(
"Initializing the Filter with a heading angle\n");
1167 printf(
"----------------------------------------------------------------------\n\n");
1169 while(mip_filter_set_init_heading(&
device_interface, angles[0]) != MIP_INTERFACE_OK){}
1178 printf(
"----------------------------------------------------------------------\n");
1179 printf(
"Resetting the Filter\n");
1180 printf(
"----------------------------------------------------------------------\n\n");
1191 printf(
"----------------------------------------------------------------------\n");
1192 printf(
"Cycle through available Vehicle Dynamics Modes\n");
1193 printf(
"----------------------------------------------------------------------\n\n");
1201 while(mip_filter_vehicle_dynamics_mode(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &dynamics_mode) != MIP_INTERFACE_OK){}
1204 readback_dynamics_mode = 0;
1207 while(mip_filter_vehicle_dynamics_mode(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &readback_dynamics_mode) != MIP_INTERFACE_OK){}
1209 if(dynamics_mode == readback_dynamics_mode)
1211 printf(
"Vehicle dynamics mode successfully set to %d\n", dynamics_mode);
1215 printf(
"ERROR: Failed to set vehicle dynamics mode to %d!!!\n", dynamics_mode);
1219 printf(
"\nLoading the default vehicle dynamics mode\n\n");
1221 while(mip_filter_vehicle_dynamics_mode(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1231 printf(
"----------------------------------------------------------------------\n");
1232 printf(
"Setting the sensor to vehicle frame transformation\n");
1233 printf(
"----------------------------------------------------------------------\n\n");
1235 angles[0] = 3.14/4.0;
1236 angles[1] = 3.14/8.0;
1237 angles[2] = 3.14/12.0;
1239 while(mip_filter_sensor2vehicle_tranformation(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, angles) != MIP_INTERFACE_OK){}
1242 while(mip_filter_sensor2vehicle_tranformation(&
device_interface, MIP_FUNCTION_SELECTOR_READ, readback_angles) != MIP_INTERFACE_OK){}
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))
1248 printf(
"Transformation successfully set.\n");
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]);
1257 printf(
"\n\nLoading the default sensor to vehicle transformation.\n\n");
1259 while(mip_filter_sensor2vehicle_tranformation(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1268 printf(
"----------------------------------------------------------------------\n");
1269 printf(
"Setting the sensor to vehicle frame offset\n");
1270 printf(
"----------------------------------------------------------------------\n\n");
1276 while(mip_filter_sensor2vehicle_offset(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, offset) != MIP_INTERFACE_OK){}
1279 while(mip_filter_sensor2vehicle_offset(&
device_interface, MIP_FUNCTION_SELECTOR_READ, readback_offset) != MIP_INTERFACE_OK){}
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))
1285 printf(
"Offset successfully set.\n");
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]);
1294 printf(
"\n\nLoading the default sensor to vehicle offset.\n\n");
1296 while(mip_filter_sensor2vehicle_offset(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1305 printf(
"----------------------------------------------------------------------\n");
1306 printf(
"Setting the GPS antenna offset\n");
1307 printf(
"----------------------------------------------------------------------\n\n");
1313 while(mip_filter_antenna_offset(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, offset) != MIP_INTERFACE_OK){}
1316 while(mip_filter_antenna_offset(&
device_interface, MIP_FUNCTION_SELECTOR_READ, readback_offset) != MIP_INTERFACE_OK){}
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))
1322 printf(
"Offset successfully set.\n");
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]);
1331 printf(
"\n\nLoading the default antenna offset.\n\n");
1333 while(mip_filter_antenna_offset(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1342 printf(
"----------------------------------------------------------------------\n");
1343 printf(
"Cycling through Estimation Control Flags\n");
1344 printf(
"----------------------------------------------------------------------\n\n");
1347 for(j=0; j < 0x0020 ; j++)
1350 estimation_control = (0xFFFF & ~j);
1353 while(mip_filter_estimation_control(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &estimation_control) != MIP_INTERFACE_OK){}
1356 while(mip_filter_estimation_control(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &estimation_control_readback) != MIP_INTERFACE_OK){}
1358 if(estimation_control != estimation_control_readback)
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");
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");
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");
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");
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");
1379 printf(
"\n\nResetting Estimation Control Flags to default state.\n\n");
1381 while(mip_filter_estimation_control(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, &estimation_control) != MIP_INTERFACE_OK){}
1390 printf(
"----------------------------------------------------------------------\n");
1391 printf(
"Cycle through available GPS sources\n");
1392 printf(
"----------------------------------------------------------------------\n\n");
1400 while(mip_filter_gps_source(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &gps_source) != MIP_INTERFACE_OK){}
1403 while(mip_filter_gps_source(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &gps_source) != MIP_INTERFACE_OK){}
1407 printf(
"GPS source successfully set to %d\n", i);
1411 printf(
"ERROR: Failed to set GPS source to %d!!!\n", i);
1415 printf(
"\n\nLoading the default gps source.\n\n");
1417 while(mip_filter_gps_source(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1427 printf(
"----------------------------------------------------------------------\n");
1428 printf(
"Performing External GPS Update with externally supplied GPS information\n");
1429 printf(
"----------------------------------------------------------------------\n\n");
1433 while(mip_filter_gps_source(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &gps_source) != MIP_INTERFACE_OK){}
1436 external_gps_update.tow = 0;
1437 external_gps_update.week_number = 0;
1438 external_gps_update.pos[0] = 44.43753433;
1439 external_gps_update.pos[1] = -73.10612488;
1440 external_gps_update.pos[2] = 134.029999;
1441 external_gps_update.vel[0] = 0.0;
1442 external_gps_update.vel[1] = 0.0;
1443 external_gps_update.vel[2] = 0.0;
1444 external_gps_update.pos_1sigma[0] = 0.1;
1445 external_gps_update.pos_1sigma[1] = 0.1;
1446 external_gps_update.pos_1sigma[2] = 0.1;
1447 external_gps_update.vel_1sigma[0] = 0.1;
1448 external_gps_update.vel_1sigma[1] = 0.1;
1449 external_gps_update.vel_1sigma[2] = 0.1;
1451 while(mip_filter_external_gps_update(&
device_interface, &external_gps_update) != MIP_INTERFACE_OK){}
1456 while(mip_filter_gps_source(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &gps_source) != MIP_INTERFACE_OK){}
1465 printf(
"----------------------------------------------------------------------\n");
1466 printf(
"Performing External Heading Update with externally supplied heading information\n");
1467 printf(
"----------------------------------------------------------------------\n\n");
1470 heading_source = 0x3;
1472 while(mip_filter_heading_source(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &heading_source) != MIP_INTERFACE_OK){}
1474 external_heading_update.heading_angle = 0.0;
1475 external_heading_update.heading_angle_1sigma = 0.01;
1476 external_heading_update.type = 0x1;
1478 while(mip_filter_external_heading_update(&
device_interface, &external_heading_update) != MIP_INTERFACE_OK){}
1482 while(mip_filter_heading_source(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, &heading_source) != MIP_INTERFACE_OK){}
1491 printf(
"----------------------------------------------------------------------\n");
1492 printf(
"Cycle through available Heading sources\n");
1493 printf(
"----------------------------------------------------------------------\n\n");
1501 mip_filter_heading_source(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &heading_source);
1504 while(mip_filter_heading_source(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &heading_source) != MIP_INTERFACE_OK){}
1506 if(heading_source == i)
1508 printf(
"Heading source successfully set to %d\n", i);
1512 printf(
"ERROR: Failed to set heading source to %d!!!\n", i);
1516 printf(
"\n\nLoading the default heading source.\n\n");
1518 while(mip_filter_heading_source(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1527 printf(
"----------------------------------------------------------------------\n");
1528 printf(
"Cycle through available auto-init values\n");
1529 printf(
"----------------------------------------------------------------------\n\n");
1537 while(mip_filter_auto_initialization(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &auto_init) != MIP_INTERFACE_OK){}
1540 while(mip_filter_auto_initialization(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &auto_init) != MIP_INTERFACE_OK){}
1544 printf(
"Auto-init successfully set to %d\n", i);
1548 printf(
"ERROR: Failed to set auto-init to %d!!!\n", i);
1552 printf(
"\n\nLoading the default auto-init value.\n\n");
1554 while(mip_filter_auto_initialization(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1563 printf(
"----------------------------------------------------------------------\n");
1564 printf(
"Setting the accel noise values\n");
1565 printf(
"----------------------------------------------------------------------\n\n");
1571 while(mip_filter_accel_noise(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, noise) != MIP_INTERFACE_OK){}
1574 while(mip_filter_accel_noise(&
device_interface, MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK){}
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))
1580 printf(
"Accel noise values successfully set.\n");
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]);
1589 printf(
"\n\nLoading the default accel noise values.\n\n");
1591 while(mip_filter_accel_noise(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1600 printf(
"----------------------------------------------------------------------\n");
1601 printf(
"Setting the gyro noise values\n");
1602 printf(
"----------------------------------------------------------------------\n\n");
1608 while(mip_filter_gyro_noise(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, noise) != MIP_INTERFACE_OK){}
1611 while(mip_filter_gyro_noise(&
device_interface, MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK){}
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))
1617 printf(
"Gyro noise values successfully set.\n");
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]);
1626 printf(
"\n\nLoading the default gyro noise values.\n\n");
1628 while(mip_filter_gyro_noise(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1638 printf(
"----------------------------------------------------------------------\n");
1639 printf(
"Setting the mag noise values\n");
1640 printf(
"----------------------------------------------------------------------\n\n");
1646 while(mip_filter_mag_noise(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, noise) != MIP_INTERFACE_OK){}
1649 while(mip_filter_mag_noise(&
device_interface, MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK){}
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))
1655 printf(
"Mag noise values successfully set.\n");
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]);
1664 printf(
"\n\nLoading the default mag noise values.\n\n");
1666 while(mip_filter_mag_noise(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1675 printf(
"----------------------------------------------------------------------\n");
1676 printf(
"Setting the accel bias model values\n");
1677 printf(
"----------------------------------------------------------------------\n\n");
1687 while(mip_filter_accel_bias_model(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, beta, noise) != MIP_INTERFACE_OK){}
1690 while(mip_filter_accel_bias_model(&
device_interface, MIP_FUNCTION_SELECTOR_READ, readback_beta, readback_noise) != MIP_INTERFACE_OK){}
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))
1699 printf(
"Accel bias model values successfully set.\n");
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]);
1709 printf(
"\n\nLoading the default accel bias model values.\n\n");
1711 while(mip_filter_accel_bias_model(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL, NULL) != MIP_INTERFACE_OK){}
1720 printf(
"----------------------------------------------------------------------\n");
1721 printf(
"Setting the gyro bias model values\n");
1722 printf(
"----------------------------------------------------------------------\n\n");
1732 while(mip_filter_gyro_bias_model(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, beta, noise) != MIP_INTERFACE_OK){}
1735 while(mip_filter_gyro_bias_model(&
device_interface, MIP_FUNCTION_SELECTOR_READ, readback_beta, readback_noise) != MIP_INTERFACE_OK){}
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))
1744 printf(
"Gyro bias model values successfully set.\n");
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]);
1754 printf(
"\n\nLoading the default gyro bias model values.\n\n");
1756 while(mip_filter_gyro_bias_model(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL, NULL) != MIP_INTERFACE_OK){}
1765 printf(
"----------------------------------------------------------------------\n");
1766 printf(
"Setting Zero Velocity-Update threshold\n");
1767 printf(
"----------------------------------------------------------------------\n\n");
1769 zero_update_control.threshold = 0.1;
1770 zero_update_control.enable = 1;
1773 while(mip_filter_zero_velocity_update_control(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &zero_update_control) != MIP_INTERFACE_OK){}
1776 while(mip_filter_zero_velocity_update_control(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &zero_update_readback) != MIP_INTERFACE_OK){}
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");
1781 printf(
"\n\nResetting Zero Velocity Update Control to default parameters.\n\n");
1784 while(mip_filter_zero_velocity_update_control(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1793 printf(
"----------------------------------------------------------------------\n");
1794 printf(
"Applying External Heading Update with Timestamp\n");
1795 printf(
"----------------------------------------------------------------------\n\n");
1798 heading_source = 0x3;
1800 while(mip_filter_heading_source(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &heading_source) != MIP_INTERFACE_OK){}
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;
1808 while(mip_filter_external_heading_update_with_time(&
device_interface, &external_heading_with_time) != MIP_INTERFACE_OK){}
1811 printf(
"\n\nResetting default heading update.\n\n");
1813 while(mip_filter_heading_source(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1822 printf(
"----------------------------------------------------------------------\n");
1823 printf(
"Setting Zero Angular-Rate-Update threshold\n");
1824 printf(
"----------------------------------------------------------------------\n\n");
1826 zero_update_control.threshold = 0.05;
1827 zero_update_control.enable = 1;
1830 while(mip_filter_zero_angular_rate_update_control(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &zero_update_control) != MIP_INTERFACE_OK){}
1833 while(mip_filter_zero_angular_rate_update_control(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &zero_update_readback) != MIP_INTERFACE_OK){}
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");
1838 printf(
"\n\nResetting Zero Angular Rate Update Control to default parameters.\n\n");
1841 while(mip_filter_zero_angular_rate_update_control(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
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");
1858 printf(
"Re-initializing filter (required for tare)\n\n");
1861 angles[0] = angles[1] = angles[2] = 0;
1863 while(mip_filter_set_init_attitude(&
device_interface, angles) != MIP_INTERFACE_OK){}
1873 if(mip_filter_tare_orientation(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, i) != MIP_INTERFACE_OK)
1875 printf(
"ERROR: Failed Axis - ");
1877 if(i & FILTER_TARE_ROLL_AXIS)
1878 printf(
" Roll Axis ");
1880 if(i & FILTER_TARE_PITCH_AXIS)
1881 printf(
" Pitch Axis ");
1883 if(i & FILTER_TARE_YAW_AXIS)
1884 printf(
" Yaw Axis ");
1888 printf(
"Tare Configuration = %d\n", i);
1892 if(i & FILTER_TARE_ROLL_AXIS)
1893 printf(
" Roll Axis ");
1895 if(i & FILTER_TARE_PITCH_AXIS)
1896 printf(
" Pitch Axis ");
1898 if(i & FILTER_TARE_YAW_AXIS)
1899 printf(
" Yaw Axis ");
1907 printf(
"\n\nRestoring Orientation to default value.\n\n");
1910 while(mip_filter_tare_orientation(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, 0) != MIP_INTERFACE_OK){}
1919 printf(
"----------------------------------------------------------------------\n");
1920 printf(
"Performing Commanded Zero-Velocity Update\n");
1921 printf(
"----------------------------------------------------------------------\n\n");
1923 while(mip_filter_commanded_zero_velocity_update(&
device_interface) != MIP_INTERFACE_OK){}
1932 printf(
"----------------------------------------------------------------------\n");
1933 printf(
"Performing Commanded Zero-Angular-Rate Update\n");
1934 printf(
"----------------------------------------------------------------------\n\n");
1936 while(mip_filter_commanded_zero_angular_rate_update(&
device_interface) != MIP_INTERFACE_OK){}
1945 printf(
"----------------------------------------------------------------------\n");
1946 printf(
"Cycle through available declination sources\n");
1947 printf(
"----------------------------------------------------------------------\n\n");
1953 declination_source_command = i;
1955 while(mip_filter_declination_source(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &declination_source_command) != MIP_INTERFACE_OK){}
1958 while(mip_filter_declination_source(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &declination_source_readback) != MIP_INTERFACE_OK){}
1960 if(declination_source_command == declination_source_readback)
1962 printf(
"Declination source successfully set to %d\n", i);
1966 printf(
"ERROR: Failed to set the declination source to %d!!!\n", i);
1970 printf(
"\n\nLoading the default declination source.\n\n");
1972 while(mip_filter_declination_source(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
1982 printf(
"----------------------------------------------------------------------\n");
1983 printf(
"Setting the accel magnitude error adaptive measurement values\n");
1984 printf(
"----------------------------------------------------------------------\n\n");
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;
1994 while(mip_filter_accel_magnitude_error_adaptive_measurement(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &accel_magnitude_error_command) != MIP_INTERFACE_OK){}
1997 while(mip_filter_accel_magnitude_error_adaptive_measurement(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &accel_magnitude_error_readback) != MIP_INTERFACE_OK){}
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))
2007 printf(
"accel magnitude error adaptive measurement values successfully set.\n");
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);
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);
2029 printf(
"\n\nLoading the default accel magnitude error adaptive measurement values.\n\n");
2031 while(mip_filter_accel_magnitude_error_adaptive_measurement(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
2042 printf(
"----------------------------------------------------------------------\n");
2043 printf(
"Setting the mag magnitude error adaptive measurement values\n");
2044 printf(
"----------------------------------------------------------------------\n\n");
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;
2054 while(mip_filter_mag_magnitude_error_adaptive_measurement(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &mag_magnitude_error_command) != MIP_INTERFACE_OK){}
2057 while(mip_filter_mag_magnitude_error_adaptive_measurement(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &mag_magnitude_error_readback) != MIP_INTERFACE_OK){}
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))
2067 printf(
"mag magnitude error adaptive measurement values successfully set.\n");
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);
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);
2089 printf(
"\n\nLoading the default mag magnitude error adaptive measurement values.\n\n");
2091 while(mip_filter_mag_magnitude_error_adaptive_measurement(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
2103 printf(
"----------------------------------------------------------------------\n");
2104 printf(
"Setting the mag dip angle error adaptive measurement values\n");
2105 printf(
"----------------------------------------------------------------------\n\n");
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;
2113 while(mip_filter_mag_dip_angle_error_adaptive_measurement(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, &mag_dip_angle_error_command) != MIP_INTERFACE_OK){}
2116 while(mip_filter_mag_dip_angle_error_adaptive_measurement(&
device_interface, MIP_FUNCTION_SELECTOR_READ, &mag_dip_angle_error_readback) != MIP_INTERFACE_OK){}
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))
2124 printf(
"mag dip angle error adaptive measurement values successfully set.\n");
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);
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);
2142 printf(
"\n\nLoading the default mag magnitude error adaptive measurement values.\n\n");
2144 while(mip_filter_mag_dip_angle_error_adaptive_measurement(&
device_interface, MIP_FUNCTION_SELECTOR_LOAD_DEFAULT, NULL) != MIP_INTERFACE_OK){}
2180 printf(
"----------------------------------------------------------------------\n");
2181 printf(
"Setting the AHRS message format\n");
2182 printf(
"----------------------------------------------------------------------\n\n");
2184 data_stream_format_descriptors[0] = MIP_AHRS_DATA_ACCEL_SCALED;
2185 data_stream_format_descriptors[1] = MIP_AHRS_DATA_GYRO_SCALED;
2187 data_stream_format_decimation[0] = 0x32;
2188 data_stream_format_decimation[1] = 0x32;
2190 data_stream_format_num_entries = 2;
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){}
2201 printf(
"----------------------------------------------------------------------\n");
2202 printf(
"Polling AHRS Data.\n");
2203 printf(
"----------------------------------------------------------------------\n\n");
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){}
2214 printf(
"----------------------------------------------------------------------\n");
2215 printf(
"Setting the GPS datastream format\n");
2216 printf(
"----------------------------------------------------------------------\n\n");
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;
2222 data_stream_format_decimation[0] = 0x04;
2223 data_stream_format_decimation[1] = 0x04;
2224 data_stream_format_decimation[2] = 0x04;
2226 data_stream_format_num_entries = 3;
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){}
2238 printf(
"----------------------------------------------------------------------\n");
2239 printf(
"Polling GPS Data.\n");
2240 printf(
"----------------------------------------------------------------------\n\n");
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){}
2251 printf(
"----------------------------------------------------------------------\n");
2252 printf(
"Setting the Estimation Filter datastream format\n");
2253 printf(
"----------------------------------------------------------------------\n\n");
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;
2259 data_stream_format_decimation[0] = 0x32;
2260 data_stream_format_decimation[1] = 0x32;
2261 data_stream_format_decimation[2] = 0x32;
2263 data_stream_format_num_entries = 3;
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){}
2275 printf(
"----------------------------------------------------------------------\n");
2276 printf(
"Polling Estimation Filter Data.\n");
2277 printf(
"----------------------------------------------------------------------\n\n");
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){}
2286 printf(
"ERROR: Standard mode not established\n\n");
2297 printf(
"\n----------------------------------------------------------------------\n");
2298 printf(
"Enable the AHRS datastream\n");
2299 printf(
"----------------------------------------------------------------------\n\n");
2303 while(mip_3dm_cmd_continuous_data_stream(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, MIP_3DM_AHRS_DATASTREAM, &enable) != MIP_INTERFACE_OK){}
2312 printf(
"----------------------------------------------------------------------\n");
2313 printf(
"Enable the FILTER datastream\n");
2314 printf(
"----------------------------------------------------------------------\n\n");
2318 while(mip_3dm_cmd_continuous_data_stream(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, MIP_3DM_INS_DATASTREAM, &enable) != MIP_INTERFACE_OK){}
2327 printf(
"----------------------------------------------------------------------\n");
2328 printf(
"Enable the GPS datastream\n");
2329 printf(
"----------------------------------------------------------------------\n");
2333 while(mip_3dm_cmd_continuous_data_stream(&
device_interface, MIP_FUNCTION_SELECTOR_WRITE, MIP_3DM_GPS_DATASTREAM, &enable) != MIP_INTERFACE_OK){}
2342 printf(
"----------------------------------------------------------------------\n");
2343 printf(
"Processing incoming packets\n");
2344 printf(
"----------------------------------------------------------------------\n\n\n");
2369 mip_field_header *field_header;
2371 u16 field_offset = 0;
2374 switch(callback_type)
2380 case MIP_INTERFACE_CALLBACK_VALID_PACKET:
2388 while(mip_get_next_field(packet, &field_header, &field_data, &field_offset) == MIP_OK)
2395 switch(field_header->descriptor)
2401 case MIP_FILTER_DATA_LLH_POS:
2414 case MIP_FILTER_DATA_NED_VEL:
2416 memcpy(&
curr_filter_vel, field_data,
sizeof(mip_filter_ned_velocity));
2427 case MIP_FILTER_DATA_ATT_EULER_ANGLES:
2446 case MIP_INTERFACE_CALLBACK_CHECKSUM_ERROR:
2455 case MIP_INTERFACE_CALLBACK_TIMEOUT:
2474 mip_field_header *field_header;
2476 u16 field_offset = 0;
2479 switch(callback_type)
2485 case MIP_INTERFACE_CALLBACK_VALID_PACKET:
2493 while(mip_get_next_field(packet, &field_header, &field_data, &field_offset) == MIP_OK)
2500 switch(field_header->descriptor)
2506 case MIP_AHRS_DATA_ACCEL_SCALED:
2519 case MIP_AHRS_DATA_GYRO_SCALED:
2521 memcpy(&
curr_ahrs_gyro, field_data,
sizeof(mip_ahrs_scaled_gyro));
2532 case MIP_AHRS_DATA_MAG_SCALED:
2534 memcpy(&
curr_ahrs_mag, field_data,
sizeof(mip_ahrs_scaled_mag));
2550 case MIP_INTERFACE_CALLBACK_CHECKSUM_ERROR:
2559 case MIP_INTERFACE_CALLBACK_TIMEOUT:
2578 mip_field_header *field_header;
2580 u16 field_offset = 0;
2583 switch(callback_type)
2589 case MIP_INTERFACE_CALLBACK_VALID_PACKET:
2597 while(mip_get_next_field(packet, &field_header, &field_data, &field_offset) == MIP_OK)
2604 switch(field_header->descriptor)
2610 case MIP_GPS_DATA_LLH_POS:
2612 memcpy(&
curr_llh_pos, field_data,
sizeof(mip_gps_llh_pos));
2623 case MIP_GPS_DATA_NED_VELOCITY:
2625 memcpy(&
curr_ned_vel, field_data,
sizeof(mip_gps_ned_vel));
2636 case MIP_GPS_DATA_GPS_TIME:
2655 case MIP_INTERFACE_CALLBACK_CHECKSUM_ERROR:
2664 case MIP_INTERFACE_CALLBACK_TIMEOUT:
2685 printf(
"-----------------------------------------------------------------------\n\n");
2687 printf(
" GX4-45_Test [com_port_num] [baudrate]\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");
2692 printf(
" [ ] - required command input.\n");
2693 printf(
"\n-----------------------------------------------------------------------\n");
2707 printf(
"GX4-45 Test Program\n");
2708 printf(
"Copyright 2013. LORD Microstrain\n\n");
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;
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);
2769 while(mip_3dm_cmd_device_status(device_interface, model_number, status_selector, response_buffer, &response_size) != MIP_INTERFACE_OK){}
2771 if(status_selector == GX4_IMU_BASIC_STATUS_SEL){
2773 if(response_size !=
sizeof(gx4_imu_basic_status_field))
2774 return MIP_INTERFACE_ERROR;
2775 else if(MIP_SDK_CONFIG_BYTESWAP){
2777 basic_ptr = (gx4_imu_basic_status_field *)response_buffer;
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));
2785 }
else if(status_selector == GX4_IMU_DIAGNOSTICS_STATUS_SEL){
2787 if(response_size !=
sizeof(gx4_imu_diagnostic_device_status_field))
2788 return MIP_INTERFACE_ERROR;
2789 else if(MIP_SDK_CONFIG_BYTESWAP){
2791 diagnostic_ptr = (gx4_imu_diagnostic_device_status_field *)response_buffer;
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));
2813 return MIP_INTERFACE_ERROR;
2815 return MIP_INTERFACE_OK;
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;
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);
2854 while(mip_3dm_cmd_device_status(device_interface, model_number, status_selector, response_buffer, &response_size) != MIP_INTERFACE_OK){}
2856 if(status_selector == GX4_45_BASIC_STATUS_SEL)
2859 if(response_size !=
sizeof(gx4_45_basic_status_field))
2860 return MIP_INTERFACE_ERROR;
2861 else if(MIP_SDK_CONFIG_BYTESWAP){
2863 basic_ptr = (gx4_45_basic_status_field *)response_buffer;
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));
2873 else if(status_selector == GX4_45_DIAGNOSTICS_STATUS_SEL)
2876 if(response_size !=
sizeof(gx4_45_diagnostic_device_status_field))
2877 return MIP_INTERFACE_ERROR;
2878 else if(MIP_SDK_CONFIG_BYTESWAP){
2880 diagnostic_ptr = (gx4_45_diagnostic_device_status_field *)response_buffer;
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));
2904 return MIP_INTERFACE_ERROR;
2906 return MIP_INTERFACE_OK;
mip_filter_ned_velocity curr_filter_vel
#define MIP_SDK_GX4_45_IMU_DIRECT_MODE
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
mip_ahrs_scaled_gyro curr_ahrs_gyro
mip_gps_time curr_gps_time
#define NUM_COMMAND_LINE_ARGUMENTS
mip_interface device_interface
mip_filter_llh_pos curr_filter_pos
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
u32 filter_valid_packet_count
mip_ahrs_scaled_accel curr_ahrs_accel
int main(int argc, char *argv[])
mip_gps_ned_vel curr_ned_vel
u32 gps_valid_packet_count
mip_gps_llh_pos curr_llh_pos
void print_packet_stats()
u32 filter_checksum_error_packet_count
#define MIP_SDK_GX4_45_IMU_STANDARD_MODE
void ahrs_packet_callback(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
u32 ahrs_checksum_error_packet_count
u32 gps_timeout_packet_count
u32 filter_timeout_packet_count
u32 ahrs_timeout_packet_count
mip_ahrs_scaled_mag curr_ahrs_mag
mip_filter_attitude_euler_angles curr_filter_angles
u8 enable_data_stats_output
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