6.5 RT Tutorials
The Real-Time Tutorials section introduces the Doosan Robot API’s real-time control (RT) and monitoring features. This mode allows users to stream joint or task-space commands and receive real-time data through a dedicated UDP-based communication channel.
These examples demonstrate how to establish an RT connection, configure the transmission parameters, start and stop RT control, and process real-time feedback data.
Tutorial Flow
RT Connection Setup: Establish the real-time control link.
RT Output Configuration: Define control frequency and packet loss tolerance.
Start / Stop RT Control: Enable and disable real-time command streaming.
RT Data Monitoring: Retrieve and log real-time output data (position, velocity, torque).
Speed / Torque Commands (Extension): Apply real-time speed or torque commands for each joint.
Unified Safety Handling: Combine RT loop with safety stop and disconnection recovery.
RT Connection Setup
Purpose
Establish a dedicated UDP communication channel for real-time data exchange
between the robot controller and an external PC.
// Connect using default IP and port
Drfl.connect_rt_control();
// Alternatively, specify a custom host and port
// Drfl.connect_rt_control("192.168.137.100", 12348);
Check
The connection establishes successfully without timeout,
and the controller responds with RT connection acknowledgment.
RT Output Configuration
Purpose
Define the update period and packet loss tolerance for RT communication.
std::string version = "v1.0";
float period = 0.001f; // 1 ms update period
int loss_count = 4; // allowed packet loss count
Drfl.set_rt_control_output(version, period, loss_count);
Check
The robot accepts the configuration and prepares for RT command streaming.
Start / Stop RT Control
Purpose
Start and stop the real-time control loop for command transmission.
// Start streaming
Drfl.start_rt_control();
// Stop streaming after use
Drfl.stop_rt_control();
Check
RT control starts successfully, and robot transitions into real-time operation mode.
Upon stop, the controller safely exits RT mode.
RT Data Monitoring
Purpose
Access and log real-time joint position, velocity, and torque data.
void OnRTMonitoringData(LPRT_OUTPUT_DATA_LIST tData) {
static int count = 0;
if (++count % 500 == 0) {
printf("timestamp: %.3f\\n", tData->time_stamp);
printf("q = %.4f %.4f %.4f %.4f %.4f %.4f\\n",
tData->actual_joint_position[0], tData->actual_joint_position[1],
tData->actual_joint_position[2], tData->actual_joint_position[3],
tData->actual_joint_position[4], tData->actual_joint_position[5]);
printf("q_dot = %.4f %.4f %.4f %.4f %.4f %.4f\\n",
tData->actual_joint_velocity[0], tData->actual_joint_velocity[1],
tData->actual_joint_velocity[2], tData->actual_joint_velocity[3],
tData->actual_joint_velocity[4], tData->actual_joint_velocity[5]);
}
}
// Callback registration
Drfl.set_on_rt_monitoring_data(OnRTMonitoringData);
Check
RT callback outputs continuous joint position, velocity, and torque data at 1 ms intervals.
Speed / Torque Commands (Extension)
Purpose
Send real-time speed or torque commands to each joint during RT mode.
float vel[6] = {0.2, 0.0, 0.0, 0.0, 0.0, 0.0};
float acc[6] = {0.5, 0.5, 0.5, 0.5, 0.5, 0.5};
// Set joint velocity and acceleration in real-time
Drfl.set_velj_rt(vel);
Drfl.set_accj_rt(acc);
// Optional: Cartesian space velocity control
Drfl.set_velx_rt(0.2f, 0.2f);
Drfl.set_accx_rt(0.5f, 0.5f);
Check
The robot follows the specified joint or Cartesian velocity profile
under real-time control without latency.
Unified Safety Handling
Purpose
Integrate RT control with safety stop and reconnection logic for stable long-term operation.
void OnDisconnected() {
printf("[RT] Disconnected from controller. Retrying...\\n");
while (!Drfl.open_connection("192.168.137.100")) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
Drfl.connect_rt_control();
}
void OnMonitoringStateCB(const ROBOT_STATE eState) {
if (eState == STATE_SAFE_STOP || eState == STATE_SAFE_OFF) {
Drfl.stop_rt_control();
Drfl.SetRobotControl(CONTROL_SERVO_ON);
Drfl.start_rt_control();
}
}
Check
When a connection or safety stop occurs,
the RT control automatically resets and resumes without system restart.
Note
Real-time control requires stable network conditions and a controller version that supports UDP-based RT API.
Always verify connection using 6.2 Basic Tutorials and recovery logic from 6.3 Advanced Tutorials before running RT mode.