Rosserial arduino - wrong checksum and mismatched protocol errors
Hi everyone.
My arduino uno is publishing std_msgs/Int16 messages over two topics, one for each wheels encoder ticks. It connects to rosserial on a raspberry pi 4 and data is published just fine, but I see errors/warnings that sometimes interrupt the data. These include:
[INFO] [1597354299.800672]: wrong checksum for topic id and msg
[ERROR] [1597354307.941502]: Mismatched protocol version in packet ('\x00'): lost sync or rosserial_python is from different ros release than the rosserial client
Occasionally, it also looses sync with the arduino:
[ERROR] [1597353144.897853]: Lost sync with device, restarting...
Here is my arduino code:
#include <RedBot.h>
#include <ros.h>
#include <std_msgs/Int16.h>
//ROS
ros::NodeHandle node;
std_msgs::Int16 lWheelMsg;
std_msgs::Int16 rWheelMsg;
ros::Publisher lWheelPub("/lwheel", &lWheelMsg);
ros::Publisher rWheelPub("/rwheel", &rWheelMsg);
//Encoder
const int LEFT_ENCODER_PIN = 9;
const int RIGHT_ENCODER_PIN = 10;
RedBotEncoder encoder = RedBotEncoder(LEFT_ENCODER_PIN, RIGHT_ENCODER_PIN);//left, right
int countsPerRev = 192; // 4 pairs of N-S x 48:1 gearbox = 192 ticks per wheel rev
int16_t lWheelTicks = 0;
int16_t rWheelTicks = 0;
void setup()
{
//initialize ros
node.initNode();
node.advertise(lWheelPub);
node.advertise(rWheelPub);
//reset encoders
encoder.clearEnc(BOTH);
}
void loop()
{
//send encoder data over ROS
lWheelTicks = encoder.getTicks(LEFT);
rWheelTicks = encoder.getTicks(RIGHT);
lWheelMsg.data = lWheelTicks;
rWheelMsg.data = rWheelTicks;
lWheelPub.publish(&lWheelMsg);
rWheelPub.publish(&rWheelMsg);
node.spinOnce();
delay(200);
}
Any idea what could be causing this? Thanks!