Repository navigation
feat(opcua): address node map entries by browse path - #780
Closed
mfaferek93 wants to merge 1 commit into
Closed
mfaferek93 wants to merge 1 commit into
mfaferek93 wants to merge 1 commit into
Conversation
A companion specification fixes BrowseNames and namespace URIs, not NodeIds or namespace indices. A node map entry may now give a browse_path from the Objects folder (namespace aliases, * for a vendor-named instance) instead of a node_id. It is resolved on every new session, so a server that renumbers its namespaces after a restart is followed to the new NodeIds.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical reconnect and namespace-remapping defects can direct reads and writes to unrelated OPC UA variables, producing incorrect telemetry and fault detection.
5 open issues
Suspend unresolved entries to avoid polling stale NodeIds · New Allow NodeId swaps when rebuilding namespace mappings · New Prevent writes until reconnect mapping resolution completes · New Check namespace prefix length before numeric conversion · New Recreate publishers when browse resolution replaces an entry · New
What changed in this PR
Adds browse-path addressing to the OPC-UA plugin, allowing node maps to use specification-defined names and namespace URIs instead of server-specific NodeIds.
Changes:
- Parses namespace aliases and browse paths, including wildcard traversal.
- Resolves mappings before subscriptions and revisits them on reconnect, with publisher re-keying for moved nodes.
- Adds focused unit tests and documents the configuration format.
| File | Description |
|---|---|
src/ros2_medkit_plugins/ros2_medkit_opcua/test/test_browse_path.cpp |
Tests parsing, traversal, pending entries, and remapping. |
src/ros2_medkit_plugins/ros2_medkit_opcua/src/opcua_plugin.cpp |
Integrates session resolution and publisher updates. |
src/ros2_medkit_plugins/ros2_medkit_opcua/src/opcua_client.cpp |
Implements namespace URI lookup. |
src/ros2_medkit_plugins/ros2_medkit_opcua/src/node_map.cpp |
Parses and reconciles browse-addressed entries. |
src/ros2_medkit_plugins/ros2_medkit_opcua/src/address_space_browser.cpp |
Implements bounded traversal with backtracking. |
src/ros2_medkit_plugins/ros2_medkit_opcua/README.md |
Documents browse-path configuration and behavior. |
src/ros2_medkit_plugins/ros2_medkit_opcua/include/ros2_medkit_opcua/opcua_plugin.hpp |
Declares the session-resolution helper. |
src/ros2_medkit_plugins/ros2_medkit_opcua/include/ros2_medkit_opcua/opcua_client.hpp |
Exposes namespace lookup. |
src/ros2_medkit_plugins/ros2_medkit_opcua/include/ros2_medkit_opcua/node_map.hpp |
Defines browse-path data and resolution interfaces. |
src/ros2_medkit_plugins/ros2_medkit_opcua/include/ros2_medkit_opcua/address_space_browser.hpp |
Exposes path resolution and namespace-aware browsing. |
src/ros2_medkit_plugins/ros2_medkit_opcua/CMakeLists.txt |
Registers the browse-path test target. |
Review effort: Balanced
Comment on lines
+1456
to
+1458
| auto node_id = resolve(entry); | ||
| if (!node_id || node_id->toString() == entry.node_id_str) { | ||
| continue; |
Comment on lines
+1461
to
+1465
| if (node_id_index_.count(moved_to) > 0) { | ||
| RCLCPP_WARN(rclcpp::get_logger("opcua.node_map"), | ||
| "browse_path '%s' now resolves to %s, which another entry maps - keeping %s", | ||
| entry.browse_path_str.c_str(), moved_to.c_str(), entry.node_id_str.c_str()); | ||
| continue; |
Comment on lines
+1933
to
+1934
| for (const auto & entry : node_map_.entries()) { | ||
| walk(entry); |
Comment on lines
+1415
to
+1416
| const auto index = std::stoul(prefix); | ||
| if (prefix.size() > 5 || index > 65535) { |
Comment on lines
+1973
to
+1974
| if (resolution.joined > 0) { | ||
| create_value_publishers(); |
Collaborator
Author
|
Superseded by #783, which carries this change as its own commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What
A node map entry can give a
browse_pathinstead of anode_id:Why
Companion specifications (OPC 40010 Robotics, Machinery, PackML, ...) fix the
BrowseNames and the namespace URI of their nodes. They do not fix NodeIds, and
the namespace index is the server's choice, which can change when it restarts.
A map written against one server's NodeIds only fits that server. A browse path
written against the specification fits every server that implements it.
How
<alias>:<BrowseName>with aliases from a newtop-level
namespaces:map,<index>:<BrowseName>, or*for any child (aninstance the vendor names). The last step must be a Variable.
entries()until a sessionresolves it, so the poller never subscribes a null NodeId. It is resolved
after connect, before auto_browse and before the subscribe, and again from
on_connectedon every new session: a path that was missing is retried, anda node that moved (namespaces renumbered) is re-keyed, publisher included.
*, children are tried in browse order with backtracking, first fullmatch wins, capped at 2000 children per path.
node. Fault-code uniqueness covers both kinds of entry at load.
Tests
test_browse_path(13 cases): parsing and its refusals, wildcard walkwith backtracking, namespace matched by URI and not by index, last step must
be a Variable, node budget, waiting entries, replacing an auto-browsed entry,
following a node that moved on the next session, fault-code uniqueness, one
address per entry.
ros2_medkit_opcuactest, read-only build: 28/28.nodesets: entries resolve after a failed first connect, the server restarting
with two more namespaces in front is followed to the new NodeIds, and a link
lost and restored keeps the faults. A gateway without this change skips the
same entries.
Not in this PR
auto_alarmsfolds the SourceNode NodeId string, index included, into thederived fault code, so the same condition gets another code after the
namespaces are renumbered.
the gateway restarts.