Open pfarinha91 opened 1 month ago
What does your custom message look like?
Because the function does check if the types are lists of primitive types, and then recursively calls itself on individual elements.
I'd also first confirm under which conditions the data becomes a NumPy array here, and see where there is a fixable bug before adding this special case.
Thanks for your answer.
This happens with a message type that defines an array of another custom message:
# ObjectArray.msg
std_msgs/Header header
test_msgs/Object[] objects
# Object.msg
uint32 id
std_msgs/Header header
geometry_msgs/Pose pose
test_msgs/Classification[] classification
test_msgs/Dynamics dynamics
uint32[] observers
bool is_observer
The test_msgs here is just a dummy name for my interface package, but this is basically its structure.
I'd also first confirm under which conditions the data becomes a NumPy array here, and see where there is a fixable bug before adding this special case.
I don't know where it becomes a numpy.array, the messages are generated with rosidl_generate_interfaces.
From what I can see in message_conversion.py
that has the default extract_values
/ extract_json_values
function, the list_types
definition includes np.ndarray
, deals with it in the code and converts to list.
list_types = [list, tuple, np.ndarray, array.array]
But on extract_cbor_values
on cbor_conversion.py
the list_types
only include list
and tuple
, and it does not deal with numpy arrays.
LIST_TYPES = [list, tuple]
Description
By using
Roslibjs
to subscribe to topics usingCBOR
compression, I'm having aRosbridge
error with some custom messages. I can subscribe to standard messages with the compression, but not some of my custom ones, particularly when containing vectors of other custom messages.humble
branch.Humble
Ubuntu 22.04
Expected Behavior
All messages arriving through
Roslibjs
on the wep application, whenCBOR
compression is requested.Actual Behavior
The messages don't arrive, and
Rosbridge
prints the following error:I don't know where this
numpy.array
comes from since my nodes areC++
. I'm guessing is some conversion toPython
on the message generators in between.Possible solution
I was able to got it to work, but I'm unsure of the solution. Or, if the problem is caused by another completely different issue and this workaround is not the best approach.
On
cbor_conversion.py
, I added to the beginning ofextract_cbor_values
function:And imported numpy. The final result being:
It seems to be working for every message I request, and my custom messages are being processed much faster with the
compression='cbor'
flag now.Any tips or suggestions?
Thanks!