speedj_rt

This function controls the joint velocity from an external controller in real time. It allows smooth joint motion control by continuously streaming target velocity and acceleration values through the UDP-based real-time interface.

Definition
DRFLEx.h within class CDRFLEx, public section

bool speedj_rt(float fTargetVel[NUM_JOINT],
               float fTargetAcc[NUM_JOINT],
               float fTargetTime) {
    return _speedj_rt(_rbtCtrlUDP, fTargetVel, fTargetAcc, fTargetTime);
};

Parameter

Parameter Name

Data Type

Default Value

Description

fTargetVel

float[6]

Target joint velocity [deg/s] to be commanded.

fTargetAcc

float[6]

Target joint acceleration [deg/s²].
If set to -10000, acceleration is automatically calculated based on fTargetVel.

fTargetTime

float

Duration of target command [s].

Note

  • Asynchronous command.

  • The motion profile is interpolated to reach (fTargetVel, fTargetAcc) over fTargetTime.

  • If fTargetTime ≤ controller cycle (~1 ms), motion is executed without interpolation.

  • If the next command is not received before reaching fTargetVel, the previous velocity is maintained.

  • On DRCF v3.0 to v3.3, if no new command arrives within 0.1 s, the motion stops with an alarm. On DRCF v3.4 or later and on v2.12.x, the arm keeps the last target velocity until a new command arrives. To detect missing commands, set an input period with set_rt_control_input.

  • If the acceleration exceeds the value set by set_accj_rt, an Info message is generated, at most once per second. The motion is not limited or stopped.

Caution

  • In the current version, this function is not linked with Operation Speed [%].

  • Frequent use with too short intervals may cause communication delay or jerky response.

  • Ensure that fTargetTime > communication cycle for stable performance.

Return

Value

Description

1

The command was sent. This does not confirm that the controller received or applied it.

0

The command datagram could not be sent.

Note

This function is asynchronous. It returns without waiting for the controller to accept or reject the command, so a return value of 1 does not confirm that the robot acted on it. Rejected commands and motion warnings and errors are reported through set_on_log_alarm. set_on_rt_log_alarm reports only RT session messages, so register both callbacks.

Example

#include <chrono>
#include <cmath>
#include <thread>

drfl.connect_rt_control("192.168.137.100", 12347);

std::string version = "v1.0";
float period = 0.001f;  // 1 ms
int lossCount = 4;

// RT configuration
drfl.set_rt_control_input(version, period, lossCount);
drfl.set_rt_control_output(version, period, lossCount);
drfl.start_rt_control();

float fTargetVel[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
float fTargetAcc[6] = {1000.f, 1000.f, 1000.f, 1000.f, 1000.f, 1000.f};
float fTargetTime = 0.05f; // 50 ms

float time = 0.f;
int count = 0;

while (count++ < 3000) {
    // Example: oscillate J1 between ±50 deg/s
    fTargetVel[0] = 50.f * std::sin(count * 0.01f);
    drfl.speedj_rt(fTargetVel, fTargetAcc, fTargetTime);
    std::this_thread::sleep_for(std::chrono::milliseconds(1));
}

drfl.stop_rt_control();
drfl.disconnect_rt_control();

In this example, the joint velocity is continuously commanded in a sinusoidal profile using speedj_rt at 1 ms intervals.

Tips

  • Use speedj_rt for smooth and continuous velocity control of joints.

  • Maintain a fixed update loop (typically 1 kHz) for deterministic motion.

  • For position-based streaming, use servoj_rt instead.