Skip to content

Commit

Permalink
Improve Node Field Query API (#6613)
Browse files Browse the repository at this point in the history
* fix typo

* send proto ancestry to controllers

* expose proto ancestry in controller api

* send proto ancestry in all relevant messages

* relocate proto data to WbProto

* rename WbProto to WbNodeProtoInfo

* revert last two commits

* keep track of internal proto fields

* basic supervisor proto implementation

* swap meanings of wb_supervisor_node_get_field and wb_supervisor_node_get_parameter

* use an array list rather than a linked list for keeping track of node proto parents

* allow supervisor to query protos from Webots

* use correct read_only behavior

* fix get_proto api

* update supervisor/Webots field query api

* fix Makefile

* fix return reference to temporary

* supervisor fixes

* more supervisor fixes

* fix variable name

* fix field get value impl

* fix controller field lookup

* fix get number of fields/parameters

* fix function name

* fix wb_supervisor_proto_get_parent

* better handling of hidden parameters

* remove wb_supervisor_node_get_proto_ancestor

* revert 30953fc...01e067d

* remove accidental deletion

* fix indentation

* forward proto field lookups to the actual parameters

* fix typo

* update supervisor_notify_import_remove test

* null safety

* add proto tests

* fix C_SUPERVISOR_FIELD_GET_FROM_NAME implementation

* test fixes

* update supervisor_proto test

* fix supervisor_proto_fields compilation errors

* fix proto import paths

* fix bracket type

* fix memory leak

* remove unused SolidProtoHierarchy.children field (#6630)

* add additional log info

* bugfix to previous commit

* step the simulation after setting field values

* fix null return value in wb_supervisor_proto_get_number_of_parameters

* fix actual parameter lookup in proto parameter lookup functions

* use wb_supervisor_node_get_from_proto_def to retrieve the internal node

* fix def name

* fix proto names in test

* initialize struct members to NULL

* initialize node proto_info to NULL

* update expected proto hierarchy

* increment loop counter

* alternate method of determining the actual parameter of a field

* initialize field to NULL

* fix SolidProtoHierarchyBase

* use correct parameter retrieval method

* use internal=true for proto parameter lookups

* fix bug when retrieving the first field of a proto

* fix base node field query

* refresh internal node reference after regeneration

* fix internal_proto nullity check

* fix base node field lookup error messages

* fix retrieval of internal node fields

* don't expect changes in read-only fields

* use correct check value in read-only assertion

* don't check non-existent parameters

* fix array in if condition

* add wb_supervisor_proto_is_derived

* fix wb_proto_is_derived

* update c++ api

* fix variable name conflict

* add Node::getProto and update style

* update java api

* add todo

* update python api

* update the matlab api

* use camelCase in python api

* add wb_supervisor_proto_is_derived to python and matlab apis

* update WbLanguage.cpp

* rename methods for clarity

* fix circular dependency

* fix other circular dependency

* unset allow_search_in_proto

* swap field read only logic

* update proto_get_parent method name

* update references to renamed supervisor methods

* update ros api

* run clang-format

* fix cppcheck warnings

* fix Controller.def method names

* fix function name

* python formatting

* ros fixes

* run clang-format

* more ros fixes

* pin empy version

* bump webots_ros

* bump webots_ros

* bump webots_ros

* bump webots_ros

* fix lua syntax

* account for proto regeneration in test suite

* verify field integrity before checking lookup_field

* run clang-format

* don't return invalid proto references

* fix FieldImportBase proto definition

* fix race condition (see long commit message)
Before this commit, the code would update one of the fields, wait one timestep, and verify the change while updating the next field (two separate controllers). However, because the field updates regenerated the node, this led some references used in the check to be invalidated during the check. This was not an issue before, because no internal fields were used in the previous version of the test (so nothing was invalidated). This commit adds an additional step to each field update so that the check gets its own timestep. This means that the node is no longer regenerated while its being validated.

* use snake_case in supervisor_notify_import_remove_mf

* get rid of FieldImportBase

* use spaces instead of tabs

* cleanup proto map

* run clang-format

* remove const for consistency

* make wb_supervisor_proto_get_type_name(NULL) return "" for consistency

* update documentation

* fix references to old proto field access methods

* run clang-format

* fix proto regeneration check

* update the changelog

* bug fixes

* always get fields by name

* run clang-format

* remove explicit field name array size

* Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows (#6652)

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v3...v4.1.7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* add comment

* Bump actions/upload-artifact to v4 (#6654)

* include proto id in field query when processing value get requests

* check for proto parent validity instead of just NULL
(this shouldn't be necessary because if the parent ref is invalidated, the child should've been as well, but it's good practice)

* fix variable name

* add changelog entry for matlab method signature change

* fix test assert message

* formatting

* fix types in supervisor documentation

Co-authored-by: Olivier Michel <[email protected]>

* add missing references to wb_supervisor_node_get_proto

* fix ros service ids in documentation

* add wb_supervisor_node_get_proto to Controller.def

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dean Brettle <[email protected]>
Co-authored-by: Olivier Michel <[email protected]>
  • Loading branch information
4 people authored Sep 7, 2024
1 parent 737e1f4 commit 7f9f56a
Show file tree
Hide file tree
Showing 52 changed files with 2,220 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_suite_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
run: |
export WEBOTS_HOME=$PWD/artifact/webots
export ROS_DISTRO=${{ matrix.ROS_DISTRO }}
python -m pip install rospkg catkin_pkg empy defusedxml netifaces
python -m pip install rospkg catkin_pkg empy==3.3.4 defusedxml netifaces
Xvfb :99 &
export DISPLAY=:99
./tests/ros.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_suite_linux_develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ jobs:
run: |
export WEBOTS_HOME=$PWD/artifact/webots
export ROS_DISTRO=${{ matrix.ROS_DISTRO }}
python -m pip install rospkg catkin_pkg empy defusedxml netifaces
python -m pip install rospkg catkin_pkg empy==3.3.4 defusedxml netifaces
Xvfb :99 &
export DISPLAY=:99
./tests/ros.sh
Expand Down
10 changes: 5 additions & 5 deletions docs/reference/changelog-r2020.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Released on September 1st, 2020.
- Remove scaling factor in matrix returned by [`wb_supervisor_node_get_orientation`](supervisor.md#wb_supervisor_node_get_orientation) ([#2112](https://github.com/cyberbotics/webots/pull/2112)).
- Fixed conversion of identity matrix to quaternion in ROS API ([#2112](https://github.com/cyberbotics/webots/pull/2112)).
- Fixed header stamps of the topics published by the ROS controller ([#2127](https://github.com/cyberbotics/webots/pull/2127)).
- Fixed the [`camera/recognition_objects`](camera.md#wb_camera_recognition_get_objects) ROS topic not published when the [`camera/image`](camera.md#wb_camera_recognition_get_objects) topic has no subscriber ([#2115](https://github.com/cyberbotics/webots/pull/2115)).
- **macOS: Removed the `ros` controller**, the [custom Python ROS controller](https://www.cyberbotics.com/doc/guide/using-ros#custom-ros-controller) should be used instead ([#2053](https://github.com/cyberbotics/webots/pull/2053)).
- Fixed the [`camera/recognition_objects`](camera.md#wb_camera_recognition_get_objects) ROS topic not published when the [`camera/image`](camera.md#wb_camera_recognition_get_objects) topic has no subscriber ([#2115](https://github.com/cyberbotics/webots/pull/2115)).
- **macOS: Removed the `ros` controller**, the [custom Python ROS controller](https://www.cyberbotics.com/doc/guide/using-ros#custom-ros-controller) should be used instead ([#2053](https://github.com/cyberbotics/webots/pull/2053)).
- Fixed DEF node not found if defined in PROTO default parameter value ([#2107](https://github.com/cyberbotics/webots/pull/2107)).
- Fixed crash occurring with some PROTO nodes when modifying fields from the scene tree that trigger the PROTO model regeneration ([#2100](https://github.com/cyberbotics/webots/pull/2100)).
- Fixed field changes not applied in case of nested [PROTO](proto.md) nodes ([#2063](https://github.com/cyberbotics/webots/pull/2063)).
- Windows: Fixed generation of procedural PROTO nodes using the `gd` module ([#2070](https://github.com/cyberbotics/webots/pull/2070)).
- Fixed the [vision](../guide/samples-howto.md#vision-wbt) sample simulation ([#2143](https://github.com/cyberbotics/webots/pull/2143)).
- Fixed bugs in streaming server protocol and added support for X3D/MJPEG mode selection in simulation server ([#2077](https://github.com/cyberbotics/webots/pull/2077)).
- Linux: Fixed the execution of robot controllers with firejail ([#2071](https://github.com/cyberbotics/webots/pull/2071)).
- Linux: Fixed the execution of robot controllers with firejail ([#2071](https://github.com/cyberbotics/webots/pull/2071)).
- Fixed the `roadBorderWidth` field of the `HelicoidalRoadSegment` PROTO node ([#2099](https://github.com/cyberbotics/webots/pull/2099)).
- Fixed the `near` field of the `Robotino3Webcam` [Camera](camera.md) ([#2051](https://github.com/cyberbotics/webots/pull/2051)).
- Fixed orientation of the [Lights](light.md) in the `robotino3` world ([#2051](https://github.com/cyberbotics/webots/pull/2051)).
Expand All @@ -51,7 +51,7 @@ Released on July 29th, 2020.
- New Features
- Added a [Mesh](mesh.md) node allowing to use external 3D file in Webots ([#1419](https://github.com/cyberbotics/webots/pull/1419)).
- Added the possibility to import [3D Studio mesh](https://wiki.fileformat.com/3d/3ds), [Blender](https://www.blender.org/), [Biovision Hierarchy](https://en.wikipedia.org/wiki/Biovision_Hierarchy), [Collada](https://en.wikipedia.org/wiki/COLLADA), [Filmbox](https://wiki.fileformat.com/3d/fbx/), [STL](https://en.wikipedia.org/wiki/STL_(file_format)), [Wavefront](https://wiki.fileformat.com/3d/obj), [X3D](https://www.web3d.org/getting-started-x3d) files in Webots ([#1463](https://github.com/cyberbotics/webots/pull/1463)).
- Added two new functions to get internal PROTO node fields: [`wb_supervisor_node_get_from_proto_def`](supervisor.md#wb_supervisor_node_get_from_proto_def) and [`wb_supervisor_node_get_proto_field`](supervisor.md#wb_supervisor_node_get_proto_field) ([#1331](https://github.com/cyberbotics/webots/pull/1331)).
- Added two new functions to get internal PROTO node fields: [`wb_supervisor_node_get_from_proto_def`](supervisor.md#wb_supervisor_node_get_from_proto_def) and [`wb_supervisor_node_get_proto_field`](supervisor.md#wb_supervisor_node_get_base_node_field) ([#1331](https://github.com/cyberbotics/webots/pull/1331)).
- Added the `mjpeg` web streaming mode ([#1352](https://github.com/cyberbotics/webots/pull/1352)).
- Exposed global texture maximum filtering as a parameter in the Webots preferences ([#1851](https://github.com/cyberbotics/webots/pull/1851)).
- Added a [`wb_robot_get_urdf`](robot.md#wb_robot_get_urdf) function to the [Robot](robot.md) node which allows URDF export ([#1706](https://github.com/cyberbotics/webots/pull/1706)).
Expand Down Expand Up @@ -105,7 +105,7 @@ Released on July 29th, 2020.
- Fixed crash when setting an invalid value to a field that triggers the parent PROTO regeneration ([#1868](https://github.com/cyberbotics/webots/pull/1868)).
- Fixed crash when converting a PROTO node to Base node(s) if contained in a field that triggers the parent PROTO regeneration ([#1868](https://github.com/cyberbotics/webots/pull/1868)).
- Fixed crash when deleting a node contained in a field that triggers the parent PROTO regeneration ([#1868](https://github.com/cyberbotics/webots/pull/1868)).
- Fixed crash occurring when reloading or resetting a simulation containing a [Display](display.md) device ([#1865](https://github.com/cyberbotics/webots/pull/1865)).
- Fixed crash occurring when reloading or resetting a simulation containing a [Display](display.md) device ([#1865](https://github.com/cyberbotics/webots/pull/1865)).
- Fixed crash with Python [`RangeFinder.rangeImageGetDepth`](rangefinder.md#wb_range_finder_image_get_depth) function ([#1858](https://github.com/cyberbotics/webots/pull/1858)).
- Fixed mismatch between the bounding object and visual shape of the [UnevenTerrain](https://www.cyberbotics.com/doc/guide/object-floors#uneventerrain), **and removed the `textureScale` field** ([#1792](https://github.com/cyberbotics/webots/pull/1792)).
- Fixed crash when using a [Normal](normal.md) node in a PROTO node ([#1813](https://github.com/cyberbotics/webots/pull/1813)).
Expand Down
7 changes: 7 additions & 0 deletions docs/reference/changelog-r2024.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ Released on December **th, 2023.
- Removed support for macOS 11 "Big Sur" and added support for macOS 14 "Sonoma" ([#6580](https://github.com/cyberbotics/webots/pull/6580)).
- Added the `indirectFieldAccess` tag to allow the `fields` variable to be used in proto templates without referencing a specific field ([#6614](https://github.com/cyberbotics/webots/pull/6614)).
- Added a method to include all subtypes of a node type in a PROTO field restriction ([#6574](https://github.com/cyberbotics/webots/pull/6574)).
- Improved the node field query api ([#6613](https://github.com/cyberbotics/webots/issues/6613)).
- **Renamed the `wb_supervisor_node_get_proto_*` methods to `wb_supervisor_node_get_base_node_*`**
- **Renamed the `proto` field in the `supervisor_node_get_field_*` ROS services to `queryBaseNode`**
- Added the `WbProtoRef` type to the supervisor API.
- Added the ability to query the internal structure and fields of a proto node.
- Added the ability to query the field in the scene tree that corresponds to a proto internal field.
- Fixed the method signature of `wb_supervisor_node_get_number_of_fields` in MATLAB.
- Removed support for Lua as a PROTO scripting language ([#6642](https://github.com/cyberbotics/webots/pull/6642)).
- Enhancements
- Improved the image range of the rotating [Lidar](lidar.md) ([#6324](https://github.com/cyberbotics/webots/pull/6324)).
Expand Down
Loading

0 comments on commit 7f9f56a

Please sign in to comment.