ROS service: problem passing parameters

asked 2016-08-25 12:54:47 -0600

San gravatar image

My service file is as follows:

float64[] sample
---
float64[] classify_probs

When I try to pass a numpy array of type float64 to the server, It gives me an error which is:

in check_type
raise SerializationError('field %s must be a list or tuple type'%field_name)
genpy.message.SerializationError: field sample must be a list or tuple type

I understood that I have to pass a list or tuple, so I converted the numpy array to a list as

temp_sample = testData.tolist()

and now it gives me the following error:

_check_types
raise SerializationError(str(exc))
genpy.message.SerializationError: <class 'struct.error'>: 'required argument is not a float' when writing 'sample:

The tolist() method converts the numpy array to a list with nearest compatible python type (in this case, it is a float). My question: is it possible to preserve the float64 type when converting to a list?

I tried changing my service file to "float" and ROS is not allowing it. Only float32 and float64 are allowed. Any help in this regard is much appreciated.

edit retag flag offensive close merge delete