webots
webots copied to clipboard
Improve Node Field Query API
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_protowb_supervisor_proto_get_type_namewb_supervisor_proto_get_parentwb_supervisor_proto_get_fieldwb_supervisor_proto_get_field_by_indexwb_supervisor_proto_get_number_of_fieldswb_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_fieldwb_supervisor_node_get_proto_field_by_index->wb_supervisor_node_get_base_node_field_by_indexwb_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 the proto 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
- [x] Allow Webots to keep track of internal proto parameters
- [x] Allow internal proto parameters to be accessed from the C supervisor API
- [x] Ensure that updates to internal proto fields are propagated to the supervisor
- [x] Add tests for the new API methods
- [x] Propagate supervisor API changes to other languages
- [x] Update the C++ API
- [x] Update the Java API
- [x] Update the Python API
- [x] Update the Matlab API
- [x] Update
WbLanguage.cppwith the new api methods
- [x] Update references to the renamed API methods throughout the codebase
- ~~[ ] Add a sample usage demo~~ After looking at the existing samples, I found that there is currently no sample for and of the
wb_supervisor_node_get_proto_fieldmethods. 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). - [x] Update ROS
- [x] Update the ROS Controller (cyberbotics/webots_ros#151)
- [x] Add services for the new API methods & update existing services
- [x] Add tests for the new API methods
- ~~[ ] Update the ROS2 Controller~~ (Looks like this is automatically done by an action)
- ~~[ ] Update the webots submodule~~
- [x] Update the ROS Controller (cyberbotics/webots_ros#151)
- [x] Update the documentation
- [x] Update documentation relating to the renamed methods and clarify the distinction between them
- [x] Add documentation for the new API methods
- [x] Update the changelog
Documentation Supervisor API