4 #include <muse_v2_driver/GetCalibrationParams.h>
6 int main(
int argc,
char** argv)
8 ros::init(argc, argv,
"get_calibration_params");
24 muse_v2_driver::GetCalibrationParams srv;
27 srv.request.get_gyroscope_offset =
true;
30 srv.request.get_accelerometer_calib_params =
true;
33 srv.request.get_magnetometer_calib_params =
true;
39 std::ofstream muse_calib_file;
41 muse_calib_file.open(calib_file_path);
43 std::stringstream stream;
46 if (srv.request.get_gyroscope_offset) {
48 stream.str(std::string());
50 stream <<
"X" <<
"\t" <<
"Y" <<
"\t" <<
"Z" <<
"\n";
51 stream << std::setprecision(6) << std::fixed << srv.response.current_gyro_offset[0] <<
"\t" << srv.response.current_gyro_offset[1] <<
"\t" << srv.response.current_gyro_offset[2];
55 if (!muse_calib_file) {
56 ROS_ERROR(
"Error: file could not be opened.");
60 muse_calib_file <<
"Accelerometer Calibration params: \n" << stream.str() <<
"\n";
64 if (srv.request.get_accelerometer_calib_params) {
66 stream.str(std::string());
68 stream <<
"X" <<
"\t" <<
"Y" <<
"\t" <<
"Z" <<
"\t" <<
"offset" <<
"\n";
69 stream << std::setprecision(6) << std::fixed << srv.response.current_acc_params[0] <<
"\t" << srv.response.current_acc_params[1] <<
"\t" << srv.response.current_acc_params[2] <<
"\t" << srv.response.current_acc_params[9] <<
"\n";
70 stream << srv.response.current_acc_params[3] <<
"\t" << srv.response.current_acc_params[4] <<
"\t" << srv.response.current_acc_params[5] <<
"\t" << srv.response.current_acc_params[10] <<
"\n";
71 stream << srv.response.current_acc_params[6] <<
"\t" << srv.response.current_acc_params[7] <<
"\t" << srv.response.current_acc_params[8] <<
"\t" << srv.response.current_acc_params[11];
73 ROS_INFO_STREAM(
"Accelerometer Calibration params: \n" << stream.str());
75 if (!muse_calib_file) {
76 ROS_ERROR(
"Error: file could not be opened.");
80 muse_calib_file <<
"Accelerometer Calibration params: \n" << stream.str() <<
"\n";
84 if (srv.request.get_magnetometer_calib_params) {
86 stream.str(std::string());
88 stream <<
"X" <<
"\t" <<
"Y" <<
"\t" <<
"Z" <<
"\t" <<
"offset" <<
"\n";
89 stream << std::setprecision(6) << std::fixed << srv.response.current_mag_params[0] <<
"\t" << srv.response.current_mag_params[1] <<
"\t" << srv.response.current_mag_params[2] <<
"\t" << srv.response.current_mag_params[9] <<
"\n";
90 stream << srv.response.current_mag_params[3] <<
"\t" << srv.response.current_mag_params[4] <<
"\t" << srv.response.current_mag_params[5] <<
"\t" << srv.response.current_mag_params[10] <<
"\n";
91 stream << srv.response.current_mag_params[6] <<
"\t" << srv.response.current_mag_params[7] <<
"\t" << srv.response.current_mag_params[8] <<
"\t" << srv.response.current_mag_params[11];
95 if (!muse_calib_file) {
96 ROS_ERROR(
"Error: file could not be opened.");
100 muse_calib_file <<
"Magnetometer Calibration params: \n" << stream.str() <<
"\n";
104 muse_calib_file.close();
109 ROS_ERROR(
"Failed to call Get Calibration Params service.");