|
@@ -7,7 +7,7 @@
|
|
int main(int argc, char **argv)
|
|
int main(int argc, char **argv)
|
|
{
|
|
{
|
|
float yaw, pitch, roll;
|
|
float yaw, pitch, roll;
|
|
- tf::Quaternion q;
|
|
|
|
|
|
+ geometry_msgs::Quaternion q;
|
|
std::string imu_dev;
|
|
std::string imu_dev;
|
|
int baud = 0;
|
|
int baud = 0;
|
|
int dataBit = 0;
|
|
int dataBit = 0;
|
|
@@ -19,7 +19,7 @@ int main(int argc, char **argv)
|
|
std::string temp_topic;
|
|
std::string temp_topic;
|
|
int pub_hz;
|
|
int pub_hz;
|
|
float degree2Rad = 3.1415926/180.0;
|
|
float degree2Rad = 3.1415926/180.0;
|
|
- float acc_factor= 9.806/256.0;
|
|
|
|
|
|
+ float acc_factor = 9.806/256.0;
|
|
|
|
|
|
ros::init(argc, argv, "imu_data_pub_node");
|
|
ros::init(argc, argv, "imu_data_pub_node");
|
|
ros::NodeHandle handle;
|
|
ros::NodeHandle handle;
|
|
@@ -53,17 +53,18 @@ int main(int argc, char **argv)
|
|
break;
|
|
break;
|
|
|
|
|
|
imu_msg.header.stamp = ros::Time::now();
|
|
imu_msg.header.stamp = ros::Time::now();
|
|
- roll = getAngleX();
|
|
|
|
- pitch = getAngleY();
|
|
|
|
- yaw = getAngleZ();
|
|
|
|
|
|
+ roll = getAngleX()*degree2Rad;
|
|
|
|
+ pitch = getAngleY()*degree2Rad;
|
|
|
|
+ yaw = getAngleZ()*degree2Rad;
|
|
if(yaw >= 180.0)
|
|
if(yaw >= 180.0)
|
|
yaw -= 360.0;
|
|
yaw -= 360.0;
|
|
|
|
|
|
- q.setRPY(roll, pitch, yaw);
|
|
|
|
- imu_msg.orientation.x = q[0];
|
|
|
|
- imu_msg.orientation.y = q[1];
|
|
|
|
- imu_msg.orientation.z = q[2];
|
|
|
|
- imu_msg.orientation.w = q[3];
|
|
|
|
|
|
+ //ROS_INFO("yaw:%f pitch:%f roll:%f",yaw, pitch, roll);
|
|
|
|
+ q = tf::createQuaternionMsgFromRollPitchYaw(roll, pitch, yaw);
|
|
|
|
+ imu_msg.orientation.x = q.x;
|
|
|
|
+ imu_msg.orientation.y = q.y;
|
|
|
|
+ imu_msg.orientation.z = q.z;
|
|
|
|
+ imu_msg.orientation.w = q.w;
|
|
imu_msg.orientation_covariance = {0.0025, 0, 0,
|
|
imu_msg.orientation_covariance = {0.0025, 0, 0,
|
|
0, 0.0025, 0,
|
|
0, 0.0025, 0,
|
|
0, 0, 0.0025};
|
|
0, 0, 0.0025};
|
|
@@ -75,6 +76,7 @@ int main(int argc, char **argv)
|
|
0, 0.02, 0,
|
|
0, 0.02, 0,
|
|
0, 0, 0.02};
|
|
0, 0, 0.02};
|
|
|
|
|
|
|
|
+ //ROS_INFO("acc_x:%f acc_y:%f acc_z:%f",getAccX(), getAccY(), getAccZ());
|
|
imu_msg.linear_acceleration.x = getAccX()*acc_factor;
|
|
imu_msg.linear_acceleration.x = getAccX()*acc_factor;
|
|
imu_msg.linear_acceleration.y = getAccY()*acc_factor;
|
|
imu_msg.linear_acceleration.y = getAccY()*acc_factor;
|
|
imu_msg.linear_acceleration.z = getAccZ()*acc_factor;
|
|
imu_msg.linear_acceleration.z = getAccZ()*acc_factor;
|