14 #include "microstrain_mips/status_msg.h" 20 Microstrain::Microstrain():
22 filter_valid_packet_count_(0),
23 ahrs_valid_packet_count_(0),
24 gps_valid_packet_count_(0),
25 filter_timeout_packet_count_(0),
26 ahrs_timeout_packet_count_(0),
27 gps_timeout_packet_count_(0),
28 filter_checksum_error_packet_count_(0),
29 ahrs_checksum_error_packet_count_(0),
30 gps_checksum_error_packet_count_(0),
31 gps_frame_id_(
"gps_frame"),
32 imu_frame_id_(
"imu_frame"),
33 odom_frame_id_(
"odom_frame"),
34 odom_child_frame_id_(
"odom_frame"),
38 publish_filtered_imu_(
false),
39 remove_imu_gravity_(
false),
40 frame_based_enu_(
false),
41 imu_linear_cov_(std::vector<double>(9, 0.0)),
42 imu_angular_cov_(std::vector<double>(9, 0.0)),
43 imu_orientation_cov_(std::vector<double>(9, 0.0))
47 Microstrain::~Microstrain()
51 void Microstrain::run()
54 u32 com_port, baudrate;
55 bool device_setup =
false;
56 bool readback_settings =
true;
57 bool save_settings =
true;
58 bool auto_init =
true;
60 u8 readback_headingsource = 0;
61 u8 readback_auto_init = 0;
62 int declination_source;
63 u8 declination_source_u8;
64 u8 readback_declination_source;
68 base_device_info_field device_info;
70 u8 data_stream_format_descriptors[10];
71 u16 data_stream_format_decimation[10];
72 u8 data_stream_format_num_entries = 0;
73 u8 readback_data_stream_format_descriptors[10] = {0};
74 u16 readback_data_stream_format_decimation[10] = {0};
75 u8 readback_data_stream_format_num_entries = 0;
77 u16 device_descriptors[128] = {0};
78 u16 device_descriptors_size = 128*2;
80 u8 heading_source = 0x1;
81 mip_low_pass_filter_settings filter_settings;
83 mip_filter_external_gps_update_command external_gps_update;
84 mip_filter_external_heading_update_command external_heading_update;
85 mip_filter_external_heading_with_time_command external_heading_with_time;
104 private_nh.
param(
"port", port, std::string(
"/dev/ttyACM1"));
105 private_nh.
param(
"baudrate", baud, 115200);
106 baudrate = (u32)baud;
108 private_nh.
param(
"device_setup", device_setup,
false);
109 private_nh.
param(
"readback_settings", readback_settings,
true);
110 private_nh.
param(
"save_settings", save_settings,
true);
112 private_nh.
param(
"auto_init", auto_init,
true);
113 private_nh.
param(
"gps_rate", gps_rate_, 1);
114 private_nh.
param(
"imu_rate", imu_rate_, 10);
115 private_nh.
param(
"nav_rate", nav_rate_, 10);
116 private_nh.
param(
"dynamics_mode", pdyn_mode, 1);
118 dynamics_mode = (u8)pdyn_mode;
119 if (dynamics_mode < 1 || dynamics_mode > 3)
121 ROS_WARN(
"dynamics_mode can't be %#04X, must be 1, 2 or 3. Setting to 1.", dynamics_mode);
125 private_nh.
param(
"declination_source", declination_source, 2);
126 if (declination_source < 1 || declination_source > 3)
128 ROS_WARN(
"declination_source can't be %#04X, must be 1, 2 or 3. Setting to 2.", declination_source);
129 declination_source = 2;
131 declination_source_u8 = (u8)declination_source;
134 private_nh.
param(
"declination", declination, 0.23);
135 private_nh.
param(
"gps_frame_id", gps_frame_id_, std::string(
"wgs84"));
136 private_nh.
param(
"imu_frame_id", imu_frame_id_, std::string(
"base_link"));
137 private_nh.
param(
"odom_frame_id", odom_frame_id_, std::string(
"wgs84"));
138 private_nh.
param(
"odom_child_frame_id", odom_child_frame_id_, std::string(
"base_link"));
140 private_nh.
param(
"publish_imu", publish_imu_,
true);
141 private_nh.
param(
"publish_bias", publish_bias_,
true);
142 private_nh.
param(
"publish_filtered_imu", publish_filtered_imu_,
false);
143 private_nh.
param(
"remove_imu_gravity", remove_imu_gravity_,
false);
144 private_nh.
param(
"frame_based_enu", frame_based_enu_,
false);
147 std::vector<double> default_cov(9, 0.0);
148 private_nh.
param(
"imu_orientation_cov", imu_orientation_cov_, default_cov);
149 private_nh.
param(
"imu_linear_cov", imu_linear_cov_, default_cov);
150 private_nh.
param(
"imu_angular_cov", imu_angular_cov_, default_cov);
154 imu_pub_ = node.
advertise<sensor_msgs::Imu>(
"imu/data", 100);
155 if (publish_filtered_imu_)
156 filtered_imu_pub_ = node.
advertise<sensor_msgs::Imu>(
"filtered/imu/data", 100);
159 device_status_pub_ = node.
advertise<microstrain_mips::status_msg>(
"device/status", 100);
163 &Microstrain::reset_callback,
this);
165 &Microstrain::device_report,
this);
167 &Microstrain::gyro_bias_capture,
this);
169 &Microstrain::set_soft_iron_matrix,
this);
171 &Microstrain::set_complementary_filter,
this);
173 &Microstrain::set_filter_euler,
this);
175 &Microstrain::set_filter_heading,
this);
177 &Microstrain::set_accel_bias_model,
this);
179 &Microstrain::set_accel_adaptive_vals,
this);
181 &Microstrain::set_sensor_vehicle_frame_trans,
this);
183 &Microstrain::set_sensor_vehicle_frame_offset,
this);
185 &Microstrain::set_accel_bias,
this);
187 &Microstrain::set_gyro_bias,
this);
189 &Microstrain::set_hard_iron_values,
this);
191 &Microstrain::get_accel_bias,
this);
193 &Microstrain::get_gyro_bias,
this);
195 &Microstrain::get_hard_iron_values,
this);
197 &Microstrain::get_soft_iron_matrix,
this);
199 &Microstrain::get_sensor_vehicle_frame_trans,
this);
201 &Microstrain::get_complementary_filter,
this);
203 &Microstrain::set_reference_position,
this);
205 &Microstrain::get_reference_position,
this);
207 &Microstrain::set_coning_sculling_comp,
this);
209 &Microstrain::get_coning_sculling_comp,
this);
211 &Microstrain::set_estimation_control_flags,
this);
213 &Microstrain::get_estimation_control_flags,
this);
215 &Microstrain::set_dynamics_mode,
this);
217 &Microstrain::get_basic_status,
this);
219 &Microstrain::get_diagnostic_report,
this);
221 &Microstrain::set_zero_angle_update_threshold,
this);
223 &Microstrain::get_zero_angle_update_threshold,
this);
225 &Microstrain::set_tare_orientation,
this);
227 &Microstrain::set_accel_noise,
this);
229 &Microstrain::get_accel_noise,
this);
231 &Microstrain::set_gyro_noise,
this);
233 &Microstrain::get_gyro_noise,
this);
235 &Microstrain::set_mag_noise,
this);
237 &Microstrain::get_mag_noise,
this);
239 &Microstrain::set_gyro_bias_model,
this);
241 &Microstrain::get_gyro_bias_model,
this);
243 &Microstrain::get_accel_adaptive_vals,
this);
245 &Microstrain::set_mag_adaptive_vals,
this);
247 &Microstrain::get_mag_adaptive_vals,
this);
249 &Microstrain::set_mag_dip_adaptive_vals,
this);
251 &Microstrain::get_accel_bias_model,
this);
253 &Microstrain::get_mag_dip_adaptive_vals,
this);
255 &Microstrain::get_sensor_vehicle_frame_offset,
this);
257 &Microstrain::get_dynamics_mode,
this);
260 ROS_INFO(
"Attempting to open serial port <%s> at <%d> \n", port.c_str(), baudrate);
261 if (mip_interface_init(port.c_str(), baudrate,
264 ROS_FATAL(
"Couldn't open serial port! Is it plugged in?");
270 while (mip_base_cmd_get_device_info(&device_interface_, &device_info) != MIP_INTERFACE_OK)
272 if (clock() - start > 5000)
274 ROS_INFO(
"mip_base_cmd_get_device_info function timed out.");
280 memset(temp_string, 0, 20*
sizeof(
char));
281 memcpy(temp_string, device_info.model_name, BASE_DEVICE_INFO_PARAM_LENGTH*2);
282 ROS_INFO(
"Model Name => %s\n", temp_string);
283 std::string model_name;
285 for (
int i = 6; i < 20; i++)
287 model_name += temp_string[i];
291 model_name = model_name.c_str();
315 ROS_INFO(
"Putting device communications into 'standard mode'");
316 device_descriptors_size = 128*2;
319 while (mip_system_com_mode(&device_interface_,
320 MIP_FUNCTION_SELECTOR_WRITE, &com_mode) != MIP_INTERFACE_OK)
322 if (clock() - start > 5000)
324 ROS_INFO(
"mip_system_com_mode function timed out.");
332 while (mip_system_com_mode(&device_interface_,
333 MIP_FUNCTION_SELECTOR_READ, &com_mode) != MIP_INTERFACE_OK)
335 if (clock() - start > 5000)
337 ROS_INFO(
"mip_system_com_mode function timed out.");
347 ROS_ERROR(
"Appears we didn't get into standard mode!");
351 if (GX5_45 || GX5_35)
353 private_nh.
param(
"publish_gps", publish_gps_,
true);
354 private_nh.
param(
"publish_odom", publish_odom_,
true);
358 private_nh.
param(
"publish_gps", publish_gps_,
false);
359 private_nh.
param(
"publish_odom", publish_odom_,
false);
364 gps_pub_ = node.
advertise<sensor_msgs::NavSatFix>(
"gps/fix", 100);
369 nav_pub_ = node.
advertise<nav_msgs::Odometry>(
"nav/odom", 100);
373 if (publish_odom_ || publish_filtered_imu_)
375 nav_status_pub_ = node.
advertise<std_msgs::Int16MultiArray>(
"nav/status", 100);
379 if (mip_interface_add_descriptor_set_callback(&device_interface_, MIP_FILTER_DATA_SET,
382 ROS_FATAL(
"Can't setup filter callback!");
386 if (mip_interface_add_descriptor_set_callback(&device_interface_, MIP_AHRS_DATA_SET,
389 ROS_FATAL(
"Can't setup ahrs callbacks!");
393 if (mip_interface_add_descriptor_set_callback(&device_interface_, MIP_GPS_DATA_SET,
401 ROS_INFO(
"Idling Device: Stopping data streams and/or waking from sleep");
403 while (mip_base_cmd_idle(&device_interface_) != MIP_INTERFACE_OK)
405 if (clock() - start > 5000)
407 ROS_INFO(
"mip_base_cmd_idle function timed out.");
415 if (publish_imu_ || publish_filtered_imu_)
418 while (mip_3dm_cmd_get_ahrs_base_rate(&device_interface_, &base_rate) != MIP_INTERFACE_OK)
420 if (clock() - start > 5000)
422 ROS_INFO(
"mip_3dm_cmd_get_ahrs_base_rate function timed out.");
427 ROS_INFO(
"AHRS Base Rate => %d Hz", base_rate);
430 int rate = (imu_rate_ > nav_rate_) ? imu_rate_ : nav_rate_;
431 u8 imu_decimation = (u8)(static_cast<float>(base_rate)/
static_cast<float>(rate));
432 ROS_INFO(
"AHRS decimation set to %#04X", imu_decimation);
436 ROS_INFO(
"Setting the AHRS message format");
437 data_stream_format_descriptors[0] = MIP_AHRS_DATA_ACCEL_SCALED;
438 data_stream_format_descriptors[1] = MIP_AHRS_DATA_GYRO_SCALED;
439 data_stream_format_descriptors[2] = MIP_AHRS_DATA_QUATERNION;
440 data_stream_format_decimation[0] = imu_decimation;
441 data_stream_format_decimation[1] = imu_decimation;
442 data_stream_format_decimation[2] = imu_decimation;
443 data_stream_format_num_entries = 3;
446 while (mip_3dm_cmd_ahrs_message_format(&device_interface_,
447 MIP_FUNCTION_SELECTOR_WRITE, &data_stream_format_num_entries,
448 data_stream_format_descriptors, data_stream_format_decimation) != MIP_INTERFACE_OK)
450 if (clock() - start > 5000)
452 ROS_INFO(
"mip_3dm_cmd_ahrs_message_format function timed out.");
459 ROS_INFO(
"Poll AHRS data to verify");
461 while (mip_3dm_cmd_poll_ahrs(&device_interface_,
462 MIP_3DM_POLLING_ENABLE_ACK_NACK, data_stream_format_num_entries,
463 data_stream_format_descriptors) != MIP_INTERFACE_OK)
465 if (clock() - start > 5000)
467 ROS_INFO(
"mip_3dm_cmd_poll_ahrs function timed out.");
476 ROS_INFO(
"Saving AHRS data settings");
478 while (mip_3dm_cmd_ahrs_message_format(&device_interface_,
479 MIP_FUNCTION_SELECTOR_STORE_EEPROM, 0, NULL, NULL) != MIP_INTERFACE_OK)
481 if (clock() - start > 5000)
483 ROS_INFO(
"mip_3dm_cmd_ahrs_message_format function timed out.");
492 ROS_INFO(
"Setting declination source to %#04X", declination_source_u8);
494 while (mip_filter_declination_source(&device_interface_,
495 MIP_FUNCTION_SELECTOR_WRITE, &declination_source_u8) != MIP_INTERFACE_OK)
497 if (clock() - start > 5000)
499 ROS_INFO(
"mip_filter_declination_source function timed out.");
506 ROS_INFO(
"Reading back declination source");
508 while (mip_filter_declination_source(&device_interface_,
509 MIP_FUNCTION_SELECTOR_READ, &readback_declination_source) != MIP_INTERFACE_OK)
511 if (clock() - start > 5000)
513 ROS_INFO(
"mip_filter_declination_source function timed out.");
518 if (declination_source_u8 == readback_declination_source)
520 ROS_INFO(
"Success: Declination source set to %#04X", declination_source_u8);
524 ROS_WARN(
"Failed to set the declination source to %#04X!", declination_source_u8);
530 ROS_INFO(
"Saving declination source settings to EEPROM");
532 while (mip_filter_declination_source(&device_interface_,
533 MIP_FUNCTION_SELECTOR_STORE_EEPROM, NULL) != MIP_INTERFACE_OK)
535 if (clock() - start > 5000)
537 ROS_INFO(
"mip_filter_declination_source function timed out.");
551 while (mip_3dm_cmd_get_gps_base_rate(&device_interface_, &base_rate) != MIP_INTERFACE_OK)
553 if (clock() - start > 5000)
555 ROS_INFO(
"mip_3dm_cmd_get_gps_base_rate function timed out.");
560 ROS_INFO(
"GPS Base Rate => %d Hz", base_rate);
561 u8 gps_decimation = (u8)(static_cast<float>(base_rate)/
static_cast<float>(gps_rate_));
566 ROS_INFO(
"Setting GPS stream format");
567 data_stream_format_descriptors[0] = MIP_GPS_DATA_LLH_POS;
568 data_stream_format_descriptors[1] = MIP_GPS_DATA_NED_VELOCITY;
569 data_stream_format_descriptors[2] = MIP_GPS_DATA_GPS_TIME;
570 data_stream_format_decimation[0] = gps_decimation;
571 data_stream_format_decimation[1] = gps_decimation;
572 data_stream_format_decimation[2] = gps_decimation;
573 data_stream_format_num_entries = 3;
576 while (mip_3dm_cmd_gps_message_format(&device_interface_,
577 MIP_FUNCTION_SELECTOR_WRITE, &data_stream_format_num_entries,
578 data_stream_format_descriptors, data_stream_format_decimation) != MIP_INTERFACE_OK)
580 if (clock() - start > 5000)
582 ROS_INFO(
"mip_3dm_cmd_gps_message_format function timed out.");
591 ROS_INFO(
"Saving GPS data settings");
593 while (mip_3dm_cmd_gps_message_format(&device_interface_,
594 MIP_FUNCTION_SELECTOR_STORE_EEPROM, 0, NULL, NULL) != MIP_INTERFACE_OK)
596 if (clock() - start > 5000)
598 ROS_INFO(
"mip_3dm_cmd_gps_message_format function timed out.");
607 if (publish_odom_ || publish_filtered_imu_)
610 while (mip_3dm_cmd_get_filter_base_rate(&device_interface_, &base_rate) != MIP_INTERFACE_OK)
612 if (clock() - start > 5000)
614 ROS_INFO(
"mip_3dm_cmd_get_filter_base_rate function timed out.");
619 ROS_INFO(
"FILTER Base Rate => %d Hz", base_rate);
623 int rate = nav_rate_;
624 if(publish_filtered_imu_)
627 rate = (imu_rate_ > nav_rate_) ? imu_rate_ : nav_rate_;
630 u8 nav_decimation = (u8)(static_cast<float>(base_rate)/
static_cast<float>(rate));
635 ROS_INFO(
"Setting Filter stream format");
639 data_stream_format_descriptors[0] = MIP_FILTER_DATA_ATT_QUATERNION;
640 data_stream_format_descriptors[1] = MIP_FILTER_DATA_ATT_UNCERTAINTY_EULER;
641 data_stream_format_descriptors[2] = MIP_FILTER_DATA_COMPENSATED_ANGULAR_RATE;
642 data_stream_format_descriptors[3] = MIP_FILTER_DATA_FILTER_STATUS;
643 data_stream_format_decimation[0] = nav_decimation;
644 data_stream_format_decimation[1] = nav_decimation;
645 data_stream_format_decimation[2] = nav_decimation;
646 data_stream_format_decimation[3] = nav_decimation;
649 if (publish_odom_ && publish_filtered_imu_)
652 data_stream_format_descriptors[4] = MIP_FILTER_DATA_LLH_POS;
653 data_stream_format_descriptors[5] = MIP_FILTER_DATA_NED_VEL;
655 data_stream_format_descriptors[6] = MIP_FILTER_DATA_POS_UNCERTAINTY;
656 data_stream_format_descriptors[7] = MIP_FILTER_DATA_VEL_UNCERTAINTY;
659 if (remove_imu_gravity_)
661 data_stream_format_descriptors[8] = MIP_FILTER_DATA_LINEAR_ACCELERATION;
665 data_stream_format_descriptors[8] = MIP_FILTER_DATA_COMPENSATED_ACCELERATION;
668 data_stream_format_decimation[4] = nav_decimation;
669 data_stream_format_decimation[5] = nav_decimation;
670 data_stream_format_decimation[6] = nav_decimation;
671 data_stream_format_decimation[7] = nav_decimation;
672 data_stream_format_decimation[8] = nav_decimation;
673 data_stream_format_num_entries = 9;
675 else if (publish_odom_ && !publish_filtered_imu_)
677 data_stream_format_descriptors[4] = MIP_FILTER_DATA_LLH_POS;
678 data_stream_format_descriptors[5] = MIP_FILTER_DATA_NED_VEL;
680 data_stream_format_descriptors[6] = MIP_FILTER_DATA_POS_UNCERTAINTY;
681 data_stream_format_descriptors[7] = MIP_FILTER_DATA_VEL_UNCERTAINTY;
683 data_stream_format_decimation[4] = nav_decimation;
684 data_stream_format_decimation[5] = nav_decimation;
685 data_stream_format_decimation[6] = nav_decimation;
686 data_stream_format_decimation[7] = nav_decimation;
687 data_stream_format_num_entries = 8;
692 if (remove_imu_gravity_)
694 data_stream_format_descriptors[4] = MIP_FILTER_DATA_LINEAR_ACCELERATION;
698 data_stream_format_descriptors[4] = MIP_FILTER_DATA_COMPENSATED_ACCELERATION;
700 data_stream_format_decimation[4] = nav_decimation;
701 data_stream_format_num_entries = 5;
705 while (mip_3dm_cmd_filter_message_format(&device_interface_,
706 MIP_FUNCTION_SELECTOR_WRITE, &data_stream_format_num_entries,
707 data_stream_format_descriptors, data_stream_format_decimation) != MIP_INTERFACE_OK)
709 if (clock() - start > 5000)
711 ROS_INFO(
"mip_3dm_cmd_filter_message_format function timed out.");
718 ROS_INFO(
"Poll filter data to test stream");
720 while (mip_3dm_cmd_poll_filter(&device_interface_,
721 MIP_3DM_POLLING_ENABLE_ACK_NACK, data_stream_format_num_entries,
722 data_stream_format_descriptors) != MIP_INTERFACE_OK)
724 if (clock() - start > 5000)
726 ROS_INFO(
"mip_3dm_cmd_poll_filter function timed out.");
735 ROS_INFO(
"Saving Filter data settings");
737 while (mip_3dm_cmd_filter_message_format(&device_interface_,
738 MIP_FUNCTION_SELECTOR_STORE_EEPROM, 0, NULL, NULL) != MIP_INTERFACE_OK)
740 if (clock() - start > 5000)
742 ROS_INFO(
"mip_3dm_cmd_filter_message_format function timed out.");
751 if (GX5_35 ==
true || GX5_45 ==
true)
755 ROS_INFO(
"Setting dynamics mode to %#04X", dynamics_mode);
757 while (mip_filter_vehicle_dynamics_mode(&device_interface_,
758 MIP_FUNCTION_SELECTOR_WRITE, &dynamics_mode) != MIP_INTERFACE_OK)
760 if (clock() - start > 5000)
762 ROS_INFO(
"mip_filter_vehicle_dynamics_mode function timed out.");
769 if (readback_settings)
772 ROS_INFO(
"Reading back dynamics mode setting");
774 while (mip_filter_vehicle_dynamics_mode(&device_interface_,
775 MIP_FUNCTION_SELECTOR_READ, &readback_dynamics_mode) != MIP_INTERFACE_OK)
777 if (clock() - start > 5000)
779 ROS_INFO(
"mip_filter_vehicle_dynamics_mode function timed out.");
785 if (dynamics_mode == readback_dynamics_mode)
786 ROS_INFO(
"Success: Dynamics mode setting is: %#04X", readback_dynamics_mode);
788 ROS_ERROR(
"Failure: Dynamics mode set to be %#04X, but reads as %#04X",
789 dynamics_mode, readback_dynamics_mode);
794 ROS_INFO(
"Saving dynamics mode settings to EEPROM");
796 while (mip_filter_vehicle_dynamics_mode(&device_interface_,
797 MIP_FUNCTION_SELECTOR_STORE_EEPROM, NULL) != MIP_INTERFACE_OK)
799 if (clock() - start > 5000)
801 ROS_INFO(
"mip_filter_vehicle_dynamics_mode function timed out.");
810 ROS_INFO(
"Set heading source to internal mag.");
811 heading_source = 0x1;
812 ROS_INFO(
"Setting heading source to %#04X", heading_source);
814 while (mip_filter_heading_source(&device_interface_,
815 MIP_FUNCTION_SELECTOR_WRITE, &heading_source) != MIP_INTERFACE_OK)
817 if (clock() - start > 5000)
819 ROS_INFO(
"mip_filter_heading_source function timed out.");
825 ROS_INFO(
"Read back heading source...");
827 while (mip_filter_heading_source(&device_interface_,
828 MIP_FUNCTION_SELECTOR_READ, &readback_headingsource)!= MIP_INTERFACE_OK)
830 if (clock() - start > 5000)
832 ROS_INFO(
"mip_filter_heading_source function timed out.");
837 ROS_INFO(
"Heading source = %#04X", readback_headingsource);
842 ROS_INFO(
"Saving heading source to EEPROM");
844 while (mip_filter_heading_source(&device_interface_,
845 MIP_FUNCTION_SELECTOR_STORE_EEPROM, NULL)!= MIP_INTERFACE_OK)
847 if (clock() - start > 5000)
849 ROS_INFO(
"mip_filter_heading_source function timed out.");
858 ROS_INFO(
"Setting auto-initinitalization to: %#04X", auto_init);
859 auto_init_u8 = auto_init;
861 while (mip_filter_auto_initialization(&device_interface_,
862 MIP_FUNCTION_SELECTOR_WRITE, &auto_init_u8) != MIP_INTERFACE_OK)
864 if (clock() - start > 5000)
866 ROS_INFO(
"mip_filter_auto_initialization function timed out.");
872 if (readback_settings)
875 ROS_INFO(
"Reading back auto-initialization value");
877 while (mip_filter_auto_initialization(&device_interface_,
878 MIP_FUNCTION_SELECTOR_READ, &readback_auto_init)!= MIP_INTERFACE_OK)
880 if (clock() - start > 5000)
882 ROS_INFO(
"mip_filter_auto_initialization function timed out.");
888 if (auto_init == readback_auto_init)
889 ROS_INFO(
"Success: Auto init. setting is: %#04X",
892 ROS_ERROR(
"Failure: Auto init. setting set to be %#04X, but reads as %#04X",
893 auto_init, readback_auto_init);
898 ROS_INFO(
"Saving auto init. settings to EEPROM");
900 while (mip_filter_auto_initialization(&device_interface_,
901 MIP_FUNCTION_SELECTOR_STORE_EEPROM, NULL) != MIP_INTERFACE_OK)
903 if (clock() - start > 5000)
905 ROS_INFO(
"mip_filter_auto_initialization function timed out.");
914 if (publish_imu_ || publish_filtered_imu_)
919 while (mip_3dm_cmd_continuous_data_stream(&device_interface_,
920 MIP_FUNCTION_SELECTOR_WRITE, MIP_3DM_AHRS_DATASTREAM, &enable) != MIP_INTERFACE_OK)
922 if (clock() - start > 5000)
924 ROS_INFO(
"mip_3dm_cmd_continuous_data_stream function timed out.");
936 while (mip_3dm_cmd_continuous_data_stream(&device_interface_,
937 MIP_FUNCTION_SELECTOR_WRITE, MIP_3DM_INS_DATASTREAM, &enable) != MIP_INTERFACE_OK)
939 if (clock() - start > 5000)
941 ROS_INFO(
"mip_3dm_cmd_continuous_data_stream function timed out.");
953 while (mip_3dm_cmd_continuous_data_stream(&device_interface_,
954 MIP_FUNCTION_SELECTOR_WRITE, MIP_3DM_GPS_DATASTREAM, &enable) != MIP_INTERFACE_OK)
956 if (clock() - start > 5000)
958 ROS_INFO(
"mip_3dm_cmd_continuous_data_stream function timed out.");
965 ROS_INFO(
"End of device setup - starting streaming");
969 ROS_INFO(
"Skipping device setup and listing for existing streams");
975 while (mip_filter_reset_filter(&device_interface_) != MIP_INTERFACE_OK)
977 if (clock() - start > 5000)
979 ROS_INFO(
"mip_filter_reset_filter function timed out.");
990 max_rate = std::max(max_rate, imu_rate_);
992 if (publish_filtered_imu_)
994 max_rate = std::max(std::max(max_rate, nav_rate_),imu_rate_);
998 max_rate = std::max(max_rate, gps_rate_);
1002 max_rate = std::max(max_rate, nav_rate_);
1004 int spin_rate = std::min(3*max_rate, 1000);
1005 ROS_INFO(
"Setting spin rate to <%d>", spin_rate);
1013 mip_interface_update(&device_interface_);
1017 device_status_callback();
1028 bool Microstrain::reset_callback(std_srvs::Empty::Request &req,
1029 std_srvs::Empty::Response &resp)
1033 while (mip_filter_reset_filter(&device_interface_) != MIP_INTERFACE_OK)
1035 if (clock() - start > 5000)
1037 ROS_INFO(
"mip_filter_reset_filter function timed out.");
1046 bool Microstrain::set_accel_bias(microstrain_mips::SetAccelBias::Request &req,
1047 microstrain_mips::SetAccelBias::Response &res)
1049 ROS_INFO(
"Setting accel bias values");
1050 memset(field_data, 0, 3*
sizeof(
float));
1052 while (mip_3dm_cmd_accel_bias(&device_interface_,
1053 MIP_FUNCTION_SELECTOR_READ, field_data) != MIP_INTERFACE_OK)
1055 if (clock() - start > 5000)
1057 ROS_INFO(
"mip_3dm_cmd_accel_bias function timed out.");
1062 ROS_INFO(
"Accel bias vector values are: %f %f %f",
1063 field_data[0], field_data[1], field_data[2]);
1064 ROS_INFO(
"Client request values are: %.2f %.2f %.2f",
1065 req.bias.x, req.bias.y, req.bias.z);
1067 field_data[0] = req.bias.x;
1068 field_data[1] = req.bias.y;
1069 field_data[2] = req.bias.z;
1072 while (mip_3dm_cmd_accel_bias(&device_interface_,
1073 MIP_FUNCTION_SELECTOR_WRITE, field_data) != MIP_INTERFACE_OK)
1075 if (clock() - start > 5000)
1077 ROS_INFO(
"mip_3dm_cmd_accel_bias function timed out.");
1082 memset(field_data, 0, 3*
sizeof(
float));
1084 while (mip_3dm_cmd_accel_bias(&device_interface_,
1085 MIP_FUNCTION_SELECTOR_READ, field_data) != MIP_INTERFACE_OK)
1087 if (clock() - start > 5000)
1089 ROS_INFO(
"mip_3dm_cmd_accel_bias function timed out.");
1093 ROS_INFO(
"New accel bias vector values are: %.2f %.2f %.2f",
1094 field_data[0], field_data[1], field_data[2]);
1101 bool Microstrain::get_accel_bias(std_srvs::Trigger::Request &req,
1102 std_srvs::Trigger::Response &res)
1104 ROS_INFO(
"Getting accel bias values");
1105 memset(field_data, 0, 3*
sizeof(
float));
1108 while (mip_3dm_cmd_accel_bias(&device_interface_,
1109 MIP_FUNCTION_SELECTOR_READ, field_data) != MIP_INTERFACE_OK)
1111 if (clock() - start > 5000)
1113 ROS_INFO(
"mip_3dm_cmd_accel_bias function timed out.");
1117 ROS_INFO(
"Accel bias vector values are: %f %f %f",
1118 field_data[0], field_data[1], field_data[2]);
1125 bool Microstrain::set_gyro_bias(microstrain_mips::SetGyroBias::Request &req,
1126 microstrain_mips::SetGyroBias::Response &res)
1128 ROS_INFO(
"Setting gyro bias values");
1129 memset(field_data, 0, 3*
sizeof(
float));
1132 while (mip_3dm_cmd_gyro_bias(&device_interface_,
1133 MIP_FUNCTION_SELECTOR_READ, field_data) != MIP_INTERFACE_OK)
1135 if (clock() - start > 5000)
1137 ROS_INFO(
"mip_3dm_cmd_gyro_bias function timed out.");
1142 ROS_INFO(
"Gyro bias vector values are: %f %f %f",
1143 field_data[0], field_data[1], field_data[2]);
1144 ROS_INFO(
"Client request values are: %.2f %.2f %.2f",
1145 req.bias.x, req.bias.y, req.bias.z);
1147 field_data[0] = req.bias.x;
1148 field_data[1] = req.bias.y;
1149 field_data[2] = req.bias.z;
1152 while (mip_3dm_cmd_gyro_bias(&device_interface_,
1153 MIP_FUNCTION_SELECTOR_WRITE, field_data) != MIP_INTERFACE_OK)
1155 if (clock() - start > 5000)
1157 ROS_INFO(
"mip_3dm_cmd_gyro_bias function timed out.");
1161 memset(field_data, 0, 3*
sizeof(
float));
1163 while (mip_3dm_cmd_gyro_bias(&device_interface_,
1164 MIP_FUNCTION_SELECTOR_READ, field_data) != MIP_INTERFACE_OK)
1166 if (clock() - start > 5000)
1168 ROS_INFO(
"mip_3dm_cmd_gyro_bias function timed out.");
1172 ROS_INFO(
"New gyro bias vector values are: %.2f %.2f %.2f",
1173 field_data[0], field_data[1], field_data[2]);
1180 bool Microstrain::get_gyro_bias(std_srvs::Trigger::Request &req,
1181 std_srvs::Trigger::Response &res)
1183 ROS_INFO(
"Getting gyro bias values");
1184 memset(field_data, 0, 3*
sizeof(
float));
1187 while (mip_3dm_cmd_gyro_bias(&device_interface_,
1188 MIP_FUNCTION_SELECTOR_READ, field_data) != MIP_INTERFACE_OK)
1190 if (clock() - start > 5000)
1192 ROS_INFO(
"mip_3dm_cmd_gyro_bias function timed out.");
1196 ROS_INFO(
"Gyro bias vector values are: %f %f %f", field_data[0], field_data[1], field_data[2]);
1203 bool Microstrain::set_hard_iron_values(microstrain_mips::SetHardIronValues::Request &req,
1204 microstrain_mips::SetHardIronValues::Response &res)
1208 ROS_INFO(
"Device does not support this feature");
1209 res.success =
false;
1213 ROS_INFO(
"Setting hard iron values");
1214 float field_data[3] = {0};
1217 while (mip_3dm_cmd_hard_iron(&device_interface_,
1218 MIP_FUNCTION_SELECTOR_READ, field_data) != MIP_INTERFACE_OK)
1220 if (clock() - start > 5000)
1222 ROS_INFO(
"mip_3dm_cmd_hard_iron function timed out.");
1227 ROS_INFO(
"Hard iron values are: %f %f %f", field_data[0], field_data[1], field_data[2]);
1228 ROS_INFO(
"Client request values are: %.2f %.2f %.2f", req.bias.x, req.bias.y, req.bias.z);
1230 field_data[0] = req.bias.x;
1231 field_data[1] = req.bias.y;
1232 field_data[2] = req.bias.z;
1235 while (mip_3dm_cmd_hard_iron(&device_interface_,
1236 MIP_FUNCTION_SELECTOR_WRITE, field_data) != MIP_INTERFACE_OK)
1238 if (clock() - start > 5000)
1240 ROS_INFO(
"mip_3dm_cmd_hard_iron function timed out.");
1245 memset(field_data, 0, 3*
sizeof(
float));
1247 while (mip_3dm_cmd_hard_iron(&device_interface_,
1248 MIP_FUNCTION_SELECTOR_READ, field_data) != MIP_INTERFACE_OK)
1250 if (clock() - start > 5000)
1252 ROS_INFO(
"mip_3dm_cmd_hard_iron function timed out.");
1256 ROS_INFO(
"New hard iron values are: %.2f %.2f %.2f", field_data[0], field_data[1], field_data[2]);
1263 bool Microstrain::get_hard_iron_values(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
1267 ROS_INFO(
"Device does not support this feature");
1268 res.success =
false;
1272 ROS_INFO(
"Getting hard iron values");
1273 memset(field_data, 0, 3*
sizeof(
float));
1276 while (mip_3dm_cmd_hard_iron(&device_interface_,
1277 MIP_FUNCTION_SELECTOR_READ, field_data) != MIP_INTERFACE_OK)
1279 if (clock() - start > 5000)
1281 ROS_INFO(
"mip_3dm_cmd_hard_iron function timed out.");
1285 ROS_INFO(
"Hard iron values are: %f %f %f", field_data[0], field_data[1], field_data[2]);
1293 bool Microstrain::device_report(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
1296 while (mip_base_cmd_get_device_info(&device_interface_, &device_info) != MIP_INTERFACE_OK)
1298 if (clock() - start > 5000)
1300 ROS_INFO(
"mip_base_cmd_get_device_info function timed out.");
1307 memset(temp_string, 0, 20*
sizeof(
int));
1309 memcpy(temp_string, device_info.model_name, BASE_DEVICE_INFO_PARAM_LENGTH*2);
1310 ROS_INFO(
"Model Name => %s\n", temp_string);
1312 memcpy(temp_string, device_info.model_number, BASE_DEVICE_INFO_PARAM_LENGTH*2);
1313 ROS_INFO(
"Model Number => %s\n", temp_string);
1315 memcpy(temp_string, device_info.serial_number, BASE_DEVICE_INFO_PARAM_LENGTH*2);
1316 ROS_INFO(
"Serial Number => %s\n", temp_string);
1318 memcpy(temp_string, device_info.lotnumber, BASE_DEVICE_INFO_PARAM_LENGTH*2);
1319 ROS_INFO(
"Lot Number => %s\n", temp_string);
1321 memcpy(temp_string, device_info.device_options, BASE_DEVICE_INFO_PARAM_LENGTH*2);
1322 ROS_INFO(
"Options => %s\n", temp_string);
1324 ROS_INFO(
"Firmware Version => %d.%d.%.2d\n\n", (device_info.firmware_version)/1000,
1325 (device_info.firmware_version)%1000/100, (device_info.firmware_version)%100);
1332 bool Microstrain::gyro_bias_capture(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
1334 memset(field_data, 0, 3*
sizeof(
float));
1335 ROS_INFO(
"Performing Gyro Bias capture.\nPlease keep device stationary during the 5 second gyro bias capture interval\n");
1338 while (mip_3dm_cmd_capture_gyro_bias(&device_interface_, duration, field_data) != MIP_INTERFACE_OK)
1340 if (clock() - start > 5000)
1342 ROS_INFO(
"mip_3dm_cmd_capture_gyro_bias function timed out.");
1346 ROS_INFO(
"Gyro Bias Captured:\nbias_vector[0] = %f\nbias_vector[1] = %f\nbias_vector[2] = %f\n\n",
1347 field_data[0], field_data[1], field_data[2]);
1354 bool Microstrain::set_soft_iron_matrix(microstrain_mips::SetSoftIronMatrix::Request &req,
1355 microstrain_mips::SetSoftIronMatrix::Response &res)
1359 ROS_INFO(
"Device does not support this feature");
1360 res.success =
false;
1364 memset(soft_iron, 0, 9*
sizeof(
float));
1365 memset(soft_iron_readback, 0, 9*
sizeof(
float));
1367 ROS_INFO(
"Setting the soft iron matrix values\n");
1369 soft_iron[0] = req.soft_iron_1.x;
1370 soft_iron[1] = req.soft_iron_1.y;
1371 soft_iron[2] = req.soft_iron_1.z;
1372 soft_iron[3] = req.soft_iron_2.x;
1373 soft_iron[4] = req.soft_iron_2.y;
1374 soft_iron[5] = req.soft_iron_2.z;
1375 soft_iron[6] = req.soft_iron_3.x;
1376 soft_iron[7] = req.soft_iron_3.y;
1377 soft_iron[8] = req.soft_iron_3.z;
1380 while (mip_3dm_cmd_soft_iron(&device_interface_,
1381 MIP_FUNCTION_SELECTOR_WRITE, soft_iron) != MIP_INTERFACE_OK)
1383 if (clock() - start > 5000)
1385 ROS_INFO(
"mip_3dm_cmd_soft_iron function timed out.");
1392 while (mip_3dm_cmd_soft_iron(&device_interface_,
1393 MIP_FUNCTION_SELECTOR_READ, soft_iron_readback) != MIP_INTERFACE_OK)
1395 if (clock() - start > 5000)
1397 ROS_INFO(
"mip_3dm_cmd_soft_iron function timed out.");
1402 if ((abs(soft_iron_readback[0] - soft_iron[0]) < 0.001) &&
1403 (abs(soft_iron_readback[1] - soft_iron[1]) < 0.001) &&
1404 (abs(soft_iron_readback[2] - soft_iron[2]) < 0.001) &&
1405 (abs(soft_iron_readback[3] - soft_iron[3]) < 0.001) &&
1406 (abs(soft_iron_readback[4] - soft_iron[4]) < 0.001) &&
1407 (abs(soft_iron_readback[5] - soft_iron[5]) < 0.001) &&
1408 (abs(soft_iron_readback[6] - soft_iron[6]) < 0.001) &&
1409 (abs(soft_iron_readback[7] - soft_iron[7]) < 0.001) &&
1410 (abs(soft_iron_readback[8] - soft_iron[8]) < 0.001))
1412 ROS_INFO(
"Soft iron matrix values successfully set.\n");
1413 ROS_INFO(
"Sent values: [%f %f %f][%f %f %f][%f %f %f]\n",
1414 soft_iron[0], soft_iron[1], soft_iron[2],
1415 soft_iron[3], soft_iron[4], soft_iron[5],
1416 soft_iron[6], soft_iron[7], soft_iron[8]);
1417 ROS_INFO(
"Returned values: [%f %f %f][%f %f %f][%f %f %f]\n",
1418 soft_iron_readback[0], soft_iron_readback[1], soft_iron_readback[2],
1419 soft_iron_readback[3], soft_iron_readback[4], soft_iron_readback[5],
1420 soft_iron_readback[6], soft_iron_readback[7], soft_iron_readback[8]);
1424 ROS_INFO(
"ERROR: Failed to set hard iron values!!!\n");
1425 ROS_INFO(
"Sent values: [%f %f %f][%f %f %f][%f %f %f]\n",
1426 soft_iron[0], soft_iron[1], soft_iron[2],
1427 soft_iron[3], soft_iron[4], soft_iron[5],
1428 soft_iron[6], soft_iron[7], soft_iron[8]);
1429 ROS_INFO(
"Returned values: [%f %f %f][%f %f %f][%f %f %f]\n",
1430 soft_iron_readback[0], soft_iron_readback[1], soft_iron_readback[2],
1431 soft_iron_readback[3], soft_iron_readback[4], soft_iron_readback[5],
1432 soft_iron_readback[6], soft_iron_readback[7], soft_iron_readback[8]);
1439 bool Microstrain::get_soft_iron_matrix(std_srvs::Trigger::Request &req,
1440 std_srvs::Trigger::Response &res)
1444 ROS_INFO(
"Device does not support this feature");
1445 res.success =
false;
1449 memset(soft_iron, 0, 9*
sizeof(
float));
1450 memset(soft_iron_readback, 0, 9*
sizeof(
float));
1452 ROS_INFO(
"Getting the soft iron matrix values\n");
1455 while (mip_3dm_cmd_soft_iron(&device_interface_,
1456 MIP_FUNCTION_SELECTOR_READ, soft_iron_readback) != MIP_INTERFACE_OK)
1458 if (clock() - start > 5000)
1460 ROS_INFO(
"mip_3dm_cmd_soft_iron function timed out.");
1465 ROS_INFO(
"Soft iron matrix values: [%f %f %f][%f %f %f][%f %f %f]\n",
1466 soft_iron_readback[0], soft_iron_readback[1], soft_iron_readback[2],
1467 soft_iron_readback[3], soft_iron_readback[4], soft_iron_readback[5],
1468 soft_iron_readback[6], soft_iron_readback[7], soft_iron_readback[8]);
1474 bool Microstrain::set_complementary_filter(microstrain_mips::SetComplementaryFilter::Request &req,
1475 microstrain_mips::SetComplementaryFilter::Response &res)
1477 ROS_INFO(
"Setting the complementary filter values\n");
1479 comp_filter_command.north_compensation_enable = req.north_comp_enable;
1480 comp_filter_command.up_compensation_enable = req.up_comp_enable;
1481 comp_filter_command.north_compensation_time_constant = req.north_comp_time_const;
1482 comp_filter_command.up_compensation_time_constant = req.up_comp_time_const;
1485 while (mip_3dm_cmd_complementary_filter_settings(&device_interface_,
1486 MIP_FUNCTION_SELECTOR_WRITE, &comp_filter_command) != MIP_INTERFACE_OK)
1488 if (clock() - start > 5000)
1490 ROS_INFO(
"mip_3dm_cmd_complementary_filter_settings function timed out.");
1497 while (mip_3dm_cmd_complementary_filter_settings(&device_interface_,
1498 MIP_FUNCTION_SELECTOR_READ, &comp_filter_readback) != MIP_INTERFACE_OK)
1500 if (clock() - start > 5000)
1502 ROS_INFO(
"mip_3dm_cmd_complementary_filter_settings function timed out.");
1507 if ((comp_filter_command.north_compensation_enable == comp_filter_readback.north_compensation_enable) &&
1508 (comp_filter_command.up_compensation_enable == comp_filter_readback.up_compensation_enable) &&
1509 (abs(comp_filter_command.north_compensation_time_constant -
1510 comp_filter_readback.north_compensation_time_constant) < 0.001) &&
1511 (abs(comp_filter_command.up_compensation_time_constant -
1512 comp_filter_readback.up_compensation_time_constant) < 0.001))
1514 ROS_INFO(
"Complementary filter values successfully set.\n");
1515 ROS_INFO(
"Sent values: Up Enable: %d North Enable: %d Up Time Constant: %f North Time Constant: %f \n",
1516 comp_filter_command.up_compensation_enable, comp_filter_command.north_compensation_enable,
1517 comp_filter_command.up_compensation_time_constant, comp_filter_command.north_compensation_time_constant);
1518 ROS_INFO(
"Returned values: Up Enable: %d North Enable: %d Up Time Constant: %f North Time Constant: %f \n",
1519 comp_filter_readback.up_compensation_enable, comp_filter_readback.north_compensation_enable,
1520 comp_filter_readback.up_compensation_time_constant, comp_filter_readback.north_compensation_time_constant);
1524 ROS_INFO(
"ERROR: Failed to set complementary filter values!!!\n");
1525 ROS_INFO(
"Sent values: Up Enable: %d North Enable: %d Up Time Constant: %f North Time Constant: %f \n",
1526 comp_filter_command.up_compensation_enable, comp_filter_command.north_compensation_enable,
1527 comp_filter_command.up_compensation_time_constant, comp_filter_command.north_compensation_time_constant);
1528 ROS_INFO(
"Returned values: Up Enable: %d North Enable: %d Up Time Constant: %f North Time Constant: %f \n",
1529 comp_filter_readback.up_compensation_enable, comp_filter_readback.north_compensation_enable,
1530 comp_filter_readback.up_compensation_time_constant, comp_filter_readback.north_compensation_time_constant);
1537 bool Microstrain::get_complementary_filter(std_srvs::Trigger::Request &req,
1538 std_srvs::Trigger::Response &res)
1542 while (mip_3dm_cmd_complementary_filter_settings(&device_interface_,
1543 MIP_FUNCTION_SELECTOR_READ, &comp_filter_readback) != MIP_INTERFACE_OK)
1545 if (clock() - start > 5000)
1547 ROS_INFO(
"mip_3dm_cmd_complementary_filter_settings function timed out.");
1551 ROS_INFO(
"Returned values: Up Enable: %d North Enable: %d Up Time Constant: %f North Time Constant: %f \n",
1552 comp_filter_readback.up_compensation_enable, comp_filter_readback.north_compensation_enable,
1553 comp_filter_readback.up_compensation_time_constant, comp_filter_readback.north_compensation_time_constant);
1559 bool Microstrain::set_filter_euler(microstrain_mips::SetFilterEuler::Request &req,
1560 microstrain_mips::SetFilterEuler::Response &res)
1562 memset(angles, 0, 3*
sizeof(
float));
1563 ROS_INFO(
"Resetting the Filter\n");
1566 while (mip_filter_reset_filter(&device_interface_) != MIP_INTERFACE_OK)
1568 if (clock() - start > 5000)
1570 ROS_INFO(
"mip_filter_reset_filter function timed out.");
1575 ROS_INFO(
"Initializing the Filter with Euler angles\n");
1577 angles[0] = req.angle.x;
1578 angles[1] = req.angle.y;
1579 angles[2] = req.angle.z;
1582 while (mip_filter_set_init_attitude(&device_interface_, angles) != MIP_INTERFACE_OK)
1584 if (clock() - start > 5000)
1586 ROS_INFO(
"mip_filter_set_init_attitude function timed out.");
1596 bool Microstrain::set_filter_heading(microstrain_mips::SetFilterHeading::Request &req,
1597 microstrain_mips::SetFilterHeading::Response &res)
1599 ROS_INFO(
"Resetting the Filter\n");
1602 while (mip_filter_reset_filter(&device_interface_) != MIP_INTERFACE_OK)
1604 if (clock() - start > 5000)
1606 ROS_INFO(
"mip_filter_reset_filter function timed out.");
1611 ROS_INFO(
"Initializing the Filter with a heading angle\n");
1613 heading_angle = req.angle;
1615 while (mip_filter_set_init_heading(&device_interface_, heading_angle) != MIP_INTERFACE_OK)
1617 if (clock() - start > 5000)
1619 ROS_INFO(
"mip_filter_set_init_heading function timed out.");
1630 bool Microstrain::set_sensor_vehicle_frame_trans(microstrain_mips::SetSensorVehicleFrameTrans::Request &req,
1631 microstrain_mips::SetSensorVehicleFrameTrans::Response &res)
1635 ROS_INFO(
"Device does not support this feature");
1636 res.success =
false;
1640 memset(angles, 0, 3*
sizeof(
float));
1641 memset(readback_angles, 0, 3*
sizeof(
float));
1643 ROS_INFO(
"Setting the sensor to vehicle frame transformation\n");
1645 angles[0] = req.angle.x;
1646 angles[1] = req.angle.y;
1647 angles[2] = req.angle.z;
1650 while (mip_filter_sensor2vehicle_tranformation(&device_interface_,
1651 MIP_FUNCTION_SELECTOR_WRITE, angles) != MIP_INTERFACE_OK)
1653 if (clock() - start > 5000)
1655 ROS_INFO(
"mip_filter_sensor2vehicle_tranformation function timed out.");
1662 while (mip_filter_sensor2vehicle_tranformation(&device_interface_,
1663 MIP_FUNCTION_SELECTOR_READ, readback_angles) != MIP_INTERFACE_OK)
1665 if (clock() - start > 5000)
1667 ROS_INFO(
"mip_filter_sensor2vehicle_tranformation function timed out.");
1672 if ((abs(readback_angles[0]-angles[0]) < 0.001) &&
1673 (abs(readback_angles[1]-angles[1]) < 0.001) &&
1674 (abs(readback_angles[2]-angles[2]) < 0.001))
1676 ROS_INFO(
"Transformation successfully set.\n");
1677 ROS_INFO(
"New angles: %f roll %f pitch %f yaw\n",
1678 readback_angles[0], readback_angles[1], readback_angles[2]);
1682 ROS_INFO(
"ERROR: Failed to set transformation!!!\n");
1683 ROS_INFO(
"Sent angles: %f roll %f pitch %f yaw\n",
1684 angles[0], angles[1], angles[2]);
1685 ROS_INFO(
"Returned angles: %f roll %f pitch %f yaw\n",
1686 readback_angles[0], readback_angles[1], readback_angles[2]);
1693 bool Microstrain::get_sensor_vehicle_frame_trans(std_srvs::Trigger::Request &req,
1694 std_srvs::Trigger::Response &res)
1698 ROS_INFO(
"Device does not support this feature");
1699 res.success =
false;
1703 memset(readback_angles, 0, 3*
sizeof(
float));
1706 while (mip_filter_sensor2vehicle_tranformation(&device_interface_,
1707 MIP_FUNCTION_SELECTOR_READ, readback_angles) != MIP_INTERFACE_OK)
1709 if (clock() - start > 5000)
1711 ROS_INFO(
"mip_filter_sensor2vehicle_tranformation function timed out.");
1716 ROS_INFO(
"Sensor Vehicle Frame Transformation Angles: %f roll %f pitch %f yaw\n",
1717 readback_angles[0], readback_angles[1], readback_angles[2]);
1724 bool Microstrain::set_reference_position(microstrain_mips::SetReferencePosition::Request &req,
1725 microstrain_mips::SetReferencePosition::Response &res)
1727 ROS_INFO(
"Setting reference Position\n");
1729 memset(reference_position_command, 0, 3*
sizeof(
double));
1730 memset(reference_position_readback, 0, 3*
sizeof(
double));
1731 reference_position_enable_command = 1;
1732 reference_position_enable_readback = 1;
1734 reference_position_command[0] = req.position.x;
1735 reference_position_command[1] = req.position.y;
1736 reference_position_command[2] = req.position.z;
1739 while (mip_filter_reference_position(&device_interface_, MIP_FUNCTION_SELECTOR_WRITE,
1740 &reference_position_enable_command, reference_position_command) != MIP_INTERFACE_OK)
1742 if (clock() - start > 5000)
1744 ROS_INFO(
"mip_filter_reference_position function timed out.");
1751 while (mip_filter_reference_position(&device_interface_, MIP_FUNCTION_SELECTOR_READ,
1752 &reference_position_enable_readback, reference_position_readback) != MIP_INTERFACE_OK)
1754 if (clock() - start > 5000)
1756 ROS_INFO(
"mip_filter_reference_position function timed out.");
1761 if ((reference_position_enable_command == reference_position_enable_readback) &&
1762 (abs(reference_position_command[0] - reference_position_readback[0]) < 0.001) &&
1763 (abs(reference_position_command[1] - reference_position_readback[1]) < 0.001) &&
1764 (abs(reference_position_command[2] - reference_position_readback[2]) < 0.001))
1766 ROS_INFO(
"Reference position successfully set\n");
1770 ROS_ERROR(
"Failed to set the reference position!!!\n");
1778 bool Microstrain::get_reference_position(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
1780 ROS_INFO(
"Getting reference position");
1781 memset(reference_position_readback, 0, 3*
sizeof(
double));
1783 while (mip_filter_reference_position(&device_interface_, MIP_FUNCTION_SELECTOR_READ,
1784 &reference_position_enable_readback, reference_position_readback) != MIP_INTERFACE_OK)
1786 if (clock() - start > 5000)
1788 ROS_INFO(
"mip_filter_reference_position function timed out.");
1792 ROS_INFO(
"Reference position: Lat %f , Long %f, Alt %f", reference_position_readback[0],
1793 reference_position_readback[1], reference_position_readback[2]);
1800 bool Microstrain::set_coning_sculling_comp(microstrain_mips::SetConingScullingComp::Request &req,
1801 microstrain_mips::SetConingScullingComp::Response &res)
1803 if (req.enable == 0)
1805 ROS_INFO(
"Disabling Coning and Sculling compensation\n");
1806 enable_flag = MIP_3DM_CONING_AND_SCULLING_DISABLE;
1808 while (mip_3dm_cmd_coning_sculling_compensation(&device_interface_,
1809 MIP_FUNCTION_SELECTOR_WRITE, &enable_flag) != MIP_INTERFACE_OK)
1811 if (clock() - start > 5000)
1813 ROS_INFO(
"mip_3dm_cmd_coning_sculling_compensation function timed out.");
1818 ROS_INFO(
"Reading Coning and Sculling compensation enabled state:\n");
1820 while (mip_3dm_cmd_coning_sculling_compensation(&device_interface_,
1821 MIP_FUNCTION_SELECTOR_READ, &enable_flag) != MIP_INTERFACE_OK)
1823 if (clock() - start > 5000)
1825 ROS_INFO(
"mip_3dm_cmd_coning_sculling_compensation function timed out.");
1829 ROS_INFO(
"%s\n\n", enable_flag == MIP_3DM_CONING_AND_SCULLING_DISABLE ?
"DISABLED" :
"ENABLED");
1831 else if (req.enable == 1)
1833 ROS_INFO(
"Enabling Coning and Sculling compensation\n");
1834 enable_flag = MIP_3DM_CONING_AND_SCULLING_ENABLE;
1836 while (mip_3dm_cmd_coning_sculling_compensation(&device_interface_,
1837 MIP_FUNCTION_SELECTOR_WRITE, &enable_flag) != MIP_INTERFACE_OK)
1839 if (clock() - start > 5000)
1841 ROS_INFO(
"mip_3dm_cmd_coning_sculling_compensation function timed out.");
1847 ROS_INFO(
"Reading Coning and Sculling compensation enabled state:\n");
1849 while (mip_3dm_cmd_coning_sculling_compensation(&device_interface_,
1850 MIP_FUNCTION_SELECTOR_READ, &enable_flag) != MIP_INTERFACE_OK)
1852 if (clock() - start > 5000)
1854 ROS_INFO(
"mip_3dm_cmd_coning_sculling_compensation function timed out.");
1858 ROS_INFO(
"%s\n\n", enable_flag == MIP_3DM_CONING_AND_SCULLING_DISABLE ?
"DISABLED" :
"ENABLED");
1862 ROS_INFO(
"Error: Input must be either 0 (disable) or 1 (enable).");
1865 res.success =
false;
1870 bool Microstrain::get_coning_sculling_comp(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
1873 while (mip_3dm_cmd_coning_sculling_compensation(&device_interface_,
1874 MIP_FUNCTION_SELECTOR_READ, &enable_flag) != MIP_INTERFACE_OK)
1876 if (clock() - start > 5000)
1878 ROS_INFO(
"mip_3dm_cmd_coning_sculling_compensation function timed out.");
1882 ROS_INFO(
"Coning and Sculling compensation is: %s\n\n",
1883 enable_flag == MIP_3DM_CONING_AND_SCULLING_DISABLE ?
"DISABLED" :
"ENABLED");
1889 bool Microstrain::set_estimation_control_flags(microstrain_mips::SetEstimationControlFlags::Request &req,
1890 microstrain_mips::SetEstimationControlFlags::Response &res)
1892 estimation_control = req.flag;
1894 while (mip_filter_estimation_control(&device_interface_,
1895 MIP_FUNCTION_SELECTOR_WRITE, &estimation_control) != MIP_INTERFACE_OK)
1897 if (clock() - start > 5000)
1899 ROS_INFO(
"mip_filter_estimation_control function timed out.");
1905 while (mip_filter_estimation_control(&device_interface_,
1906 MIP_FUNCTION_SELECTOR_READ, &estimation_control_readback) != MIP_INTERFACE_OK)
1908 if (clock() - start > 5000)
1910 ROS_INFO(
"mip_filter_estimation_control function timed out.");
1914 ROS_INFO(
"Estimation control set to: %d", estimation_control_readback);
1922 bool Microstrain::get_estimation_control_flags(std_srvs::Trigger::Request &req,
1923 std_srvs::Trigger::Response &res)
1926 while (mip_filter_estimation_control(&device_interface_,
1927 MIP_FUNCTION_SELECTOR_READ, &estimation_control_readback) != MIP_INTERFACE_OK)
1929 if (clock() - start > 5000)
1931 ROS_INFO(
"mip_filter_estimation_control function timed out.");
1935 ROS_INFO(
"Estimation control set to: %d", estimation_control_readback);
1943 bool Microstrain::get_basic_status(std_srvs::Trigger::Request &req,
1944 std_srvs::Trigger::Response &res)
1949 u8 response_buffer[
sizeof(gx4_25_basic_status_field)];
1952 GX4_25_BASIC_STATUS_SEL, response_buffer) != MIP_INTERFACE_OK)
1954 if (clock() - start > 5000)
1956 ROS_INFO(
"mip_3dm_cmd_hw_specific_device_status function timed out.");
1961 ROS_INFO(
"Model Number: \t\t\t\t\t%04u\n", basic_field.device_model);
1962 ROS_INFO(
"Status Selector: \t\t\t\t%d\n", basic_field.status_selector);
1964 ROS_INFO(
"Status Flags: \t\t\t\t\t%lu\n", basic_field.status_flags);
1965 ROS_INFO(
"System state: \t\t\t\t\t%04u\n", basic_field.system_state);
1966 ROS_INFO(
"System Microsecond Timer Count: \t\t%lu ms\n\n", basic_field.system_timer_ms);
1970 ROS_INFO(
"Command not supported on this model");
1978 bool Microstrain::get_diagnostic_report(std_srvs::Trigger::Request &req,
1979 std_srvs::Trigger::Response &res)
1984 u8 response_buffer[
sizeof(gx4_25_diagnostic_device_status_field)];
1987 GX4_25_DIAGNOSTICS_STATUS_SEL, response_buffer) != MIP_INTERFACE_OK)
1989 if (clock() - start > 5000)
1991 ROS_INFO(
"mip_3dm_cmd_hw_specific_device_status function timed out.");
1996 ROS_INFO(
"Model Number: \t\t\t\t\t%04u\n", diagnostic_field.device_model);
1997 ROS_INFO(
"Status Selector: \t\t\t\t%d\n", diagnostic_field.status_selector);
1999 ROS_INFO(
"Status Flags: \t\t\t\t\t%lu\n", diagnostic_field.status_flags);
2000 ROS_INFO(
"System Millisecond Timer Count: \t\t%lu ms\n", diagnostic_field.system_timer_ms);
2001 ROS_INFO(
"IMU Streaming Enabled: \t\t\t\t%s\n", diagnostic_field.imu_stream_enabled == 1 ?
"TRUE" :
"FALSE");
2002 ROS_INFO(
"FILTER Streaming Enabled: \t\t\t%s\n", diagnostic_field.filter_stream_enabled == 1 ?
"TRUE" :
"FALSE");
2003 ROS_INFO(
"Number of Dropped IMU Packets: \t\t\t%lu packets\n", diagnostic_field.imu_dropped_packets);
2004 ROS_INFO(
"Number of Dropped FILTER Packets: \t\t%lu packets\n", diagnostic_field.filter_dropped_packets);
2005 ROS_INFO(
"Communications Port Bytes Written: \t\t%lu Bytes\n", diagnostic_field.com1_port_bytes_written);
2006 ROS_INFO(
"Communications Port Bytes Read: \t\t%lu Bytes\n", diagnostic_field.com1_port_bytes_read);
2007 ROS_INFO(
"Communications Port Write Overruns: \t\t%lu Bytes\n", diagnostic_field.com1_port_write_overruns);
2008 ROS_INFO(
"Communications Port Read Overruns: \t\t%lu Bytes\n", diagnostic_field.com1_port_read_overruns);
2009 ROS_INFO(
"IMU Parser Errors: \t\t\t\t%lu Errors\n", diagnostic_field.imu_parser_errors);
2010 ROS_INFO(
"IMU Message Count: \t\t\t\t%lu Messages\n", diagnostic_field.imu_message_count);
2011 ROS_INFO(
"IMU Last Message Received: \t\t\t%lu ms\n", diagnostic_field.imu_last_message_ms);
2016 ROS_INFO(
"Command not supported on this model");
2024 bool Microstrain::set_zero_angle_update_threshold(microstrain_mips::SetZeroAngleUpdateThreshold::Request &req,
2025 microstrain_mips::SetZeroAngleUpdateThreshold::Response &res)
2027 ROS_INFO(
"Setting Zero Angular-Rate-Update threshold\n");
2029 zero_update_control.threshold = req.threshold;
2030 zero_update_control.enable = req.enable;
2034 while (mip_filter_zero_angular_rate_update_control(&device_interface_,
2035 MIP_FUNCTION_SELECTOR_WRITE, &zero_update_control) != MIP_INTERFACE_OK)
2037 if (clock() - start > 5000)
2039 ROS_INFO(
"mip_filter_zero_angular_rate_update_control function timed out.");
2046 while (mip_filter_zero_angular_rate_update_control(&device_interface_,
2047 MIP_FUNCTION_SELECTOR_READ, &zero_update_readback) != MIP_INTERFACE_OK)
2049 if (clock() - start > 5000)
2051 ROS_INFO(
"mip_filter_zero_angular_rate_update_control function timed out.");
2056 if (zero_update_control.enable != zero_update_readback.enable ||
2057 zero_update_control.threshold != zero_update_readback.threshold)
2058 ROS_INFO(
"ERROR configuring Zero Angular Rate Update.\n");
2060 ROS_INFO(
"Enable value set to: %d, Threshold is: %f rad/s",
2061 zero_update_readback.enable, zero_update_readback.threshold);
2069 bool Microstrain::get_zero_angle_update_threshold(std_srvs::Trigger::Request &req,
2070 std_srvs::Trigger::Response &res)
2072 ROS_INFO(
"Setting Zero Angular-Rate-Update threshold\n");
2076 while (mip_filter_zero_angular_rate_update_control(&device_interface_,
2077 MIP_FUNCTION_SELECTOR_READ, &zero_update_readback) != MIP_INTERFACE_OK)
2079 if (clock() - start > 5000)
2081 ROS_INFO(
"mip_filter_zero_angular_rate_update_control function timed out.");
2085 ROS_INFO(
"Enable value set to: %d, Threshold is: %f rad/s",
2086 zero_update_readback.enable, zero_update_readback.threshold);
2093 bool Microstrain::set_tare_orientation(microstrain_mips::SetTareOrientation::Request &req,
2094 microstrain_mips::SetTareOrientation::Response &res)
2096 if (req.axis < 1 || req.axis > 7)
2098 ROS_INFO(
"Value must be between 1-7. 1 = Roll, 2 = Pitch, 3 = Roll/Pitch, 4 = Yaw, 5 = Roll/Yaw, 6 = Pitch/Yaw, 7 = Roll/Pitch/Yaw");
2099 res.success =
false;
2102 angles[0] = angles[1] = angles[2] = 0;
2106 while (mip_filter_set_init_attitude(&device_interface_, angles) != MIP_INTERFACE_OK)
2108 if (clock() - start > 5000)
2110 ROS_INFO(
"mip_filter_set_init_attitude function timed out.");
2118 if (mip_filter_tare_orientation(&device_interface_,
2119 MIP_FUNCTION_SELECTOR_WRITE, i) != MIP_INTERFACE_OK)
2123 if (i & FILTER_TARE_ROLL_AXIS)
2128 if (i & FILTER_TARE_PITCH_AXIS)
2133 if (i & FILTER_TARE_YAW_AXIS)
2140 ROS_INFO(
"Tare Configuration = %d\n", i);
2144 if (i & FILTER_TARE_ROLL_AXIS)
2149 if (i & FILTER_TARE_PITCH_AXIS)
2154 if (i & FILTER_TARE_YAW_AXIS)
2167 bool Microstrain::set_accel_noise(microstrain_mips::SetAccelNoise::Request &req,
2168 microstrain_mips::SetAccelNoise::Response &res)
2170 ROS_INFO(
"Setting the accel noise values\n");
2172 noise[0] = req.noise.x;
2173 noise[1] = req.noise.y;
2174 noise[2] = req.noise.z;
2177 while (mip_filter_accel_noise(&device_interface_,
2178 MIP_FUNCTION_SELECTOR_WRITE, noise) != MIP_INTERFACE_OK)
2180 if (clock() - start > 5000)
2182 ROS_INFO(
"mip_filter_accel_noise function timed out.");
2189 while (mip_filter_accel_noise(&device_interface_,
2190 MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK)
2192 if (clock() - start > 5000)
2194 ROS_INFO(
"mip_filter_accel_noise function timed out.");
2199 if ((abs(readback_noise[0]-noise[0]) < 0.001) &&
2200 (abs(readback_noise[1]-noise[1]) < 0.001) &&
2201 (abs(readback_noise[2]-noise[2]) < 0.001))
2203 ROS_INFO(
"Accel noise values successfully set.\n");
2207 ROS_INFO(
"ERROR: Failed to set accel noise values!!!\n");
2208 ROS_INFO(
"Sent values: %f X %f Y %f Z\n",
2209 noise[0], noise[1], noise[2]);
2210 ROS_INFO(
"Returned values: %f X %f Y %f Z\n",
2211 readback_noise[0], readback_noise[1], readback_noise[2]);
2219 bool Microstrain::get_accel_noise(std_srvs::Trigger::Request &req,
2220 std_srvs::Trigger::Response &res)
2223 while (mip_filter_accel_noise(&device_interface_,
2224 MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK)
2226 if (clock() - start > 5000)
2228 ROS_INFO(
"mip_filter_accel_noise function timed out.");
2232 ROS_INFO(
"Accel noise values: %f X %f Y %f Z\n",
2233 readback_noise[0], readback_noise[1], readback_noise[2]);
2240 bool Microstrain::set_gyro_noise(microstrain_mips::SetGyroNoise::Request &req,
2241 microstrain_mips::SetGyroNoise::Response &res)
2243 ROS_INFO(
"Setting the gyro noise values\n");
2245 noise[0] = req.noise.x;
2246 noise[1] = req.noise.y;
2247 noise[2] = req.noise.z;
2250 while (mip_filter_gyro_noise(&device_interface_,
2251 MIP_FUNCTION_SELECTOR_WRITE, noise) != MIP_INTERFACE_OK)
2253 if (clock() - start > 5000)
2255 ROS_INFO(
"mip_filter_gyro_noise function timed out.");
2262 while (mip_filter_gyro_noise(&device_interface_,
2263 MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK)
2265 if (clock() - start > 5000)
2267 ROS_INFO(
"mip_filter_gyro_noise function timed out.");
2272 if ((abs(readback_noise[0]-noise[0]) < 0.001) &&
2273 (abs(readback_noise[1]-noise[1]) < 0.001) &&
2274 (abs(readback_noise[2]-noise[2]) < 0.001))
2276 ROS_INFO(
"Gyro noise values successfully set.\n");
2280 ROS_INFO(
"ERROR: Failed to set gyro noise values!!!\n");
2281 ROS_INFO(
"Sent values: %f X %f Y %f Z\n",
2282 noise[0], noise[1], noise[2]);
2283 ROS_INFO(
"Returned values: %f X %f Y %f Z\n",
2284 readback_noise[0], readback_noise[1], readback_noise[2]);
2292 bool Microstrain::get_gyro_noise(std_srvs::Trigger::Request &req,
2293 std_srvs::Trigger::Response &res)
2296 while (mip_filter_gyro_noise(&device_interface_,
2297 MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK)
2299 if (clock() - start > 5000)
2301 ROS_INFO(
"mip_filter_gyro_noise function timed out.");
2305 ROS_INFO(
"Gyro noise values: %f X %f Y %f Z\n",
2306 readback_noise[0], readback_noise[1], readback_noise[2]);
2313 bool Microstrain::set_mag_noise(microstrain_mips::SetMagNoise::Request &req,
2314 microstrain_mips::SetMagNoise::Response &res)
2318 ROS_INFO(
"Device does not support this feature");
2319 res.success =
false;
2323 ROS_INFO(
"Setting the mag noise values\n");
2325 noise[0] = req.noise.x;
2326 noise[1] = req.noise.y;
2327 noise[2] = req.noise.z;
2330 while (mip_filter_mag_noise(&device_interface_,
2331 MIP_FUNCTION_SELECTOR_WRITE, noise) != MIP_INTERFACE_OK)
2333 if (clock() - start > 5000)
2335 ROS_INFO(
"mip_filter_mag_noise function timed out.");
2342 while (mip_filter_mag_noise(&device_interface_,
2343 MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK)
2345 if (clock() - start > 5000)
2347 ROS_INFO(
"mip_filter_mag_noise function timed out.");
2352 if ((abs(readback_noise[0] - noise[0]) < 0.001) &&
2353 (abs(readback_noise[1] - noise[1]) < 0.001) &&
2354 (abs(readback_noise[2] - noise[2]) < 0.001))
2356 ROS_INFO(
"Mag noise values successfully set.\n");
2360 ROS_INFO(
"ERROR: Failed to set mag noise values!!!\n");
2361 ROS_INFO(
"Sent values: %f X %f Y %f Z\n",
2362 noise[0], noise[1], noise[2]);
2363 ROS_INFO(
"Returned values: %f X %f Y %f Z\n",
2364 readback_noise[0], readback_noise[1], readback_noise[2]);
2372 bool Microstrain::get_mag_noise(std_srvs::Trigger::Request &req,
2373 std_srvs::Trigger::Response &res)
2377 ROS_INFO(
"Device does not support this feature");
2378 res.success =
false;
2383 while (mip_filter_mag_noise(&device_interface_,
2384 MIP_FUNCTION_SELECTOR_READ, readback_noise) != MIP_INTERFACE_OK)
2386 if (clock() - start > 5000)
2388 ROS_INFO(
"mip_filter_mag_noise function timed out.");
2392 ROS_INFO(
"Returned values: %f X %f Y %f Z\n",
2393 readback_noise[0], readback_noise[1], readback_noise[2]);
2401 bool Microstrain::set_gyro_bias_model(microstrain_mips::SetGyroBiasModel::Request &req,
2402 microstrain_mips::SetGyroBiasModel::Response &res)
2404 ROS_INFO(
"Setting the gyro bias model values\n");
2406 noise[0] = req.noise_vector.x;
2407 noise[1] = req.noise_vector.y;
2408 noise[2] = req.noise_vector.z;
2410 beta[0] = req.beta_vector.x;
2411 beta[1] = req.beta_vector.x;
2412 beta[2] = req.beta_vector.x;
2415 while (mip_filter_gyro_bias_model(&device_interface_,
2416 MIP_FUNCTION_SELECTOR_WRITE, beta, noise) != MIP_INTERFACE_OK)
2418 if (clock() - start > 5000)
2420 ROS_INFO(
"mip_filter_gyro_bias_model function timed out.");
2427 while (mip_filter_gyro_bias_model(&device_interface_,
2428 MIP_FUNCTION_SELECTOR_READ, readback_beta, readback_noise) != MIP_INTERFACE_OK)
2430 if (clock() - start > 5000)
2432 ROS_INFO(
"mip_filter_gyro_bias_model function timed out.");
2437 if ((abs(readback_noise[0]-noise[0]) < 0.001) &&
2438 (abs(readback_noise[1]-noise[1]) < 0.001) &&
2439 (abs(readback_noise[2]-noise[2]) < 0.001) &&
2440 (abs(readback_beta[0]-beta[0]) < 0.001) &&
2441 (abs(readback_beta[1]-beta[1]) < 0.001) &&
2442 (abs(readback_beta[2]-beta[2]) < 0.001))
2444 ROS_INFO(
"Gyro bias model values successfully set.\n");
2448 ROS_INFO(
"ERROR: Failed to set gyro bias model values!!!\n");
2449 ROS_INFO(
"Sent values: Beta: %f X %f Y %f Z, White Noise: %f X %f Y %f Z\n",
2450 beta[0], beta[1], beta[2], noise[0], noise[1], noise[2]);
2451 ROS_INFO(
"Returned values: Beta: %f X %f Y %f Z, White Noise: %f X %f Y %f Z\n",
2452 readback_beta[0], readback_beta[1], readback_beta[2],
2453 readback_noise[0], readback_noise[1], readback_noise[2]);
2461 bool Microstrain::get_gyro_bias_model(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
2464 while (mip_filter_gyro_bias_model(&device_interface_,
2465 MIP_FUNCTION_SELECTOR_READ, readback_beta, readback_noise) != MIP_INTERFACE_OK)
2467 if (clock() - start > 5000)
2469 ROS_INFO(
"mip_filter_gyro_bias_model function timed out.");
2474 ROS_INFO(
"Gyro bias model values: Beta: %f X %f Y %f Z, White Noise: %f X %f Y %f Z\n",
2475 readback_beta[0], readback_beta[1], readback_beta[2], readback_noise[0], readback_noise[1], readback_noise[2]);
2481 bool Microstrain::get_accel_bias_model(std_srvs::Trigger::Request &req,
2482 std_srvs::Trigger::Response &res)
2484 if (GX5_15 ==
true || GX5_25 ==
true)
2486 ROS_INFO(
"Device does not support this feature");
2487 res.success =
false;
2491 memset(readback_noise, 0, 3*
sizeof(
float));
2492 memset(readback_beta, 0, 3*
sizeof(
float));
2495 while (mip_filter_accel_bias_model(&device_interface_,
2496 MIP_FUNCTION_SELECTOR_READ, readback_beta, readback_noise) != MIP_INTERFACE_OK)
2498 if (clock() - start > 5000)
2500 ROS_INFO(
"mip_filter_accel_bias_model function timed out.");
2505 ROS_INFO(
"Returned values: Beta: %f X %f Y %f Z, White Noise: %f X %f Y %f Z\n",
2506 readback_beta[0], readback_beta[1], readback_beta[2],
2507 readback_noise[0], readback_noise[1], readback_noise[2]);
2514 bool Microstrain::set_accel_bias_model(microstrain_mips::SetAccelBiasModel::Request &req,
2515 microstrain_mips::SetAccelBiasModel::Response &res)
2517 if (GX5_15 ==
true || GX5_25 ==
true)
2519 ROS_INFO(
"Device does not support this feature");
2520 res.success =
false;
2524 memset(noise, 0, 3*
sizeof(
float));
2525 memset(beta, 0, 3*
sizeof(
float));
2526 memset(readback_noise, 0, 3*
sizeof(
float));
2527 memset(readback_beta, 0, 3*
sizeof(
float));
2528 ROS_INFO(
"Setting the accel bias model values\n");
2530 noise[0] = req.noise_vector.x;
2531 noise[1] = req.noise_vector.y;
2532 noise[2] = req.noise_vector.z;
2534 beta[0] = req.beta_vector.x;
2535 beta[1] = req.beta_vector.x;
2536 beta[2] = req.beta_vector.x;
2539 while (mip_filter_accel_bias_model(&device_interface_,
2540 MIP_FUNCTION_SELECTOR_WRITE, beta, noise) != MIP_INTERFACE_OK)
2542 if (clock() - start > 5000)
2544 ROS_INFO(
"mip_filter_accel_bias_model function timed out.");
2551 while (mip_filter_accel_bias_model(&device_interface_, MIP_FUNCTION_SELECTOR_READ,
2552 readback_beta, readback_noise) != MIP_INTERFACE_OK)
2554 if (clock() - start > 5000)
2556 ROS_INFO(
"mip_filter_accel_bias_model function timed out.");
2561 if ((abs(readback_noise[0]-noise[0]) < 0.001) &&
2562 (abs(readback_noise[1]-noise[1]) < 0.001) &&
2563 (abs(readback_noise[2]-noise[2]) < 0.001) &&
2564 (abs(readback_beta[0]-beta[0]) < 0.001) &&
2565 (abs(readback_beta[1]-beta[1]) < 0.001) &&
2566 (abs(readback_beta[2]-beta[2]) < 0.001))
2568 ROS_INFO(
"Accel bias model values successfully set.\n");
2572 ROS_INFO(
"ERROR: Failed to set accel bias model values!!!\n");
2573 ROS_INFO(
"Sent values: Beta: %f X %f Y %f Z, White Noise: %f X %f Y %f Z\n",
2574 beta[0], beta[1], beta[2], noise[0], noise[1], noise[2]);
2575 ROS_INFO(
"Returned values: Beta: %f X %f Y %f Z, White Noise: %f X %f Y %f Z\n",
2576 readback_beta[0], readback_beta[1], readback_beta[2],
2577 readback_noise[0], readback_noise[1], readback_noise[2]);
2585 bool Microstrain::set_accel_adaptive_vals(microstrain_mips::SetAccelAdaptiveVals::Request &req,
2586 microstrain_mips::SetAccelAdaptiveVals::Response &res )
2588 ROS_INFO(
"Setting the accel magnitude error adaptive measurement values\n");
2590 accel_magnitude_error_command.enable = req.enable;
2591 accel_magnitude_error_command.low_pass_cutoff = req.low_pass_cutoff;
2592 accel_magnitude_error_command.min_1sigma = req.min_1sigma;
2593 accel_magnitude_error_command.low_limit = req.low_limit;
2594 accel_magnitude_error_command.high_limit = req.high_limit;
2595 accel_magnitude_error_command.low_limit_1sigma = req.low_limit_1sigma;
2596 accel_magnitude_error_command.high_limit_1sigma = req.high_limit_1sigma;
2599 while (mip_filter_accel_magnitude_error_adaptive_measurement(&device_interface_,
2600 MIP_FUNCTION_SELECTOR_WRITE, &accel_magnitude_error_command) != MIP_INTERFACE_OK)
2602 if (clock() - start > 5000)
2604 ROS_INFO(
"mip_filter_accel_magnitude_error_adaptive_measurement function timed out.");
2611 while (mip_filter_accel_magnitude_error_adaptive_measurement(&device_interface_,
2612 MIP_FUNCTION_SELECTOR_READ, &accel_magnitude_error_readback) != MIP_INTERFACE_OK)
2614 if (clock() - start > 5000)
2616 ROS_INFO(
"mip_filter_accel_magnitude_error_adaptive_measurement function timed out.");
2621 if ((accel_magnitude_error_command.enable == accel_magnitude_error_readback.enable) &&
2622 (abs(accel_magnitude_error_command.low_pass_cutoff - accel_magnitude_error_readback.low_pass_cutoff) < 0.001) &&
2623 (abs(accel_magnitude_error_command.min_1sigma - accel_magnitude_error_readback.min_1sigma) < 0.001) &&
2624 (abs(accel_magnitude_error_command.low_limit - accel_magnitude_error_readback.low_limit) < 0.001) &&
2625 (abs(accel_magnitude_error_command.high_limit - accel_magnitude_error_readback.high_limit) < 0.001) &&
2626 (abs(accel_magnitude_error_command.low_limit_1sigma - accel_magnitude_error_readback.low_limit_1sigma) < 0.001) &&
2627 (abs(accel_magnitude_error_command.high_limit_1sigma - accel_magnitude_error_readback.high_limit_1sigma) < 0.001))
2629 ROS_INFO(
"accel magnitude error adaptive measurement values successfully set.\n");
2633 ROS_INFO(
"ERROR: Failed to set accel magnitude error adaptive measurement values!!!");
2634 ROS_INFO(
"Sent values: Enable: %i, Parameters: %f %f %f %f %f %f",
2635 accel_magnitude_error_command.enable, accel_magnitude_error_command.low_pass_cutoff,
2636 accel_magnitude_error_command.min_1sigma, accel_magnitude_error_command.low_limit,
2637 accel_magnitude_error_command.high_limit, accel_magnitude_error_command.low_limit_1sigma,
2638 accel_magnitude_error_command.high_limit_1sigma);
2639 ROS_INFO(
"Returned values: Enable: %i, Parameters: %f %f %f %f %f %f",
2640 accel_magnitude_error_readback.enable, accel_magnitude_error_readback.low_pass_cutoff,
2641 accel_magnitude_error_readback.min_1sigma, accel_magnitude_error_readback.low_limit,
2642 accel_magnitude_error_readback.high_limit, accel_magnitude_error_readback.low_limit_1sigma,
2643 accel_magnitude_error_readback.high_limit_1sigma);
2651 bool Microstrain::get_accel_adaptive_vals(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res )
2654 while (mip_filter_accel_magnitude_error_adaptive_measurement(&device_interface_,
2655 MIP_FUNCTION_SELECTOR_READ, &accel_magnitude_error_readback) != MIP_INTERFACE_OK)
2657 if (clock() - start > 5000)
2659 ROS_INFO(
"mip_filter_accel_magnitude_error_adaptive_measurement function timed out.");
2663 ROS_INFO(
"Accel magnitude error adaptive measurement values are: Enable: %i, Parameters: %f %f %f %f %f %f",
2664 accel_magnitude_error_readback.enable, accel_magnitude_error_readback.low_pass_cutoff,
2665 accel_magnitude_error_readback.min_1sigma, accel_magnitude_error_readback.low_limit,
2666 accel_magnitude_error_readback.high_limit, accel_magnitude_error_readback.low_limit_1sigma,
2667 accel_magnitude_error_readback.high_limit_1sigma);
2674 bool Microstrain::set_mag_adaptive_vals(microstrain_mips::SetMagAdaptiveVals::Request &req,
2675 microstrain_mips::SetMagAdaptiveVals::Response &res )
2679 ROS_INFO(
"Device does not support this feature");
2680 res.success =
false;
2684 ROS_INFO(
"Setting the mag magnitude error adaptive measurement values\n");
2686 mag_magnitude_error_command.enable = req.enable;
2687 mag_magnitude_error_command.low_pass_cutoff = req.low_pass_cutoff;
2688 mag_magnitude_error_command.min_1sigma = req.min_1sigma;
2689 mag_magnitude_error_command.low_limit = req.low_limit;
2690 mag_magnitude_error_command.high_limit = req.high_limit;
2691 mag_magnitude_error_command.low_limit_1sigma = req.low_limit_1sigma;
2692 mag_magnitude_error_command.high_limit_1sigma = req.high_limit_1sigma;
2695 while (mip_filter_mag_magnitude_error_adaptive_measurement(&device_interface_, MIP_FUNCTION_SELECTOR_WRITE,
2696 &mag_magnitude_error_command) != MIP_INTERFACE_OK)
2698 if (clock() - start > 5000)
2700 ROS_INFO(
"mip_filter_mag_magnitude_error_adaptive_measurement function timed out.");
2707 while (mip_filter_mag_magnitude_error_adaptive_measurement(&device_interface_,
2708 MIP_FUNCTION_SELECTOR_READ, &mag_magnitude_error_readback) != MIP_INTERFACE_OK)
2710 if (clock() - start > 5000)
2712 ROS_INFO(
"mip_filter_mag_magnitude_error_adaptive_measurement function timed out.");
2717 if ((mag_magnitude_error_command.enable == mag_magnitude_error_readback.enable) &&
2718 (abs(mag_magnitude_error_command.low_pass_cutoff - mag_magnitude_error_readback.low_pass_cutoff) < 0.001) &&
2719 (abs(mag_magnitude_error_command.min_1sigma - mag_magnitude_error_readback.min_1sigma) < 0.001) &&
2720 (abs(mag_magnitude_error_command.low_limit - mag_magnitude_error_readback.low_limit) < 0.001) &&
2721 (abs(mag_magnitude_error_command.high_limit - mag_magnitude_error_readback.high_limit) < 0.001) &&
2722 (abs(mag_magnitude_error_command.low_limit_1sigma - mag_magnitude_error_readback.low_limit_1sigma) < 0.001) &&
2723 (abs(mag_magnitude_error_command.high_limit_1sigma - mag_magnitude_error_readback.high_limit_1sigma) < 0.001))
2725 ROS_INFO(
"mag magnitude error adaptive measurement values successfully set.\n");
2729 ROS_INFO(
"ERROR: Failed to set mag magnitude error adaptive measurement values!!!\n");
2730 ROS_INFO(
"Sent values: Enable: %i, Parameters: %f %f %f %f %f %f\n",
2731 mag_magnitude_error_command.enable, mag_magnitude_error_command.low_pass_cutoff,
2732 mag_magnitude_error_command.min_1sigma, mag_magnitude_error_command.low_limit,
2733 mag_magnitude_error_command.high_limit, mag_magnitude_error_command.low_limit_1sigma,
2734 mag_magnitude_error_command.high_limit_1sigma);
2735 ROS_INFO(
"Returned values: Enable: %i, Parameters: %f %f %f %f %f %f\n",
2736 mag_magnitude_error_readback.enable, mag_magnitude_error_readback.low_pass_cutoff,
2737 mag_magnitude_error_readback.min_1sigma, mag_magnitude_error_readback.low_limit,
2738 mag_magnitude_error_readback.high_limit, mag_magnitude_error_readback.low_limit_1sigma,
2739 mag_magnitude_error_readback.high_limit_1sigma);
2747 bool Microstrain::get_mag_adaptive_vals(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res )
2751 ROS_INFO(
"Device does not support this feature");
2752 res.success =
false;
2757 while (mip_filter_mag_magnitude_error_adaptive_measurement(&device_interface_,
2758 MIP_FUNCTION_SELECTOR_READ, &mag_magnitude_error_readback) != MIP_INTERFACE_OK)
2760 if (clock() - start > 5000)
2762 ROS_INFO(
"mip_filter_mag_magnitude_error_adaptive_measurement function timed out.");
2767 ROS_INFO(
"Returned values: Enable: %i, Parameters: %f %f %f %f %f %f\n",
2768 mag_magnitude_error_readback.enable, mag_magnitude_error_readback.low_pass_cutoff,
2769 mag_magnitude_error_readback.min_1sigma, mag_magnitude_error_readback.low_limit,
2770 mag_magnitude_error_readback.high_limit, mag_magnitude_error_readback.low_limit_1sigma,
2771 mag_magnitude_error_readback.high_limit_1sigma);
2777 bool Microstrain::get_mag_dip_adaptive_vals(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res )
2779 if (GX5_15 ==
true || GX5_25 ==
true)
2781 ROS_INFO(
"Device does not support this feature");
2782 res.success =
false;
2787 while (mip_filter_mag_dip_angle_error_adaptive_measurement(&device_interface_,
2788 MIP_FUNCTION_SELECTOR_READ, &mag_dip_angle_error_readback) != MIP_INTERFACE_OK)
2790 if (clock() - start > 5000)
2792 ROS_INFO(
"mip_filter_mag_magnitude_error_adaptive_measurement function timed out.");
2797 ROS_INFO(
"Returned values: Enable: %i, Parameters: %f %f %f %f\n", mag_dip_angle_error_readback.enable,
2798 mag_dip_angle_error_readback.low_pass_cutoff,
2799 mag_dip_angle_error_readback.min_1sigma,
2800 mag_dip_angle_error_readback.high_limit,
2801 mag_dip_angle_error_readback.high_limit_1sigma);
2808 bool Microstrain::set_mag_dip_adaptive_vals(microstrain_mips::SetMagDipAdaptiveVals::Request &req,
2809 microstrain_mips::SetMagDipAdaptiveVals::Response &res )
2811 if (GX5_15 ==
true || GX5_25 ==
true)
2813 ROS_INFO(
"Device does not support this feature");
2814 res.success =
false;
2818 ROS_INFO(
"Setting the mag dip angle error adaptive measurement values\n");
2820 mag_dip_angle_error_command.enable = req.enable;
2821 mag_dip_angle_error_command.low_pass_cutoff = req.low_pass_cutoff;
2822 mag_dip_angle_error_command.min_1sigma = req.min_1sigma;
2823 mag_dip_angle_error_command.high_limit = req.high_limit;
2824 mag_dip_angle_error_command.high_limit_1sigma = req.high_limit_1sigma;
2827 while (mip_filter_mag_dip_angle_error_adaptive_measurement(&device_interface_,
2828 MIP_FUNCTION_SELECTOR_WRITE, &mag_dip_angle_error_command) != MIP_INTERFACE_OK)
2830 if (clock() - start > 5000)
2832 ROS_INFO(
"mip_filter_mag_magnitude_error_adaptive_measurement function timed out.");
2839 while (mip_filter_mag_dip_angle_error_adaptive_measurement(&device_interface_,
2840 MIP_FUNCTION_SELECTOR_READ, &mag_dip_angle_error_readback) != MIP_INTERFACE_OK)
2842 if (clock() - start > 5000)
2844 ROS_INFO(
"mip_filter_mag_magnitude_error_adaptive_measurement function timed out.");
2849 if ((mag_dip_angle_error_command.enable == mag_magnitude_error_readback.enable) &&
2850 (abs(mag_dip_angle_error_command.low_pass_cutoff - mag_dip_angle_error_readback.low_pass_cutoff) < 0.001) &&
2851 (abs(mag_dip_angle_error_command.min_1sigma - mag_dip_angle_error_readback.min_1sigma) < 0.001) &&
2852 (abs(mag_dip_angle_error_command.high_limit - mag_dip_angle_error_readback.high_limit) < 0.001) &&
2853 (abs(mag_dip_angle_error_command.high_limit_1sigma - mag_dip_angle_error_readback.high_limit_1sigma) < 0.001))
2855 ROS_INFO(
"mag dip angle error adaptive measurement values successfully set.\n");
2859 ROS_INFO(
"ERROR: Failed to set mag dip angle error adaptive measurement values!!!\n");
2860 ROS_INFO(
"Sent values: Enable: %i, Parameters: %f %f %f %f\n", mag_dip_angle_error_command.enable,
2861 mag_dip_angle_error_command.low_pass_cutoff,
2862 mag_dip_angle_error_command.min_1sigma,
2863 mag_dip_angle_error_command.high_limit,
2864 mag_dip_angle_error_command.high_limit_1sigma);
2866 ROS_INFO(
"Returned values: Enable: %i, Parameters: %f %f %f %f\n", mag_dip_angle_error_readback.enable,
2867 mag_dip_angle_error_readback.low_pass_cutoff,
2868 mag_dip_angle_error_readback.min_1sigma,
2869 mag_dip_angle_error_readback.high_limit,
2870 mag_dip_angle_error_readback.high_limit_1sigma);
2878 bool Microstrain::get_dynamics_mode(std_srvs::Trigger::Request &req,
2879 std_srvs::Trigger::Response &res)
2881 if (GX5_15 ==
true || GX5_25 ==
true)
2883 ROS_INFO(
"Device does not support this feature");
2884 res.success =
false;
2888 readback_dynamics_mode = 0;
2889 while (mip_filter_vehicle_dynamics_mode(&device_interface_,
2890 MIP_FUNCTION_SELECTOR_READ, &readback_dynamics_mode) != MIP_INTERFACE_OK) {}
2892 ROS_INFO(
"Vehicle dynamics mode is: %d\n", dynamics_mode);
2900 bool Microstrain::set_dynamics_mode(microstrain_mips::SetDynamicsMode::Request &req,
2901 microstrain_mips::SetDynamicsMode::Response &res)
2903 if (GX5_15 ==
true || GX5_25 ==
true)
2905 ROS_INFO(
"Device does not support this feature");
2906 res.success =
false;
2910 dynamics_mode = req.mode;
2912 if (dynamics_mode < 1 || dynamics_mode > 3)
2914 ROS_INFO(
"Error: Vehicle dynamics mode must be between 1-3");
2915 res.success =
false;
2920 while (mip_filter_vehicle_dynamics_mode(&device_interface_,
2921 MIP_FUNCTION_SELECTOR_WRITE, &dynamics_mode) != MIP_INTERFACE_OK)
2923 if (clock() - start > 5000)
2925 ROS_INFO(
"mip_filter_vehicle_dynamics_mode function timed out.");
2930 readback_dynamics_mode = 0;
2931 while (mip_filter_vehicle_dynamics_mode(&device_interface_,
2932 MIP_FUNCTION_SELECTOR_READ, &readback_dynamics_mode) != MIP_INTERFACE_OK) {}
2934 if (dynamics_mode == readback_dynamics_mode)
2936 ROS_INFO(
"Vehicle dynamics mode successfully set to %d\n", dynamics_mode);
2941 ROS_INFO(
"ERROR: Failed to set vehicle dynamics mode to %d!!!\n", dynamics_mode);
2942 res.success =
false;
2949 bool Microstrain::set_sensor_vehicle_frame_offset(microstrain_mips::SetSensorVehicleFrameOffset::Request &req,
2950 microstrain_mips::SetSensorVehicleFrameOffset::Response &res)
2952 if (GX5_15 ==
true || GX5_25 ==
true)
2954 ROS_INFO(
"Device does not support this feature");
2955 res.success =
false;
2959 memset(offset, 0, 3*
sizeof(
float));
2960 memset(readback_offset, 0, 3*
sizeof(
float));
2961 ROS_INFO(
"Setting the sensor to vehicle frame offset\n");
2963 offset[0] = req.offset.x;
2964 offset[1] = req.offset.y;
2965 offset[2] = req.offset.z;
2968 while (mip_filter_sensor2vehicle_offset(&device_interface_,
2969 MIP_FUNCTION_SELECTOR_WRITE, offset) != MIP_INTERFACE_OK)
2971 if (clock() - start > 5000)
2973 ROS_INFO(
"mip_filter_sensor2vehicle_offset function timed out.");
2980 while (mip_filter_sensor2vehicle_offset(&device_interface_,
2981 MIP_FUNCTION_SELECTOR_READ, readback_offset) != MIP_INTERFACE_OK)
2983 if (clock() - start > 5000)
2985 ROS_INFO(
"mip_filter_sensor2vehicle_offset function timed out.");
2990 if ((abs(readback_offset[0]-offset[0]) < 0.001) &&
2991 (abs(readback_offset[1]-offset[1]) < 0.001) &&
2992 (abs(readback_offset[2]-offset[2]) < 0.001))
2994 ROS_INFO(
"Offset successfully set.\n");
2998 ROS_INFO(
"ERROR: Failed to set offset!!!\n");
2999 ROS_INFO(
"Sent offset: %f X %f Y %f Z\n", offset[0], offset[1], offset[2]);
3000 ROS_INFO(
"Returned offset: %f X %f Y %f Z\n", readback_offset[0], readback_offset[1], readback_offset[2]);
3008 bool Microstrain::get_sensor_vehicle_frame_offset(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
3010 if (GX5_15 ==
true || GX5_25 ==
true)
3012 ROS_INFO(
"Device does not support this feature");
3013 res.success =
false;
3017 memset(readback_offset, 0, 3*
sizeof(
float));
3020 while (mip_filter_sensor2vehicle_offset(&device_interface_,
3021 MIP_FUNCTION_SELECTOR_READ, readback_offset) != MIP_INTERFACE_OK)
3023 if (clock() - start > 5000)
3025 ROS_INFO(
"mip_filter_sensor2vehicle_offset function timed out.");
3030 ROS_INFO(
"Returned offset: %f X %f Y %f Z\n", readback_offset[0], readback_offset[1], readback_offset[2]);
3038 u16 model_number, u8 status_selector, u8 *response_buffer)
3043 gx4_25_basic_status_field *basic_ptr;
3044 gx4_25_diagnostic_device_status_field *diagnostic_ptr;
3045 u16 response_size = MIP_FIELD_HEADER_SIZE;
3048 if (status_selector == GX4_25_BASIC_STATUS_SEL)
3050 response_size +=
sizeof(gx4_25_basic_status_field);
3052 else if (status_selector == GX4_25_DIAGNOSTICS_STATUS_SEL)
3054 response_size +=
sizeof(gx4_25_diagnostic_device_status_field);
3057 while (mip_3dm_cmd_device_status(device_interface, model_number,
3058 status_selector, response_buffer, &response_size) != MIP_INTERFACE_OK) {}
3060 if (status_selector == GX4_25_BASIC_STATUS_SEL)
3062 if (response_size !=
sizeof(gx4_25_basic_status_field))
3064 return MIP_INTERFACE_ERROR;
3066 else if (MIP_SDK_CONFIG_BYTESWAP)
3069 byteswap_inplace(&response_buffer[0],
sizeof(basic_field.device_model));
3070 byteswap_inplace(&response_buffer[2],
sizeof(basic_field.status_selector));
3071 byteswap_inplace(&response_buffer[3],
sizeof(basic_field.status_flags));
3072 byteswap_inplace(&response_buffer[7],
sizeof(basic_field.system_state));
3073 byteswap_inplace(&response_buffer[9],
sizeof(basic_field.system_timer_ms));
3076 void * struct_pointer;
3077 struct_pointer = &basic_field;
3080 memcpy(struct_pointer, response_buffer,
sizeof(basic_field.device_model));
3081 memcpy((struct_pointer+2), &(response_buffer[2]),
sizeof(basic_field.status_selector));
3082 memcpy((struct_pointer+3), &(response_buffer[3]),
sizeof(basic_field.status_flags));
3083 memcpy((struct_pointer+7), &(response_buffer[7]),
sizeof(basic_field.system_state));
3084 memcpy((struct_pointer+9), &(response_buffer[9]),
sizeof(basic_field.system_timer_ms));
3086 else if (status_selector == GX4_25_DIAGNOSTICS_STATUS_SEL)
3088 if (response_size !=
sizeof(gx4_25_diagnostic_device_status_field))
3090 return MIP_INTERFACE_ERROR;
3092 else if (MIP_SDK_CONFIG_BYTESWAP)
3095 byteswap_inplace(&response_buffer[total_size],
3096 sizeof(diagnostic_field.device_model));
3097 total_size +=
sizeof(diagnostic_field.device_model);
3098 byteswap_inplace(&response_buffer[total_size],
3099 sizeof(diagnostic_field.status_selector));
3100 total_size +=
sizeof(diagnostic_field.status_selector);
3101 byteswap_inplace(&response_buffer[total_size],
3102 sizeof(diagnostic_field.status_flags));
3103 total_size +=
sizeof(diagnostic_field.status_flags);
3104 byteswap_inplace(&response_buffer[total_size],
3105 sizeof(diagnostic_field.system_state));
3106 total_size +=
sizeof(diagnostic_field.system_state);
3107 byteswap_inplace(&response_buffer[total_size],
3108 sizeof(diagnostic_field.system_timer_ms));
3109 total_size +=
sizeof(diagnostic_field.system_timer_ms);
3110 byteswap_inplace(&response_buffer[total_size],
3111 sizeof(diagnostic_field.imu_stream_enabled));
3112 total_size +=
sizeof(diagnostic_field.imu_stream_enabled);
3113 byteswap_inplace(&response_buffer[total_size],
3114 sizeof(diagnostic_field.filter_stream_enabled));
3115 total_size +=
sizeof(diagnostic_field.filter_stream_enabled);
3116 byteswap_inplace(&response_buffer[total_size],
3117 sizeof(diagnostic_field.imu_dropped_packets));
3118 total_size +=
sizeof(diagnostic_field.imu_dropped_packets);
3119 byteswap_inplace(&response_buffer[total_size],
3120 sizeof(diagnostic_field.filter_dropped_packets));
3121 total_size +=
sizeof(diagnostic_field.filter_dropped_packets);
3122 byteswap_inplace(&response_buffer[total_size],
3123 sizeof(diagnostic_field.com1_port_bytes_written));
3124 total_size +=
sizeof(diagnostic_field.com1_port_bytes_written);
3125 byteswap_inplace(&response_buffer[total_size],
3126 sizeof(diagnostic_field.com1_port_bytes_read));
3127 total_size +=
sizeof(diagnostic_field.com1_port_bytes_read);
3128 byteswap_inplace(&response_buffer[total_size],
3129 sizeof(diagnostic_field.com1_port_write_overruns));
3130 total_size +=
sizeof(diagnostic_field.com1_port_write_overruns);
3131 byteswap_inplace(&response_buffer[total_size],
3132 sizeof(diagnostic_field.com1_port_read_overruns));
3133 total_size +=
sizeof(diagnostic_field.com1_port_read_overruns);
3134 byteswap_inplace(&response_buffer[total_size],
3135 sizeof(diagnostic_field.imu_parser_errors));
3136 total_size +=
sizeof(diagnostic_field.imu_parser_errors);
3137 byteswap_inplace(&response_buffer[total_size],
3138 sizeof(diagnostic_field.imu_message_count));
3139 total_size +=
sizeof(diagnostic_field.imu_message_count);
3140 byteswap_inplace(&response_buffer[total_size],
3141 sizeof(diagnostic_field.imu_last_message_ms));
3144 void * struct_pointer;
3145 struct_pointer = &diagnostic_field;
3148 memcpy(struct_pointer, response_buffer,
3149 sizeof(diagnostic_field.device_model));
3150 total_size +=
sizeof(diagnostic_field.device_model);
3151 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3152 sizeof(diagnostic_field.status_selector));
3153 total_size +=
sizeof(diagnostic_field.status_selector);
3154 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3155 sizeof(diagnostic_field.status_flags));
3156 total_size +=
sizeof(diagnostic_field.status_flags);
3157 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3158 sizeof(diagnostic_field.system_state));
3159 total_size +=
sizeof(diagnostic_field.system_state);
3160 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3161 sizeof(diagnostic_field.system_timer_ms));
3162 total_size +=
sizeof(diagnostic_field.system_timer_ms);
3163 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3164 sizeof(diagnostic_field.imu_stream_enabled));
3165 total_size +=
sizeof(diagnostic_field.imu_stream_enabled);
3166 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3167 sizeof(diagnostic_field.filter_stream_enabled));
3168 total_size +=
sizeof(diagnostic_field.filter_stream_enabled);
3169 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3170 sizeof(diagnostic_field.imu_dropped_packets));
3171 total_size +=
sizeof(diagnostic_field.imu_dropped_packets);
3172 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3173 sizeof(diagnostic_field.filter_dropped_packets));
3174 total_size +=
sizeof(diagnostic_field.filter_dropped_packets);
3175 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3176 sizeof(diagnostic_field.com1_port_bytes_written));
3177 total_size +=
sizeof(diagnostic_field.com1_port_bytes_written);
3178 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3179 sizeof(diagnostic_field.com1_port_bytes_read));
3180 total_size +=
sizeof(diagnostic_field.com1_port_bytes_read);
3181 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3182 sizeof(diagnostic_field.com1_port_write_overruns));
3183 total_size +=
sizeof(diagnostic_field.com1_port_write_overruns);
3184 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3185 sizeof(diagnostic_field.com1_port_read_overruns));
3186 total_size +=
sizeof(diagnostic_field.com1_port_read_overruns);
3187 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3188 sizeof(diagnostic_field.imu_parser_errors));
3189 total_size +=
sizeof(diagnostic_field.imu_parser_errors);
3190 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3191 sizeof(diagnostic_field.imu_message_count));
3192 total_size +=
sizeof(diagnostic_field.imu_message_count);
3193 memcpy((struct_pointer + total_size), &(response_buffer[total_size]),
3194 sizeof(diagnostic_field.imu_last_message_ms));
3195 total_size +=
sizeof(diagnostic_field.imu_last_message_ms);
3198 return MIP_INTERFACE_ERROR;
3200 return MIP_INTERFACE_OK;
3213 mip_field_header *field_header;
3215 u16 field_offset = 0;
3218 if (!publish_odom_ && !publish_filtered_imu_)
3223 switch (callback_type)
3228 case MIP_INTERFACE_CALLBACK_VALID_PACKET:
3230 filter_valid_packet_count_++;
3236 while (mip_get_next_field(packet, &field_header, &field_data, &field_offset) == MIP_OK)
3242 switch (field_header->descriptor)
3248 case MIP_FILTER_DATA_LLH_POS:
3250 memcpy(&curr_filter_pos_, field_data,
sizeof(mip_filter_llh_pos));
3253 mip_filter_llh_pos_byteswap(&curr_filter_pos_);
3255 nav_msg_.header.seq = filter_valid_packet_count_;
3257 nav_msg_.header.frame_id = odom_frame_id_;
3258 nav_msg_.child_frame_id = odom_child_frame_id_;
3259 nav_msg_.pose.pose.position.y = curr_filter_pos_.latitude;
3260 nav_msg_.pose.pose.position.x = curr_filter_pos_.longitude;
3261 nav_msg_.pose.pose.position.z = curr_filter_pos_.ellipsoid_height;
3269 case MIP_FILTER_DATA_NED_VEL:
3271 memcpy(&curr_filter_vel_, field_data,
sizeof(mip_filter_ned_velocity));
3274 mip_filter_ned_velocity_byteswap(&curr_filter_vel_);
3279 curr_filter_quaternion_.q[1],
3280 -1.0*curr_filter_quaternion_.q[3],
3281 curr_filter_quaternion_.q[0]);
3283 tf2::Vector3 vel_enu(curr_filter_vel_.east,
3284 curr_filter_vel_.north,
3285 -1.0*curr_filter_vel_.down);
3288 nav_msg_.twist.twist.linear.x = vel_in_sensor_frame[0];
3289 nav_msg_.twist.twist.linear.y = vel_in_sensor_frame[1];
3290 nav_msg_.twist.twist.linear.z = vel_in_sensor_frame[2];
3298 case MIP_FILTER_DATA_ATT_EULER_ANGLES:
3300 memcpy(&curr_filter_angles_, field_data,
sizeof(mip_filter_attitude_euler_angles));
3303 mip_filter_attitude_euler_angles_byteswap(&curr_filter_angles_);
3308 case MIP_FILTER_DATA_ATT_QUATERNION:
3310 memcpy(&curr_filter_quaternion_, field_data,
sizeof(mip_filter_attitude_quaternion));
3313 mip_filter_attitude_quaternion_byteswap(&curr_filter_quaternion_);
3316 tf2::Quaternion q(curr_filter_quaternion_.q[1],curr_filter_quaternion_.q[2],
3317 curr_filter_quaternion_.q[3],curr_filter_quaternion_.q[0]);
3318 geometry_msgs::Quaternion quat_msg;
3320 if(frame_based_enu_)
3324 q_rotate.
setRPY(M_PI,0.0,M_PI/2);
3334 quat_msg.z = -1.0*q[2];
3338 nav_msg_.pose.pose.orientation = quat_msg;
3340 if (publish_filtered_imu_)
3343 filtered_imu_msg_.header.seq = filter_valid_packet_count_;
3345 filtered_imu_msg_.header.frame_id = imu_frame_id_;
3346 filtered_imu_msg_.orientation = nav_msg_.pose.pose.orientation;
3352 case MIP_FILTER_DATA_COMPENSATED_ANGULAR_RATE:
3354 memcpy(&curr_filter_angular_rate_, field_data,
sizeof(mip_filter_compensated_angular_rate));
3357 mip_filter_compensated_angular_rate_byteswap(&curr_filter_angular_rate_);
3359 nav_msg_.twist.twist.angular.x = curr_filter_angular_rate_.x;
3360 nav_msg_.twist.twist.angular.y = curr_filter_angular_rate_.y;
3361 nav_msg_.twist.twist.angular.z = curr_filter_angular_rate_.z;
3363 if (publish_filtered_imu_)
3365 filtered_imu_msg_.angular_velocity.x = curr_filter_angular_rate_.x;
3366 filtered_imu_msg_.angular_velocity.y = curr_filter_angular_rate_.y;
3367 filtered_imu_msg_.angular_velocity.z = curr_filter_angular_rate_.z;
3373 case MIP_FILTER_DATA_POS_UNCERTAINTY:
3375 memcpy(&curr_filter_pos_uncertainty_, field_data,
sizeof(mip_filter_llh_pos_uncertainty));
3378 mip_filter_llh_pos_uncertainty_byteswap(&curr_filter_pos_uncertainty_);
3381 nav_msg_.pose.covariance[0] = curr_filter_pos_uncertainty_.east*curr_filter_pos_uncertainty_.east;
3382 nav_msg_.pose.covariance[7] = curr_filter_pos_uncertainty_.north*curr_filter_pos_uncertainty_.north;
3383 nav_msg_.pose.covariance[14] = curr_filter_pos_uncertainty_.down*curr_filter_pos_uncertainty_.down;
3388 case MIP_FILTER_DATA_VEL_UNCERTAINTY:
3390 memcpy(&curr_filter_vel_uncertainty_, field_data,
sizeof(mip_filter_ned_vel_uncertainty));
3393 mip_filter_ned_vel_uncertainty_byteswap(&curr_filter_vel_uncertainty_);
3395 nav_msg_.twist.covariance[0] = curr_filter_vel_uncertainty_.east*curr_filter_vel_uncertainty_.east;
3396 nav_msg_.twist.covariance[7] = curr_filter_vel_uncertainty_.north*curr_filter_vel_uncertainty_.north;
3397 nav_msg_.twist.covariance[14] = curr_filter_vel_uncertainty_.down*curr_filter_vel_uncertainty_.down;
3402 case MIP_FILTER_DATA_ATT_UNCERTAINTY_EULER:
3404 memcpy(&curr_filter_att_uncertainty_, field_data,
sizeof(mip_filter_euler_attitude_uncertainty));
3407 mip_filter_euler_attitude_uncertainty_byteswap(&curr_filter_att_uncertainty_);
3408 nav_msg_.pose.covariance[21] = curr_filter_att_uncertainty_.roll*curr_filter_att_uncertainty_.roll;
3409 nav_msg_.pose.covariance[28] = curr_filter_att_uncertainty_.pitch*curr_filter_att_uncertainty_.pitch;
3410 nav_msg_.pose.covariance[35] = curr_filter_att_uncertainty_.yaw*curr_filter_att_uncertainty_.yaw;
3412 if (publish_filtered_imu_)
3414 filtered_imu_msg_.orientation_covariance[0] =
3415 curr_filter_att_uncertainty_.roll*curr_filter_att_uncertainty_.roll;
3416 filtered_imu_msg_.orientation_covariance[4] =
3417 curr_filter_att_uncertainty_.pitch*curr_filter_att_uncertainty_.pitch;
3418 filtered_imu_msg_.orientation_covariance[8] =
3419 curr_filter_att_uncertainty_.yaw*curr_filter_att_uncertainty_.yaw;
3425 case MIP_FILTER_DATA_FILTER_STATUS:
3427 memcpy(&curr_filter_status_, field_data,
sizeof(mip_filter_status));
3430 mip_filter_status_byteswap(&curr_filter_status_);
3432 nav_status_msg_.data.clear();
3433 ROS_DEBUG_THROTTLE(1.0,
"Filter Status: %#06X, Dyn. Mode: %#06X, Filter State: %#06X",
3434 curr_filter_status_.filter_state,
3435 curr_filter_status_.dynamics_mode,
3436 curr_filter_status_.status_flags);
3437 nav_status_msg_.data.push_back(curr_filter_status_.filter_state);
3438 nav_status_msg_.data.push_back(curr_filter_status_.dynamics_mode);
3439 nav_status_msg_.data.push_back(curr_filter_status_.status_flags);
3440 nav_status_pub_.publish(nav_status_msg_);
3448 case MIP_FILTER_DATA_LINEAR_ACCELERATION:
3450 memcpy(&curr_filter_linear_accel_, field_data,
sizeof(mip_filter_linear_acceleration));
3453 mip_filter_linear_acceleration_byteswap(&curr_filter_linear_accel_);
3456 if (remove_imu_gravity_)
3459 filtered_imu_msg_.linear_acceleration.x = curr_filter_linear_accel_.x;
3460 filtered_imu_msg_.linear_acceleration.y = curr_filter_linear_accel_.y;
3461 filtered_imu_msg_.linear_acceleration.z = curr_filter_linear_accel_.z;
3467 case MIP_FILTER_DATA_COMPENSATED_ACCELERATION:
3469 memcpy(&curr_filter_accel_comp_, field_data,
sizeof(mip_filter_compensated_acceleration));
3472 mip_filter_compensated_acceleration_byteswap(&curr_filter_accel_comp_);
3475 if (!remove_imu_gravity_)
3478 filtered_imu_msg_.linear_acceleration.x = curr_filter_accel_comp_.x;
3479 filtered_imu_msg_.linear_acceleration.y = curr_filter_accel_comp_.y;
3480 filtered_imu_msg_.linear_acceleration.z = curr_filter_accel_comp_.z;
3493 nav_pub_.publish(nav_msg_);
3496 if (publish_filtered_imu_)
3501 std::copy(imu_linear_cov_.begin(), imu_linear_cov_.end(),
3502 filtered_imu_msg_.linear_acceleration_covariance.begin());
3505 std::copy(imu_angular_cov_.begin(), imu_angular_cov_.end(),
3506 filtered_imu_msg_.angular_velocity_covariance.begin());
3507 filtered_imu_pub_.publish(filtered_imu_msg_);
3516 case MIP_INTERFACE_CALLBACK_CHECKSUM_ERROR:
3518 filter_checksum_error_packet_count_++;
3526 case MIP_INTERFACE_CALLBACK_TIMEOUT:
3528 filter_timeout_packet_count_++;
3541 void Microstrain::device_status_callback()
3545 u8 response_buffer[
sizeof(gx4_25_diagnostic_device_status_field)];
3548 GX4_25_MODEL_NUMBER, GX4_25_DIAGNOSTICS_STATUS_SEL,
3549 response_buffer) != MIP_INTERFACE_OK)
3551 if (clock() - start > 5000)
3553 ROS_INFO(
"mip_3dm_cmd_hw_specific_device_status function timed out.");
3560 device_status_msg_.device_model = diagnostic_field.device_model;
3561 device_status_msg_.status_selector = diagnostic_field.status_selector;
3562 device_status_msg_.status_flags = diagnostic_field.status_flags;
3563 device_status_msg_.system_state = diagnostic_field.system_state;
3564 device_status_msg_.system_timer_ms = diagnostic_field.system_timer_ms;
3565 device_status_msg_.imu_stream_enabled = diagnostic_field.imu_stream_enabled;
3566 device_status_msg_.filter_stream_enabled = diagnostic_field.filter_stream_enabled;
3567 device_status_msg_.imu_dropped_packets = diagnostic_field.imu_dropped_packets;
3568 device_status_msg_.filter_dropped_packets = diagnostic_field.filter_dropped_packets;
3569 device_status_msg_.com1_port_bytes_written = diagnostic_field.com1_port_bytes_written;
3570 device_status_msg_.com1_port_bytes_read = diagnostic_field.com1_port_bytes_read;
3571 device_status_msg_.com1_port_write_overruns = diagnostic_field.com1_port_write_overruns;
3572 device_status_msg_.com1_port_read_overruns = diagnostic_field.com1_port_read_overruns;
3573 device_status_msg_.imu_parser_errors = diagnostic_field.imu_parser_errors;
3574 device_status_msg_.imu_message_count = diagnostic_field.imu_message_count;
3575 device_status_msg_.imu_last_message_ms = diagnostic_field.imu_last_message_ms;
3577 device_status_pub_.publish(device_status_msg_);
3581 ROS_INFO(
"Device status messages not configured for this model");
3593 mip_field_header *field_header;
3595 u16 field_offset = 0;
3600 switch (callback_type)
3606 case MIP_INTERFACE_CALLBACK_VALID_PACKET:
3608 ahrs_valid_packet_count_++;
3614 while (mip_get_next_field(packet, &field_header, &field_data, &field_offset) == MIP_OK)
3620 switch (field_header->descriptor)
3626 case MIP_AHRS_DATA_ACCEL_SCALED:
3628 memcpy(&curr_ahrs_accel_, field_data,
sizeof(mip_ahrs_scaled_accel));
3631 mip_ahrs_scaled_accel_byteswap(&curr_ahrs_accel_);
3635 imu_msg_.header.seq = ahrs_valid_packet_count_;
3637 imu_msg_.header.frame_id = imu_frame_id_;
3638 imu_msg_.linear_acceleration.x = 9.81*curr_ahrs_accel_.scaled_accel[0];
3639 imu_msg_.linear_acceleration.y = 9.81*curr_ahrs_accel_.scaled_accel[1];
3640 imu_msg_.linear_acceleration.z = 9.81*curr_ahrs_accel_.scaled_accel[2];
3643 std::copy(imu_linear_cov_.begin(), imu_linear_cov_.end(),
3644 imu_msg_.linear_acceleration_covariance.begin());
3652 case MIP_AHRS_DATA_GYRO_SCALED:
3654 memcpy(&curr_ahrs_gyro_, field_data,
sizeof(mip_ahrs_scaled_gyro));
3657 mip_ahrs_scaled_gyro_byteswap(&curr_ahrs_gyro_);
3659 imu_msg_.angular_velocity.x = curr_ahrs_gyro_.scaled_gyro[0];
3660 imu_msg_.angular_velocity.y = curr_ahrs_gyro_.scaled_gyro[1];
3661 imu_msg_.angular_velocity.z = curr_ahrs_gyro_.scaled_gyro[2];
3664 std::copy(imu_angular_cov_.begin(), imu_angular_cov_.end(),
3665 imu_msg_.angular_velocity_covariance.begin());
3673 case MIP_AHRS_DATA_MAG_SCALED:
3675 memcpy(&curr_ahrs_mag_, field_data,
sizeof(mip_ahrs_scaled_mag));
3678 mip_ahrs_scaled_mag_byteswap(&curr_ahrs_mag_);
3683 case MIP_AHRS_DATA_QUATERNION:
3685 memcpy(&curr_ahrs_quaternion_, field_data,
sizeof(mip_ahrs_quaternion));
3688 mip_ahrs_quaternion_byteswap(&curr_ahrs_quaternion_);
3691 tf2::Quaternion q(curr_ahrs_quaternion_.q[1],curr_ahrs_quaternion_.q[2],
3692 curr_ahrs_quaternion_.q[3],curr_ahrs_quaternion_.q[0]);
3693 geometry_msgs::Quaternion quat_msg;
3695 if(frame_based_enu_)
3699 q_rotate.
setRPY(M_PI,0.0,M_PI/2);
3709 quat_msg.z = -1.0*q[2];
3713 imu_msg_.orientation = quat_msg;
3719 std::copy(imu_orientation_cov_.begin(), imu_orientation_cov_.end(),
3720 imu_msg_.orientation_covariance.begin());
3729 imu_pub_.publish(imu_msg_);
3737 case MIP_INTERFACE_CALLBACK_CHECKSUM_ERROR:
3739 ahrs_checksum_error_packet_count_++;
3747 case MIP_INTERFACE_CALLBACK_TIMEOUT:
3749 ahrs_timeout_packet_count_++;
3766 mip_field_header *field_header;
3768 u16 field_offset = 0;
3775 switch (callback_type)
3781 case MIP_INTERFACE_CALLBACK_VALID_PACKET:
3783 gps_valid_packet_count_++;
3789 while (mip_get_next_field(packet, &field_header, &field_data, &field_offset) == MIP_OK)
3795 switch (field_header->descriptor)
3801 case MIP_GPS_DATA_LLH_POS:
3803 memcpy(&curr_llh_pos_, field_data,
sizeof(mip_gps_llh_pos));
3806 mip_gps_llh_pos_byteswap(&curr_llh_pos_);
3809 gps_msg_.latitude = curr_llh_pos_.latitude;
3810 gps_msg_.longitude = curr_llh_pos_.longitude;
3811 gps_msg_.altitude = curr_llh_pos_.ellipsoid_height;
3812 gps_msg_.position_covariance_type = 2;
3813 gps_msg_.position_covariance[0] = curr_llh_pos_.horizontal_accuracy*curr_llh_pos_.horizontal_accuracy;
3814 gps_msg_.position_covariance[4] = curr_llh_pos_.horizontal_accuracy*curr_llh_pos_.horizontal_accuracy;
3815 gps_msg_.position_covariance[8] = curr_llh_pos_.vertical_accuracy*curr_llh_pos_.vertical_accuracy;
3816 gps_msg_.status.status = curr_llh_pos_.valid_flags - 1;
3817 gps_msg_.status.service = 1;
3819 gps_msg_.header.seq = gps_valid_packet_count_;
3821 gps_msg_.header.frame_id = gps_frame_id_;
3829 case MIP_GPS_DATA_NED_VELOCITY:
3831 memcpy(&curr_ned_vel_, field_data,
sizeof(mip_gps_ned_vel));
3834 mip_gps_ned_vel_byteswap(&curr_ned_vel_);
3842 case MIP_GPS_DATA_GPS_TIME:
3844 memcpy(&curr_gps_time_, field_data,
sizeof(mip_gps_time));
3847 mip_gps_time_byteswap(&curr_gps_time_);
3861 case MIP_INTERFACE_CALLBACK_CHECKSUM_ERROR:
3864 gps_checksum_error_packet_count_++;
3872 case MIP_INTERFACE_CALLBACK_TIMEOUT:
3875 gps_timeout_packet_count_++;
3885 gps_pub_.publish(gps_msg_);
3893 ROS_DEBUG_THROTTLE(1.0,
"%u FILTER (%u errors) %u AHRS (%u errors) %u GPS (%u errors) Packets",
3894 filter_valid_packet_count_, filter_timeout_packet_count_ + filter_checksum_error_packet_count_,
3895 ahrs_valid_packet_count_, ahrs_timeout_packet_count_ + ahrs_checksum_error_packet_count_,
3896 gps_valid_packet_count_, gps_timeout_packet_count_ + gps_checksum_error_packet_count_);
3906 ustrain->filter_packet_callback(user_ptr, packet, packet_size, callback_type);
3912 ustrain->ahrs_packet_callback(user_ptr, packet, packet_size, callback_type);
3918 ustrain->gps_packet_callback(user_ptr, packet, packet_size, callback_type);
void filter_packet_callback_wrapper(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
void setRPY(const tf2Scalar &roll, const tf2Scalar &pitch, const tf2Scalar &yaw)
void print_packet_stats()
u16 mip_sdk_port_close(void *port_handle)
#define ROS_DEBUG_THROTTLE(rate,...)
void gps_packet_callback(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
Quaternion inverse() const
void ahrs_packet_callback(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
void gps_packet_callback_wrapper(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
void ahrs_packet_callback_wrapper(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
void filter_packet_callback(void *user_ptr, u8 *packet, u16 packet_size, u8 callback_type)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
#define MIP_SDK_GX4_45_IMU_STANDARD_MODE
TF2SIMD_FORCE_INLINE Vector3 quatRotate(const Quaternion &rotation, const Vector3 &v)
u16 mip_3dm_cmd_hw_specific_device_status(mip_interface *device_interface, u16 model_number, u8 status_selector, u8 *response_buffer)
mip_interface device_interface
ROSCPP_DECL void spinOnce()
#define DEFAULT_PACKET_TIMEOUT_MS