Rosservice Kinetic vs Melodic
I'm currently working on a project that was left partly complete by someone else, a while ago. The project is written with ROS Kinetic, but I'd like to make it compatible with melodic too (running on ubuntu 16.04 and 18.04 respectively, both on VMs). I've had some issues, though. Rosservice commands in particular don't work with Melodic, while they do work with Kinetic. I get errors saying "String has no len()" (this is a std_msgs String) but I never called len() in my code! Are there any differences between the implementation of Rosservice that I should be aware of? Sorry if it's something simple; I'm completely new to ROS.
The code:
import rospy
import ethernetcommunicator
import serialcommunicator
from std_msgs.msg import Bool
from std_msgs.msg import Float64
from std_msgs.msg import String
from mswrapper.srv import *
cm = serialcommunicator.Serialcommunicator()
def send_command_callback(data):
return cm.send_command(data.data)
def set_speed_callback(data):
cm.motor_jog(data.data)
def handle_send_command(req):
controller_response = cm.send_command(str(req.command)[6:])
if not controller_response:
controller_response = ""
return SendCommandResponse(String(controller_response))
def loop():
input_1_pub = rospy.Publisher('mswrapper/input_1', Bool, queue_size=10)
rospy.Subscriber('mswrapper/set_speed', Float64, set_speed_callback)
rospy.Subscriber('mswrapper/send_command', String, send_command_callback)
rospy.init_node('asciicom', anonymous=False)
send_command_service = rospy.Service('mswrapper/send_command', SendCommand, handle_send_command)
rate = rospy.Rate(1)
while not rospy.is_shutdown():
input_1_pub.publish(cm.get_input_1())
rate.sleep()
if __name__ == '__main__':
try:
loop()
except rospy.ROSInterruptException:
pass
The error message is quite odd:
ERROR: Unable to send request. One of the fields has an incorrect type:
<type 'exceptions.TypeError'>: 'object of type 'String' has no len()' when writing 'data: 'mtr on''
srv file:
std_msgs/String command
string data
---
std_msgs/String result
string data
As you can see, there is no line number provided, only an error and a printout of my .srv file.
Meanwhile, on the node I'm running this from, I get another error message:
[ERROR] [numbers]: incoming connection failed: unable to receive data from sender, check sender's logs for details
So I have no idea where the error is coming from since I don't get a line number or even a file where this is taking place. Any help would be much appreciated!
Please describe how rosservice "doesn't work". Please check in with the support guideline http://wiki.ros.org/Support#Do
Edited, is this ok?
Can you please update your question with your code?
Code has been added
Does it really say
? I've never seen any error like this. Can you please update your question with the full error (not redacted) and the full code (not abbreviated).
The error numbers change every time...
Correct, but my point was more along the lines of what else are we missing from the error, if anything?
That's the full error. I'll update the whole program if you want.