subscribe to imu <Solved>
hi i am trying to subscribe to an imu data the imu is connected to arduino mega when i run arduino it work fine and when i see the topic there is an imu data that is publish and i can see it change but when i try to subscribe to it i git this error [WARN] [WallTime: 1466005750.393726] Could not process inbound connection: topic types do not match: [geometry_msgs/Vector3] vs. [sensor_msgs/Imu]{'topic': '/imu', 'tcp_nodelay': '0', 'md5sum': '4a842b65f413084dc2b10fb484ea7f17', 'type': 'geometry_msgs/Vector3', 'callerid': '/base_controller_node'} i use indigo
i subscribe as follow:
void handle_imu( const geometry_msgs::Vector3 angular_velocity) {
gyro_x = angular_velocity.x;
gyro_y = angular_velocity.y;
gyro_z = angular_velocity.z; }
and in the arduino code i use
#include <sensor_msgs imu.h=""> i need to know is there any other way to subscribe to imu and why this problem occure thanks i wish you can help.
this is how i subscribe to the imu :
int main(int argc, char** argv){
ros::init(argc, argv, "base_controller");
ros::NodeHandle n;
ros::NodeHandle nh_private_("~");
ros::Subscriber sub = n.subscribe("rpm", 50, handle_rpm);
ros::Subscriber imu_sub = n.subscribe("imu", 50, handle_imu);
ros::Publisher odom_pub = n.advertise<nav_msgs::odometry>("odom", 50);
tf::TransformBroadcaster broadcaster;
i need to git the the angular velocity
note: i tried this void handle_imu(const sensor_msgs::Imu::ConstPtr &angular_velocity)
{ gyro_x = angular_velocity->x;
gyro_y = angular_velocity->y;
gyro_z = angular_velocity->z; } and i got the following msg
r: ‘const struct sensor_msgs::Imu_<std::allocator<void> >’ has no member named ‘x’ { gyro_x = angular_velocity->x; ^ /home/owner/catkin_ws/src/beginner_tutorials/src/base_controller.cpp:43:28: error: ‘const struct sensor_msgs::Imu_<std::allocator<void> >’ has no member named ‘y’ gyro_y = angular_velocity->y; ^ /home/owner/catkin_ws/src/beginner_tutorials/src/base_controller.cpp:45:28: error: ‘const struct sensor_msgs::Imu_<std::allocator<void> >’ has no member named ‘z’ gyro_z = angular_velocity->z;