JuanLassoVelasco
JuanLassoVelasco

Reputation: 11

Mismatched protocol version in packet Error: lost sync or rosserial_python is from different ros release than the rosserial client

I am using a raspberry pi 4 mode B to interface communicate with a Teensy 4.0. I'm using ROS noetic on Ubuntu 20.04. I've flashed the code to the Teensy successfully using platformio. I have a problem, however, when I try and launch the calibration python script for the robot I'm working on. I'm interfacing the raspberry Pi with the Teensy through the GPIO pins (this is after I've flashed the code to the Teensy, I flashed it through usb). When I run the calibration script using roslaunch mini_ros spot_calibration I get the following error:

[servo_calibration-1] process has died [pid 4841, exit code 1, cmd /home/ubuntu/spark_ws/src/spot_mini_mini/mini_ros/src/servo_calibration __name:=servo_calibration __log:=/home/ubuntu/.ros/log/fa068172-32ea-11ec-b45a-513494152363/servo_calibration-1.log].
log file: /home/ubuntu/.ros/log/fa068172-32ea-11ec-b45a-513494152363/servo_calibration-1*.log
[ERROR] [1634874547.846356]: Mismatched protocol version in packet (b'\xf8'): lost sync or rosserial_python is from different ros release than the rosserial client

below is the python code in spot_calibration

#!/usr/bin/env python
"""
DESCRIPTION:
SUBSCRIBERS:
"""

from __future__ import division
import rospy
from mini_ros.srv import CalibServo, CalibServoResponse
from mini_ros.msg import JointPulse
import numpy as np

import sys

import rospkg
rospack = rospkg.RosPack()

sys.path.append(rospack.get_path('mini_ros') + '/../')

sys.path.append('../../')


class ServoCalibrator():
    def __init__(self):

        rospy.init_node('ServoCalibrator', anonymous=True)

        self.serv = rospy.Service('servo_calibrator', CalibServo,
                                  self.calib_service_cb)
        self.jp_pub = rospy.Publisher('spot/pulse', JointPulse, queue_size=1)

    def calib_service_cb(self, req):
        """ Requests a servo to be moved to a certain position
            Args: req
            Returns: response
        """
        try:
            jp_msg = JointPulse()

            jp_msg.servo_num = req.servo_num
            jp_msg.servo_pulse = req.servo_pulse

            self.jp_pub.publish(jp_msg)
            response = "Servo Command Sent."
        except rospy.ROSInterruptException:
            response = "FAILED to send Servo Command"
        return CalibServoResponse(response)


def main():
    """ The main() function. """
    srv_calib = ServoCalibrator()
    rospy.loginfo(
        "Use The servo_calibrator service (Pulse Width Unit is us (nominal ~500-2500))."
    )
    while not rospy.is_shutdown():
        rospy.spin()


if __name__ == '__main__':
    try:
        main()
    except rospy.ROSInterruptException:
        pass

The package was supposedly made in ROS Melodic, so that might be why it's throwing the error, but I don't know what to change if the package is melodic exclusive.

Upvotes: 1

Views: 5958

Answers (1)

BTables
BTables

Reputation: 4843

The problem is indeed because the roslib package used by rosserial was build for Melodic. As you can guess this error is just caused because of mismatched version ids coming from the arduino side. The best option would be to rebuild ros_lib for Noetic.

To rebuild ros_lib all you have to do is navigate to your sketchbook and run make_libraries.py. Note that this will build up to the currently installed distro, so you need to run this on a machine that has Noetic installed.

cd <sketchbook>/libraries
rm -rf ros_lib
rosrun rosserial_arduino make_libraries.py .

If rebuilding isn't an option you can add the definitions manually. On the arduino side you'll have a ros_lib folder. You have two sub directories you need to change.

The first is ./ros/node_handle.h. At the top of the file you'll see a few protocol versions defined as const uint8_t. Add in the version id for noetic as const uint8_t PROTOCOL_VER6 = 0xfa; then change the line that states what version should be used. const uint8_t PROTOCOL_VER = PROTOCOL_VER6;.

Lastly, you just need to make this same change in ./ros_lib/ros/node_handle.h

Upvotes: 0

Related Questions