52 int main(
int argc,
char** argv)
54 ros::init(argc, argv,
"mti_node");
55 ros::NodeHandle pn(
"~");
61 pn.param<std::string>(
"port", portname,
"/dev/ttyUSB0");
62 pn.param(
"baudrate", baudrate, 115200);
66 pn.param<
bool>(
"temperature", outputMode.temperatureData,
false);
67 pn.param<
bool>(
"calibrated", outputMode.calibratedData,
true);
68 pn.param<
bool>(
"orientation", outputMode.orientationData,
true);
69 pn.param<
bool>(
"auxiliary", outputMode.auxiliaryData,
false);
70 pn.param<
bool>(
"position", outputMode.positionData,
false);
71 pn.param<
bool>(
"velocity", outputMode.velocityData,
false);
72 pn.param<
bool>(
"status", outputMode.statusData,
false);
73 pn.param<
bool>(
"rawGPS", outputMode.rawGPSData,
false);
74 pn.param<
bool>(
"rawInertial", outputMode.rawInertialData,
false);
77 pn.param<
bool>(
"timeStamp", outputSettings.timeStamp,
false);
81 pn.param<
bool>(
"enableAcceleration", outputSettings.enableAcceleration,
false);
82 pn.param<
bool>(
"enableRateOfTurn", outputSettings.enableRateOfTurn,
false);
83 pn.param<
bool>(
"enableMagnetometer", outputSettings.enableMagnetometer,
false);
84 pn.param<
bool>(
"velocityModeNED", outputSettings.velocityModeNED,
false);
89 double GPSLeverArm_X, GPSLeverArm_Y, GPSLeverArm_Z;
90 pn.param<
double>(
"GPSLeverArm_X",GPSLeverArm_X,0.0);
91 pn.param<
double>(
"GPSLeverArm_Y",GPSLeverArm_Y,0.0);
92 pn.param<
double>(
"GPSLeverArm_Z",GPSLeverArm_Z,0.0);
94 GPS_lever_arm.
x = GPSLeverArm_X;
95 GPS_lever_arm.
y = GPSLeverArm_Y;
96 GPS_lever_arm.
z = GPSLeverArm_Z;
100 if(!mti->
openPort((
char*)portname.c_str(), baudrate))
102 ROS_FATAL(
"MTi -- Unable to connect to the MTi.");
105 ROS_INFO(
"MTi -- Successfully connected to the MTi!");
107 std::string prefix =
"";
108 pn.getParamCached(
"tf_prefix",prefix);
109 ROS_INFO(
"tf_prefix: %s",prefix.c_str());
110 if(!mti->
setSettings(outputMode, outputSettings, scenario, prefix, frame_id, GPS_lever_arm, 1000))
112 ROS_FATAL(
"MTi -- Unable to set the output mode and settings.");
115 ROS_INFO(
"MTi -- Setup complete! Initiating data streaming...");
117 ros::Publisher mti_pub = pn.advertise<sensor_msgs::Imu>(
"imu/data", 10);
118 ros::Publisher navsat_pub = pn.advertise<sensor_msgs::NavSatFix>(
"fix", 10);
119 ros::Publisher odomPub = pn.advertise<nav_msgs::Odometry>(
"odom",10);
121 tf::TransformBroadcaster odom_broadcaster;
122 tf::TransformListener listener;
127 ros::Time now = ros::Time::now();
129 mti_pub.publish(imu_msg);
132 navsat_pub.publish(nav_fix_msg);
135 odomPub.publish(odom_msg);
nav_msgs::Odometry fillOdometryMessage(const tf::TransformListener &listener, tf::TransformBroadcaster &odom_broadcaster, const ros::Time &now)
Fill ROS odometry message with the values come from the xsens.
MTOrientationMode orientationMode
enum Xsens::_MTOrientationMode MTOrientationMode
bool setSettings(outputMode mode, outputSettings settings, Scenario scenario, const std::string &rosNamespace, const std::string &frameID, const Position &GPSLeverArm, int timeout)
Set the configuration of the xsens:
enum Xsens::_Scenario Scenario
bool openPort(char *name, int baudrate)
Open serial port to communicate with the Xsens.
int main(int argc, char **argv)
sensor_msgs::Imu fillImuMessage(const ros::Time &now)
Fill ROS IMU message with the values come from the xsens.
sensor_msgs::NavSatFix fillNavFixMessage(const ros::Time &now)
Fill ROS NavSatFix message with the values come from the xsens.
static const std::string IMU_FRAME_ID