For information on the latest version, please have a look at 1.33.5.
6.2 Basic Tutorials
The Basic Tutorials section provides simple, self-contained examples to help users understand and verify the fundamental operations of the Doosan Robotics API. Each topic focuses on one essential function — such as establishing a connection, enabling servos, performing basic motions, or running a short DRL script — allowing users to confirm correct API behavior step by step before moving on to advanced control.
These examples are intentionally minimal and demonstrate the core command flow without additional logic or threading. For complete scenario-based examples, refer to 6.6 Scenario-based Examples.
Tutorial Flow
Connection & Callback Registration: Connect to the robot controller and set up monitoring callbacks.
Access Control & ServoOn: Obtain control authority and enable servo motors.
Jog & Home: Verify joint-level and homing motions.
MoveJ / MoveL (Sync & Async): Execute basic motion primitives.
DRL Mini Loop: Run and stop a simple DRL script safely.
I/O Basics: Test digital output toggling on the control box.
Each subsection below contains a concise code snippet and a key verification point.
Connection & Callback Registration
Purpose
Connect to the controller and register monitoring callbacks to receive robot state updates and alarms.
#include "DRFLEx.h"
#include <iostream>
#include <thread>
#include <chrono>
using namespace DRAFramework;
CDRFLEx Drfl;
// Minimal callbacks (extend them in your application)
void OnMonitoringStateCB(const ROBOT_STATE eState) { std::cout << "State: " << eState << "\n"; }
void OnMonitroingAccessControlCB(const MONITORING_ACCESS_CONTROL eAccess) { std::cout << "Access control: " << eAccess << "\n"; }
void OnLogAlarm(LPLOG_ALARM pLogAlarm) { std::cout << "Alarm: " << pLogAlarm->_iIndex << "\n"; }
void OnMonitoringDataCB(const LPMONITORING_DATA pData) { (void)pData; }
void OnMonitoringDataExCB(const LPMONITORING_DATA_EX pData) { (void)pData; }
int main()
{
Drfl.set_on_monitoring_state(OnMonitoringStateCB);
Drfl.set_on_monitoring_access_control(OnMonitroingAccessControlCB);
Drfl.set_on_log_alarm(OnLogAlarm);
Drfl.set_on_monitoring_data(OnMonitoringDataCB);
Drfl.set_on_monitoring_data_ex(OnMonitoringDataExCB);
if (!Drfl.open_connection("192.168.137.100")) {
std::cout << "Failed to connect to controller.\n";
return -1;
}
Drfl.setup_monitoring_version(1);
SYSTEM_VERSION ver{};
Drfl.get_system_version(&ver);
std::cout << "System: " << ver._szController << "\n";
std::cout << "Library: " << Drfl.get_library_version() << "\n";
return 0;
}
Check
Connection succeeds and callbacks respond to robot events such as state or alarm updates.
Access Control & ServoOn
Purpose
Acquire control authority and activate the robot’s servo motors.
void OnTpInitializingCompleted() {
Drfl.manage_access_control(MANAGE_ACCESS_CONTROL_FORCE_REQUEST);
}
// After GRANT:
if (!Drfl.set_robot_mode(ROBOT_MODE_AUTONOMOUS)) return -1;
if (!Drfl.set_robot_system(ROBOT_SYSTEM_REAL)) return -1;
Drfl.set_robot_control(CONTROL_SERVO_ON);
Check
Control authority is granted, the robot state transitions to STANDBY,
and ServoOn completes without alarms.
Jog & Home
Purpose
Verify motion control by performing a short jog and homing sequence.
// Jog example
Drfl.jog(JOG_AXIS_JOINT_1, MOVE_REFERENCE_BASE, 0.0f); // stop jog
// Home example
Drfl.move_home(MOVE_HOME_MECHANIC, (unsigned char)1);
Check
Jog and Home operations execute normally without triggering safety stops.
MoveJ / MoveL (Sync / Async)
Purpose
Test basic motion primitives in joint and Cartesian space,
and verify the stop function under asynchronous control.
// Example: small incremental motion
// Drfl.movej(targetJ, vel, acc); // Sync
// Drfl.movel(targetX, vel, acc); // Sync
// Async execution and stop
// Drfl.amovej(targetJ, vel, acc);
Drfl.stop(STOP_TYPE_SLOW);
Check
Motions execute successfully and stop safely when commanded.
DRL Mini Loop (Start / Stop)
Purpose
Run a simple DRL script and confirm that it executes and stops safely.
const std::string drl =
"loop = 0\n"
"while loop < 3:\n"
" movej(posj(10,10,10,10,10,10), vel=30, acc=30)\n"
" movej(posj(0,0,0,0,0,0), vel=30, acc=30)\n"
" loop += 1\n";
// Start DRL
// Drfl.drl_start(ROBOT_SYSTEM_REAL, drl);
// Stop the DRL program (quick stop, normal forced stop)
Drfl.drl_stop(STOP_TYPE_QUICK);
Drfl.mwait(); // wait for controller acknowledgment
Check
The DRL loop runs for the specified iterations or stops on command.
I/O Basics (Control Box DO)
Purpose
Toggle a digital output on the control box to verify basic I/O operation.
Drfl.set_digital_output(GPIO_CTRLBOX_DIGITAL_INDEX_10, true);
std::this_thread::sleep_for(std::chrono::seconds(1));
Drfl.set_digital_output(GPIO_CTRLBOX_DIGITAL_INDEX_10, false);
Check
The digital output toggles correctly (verified via indicator lamp, relay, or tester).
Note
The examples in this section are simplified demonstrations of each core API. For complete scenario-based examples integrating multiple features, refer to 6.6 Scenario-based Examples.