Roban2 Docs
Development InterfacesRoban2 C++ SDK Interfaces

Robot Locomotion and Controller Interfaces

This page documents Roban2's movement velocity, posture height, stop, controller management, and runtime lifecycle interfaces. The current SDK does not expose a separate public API for "gait name" or "gait switching", so this document does not carry over the related descriptions from the old SDK.

VR Input Velocity

1. Function Description

publishVrVelocityCmd() publishes VR teleoperation velocity input to the control chain; subscribeVrVelocityCmd() subscribes to the same input data stream. This is the commonly used velocity interface in Quest/VR teleoperation scenarios.

2. SDK and Header File

  • SDK: lejusdk-vr
  • Header file: <lejusdk-vr/lejusdk_vr.h>

3. Request or Message Type

bool publishVrVelocityCmd(const leju::vr::VrVelocityCmd& cmd);
void subscribeVrVelocityCmd(leju::vr::VrVelocityCmdCallback callback);

4. Field Description

FieldUnitDirection definition
linear_xm/sPositive value moves forward
linear_ym/sPositive value moves left
angular_zrad/sPositive value rotates counterclockwise about the Z axis
timestampsTimestamp

5. Return Value

  • publishVrVelocityCmd(): returns true on success, false on failure.
  • subscribeVrVelocityCmd(): no return value.

6. Prerequisites

  • RobanVRAPI has been initialized, and the runtime and the current controller are in a state where they can receive velocity input.
  • The publishing frequency and velocity range should conform to the current controller configuration; the public data types do not define a unified clamping value, and this document does not assume one.
  • To stop moving, publish an all-zero velocity; do not substitute "stop publishing" for a zero-velocity command.

7. C++ Example

leju::vr::VrVelocityCmd cmd;
cmd.linear_x = 0.10;
cmd.linear_y = 0.0;
cmd.angular_z = 0.0;
if (!vr.publishVrVelocityCmd(cmd)) return 1;

// 停止移动
cmd = {};
vr.publishVrVelocityCmd(cmd);

8. Corresponding Repository Example

  • SDK example: src/lejusdk/examples/src/lejusdk-vr/03_velocity_cmd.cpp
  • VR teleoperation usage: src/leju-vr-control/src/quest_vr_abs_control_node.cpp

The SDK example uses KuavoVRAPI to demonstrate the general workflow; for Roban2, replace it with RobanVRAPI.

Controller Final Velocity

1. Function Description

publishVelocityCmd() publishes the controller's final velocity command, and subscribeVelocityCmd() subscribes to that data stream. It has the same numeric fields as VrVelocityCmd, but belongs to a different DDS topic and input stage.

2. SDK and Header File

  • SDK: lejusdk-vr
  • Header file: <lejusdk-vr/lejusdk_vr.h>

3. Request or Message Type

bool publishVelocityCmd(const leju::vr::VelocityCmd& cmd);
void subscribeVelocityCmd(leju::vr::VelocityCmdCallback callback);

4. Field Description

VelocityCmd contains linear_x, linear_y, angular_z, and timestamp, with the same units and coordinate directions as VrVelocityCmd. The corresponding DDS topic is /rt/cmd_vel; the VR input corresponds to /rt/vr/cmd_vel.

5. Return Value

The publish method returns bool; the subscribe method has no return value.

6. Prerequisites

  • Use this interface only when the application explicitly needs to publish the final velocity to /rt/cmd_vel.
  • For VR teleoperation secondary development, use publishVrVelocityCmd(), and do not use both velocity streams as control inputs at the same time.

7. C++ Example

leju::vr::VelocityCmd cmd;
cmd.linear_x = 0.0;
cmd.linear_y = 0.0;
cmd.angular_z = 0.0;
const bool sent = vr.publishVelocityCmd(cmd);

8. Corresponding Repository Example

Currently src/lejusdk/examples/ does not contain a standalone user example for publishVelocityCmd(). The public interface is defined by installed/include/lejusdk-vr/vr_api/vr_base.h and installed/include/lejusdk-vr/data_types.h.

Posture Height Control

1. Function Description

publishPostureHeightCmd() publishes a standing height target to the posture controller of ExternalInterface, for body height adjustment.

2. SDK and Header File

  • SDK: lejusdk-lowlevel
  • Header file: <lejusdk-lowlevel/leju_sdk.h>

3. Request or Message Type

bool publishPostureHeightCmd(double height_m);

4. Field Description

height_m is the target standing height, in meters. The examples in the public header are 0.77 for full standing and 0.56 for a deep squat; the actual usable range must be based on the current Roban2 configuration.

5. Return Value

Returns true on success, false on failure.

6. Prerequisites

  • The runtime and the current controller are running, and the posture controller can handle this input.
  • Use a height range permitted by the current robot model configuration, and change the target gradually.

7. C++ Example

