-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Improve Node Field Query API #6613
Improve Node Field Query API #6613
Conversation
…feature-improve-node-field-query-api
(this shouldn't be necessary because if the parent ref is invalidated, the child should've been as well, but it's good practice)
…eature-improve-node-field-query-api
tests/api/controllers/supervisor_import_remove_mf/supervisor_import_remove_mf.c
Show resolved
Hide resolved
tests/api/controllers/supervisor_notify_import_remove_mf/supervisor_notify_import_remove_mf.c
Outdated
Show resolved
Hide resolved
I'm ok with relying on the test coverage. |
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.
Excellent work!
@omichel, I've reviewed and approved but am not a maintainer so you, or someone else who is, needs to approve in order to get it merged. |
Co-authored-by: Olivier Michel <Olivier.Michel@cyberbotics.com>
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.
Thank you!
And thanks also to @brettle for the nice review!
Description
Allows accessing the internal fields of a proto hierarchy from a supervisor controller. There's still a lot of work to be done to integrate this into Webots, but now that I have a working proof-of-concept, I'm opening this PR to keep track of the remaining tasks.
This PR introduces the following new supervisor API functions:
wb_supervisor_node_get_proto
wb_supervisor_proto_get_type_name
wb_supervisor_proto_get_parent
wb_supervisor_proto_get_field
wb_supervisor_proto_get_field_by_index
wb_supervisor_proto_get_number_of_fields
wb_supervisor_proto_is_derived
These act on the new type
WbProtoRef
.Additionally, the following function has been added for
WbFieldRef
objects:wb_supervisor_field_get_actual_field
Finally, the following functions have been renamed for clarity:
wb_supervisor_node_get_proto_field
->wb_supervisor_node_get_base_node_field
wb_supervisor_node_get_proto_field_by_index
->wb_supervisor_node_get_base_node_field_by_index
wb_supervisor_node_get_number_of_proto_fields
->wb_supervisor_node_get_number_of_base_node_fields
UPDATE (Aug 19): After looking through the usages of the above methods, I've noticed that the
wb_supervisor_node_get_field
(and related) methods are used much more than theproto
variants. Thus, I've decided to keep its functionality the same in order to minimize the amount of code that will need to be updated in existing controllers. I've renamed the other methods appropriately (and updated the above text). To see the originals, check the edit history of this comment.Related Issues
This pull-request fixes issue #6354.
Tasks
WbLanguage.cpp
with the new api methods[ ] Add a sample usage demoAfter looking at the existing samples, I found that there is currently no sample for and of thewb_supervisor_node_get_proto_field
methods. Thus, I'm not sure what I good sample for a purely introspective API would look like. For the moment, I'll assume that the advice to write samples is indented for more simulation-facing features (e.g. devices).[ ] Update the ROS2 Controller(Looks like this is automatically done by an action)[ ] Update the webots submoduleDocumentation
Supervisor API