Arduino published topics do not appear [rosserial_server]

asked 2016-09-28 14:12:52 -0600

Senintel gravatar image


i wrote some code on my Arduino Mega 2560 that reads Quadrature Encoders of my Robot for odometry. For connection i am using rosserial_server. It did work once. But now topics are not publishing anymore. When calling rostopic list arduino_odom and debug topics are not listed. I tried several reboots but nothing seems to help. I also tried to reflash the code onto Arduino.

I hope somebody can help me.

Here is a extract of the code:

    ros::NodeHandle nh;
 // Publish Odometry from Arduino
  geometry_msgs::Twist odom_msg;
  ros::Publisher arduinoPub ("arduino_odom", &odom_msg);

   //Publisher for Debugging
 geometry_msgs::Twist debug_msg;
 ros::Publisher Debug ("debug", &debug_msg);

void setup()
 pinMode(leftencoderA, INPUT); 
 pinMode(leftencoderB, INPUT); 
 digitalWrite(leftencoderA, HIGH);                // turn on pullup resistor
 digitalWrite(leftencoderB, HIGH);
 attachInterrupt(1, leftencoder, RISING);

 pinMode(rightencoderA, INPUT); 
 pinMode(rightencoderB, INPUT); 
 digitalWrite(rightencoderA, HIGH);                // turn on pullup resistor
 digitalWrite(rightencoderB, HIGH);
 attachInterrupt(0, rightencoder, RISING);



void loop()
  odom_msg.linear.x  = LeftVelocity;
  odom_msg.linear.y  = RightVelocity;

  debug_msg.linear.x = leftenc;
  debug_msg.linear.y = rightenc;

  debug_msg.angular.x = LeftVelocity;
  debug_msg.angular.y = RightVelocity;


edit retag flag offensive close merge delete


No ideas? :(

Senintel gravatar imageSenintel ( 2016-09-30 05:23:39 -0600 )edit

Could you send the output of rosserial_server? You could try specifying baud rate and serial device. See this especially the serial device number changes sometimes without apparent reason... (arduino could be /dev/ttyACM1, while default is /dev/ttyACM0)

JRikken gravatar imageJRikken ( 2016-09-30 09:47:25 -0600 )edit

Thanks for your tips. I tried to specify some parameters with no success. Still no topics.

Somehow it works perfect with Rosserial python implementation. So i will work python for now.

Senintel gravatar imageSenintel ( 2016-09-30 13:05:42 -0600 )edit