// 数值仅演示公开接口的单位,使用前核对当前机型限制。
const bool sent = robot.publishPostureHeightCmd(0.77);

8. Corresponding Repository Example

  • src/leju-vr-control/src/quest_vr_abs_control_node.cpp
  • Public declaration: installed/include/lejusdk-lowlevel/robot_api/robot_base.h

Stopping the Robot

1. Function Description

publishStopRobot() publishes a low-level stop command. This operation is not semantically the same as setting the movement velocity to zero: the former stops the robot program/hardware chain, while the latter keeps the control program running but stops walking.

2. SDK and Header File

  • SDK: lejusdk-lowlevel
  • Header file: <lejusdk-lowlevel/leju_sdk.h>

3. Request or Message Type

bool publishStopRobot();

4. Field Description

No request fields. Internally, the SDK publishes a stop message to /rt/hardware/stop.

5. Return Value

Returns true on success, false on failure.

6. Prerequisites

  • The caller has confirmed that the entire robot control chain needs to be stopped, not just movement.
  • Programs should not treat this DDS command as the sole substitute for a physical emergency stop.

7. C++ Example

if (!robot.publishStopRobot()) {
  std::cerr << "停止指令发布失败\n";
}

8. Corresponding Repository Example

  • src/leju-controllers/leju-keyboard-controller/motor_keyboard_ctrl.cpp
  • src/leju-vr-control/src/quest_vr_abs_control_node.cpp

Controller State Query

1. Function Description

getControllerState() synchronously queries the current controller, the mode of each body part, the switching transition state, and the list of controllers actually provided by the server.

2. SDK and Header File

  • SDK: lejusdk-vr
  • Header file: <lejusdk-vr/lejusdk_vr.h>

3. Request or Message Type

bool getControllerState(leju::vr::ControllerState& state,
                        int timeout_ms = 3000);

4. Field Description

FieldTypeDescription
current_controllerstd::stringName of the current controller
arm_mode, head_mode, waist_modeControlModeControl mode of each body part
controller_transitioningboolWhether a switch transition is in progress
available_controllersstd::vector<std::string>Names of the controllers currently available on the server

5. Return Value

Returns true and populates state on success; returns false on timeout or service failure.

6. Prerequisites

  • RobanVRAPI has been initialized, and the controller state DDS-RPC service has started.
  • The value returned by available_controllers should be authoritative; do not guess or hard-code controller names in the application.

7. C++ Example

leju::vr::ControllerState state;
if (!vr.getControllerState(state)) return 1;
std::cout << "current: " << state.current_controller << '\n';
for (const auto& name : state.available_controllers) {
  std::cout << "available: " << name << '\n';
}

8. Corresponding Repository Example

  • src/lejusdk/examples/src/lejusdk-vr/04_get_state.cpp
  • src/lejusdk/examples/src/lejusdk-vr/08_controller_cli.cpp

Both examples follow the general VR API workflow; when using them with Roban2, replace it with RobanVRAPI.

Switching Controllers

1. Function Description

switchController() requests the controller manager to switch to the specified controller.

2. SDK and Header File

  • SDK: lejusdk-vr
  • Header file: <lejusdk-vr/lejusdk_vr.h>

3. Request or Message Type

bool switchController(const std::string& controller_name,
                      std::string* message = nullptr,
                      int timeout_ms = 3000);

4. Field Description

  • controller_name: target controller name, which should come from getControllerState().available_controllers.
  • message: optional output parameter that receives a success message or the failure reason.
  • timeout_ms: RPC timeout, default 3000 ms.

5. Return Value

Returns true if the switch request succeeds, and false on failure or timeout.

6. Prerequisites

  • The target name is in the current available_controllers.
  • The robot is in a safe state that permits switching, and controller_transitioning is false.
  • After switching, query the state again; do not judge subsequent capabilities solely by the return value of a single RPC.

7. C++ Example

leju::vr::ControllerState state;
if (!vr.getControllerState(state) || state.available_controllers.empty()) return 1;

std::string message;
if (!vr.switchController(state.available_controllers.front(), &message)) {
  std::cerr << message << '\n';
  return 2;
}

8. Corresponding Repository Example

  • src/lejusdk/examples/src/lejusdk-vr/08_controller_cli.cpp
  • src/leju-controllers/leju-rl-controller/tools/controller_switch_cli.cpp

Runtime State and Start/Stop

1. Function Description

getRuntimeState() queries the raw data, hardware, and lifecycle states; startRuntime() and stopRuntime() request starting or stopping the runtime.

2. SDK and Header File

  • SDK: lejusdk-vr
  • Header file: <lejusdk-vr/lejusdk_vr.h>

3. Request or Message Type

bool getRuntimeState(leju::vr::RuntimeState& state,
                     int timeout_ms = 3000);
bool startRuntime(std::string* message = nullptr, int timeout_ms = 3000);
bool stopRuntime(std::string* message = nullptr, int timeout_ms = 3000);

4. Field Description

