-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use array instead of List for ROS message types #165
base: dashing
Are you sure you want to change the base?
Conversation
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
* Avoid nullptr access when converting from Java arrays to C arrays * Make sure Java arrays are initialized Signed-off-by: Jacob Perron <jacob@openrobotics.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep make use of a List
backed by an array to get both the performance and the nice API.
@ivanpauno Thanks for the review 🙂
I'm open to suggestions for how to make this work, but my understanding is that the performance hit is unavoidable when converting from primitive types to their corresponding boxed type. The key improvement here is in 9a65235, where we use |
Ah, I missed that part, makes sense. I'm not sure if the change from |
In which context are you referring to? In the context of code generation, we could generate different code depending if the type is a primitive or not, but I opted for consistency, for example, consider the following ROS message definitions: Foo.msg
Bar.msg
IMO, it would be odd if In the context of the rcljava API calls, I don't have a strong opinion. I can add back methods for accepting/returning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change sounds reasonable, but we're replacing a relocatable array with an array of immutable length, which isn't that nice to handle and doesn't match what happens in cpp and python.
I'm not sure if there's a way of getting both the performance and the nice API.
(for fixed size IDL arrays, this is surely a better match)
This could also make use of an extra pair of eyes, as I had a hard time reviewing some parts of the empy templates.
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but considering that this is a hard breaking change it might be worth waiting until @esteve can take a look.
It might be also worth considering what for example the DDS java mapping does (e.g. rti connext docs), they use arrays like int[]
for IDL fixed size arrays, but a custom generated type for IDL sequences and bounded sequences.
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
I've added note about performance to the docblock of *AsLIst methods (0729503). |
@ivanpauno thanks for looping me in. If you guys are ok with the API changes, then I'm ok too :-) Thanks @jacobperron for all the work. |
why not merge into main branch? |
This builds on #151.
Switching from
java.util.List
to arrays significantly improves performance when converting from C to Java types.Though, for some applications it is still nice to use a list so I've added a convenience methods for getting and setting the value as a
List
(df08714). I've still opted for having the default getter method return an array type to encourage users to use arrays, since converting to aList
is not very efficient.