python service cannot return int32[]
Hi all,
I'm trying to create a package (in Python) which contains a service that returns int32[] named 'ids'. Unfortunately it throws two exceptions in two scenarios:
- The Python's list contains 1 item. The exception: "NameError: global name '_x' is not defined:
- The Python's list contains more than 1 item. The exception: "Invalid number of arguments, args should be ['ids'] args are(1, 2)"
Please help!
FindItems.srv:
string type
string xml_data
---
int32[] ids
service:
import rospy
from pengo_srvs.srv import *
def on_find_items(req):
return [1, 2, 3]
if __name__ == '__main__':
node_name = "knowledge_representation"
rospy.init_node(node_name, anonymous=True)
service = rospy.Service("kr/find_items", FindItems, on_find_items)
rospy.spin()
client:
import rospy, os, time
from pengo_srvs.srv import *
if __name__ == '__main__':
node_name = "knowledge_representation_test"
rospy.init_node(node_name, anonymous=True)
service_name = "kr/find_items"
rospy.wait_for_service(service_name)
findItemsProxy = rospy.ServiceProxy(service_name, FindItems)
nodeIDs = findItemsProxy.call("Node", "cvc")
Regards, Slava
Please provide source code.
Done. Thanks!