RuntimeState fields:

FieldTypeDescription
data_readyboolWhether the input data stream is ready
hardware_stateleju::vr::HardwareStatekUnknown, kInitializing, kReadyOk, kError, kStopped
lifecycle_stateleju::vr::LifecycleStatekWaitingForReady, kWaitingForStart, kRunning, kExiting

message receives the text description returned by the start/stop service, and timeout_ms defaults to 3000 ms.

5. Return Value

All three methods return true on success, and false if the service is unavailable, the call times out, or the request is rejected.

6. Prerequisites

  • The runtime DDS-RPC service has been registered by the control program.
  • Request a start only when data_ready=true, hardware_state=kReadyOk, and lifecycle_state=kWaitingForStart.
  • stopRuntime() changes the state of the entire control runtime; it is not used for ordinary zero-velocity stopping.

7. C++ Example

leju::vr::RuntimeState state;
if (!vr.getRuntimeState(state)) return 1;

if (state.data_ready &&
    state.hardware_state == leju::vr::HardwareState::kReadyOk &&
    state.lifecycle_state == leju::vr::LifecycleState::kWaitingForStart) {
  std::string message;
  if (!vr.startRuntime(&message)) std::cerr << message << '\n';
}

8. Corresponding Repository Example

  • src/leju-joystick/src/leju_joy_autostart_manager.cpp
  • Public interface: installed/include/lejusdk-vr/vr_api/vr_base.h

The current SDK examples directory does not provide a standalone runtime user program; the autostart manager above is the actual call site within the repository.

Configuration Hot-Reload Notifications

1. Function Description

Subscribe to hot-reload notifications for the joystick binding configuration and the controller list configuration, or publish a joystick binding configuration reload notification to the running controllers.

2. SDK and Header File

  • SDK: lejusdk-lowlevel
  • Header file: <lejusdk-lowlevel/leju_sdk.h>

3. Request or Message Type

void subscribeReloadTeleopConfig(const leju::StringDataCallback& callback);
void subscribeReloadControllerConfig(const leju::StringDataCallback& callback);
bool publishReloadTeleopConfig(const std::string& config_path = "");

4. Field Description

StringData contains timestamp and data. data may carry a configuration file path; when it is empty, the subscriber re-reads the already loaded path. publishReloadTeleopConfig() publishes only the teleop binding configuration reload; the current public user-facing API has no corresponding publishReloadControllerConfig().

5. Return Value

  • The two subscribe methods have no return value.
  • publishReloadTeleopConfig() returns true on successful publish, false on failure.

6. Prerequisites

  • The low-level SDK has been initialized, and the relevant configuration consumers are running.
  • When a path is passed in, that path must be accessible from the device on which the consumer runs; the web documentation does not fix an absolute path for any particular development machine.
  • The YAML content has been validated before publishing, to avoid loading an invalid configuration at runtime.

7. C++ Example

robot.subscribeReloadTeleopConfig(
    [](const leju::StringDataConstPtr& msg) {
      std::cout << "reload teleop: " << msg->data << '\n';
    });

// 空字符串表示请求重读当前已加载的路径。
if (!robot.publishReloadTeleopConfig()) return 1;

8. Corresponding Repository Example

  • Actual subscriber: src/leju-controllers/leju-rl-controller/src/main.cpp
  • Reload smoke test: src/leju-controllers/leju-rl-controller/tests/tools/reload_smoketest.cpp

On this page

VR Input Velocity1. Function Description2. SDK and Header File3. Request or Message Type4. Field Description5. Return Value6. Prerequisites7. C++ Example8. Corresponding Repository ExampleController Final Velocity1. Function Description2. SDK and Header File3. Request or Message Type4. Field Description5. Return Value6. Prerequisites7. C++ Example8. Corresponding Repository ExamplePosture Height Control1. Function Description2. SDK and Header File3. Request or Message Type4. Field Description5. Return Value6. Prerequisites7. C++ Example8. Corresponding Repository ExampleStopping the Robot1. Function Description2. SDK and Header File3. Request or Message Type4. Field Description5. Return Value6. Prerequisites7. C++ Example8. Corresponding Repository ExampleController State Query1. Function Description2. SDK and Header File3. Request or Message Type4. Field Description5. Return Value6. Prerequisites7. C++ Example8. Corresponding Repository ExampleSwitching Controllers1. Function Description2. SDK and Header File3. Request or Message Type4. Field Description5. Return Value6. Prerequisites7. C++ Example8. Corresponding Repository ExampleRuntime State and Start/Stop1. Function Description2. SDK and Header File3. Request or Message Type4. Field Description5. Return Value6. Prerequisites7. C++ Example8. Corresponding Repository ExampleConfiguration Hot-Reload Notifications1. Function Description2. SDK and Header File3. Request or Message Type4. Field Description5. Return Value6. Prerequisites7. C++ Example8. Corresponding Repository Example