You're reading the documentation for an older, but still supported version (1.33.4).
For information on the latest version, please have a look at 1.33.5.

connect_rt_control

This function establishes a UDP/IP connection between the external PC and the robot controller to enable Real-time External Control (RT) communication.
This channel is independent of the original TCP/IP API, and control authority does not apply to it.
For the integrated controller (v3), versions v3.3 or below can be connected to 192.168.137.50.

Definition
DRFLEx.h within class CDRFLEx, public section

bool connect_rt_control(string strIpAddr = "192.168.137.100",
                        unsigned int usPort = 12347) {
    return _connect_rt_control(_rbtCtrlUDP, strIpAddr.c_str(), usPort);
};

Parameter

Parameter Name

Data Type

Default Value

Description

strIpAddr

string

"192.168.137.100"

Target controller IP address for the UDP connection. Pass the controller address as a dotted IPv4 string (for example "192.168.137.100").

usPort

unsigned int

12347

Port number for RT communication (default UDP port).

Return

Value

Description

1

The controller answered the connect request. The function also returns 1 when the UDP socket cannot be opened, so a return of 1 does not confirm the connection; check that the time_stamp returned by read_data_rt advances after start_rt_control.

0

connect_rt_control has already opened the RT channel once in this process, on this or any other CDRFLEx object, including when disconnect_rt_control has been called since; the library prints Already connected. The function also returns 0 when the connect request cannot be sent.

Caution

  • The RT channel can be connected once per process. After the first call that opens the UDP socket, every later call returns 0, also after disconnect_rt_control. To connect the RT channel again, restart the application.

  • If the UDP socket opens but the controller does not answer, for example because the IP address or port is wrong, or because another RT client is already connected to the controller, the call does not return. Check that the controller is reachable and that no other RT client is connected before calling this function.

Typical usage

  • Connect before configuring RT control input/output schema and period.

  • Used as the first step of any real-time joint or task control loop.

Note

  • Real-time external control uses UDP/IP communication, not TCP/IP.

  • This channel runs independently of the TCP/IP API connection. It has no commands for control authority or safety settings; use the TCP/IP API for those.

  • On integrated controllers (v3.x) up to v3.3, the RT server accepts connections on every controller address, including 192.168.137.50. From v3.4, it accepts them only on the API address (default 192.168.137.100).

  • Default configuration supports 1-to-1 UDP communication between controller and external PC.

  • When the controller ends the RT session, it reports an alarm to the set_on_rt_log_alarm callback, and RT data stops.

  • RT has no disconnect notification. To detect a lost RT link, check that time_stamp in read_data_rt or the RT callback keeps advancing.

Example

// Connect to the robot controller via UDP for RT control
if (drfl.connect_rt_control("192.168.137.100", 12347)) {
    printf("RT connection established successfully.\n");

    // Ready to configure input/output schema and start RT streaming
    drfl.start_rt_control();
}
else {
    printf("RT connection failed.\n");
}

In this example, the function establishes a UDP connection with the controller to prepare for real-time motion control or high-frequency data exchange. Once connected, users can call start_rt_control to begin RT streaming.

Tips

  • Ensure the robot is powered and reachable on the specified IP before calling this function.

  • Close the RT channel gracefully using disconnect_rt_control after operations.

  • In real-time applications, this step should be followed by setting the input/output version and period using set_rt_control_input and set_rt_control_output.