Skip to content
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

Unable to integrate OpcUARoboticsNodeSet of OPCFoundation #6011

Open
5 of 7 tasks
madeleineKa opened this issue Sep 11, 2023 · 1 comment
Open
5 of 7 tasks

Unable to integrate OpcUARoboticsNodeSet of OPCFoundation #6011

madeleineKa opened this issue Sep 11, 2023 · 1 comment

Comments

@madeleineKa
Copy link

Description

We are trying to add the OpcUADiNodeSet2 and the OpcUARoboticsNodSet2 of Umati/OPCFoundation to the OPC UA server of our robotic system.
The OpcUADiNodeSet2 is integrated successfully and shown in the structure in UA Expert as well as our internal opc ua functionality.
But the OpcUARoboticsNodSet2 is not yet visible, though we don't have any build errors. Only when we are editing the server.cpp file with UA_Server_addObjectNode (according to the sample server example) the object with its direct children is shown, but not the children's children.
Is it necessary to add all objects manually in the server.cpp or should the content of the OpcUARoboticsNodSet2.xml structure be shown by integration to the CMakesLists.txt?

Background Information / Reproduction Steps

  1. Add OpcUADiNodeSet2.xml and OpcUARoboticsNodSet2.xml and their respective csv and bsd files to an existing OPC UA server.
  2. Add the following lines to the CMakeLists.txt:
set(UA_NAMESPACE_MAP_DI
  "2:http:https://opcfoundation.org/UA/DI/"
)
set(UA_NAMESPACE_MAP_ROBOTICS
  "2:http:https://opcfoundation.org/UA/Robotics/"
)

# First build DI Nodeset as Robotics Nodeset depends on it
ua_generate_nodeset_and_datatypes(
  NAME di
  FILE_CSV ${UA_MODEL_DIR}/Opc.Ua.Di.NodeIds.csv
  FILE_BSD ${UA_MODEL_DIR}/Opc.Ua.Di.Types.bsd
  FILE_NS ${UA_MODEL_DIR}/Opc.Ua.Di.NodeSet2.xml
  NAMESPACE_MAP "${UA_NAMESPACE_MAP_DI}"
  TARGET_PREFIX "${PROJECT_NAME}"
  INTERNAL
)

add_library(ua_gen_di)
target_sources(
    ua_gen_di
    PRIVATE # cmake-format: sort
            ${PROJECT_BINARY_DIR}/src_generated/open62541/di_nodeids.h ${UA_NODESET_DI_HEADERS}
            ${UA_NODESET_DI_SOURCES} ${UA_TYPES_DI_HEADERS} ${UA_TYPES_DI_SOURCES}
)
target_link_libraries(ua_gen_di PUBLIC open62541::open62541)

# Build Robotics nodeset 
ua_generate_nodeset_and_datatypes(
  NAME robotics
  FILE_CSV ${UA_MODEL_DIR}/Opc.Ua.Di.NodeIds.csv
  FILE_BSD ${UA_MODEL_DIR}/Opc.Ua.Di.Types.bsd
  FILE_NS ${UA_MODEL_DIR}/Opc.Ua.Di.NodeSet2.xml
  NAMESPACE_MAP "${UA_NAMESPACE_MAP_ROBOTICS}"
  TARGET_PREFIX "${PROJECT_NAME}"
  DEPENDS di
  INTERNAL
)
add_library(ua_gen_robotics)
target_sources(
   ua_gen_robotics
   PRIVATE # cmake-format: sort
           ${PROJECT_BINARY_DIR}/src_generated/open62541/robotics_nodeids.h
           ${UA_NODESET_ROBOTICS_HEADERS}
           ${UA_NODESET_ROBOTICS_SOURCES}
           ${UA_TYPES_ROBOTICS_HEADERS}
           ${UA_TYPES_ROBOTICS_SOURCES}
)
target_link_libraries(ua_gen_robotics PUBLIC ua_gen_di open62541::open62541)

add_executable(<executable_name>
  # Path to cpp files 
)
target_link_libraries(<executable_name> PRIVATE
  # Other libraries
  ua_gen_di
  ua_gen_robotics
  open62541::open62541
)

3.Add following lines of code to server.cpp:

#include "open62541/di_nodeids.h"
#include "open62541/namespace_di_generated.h"
#include "open62541/types_di_generated_handling.h"
#include "open62541/robotics_nodeids.h"
#include "open62541/namespace_robotics_generated.h"
#include "open62541/types_robotics_generated_handling.h"

server_ = UA_Server_newWithConfig(config_);

UA_StatusCode retval;

  // Add server configuration to DI namespace
  retval = namespace_di_generated(server_);
  if(retval != UA_STATUSCODE_GOOD) {
    logf(logger::Level::ERROR, "Could not add di nodeset to server. Error code: %d", retval);
    std::string errorMessage = "Could not add di nodeset to server. Error code: " + std::to_string(retval);
    throw std::runtime_error(errorMessage);
  }

  // Add server configuration Robotics namespace
  retval |= namespace_robotics_generated(server_);
  if(retval != UA_STATUSCODE_GOOD) {
    logf(logger::Level::ERROR, "Could not add robotics nodeset to server. Error code: %d", retval);
    std::string errorMessage = "Could not add robotics nodeset to server. Error code: " + std::to_string(retval);
    throw std::runtime_error(errorMessage);
  }
  1. With the following lines of code in the cpp file, the object and its children are shown in the tree:
auto nsid_robotics = UA_Server_addNamespace(server_, "http:https://opcfoundation.org/UA/Robotics/");
auto nsid_di = UA_Server_addNamespace(server_, "http:https://opcfoundation.org/UA/DI/");
UA_StatusCode status;
UA_ObjectAttributes objAttr = UA_ObjectAttributes_default;
 
UA_NodeId nodeIdMotionDeviceSystem;
status = UA_Server_addObjectNode(
    server_,
    UA_NODEID_NUMERIC(nsid_robotics, 0),
    UA_NODEID_NUMERIC(nsid_di, UA_DIID_DEVICESET),
    UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
    UA_QUALIFIEDNAME(1, const_cast<char*>("MotionDeviceSystem")),
    UA_NODEID_NUMERIC(nsid_robotics, UA_ROBOTICSID_MOTIONDEVICESYSTEMTYPE),
    objAttr,
    NULL,
    &nodeIdMotionDeviceSystem);
if (status != UA_STATUSCODE_GOOD) {
    throw std::runtime_error("Add motionDeviceSystem object failed.");
}

Used CMake options:

-DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_ENCRYPTION=ON -DUA_NAMESPACE_ZERO=FULL

Checklist

Please provide the following information:

  • open62541 Version (release number or git tag): 1.3.6 (also tested with 1.3.7)
  • Other OPC UA SDKs used (client or server): UA Expert
  • Operating system: Linux
  • Logs (with UA_LOGLEVEL set as low as necessary) attached
  • Wireshark network dump attached
  • Self-contained code example attached
  • Critical issue
@jpfr
Copy link
Member

jpfr commented Sep 14, 2023

@andreasebner please check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants