Issues with Arduino: Wrong checksum, Mismatched protocol version
I am trying to run base controller on an arduino uno, which will run the motors by subscribing to topics for left and right motor speeds which come through the Twist messages, and also publishes encoder values to topics /lwheel
and /rwheel.
When I run the arduino rosserial by connecting it to my PC, there is no problem and everything works fine.
However, when I connect the uno to my raspberry pi, which is connected to my PC, problems occur. I notice the following messages and errors on my terminal running the command rosrun rosserial_python serial_node.py /dev/ttyACM0
:
[INFO] [1577335551.127150]: Connecting to /dev/ttyACM0 at 57600 baud
[INFO] [1577335553.249219]: Requesting topics...
[INFO] [1577335553.290434]: Note: publish buffer size is 512 bytes
[INFO] [1577335553.298687]: Setup publisher on lwheel [std_msgs/Float32]
[INFO] [1577335553.321495]: Setup publisher on rwheel [std_msgs/Float32]
[INFO] [1577335553.348951]: Note: subscribe buffer size is 512 bytes
[INFO] [1577335553.357481]: Setup subscriber on left_wheel_speed [std_msgs/Float32]
[INFO] [1577335553.386113]: Setup subscriber on right_wheel_speed [std_msgs/Float32]
[INFO] [1577335556.177063]: wrong checksum for topic id and msg
[INFO] [1577335559.040959]: wrong checksum for topic id and msg
[ERROR] [1577335561.888282]: Mismatched protocol version in packet ('\x00'): lost sync or rosserial_python is from different ros release than the rosserial client
[INFO] [1577335561.896526]: Protocol version of client is unrecognized, expected Rev 1 (rosserial 0.5+)
[INFO] [1577335564.716741]: wrong checksum for topic id and msg
[ERROR] [1577335579.781605]: Lost sync with device, restarting...
[INFO] [1577335579.790889]: Requesting topics...
[INFO] [1577335579.826395]: Setup publisher on lwheel [std_msgs/Float32]
[INFO] [1577335579.839117]: Setup publisher on rwheel [std_msgs/Float32]
[INFO] [1577335582.842464]: wrong checksum for msg length, length 4
[INFO] [1577335582.850964]: chk is 0
These messages are repeated over and over. I also notice weird behavior in the robot itself. There is random latency between my key press and actual movement, and the longer I press the key, the longer it continues that movement "after" I release the key.
I thought it might be an issue with the uno's dynamic memory size. So I shifted to arduino mega. It uses 28% of its dynamic memory, but I face the same issue with Arduino Mega. I don't think its an issue with buffer as well, because it works well when connected directly to the PC. I am running Ubuntu 16.04 and ROS Kinetic on PC, and Ubuntu Mate 18.04 and ROS Melodic on Raspberry Pi Model 3 B. Can that be the cause? If yes, then why isn't that causing problems when I have no publishers? (The uno works perfectly well when the code is just subscribing to speed topics and running motors, even when connected to pi).
Arduino Code:
#include <ros.h>
#include <std_msgs/Float32.h>
#include "Arduino.h"
ros::NodeHandle nh;
// Left encoder
int Left_Encoder_PinA = 2;
int Left_Encoder_PinB = 9;
volatile long Left_Encoder_Ticks = 0;
//Variable to read current state of left encoder pin
volatile bool LeftEncoderBSet;
//Right Encoder
int Right_Encoder_PinA = 3;
int Right_Encoder_PinB = 10;
volatile ...
I'm not an arduino expert, but you appear to be using
Serial
androsserial
at the same time, with the same serial port.That is not supported.
Remove the
Serial.begin()
andSerial.println(..)
calls and try again.Hi @gvdhoorn that wasn't a problem when just running motors. However, I'll try that
@gvdhoorn I tried your suggestion, but still the same problem.
Regardless of whether it solves your problem, you cannot use
Serial
together withrosserial
. Unless you've changed the serial hwrosserial
should use (on the Arduino side, not the ROS side).