Giter Site home page Giter Site logo

Comments (13)

dirk-thomas avatar dirk-thomas commented on June 28, 2024

It looks like the primitive array struct lacks the necessary documentation. Please take a look at the similar struct for strings (https://github.com/ros2/rosidl/blob/8f507b9a656eea1a7ed196b34d7fa5bd1311052e/rosidl_generator_c/include/rosidl_generator_c/string.h#L23-L30). The capacity contains the actually allocated size of data. Size contains the number of valid entries in the array.

In the case where all your elements contain valid data both numbers are equal. But in the case of a dynamically filled array capacity might be bigger then size.

I should use the provided functions to initialize / finalize any array: https://github.com/ros2/rosidl/blob/8f507b9a656eea1a7ed196b34d7fa5bd1311052e/rosidl_generator_c/include/rosidl_generator_c/primitives_array_functions.h#L30-L36

from rcl.

firesurfer avatar firesurfer commented on June 28, 2024

Perhaps I got another bug. Perhaps I'm using the function the wrong way.

I got the following struct:

typedef struct test_msgs__msg__Dummy
{
  bool thisisabool;
  int8_t thisisaint8;
  uint8_t thisiauint8;
  int16_t thisisaint16;
  uint16_t thisisauint16;
  int32_t thisisaint32;
  uint32_t thisisauint32;
  int64_t thisisaint64;
  uint64_t thisisauint64;
  float thisafloat32;
  double thisisfloat64;
  rosidl_generator_c__String thisisastring;
  rosidl_generator_c__String thisisanotherstring;
  rosidl_generator_c__int8__Array thisisaint8array;
} test_msgs__msg__Dummy;

As described above I'm using .net P/Invoke on the rcl_publish function to publish this struct from C#.
I got a subscription in a c++ client running that simply prints out all values of the message. All the primitive members and the strings are working fine, but the array is making troubles.

The c++ client dies with the above mentioned exception:

terminate called after throwing an instance of 'eprosima::fastcdr::exception::NotEnoughMemoryException'
  what():  Not enough memory in the buffer stream

I ensured that the rosidl_generator_c__int8__Array is correctly passed into the native code, by adding some debug code to the rcl_publish function.

rcl_publish(const rcl_publisher_t * publisher, const void * ros_message)
{
  test_msgs__msg__Dummy * dummyStruct = (test_msgs__msg__Dummy*)ros_message;
  puts("Some native debug output:");
  printf("Pointer: %u  \n",dummyStruct->thisisaint8array.data);
  printf("Array size: %u \n", dummyStruct->thisisaint8array.size);
  printf("Array capacity: %u \n", dummyStruct->thisisaint8array.capacity);

The memory address and the size/capacity values are the same as on the C# side.
For example: I got an int8 array with one element: In this case size and capacity should both be one?
I' sure that I'm passing the correct data to the rcl_publish function.

from rcl.

wjwwood avatar wjwwood commented on June 28, 2024

How big are you making the array? It may be that the current rmw implementation for FastRTPS doesn't support messages that are that large. We're actively working on that here:

ros2/rmw_fastrtps#51

You can try to see if that is the issue by making the arrays smaller or by trying Connext or OpenSplice with your example.

from rcl.

firesurfer avatar firesurfer commented on June 28, 2024

Sorry for the late answer. I had some trouble with the email notifications.

I tested my wrapper with an int8_t array with 1,2 and 3 elements. This should'nt be to large. Publishing the same message from C++ over FastRTPS works.

from rcl.

dirk-thomas avatar dirk-thomas commented on June 28, 2024

Without more information it is hard to suggest anything specific. Maybe try to break in the beginning of the serialization code to check what exact data it is trying to serialize (https://github.com/eProsima/ROS-RMW-Fast-RTPS-cpp/blob/e336a8b0f93c8179cc2b4a62d02272403ed356bb/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport_impl.h#L309-L472). That might help in narrowing down where the problem is.

from rcl.

firesurfer avatar firesurfer commented on June 28, 2024

I think I found the problem. I think it's located in the message deserialisation:
I put a debug output to: https://github.com/eProsima/ROS-RMW-Fast-RTPS-cpp/blob/e336a8b0f93c8179cc2b4a62d02272403ed356bb/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport_impl.h#L497
which prints out printf("Size: %u \n", member->array_size_);.In my case this array_size is 0. This shouldn't be a problem because I'm using a dynamic allocated array.
But apparently there's no case which handles arrays with a dynamic size like in deserialization function for c++.

from rcl.

dirk-thomas avatar dirk-thomas commented on June 28, 2024

@richiprosima It looks like the mentioned case is missing for the C type support. Can you please suggest a fix for this or create a PR.

from rcl.

esteve avatar esteve commented on June 28, 2024

This should already be addressed in #45

On Aug 31, 2016 18:15, "Dirk Thomas" [email protected] wrote:

@richiprosima https://github.com/richiprosima It looks like the
mentioned case is missing for the C type support. Can you please suggest a
fix for this or create a PR.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#77 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AACDVFKZUu8l6INMoVEnGDwzaWwsuzfdks5qlba8gaJpZM4JtKkN
.

from rcl.

esteve avatar esteve commented on June 28, 2024

Sorry, I meant ros2/rmw_fastrtps#45

On Aug 31, 2016 18:32, "Esteve Fernandez" [email protected] wrote:

This should already be addressed in #45

On Aug 31, 2016 18:15, "Dirk Thomas" [email protected] wrote:

@richiprosima https://github.com/richiprosima It looks like the
mentioned case is missing for the C type support. Can you please suggest a
fix for this or create a PR.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#77 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AACDVFKZUu8l6INMoVEnGDwzaWwsuzfdks5qlba8gaJpZM4JtKkN
.

from rcl.

dirk-thomas avatar dirk-thomas commented on June 28, 2024

@esteve It looks like the referenced PR needs to be rebased and has one pending comment. Once it is mergable again I can trigger new CI builds for it.

from rcl.

esteve avatar esteve commented on June 28, 2024

I responded to your comment regarding printf in
ros2/rmw_fastrtps#45 (comment)

Though I agree with you about removing the printf calls, I also want to
be consistent with what seems to be eProsima's codestyle guidelines.
@richiprosima, are you ok with removing the printf calls when catching an
exception? Do you have codestyle guidelines about this or the printf
calls are just a personal preference?

On Aug 31, 2016 18:48, "Dirk Thomas" [email protected] wrote:

@esteve https://github.com/esteve It looks like the referenced PR needs
to be rebased and has one pending comment. Once it is mergable again I can
trigger new CI builds for it.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#77 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AACDVHG4GiSEnP9xqonPlyyW0EA-UYN7ks5qlb1MgaJpZM4JtKkN
.

from rcl.

richiprosima avatar richiprosima commented on June 28, 2024

Go on removing printf. It is not about codestyle. Surely I forgot to remove it.

from rcl.

firesurfer avatar firesurfer commented on June 28, 2024

I think this can be closed because it was addressed in: ros2/rmw_fastrtps#45

from rcl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.