How to Set Up Read-Only RTDE Client in C++ While Another App Controls the Robot?

Hi all,

I’m working with a Universal Robots robot, and I have a main application running that sends commands and listens to robot feedback using RTDE — meaning it actively uses both input and output recipes.

Now, I want to run a secondary script that only reads values like actual_TCP_pose, without interfering with the main application.

I was able to do this in Python using the RTDE interface. I defined a simple XML configuration with just:
XML

recipe key=“state”
field name=“actual_TCP_pose” type=“VECTOR6D”

This setup works fine — the Python script can read the TCP pose even when the main application is already connected.

However, when I try to do the same using C++, with the Universal Robots Client Library (C++ RTDE client), I encounter issues. Here’s the code snippet:

std::vectorstd::string OUTPUT_RECIPE = { “actual_TCP_pose” };
std::vectorstd::string INPUT_RECIPE = { “input_double_register_0” };

rtde_interface::RTDEClient my_client(robot_ip, notifier, OUTPUT_RECIPE, INPUT_RECIPE, rtde_frequency);

if (!my_client.init())
{
std::cerr << “Failed to initialize RTDE client.” << std::endl;
return 1;
}

Problems I’m facing:

  • If the main control application is running, the C++ script fails to initialize the RTDE client — the init() call fails.
  • If I leave the input recipe empty, the code fails to build.
  • This works perfectly in Python, but not in C++.

To clarify:

Is there a way to configure the UR C++ RTDE client to create a read-only listener, similar to what works in Python?

I don’t necessarily need to connect to port 30004 — I just want to subscribe to output fields like actual_TCP_pose in a way that works without conflicting with the main application that’s already connected to the robot.

How can I achieve this in C++? Any guidance or example would be greatly appreciated!