ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

the topic types does not mach.

You must not subscribe to the imu topic as a vector3 type but as a sensor_msgs/Imu type.

Can you provide in the question how you do the subscription?

the topic types does not mach.

You must not subscribe to the imu topic as a vector3 type but as a sensor_msgs/Imu type.

Can In your code, you provide in the question how you do the subscription?are subscribing to a topic called "imu" that must have a Vector3 type.

However, in practice the sensor publishes messages on the "imu" topic with type sensor_msgs/Imu.

the topic types does not mach.

You must not subscribe to the imu topic as a vector3 type but as a sensor_msgs/Imu type.

In your code, you are subscribing to a topic called "imu" that must have a Vector3 type.

However, in practice the sensor publishes messages on the "imu" topic with type sensor_msgs/Imu.sensor_msgs/Imu. These are the fields of a sensor_msgs/Imu:

std_msgs/Header header
geometry_msgs/Quaternion orientation
float64[9] orientation_covariance
geometry_msgs/Vector3 angular_velocity
float64[9] angular_velocity_covariance
geometry_msgs/Vector3 linear_acceleration
float64[9] linear_acceleration_covariance

You have to take the orientation field (that it is a quaternion) and convert it to euler angles (roll, pitch, yaw)... then you will have the three values you are looking. In order to do that you can use the conversion functions that exist in the "tf" library.

the topic types does not mach.

You must not subscribe to the imu topic as a vector3 type but as a sensor_msgs/Imu type.

In your code, you are subscribing to a topic called "imu" that must have a Vector3 type.

However, in practice the sensor publishes messages on the "imu" topic with type sensor_msgs/Imu. These are the fields of a sensor_msgs/Imu:

std_msgs/Header header
geometry_msgs/Quaternion orientation
float64[9] orientation_covariance
geometry_msgs/Vector3 angular_velocity
float64[9] angular_velocity_covariance
geometry_msgs/Vector3 linear_acceleration
float64[9] linear_acceleration_covariance

You have to take the orientation field (that it is a quaternion) and convert it to euler angles (roll, pitch, yaw)... then you will have the three values you are looking. In order to do that you can use the conversion functions that exist in the "tf" library.

This would be approximately a more correct code:

note: i tried this

void handle_imu(const sensor_msgs::Imu::ConstPtr &msg) { gyro_x = msg->angular_velocity.x; gyro_y = msg->angular_velocity->y; gyro_z = msg->angular_velocity->z; }

the topic types does not mach.

You must not subscribe to the imu topic as a vector3 type but as a sensor_msgs/Imu type.

In your code, you are subscribing to a topic called "imu" that must have a Vector3 type.

However, in practice the sensor publishes messages on the "imu" topic with type sensor_msgs/Imu. These are the fields of a sensor_msgs/Imu:

std_msgs/Header header
geometry_msgs/Quaternion orientation
float64[9] orientation_covariance
geometry_msgs/Vector3 angular_velocity
float64[9] angular_velocity_covariance
geometry_msgs/Vector3 linear_acceleration
float64[9] linear_acceleration_covariance

You have to take the orientation field (that it is a quaternion) and convert it to euler angles (roll, pitch, yaw)... then you will have the three values you are looking. In order to do that you can use the conversion functions that exist in the "tf" library.

This would be approximately a more correct code:

note: i tried this

void handle_imu(const sensor_msgs::Imu::ConstPtr &msg)
{ 
   gyro_x = msg->angular_velocity.x;
   gyro_y = msg->angular_velocity->y;
   gyro_z = msg->angular_velocity->z; 
}

}

the topic types does not mach.

You must not subscribe to the imu topic as a vector3 type but as a sensor_msgs/Imu type.

In your code, you are subscribing to a topic called "imu" that must have a Vector3 type.

However, in practice the sensor publishes messages on the "imu" topic with type sensor_msgs/Imu. These are the fields of a sensor_msgs/Imu:

std_msgs/Header header
geometry_msgs/Quaternion orientation
float64[9] orientation_covariance
geometry_msgs/Vector3 angular_velocity
float64[9] angular_velocity_covariance
geometry_msgs/Vector3 linear_acceleration
float64[9] linear_acceleration_covariance

You have to take the orientation field (that it is a quaternion) and convert it to euler angles (roll, pitch, yaw)... then you will have the three values you are looking. In order to do that you can use the conversion functions that exist in the "tf" library.

This would be approximately a more correct code:

note: i tried this

void handle_imu(const sensor_msgs::Imu::ConstPtr &msg)
{ 
   gyro_x = msg->angular_velocity.x;
   gyro_y = msg->angular_velocity->y;
   gyro_z = msg->angular_velocity->z; 
}

the topic types does not mach.

You must not subscribe to the imu topic as a vector3 type but as a sensor_msgs/Imu type.

In your code, you are subscribing to a topic called "imu" that must have a Vector3 type.

However, in practice the sensor publishes messages on the "imu" topic with type sensor_msgs/Imu. These are the fields of a sensor_msgs/Imu:

std_msgs/Header header
geometry_msgs/Quaternion orientation
float64[9] orientation_covariance
geometry_msgs/Vector3 angular_velocity
float64[9] angular_velocity_covariance
geometry_msgs/Vector3 linear_acceleration
float64[9] linear_acceleration_covariance

You have to take the orientation field (that it is a quaternion) and convert it to euler angles (roll, pitch, yaw)... then you will have the three values you are looking. In order to do that you can use the conversion functions that exist in the "tf" library.

This would be approximately a more correct code:

void handle_imu(const sensor_msgs::Imu::ConstPtr &msg)
{ 
   gyro_x = msg->angular_velocity.x;
   gyro_y = msg->angular_velocity->y;
msg->angular_velocity.y;
   gyro_z = msg->angular_velocity->z; msg->angular_velocity.z; 
}