0
$\begingroup$

I'm trying to populate a service response array in a Python coded service node and I'm getting an assertion violations from one of the IDL generated files. The service Service.srv definition is the following:

string req
---
my_interfaces/MyCustomResponse[] resp

Where MyCustomResponse.msg is defined as following:

int64 an_id

The runtime error is something like:

python3: /projects/my_proj/build/my_interfaces/rosidl_generator_py/my_interfaces/msg/_my_custom_response_s.c:53: my_interfaces__msg__my_custon_response__convert_from_py: Assertion `strncmp("my_interfaces.msg._my_custom_response.MyCustomResponse", full_classname_dest, 54) == 0' failed.

If I remove the array to make the response just a simple MyCustomResponse response, everything works fine. Are there any issues with the arrays of custom messages in Python written services (the C++ counterpart works fine).

Thanks.

$\endgroup$
1
  • $\begingroup$ Please consider sharing exactly how you're using it in a minimal example to get the best help. $\endgroup$ Commented Sep 16, 2024 at 8:57

1 Answer 1

0
$\begingroup$

can you update your Python service advertiser (callback) function like this for a test.

def service_callback(self, request, response):
    # Populate the response array
    response.resp = []  # Initialize the array

    for i in range(5):  # Example of adding 5 items to the array
        custom_resp = MyCustomResponse()
        custom_resp.an_id = i
        response.resp.append(custom_resp)  # Add to the response array

    return response
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.