Arduino published topics do not appear [rosserial_server]
Hello,
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);
nh.initNode();
nh.advertise(arduinoPub);
nh.advertise(Debug);
}
void loop()
{
nh.spinOnce();
calcvel();
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;
Debug.publish(&debug_msg);
arduinoPub.publish(&odom_msg);
}
Asked by anonymous26353 on 2016-09-28 14:12:52 UTC
Comments
No ideas? :(
Asked by anonymous26353 on 2016-09-30 05:23:39 UTC
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)
Asked by JRikken on 2016-09-30 09:47:25 UTC
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.
Asked by anonymous26353 on 2016-09-30 13:05:42 UTC