Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

unable to integrate MPU6050 with ros

I am trying to get yaw pitch roll from an MPU6050 imu using the following code(some parts of code removed for clarity). Its getting uploaded

  #include <I2Cdev.h>
  #include <Wire.h>
  #include <MPU6050.h>

  #include <ros.h>
  #include <geometry_msgs/Vector3.h>

  ros::NodeHandle nh;
  geometry_msgs::Vector3 yaw_pitch_roll;
  ros::Publisher pubyaw_pitch_roll("yaw_pitch_roll", &yaw_pitch_roll);

  MPU6050 mpu;

  // Timers
  unsigned long timer = 0;
  float timeStep = 0.01;

  // Pitch, Roll and Yaw values
  float pitch = 0;
  float roll = 0;
  float yaw = 0;

  void setup() 

     //main problem here

  void loop()
    timer = millis();
    yaw_pitch_roll.x = yaw;
    yaw_pitch_roll.y = pitch;
    yaw_pitch_roll.z = roll;
    pubyaw_pitch_roll.publish( &yaw_pitch_roll );


But when i try to run the following command in terminal after uploading:

rosrun rosserial_python /dev/ttyACM0 _baud:=57600

I get the following error:

[ERROR] [1517073128.320418]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

Now, I have run many arduino programs using same configurations( baud_rate) and commands. But this is the only program thats giving me a tough time.

Also when i remove the following line: mpu.calibrateGyro(); the program runs fine.

Can anyone suggest me any workaround for this?

NOTE: I have tried to change the baudrate to 115200 and serial port is also right(other programs run fine) and message is not too big( i have sent the same message in other programs)