Robot Information and Status Interfaces
This page documents the basic information, hardware state, joint state, IMU, standard gamepad, and Quest input interfaces currently available for Roban2.
General Initialization
The subscription interfaces of lejusdk-lowlevel use a global robot instance:
const auto version = leju::RobotVersion::from_env();
if (!leju::GlobalRobot::init_env(version)) return 1;
auto& robot = leju::GlobalRobot::getInstance();GlobalRobot::init_env() is called only once per process. The low-level SDK code snippets below assume that robot has been initialized as described above.
Basic Robot Information
1. Function Description
Queries the robot version, motor count, all joint names, and the arm, waist, head, and leg joint names. When parsing joint arrays later, the name order returned by the SDK should be treated as authoritative.
2. SDK and Header File
- SDK:
lejusdk-lowlevel - Header file:
<lejusdk-lowlevel/leju_sdk.h> - Object:
leju::RobotBaseAPI
3. Request or Message Type
uint8_t getMotorNumber() const;
std::vector<std::string> getMotorNames() const;
std::vector<std::string> getArmJointNames() const;
std::vector<std::string> getWaistJointNames() const;
std::vector<std::string> getHeadJointNames() const;
std::vector<std::string> getLegJointNames() const;
const leju::RobotVersion& getRobotVersion() const;4. Field Description
No request fields. The joint name interfaces return ordered string arrays whose indices correspond to the joint indices in RobotState and RobotCmd.
5. Return Value
getMotorNumber(): motor count.get...JointNames(): array of joint names for the corresponding body part.getRobotVersion(): reference to theRobotVersionused by the current instance.
6. Prerequisites
ROBOT_VERSIONhas been set to the actual robot model version; Roban2.2 uses17.GlobalRobot::init_env()has been called successfully.- This query comes from the SDK's model definition and does not require waiting for DDS state messages.
7. C++ Example
#include <iostream>
#include <lejusdk-lowlevel/leju_sdk.h>
int main() {
const auto version = leju::RobotVersion::from_env();
if (!leju::GlobalRobot::init_env(version)) return 1;
auto& robot = leju::GlobalRobot::getInstance();
std::cout << "motor count: "
<< static_cast<int>(robot.getMotorNumber()) << '\n';
for (const auto& name : robot.getMotorNames()) {
std::cout << name << '\n';
}
robot.shutdown();
return 0;
}8. Corresponding Repository Examples
src/lejusdk/examples/src/joint_cmd_publisher.cppsrc/lejusdk/examples/src/kuavo_control_example.cpp
Both examples establish the joint order via getMotorNames(); the file names retain the generic historical naming and do not imply that this page uses a Kuavo model.
Hardware State
1. Function Description
subscribeHardwareState() continuously receives low-level hardware stages. Programs that use low-level joint commands should wait for READY_OK before publishing.
2. SDK and Header File
- SDK:
lejusdk-lowlevel - Header file:
<lejusdk-lowlevel/leju_sdk.h>
3. Request or Message Type
void subscribeHardwareState(const leju::HwStateCallback& callback);
using HwStateCallback =
std::function<void(const leju::StringDataConstPtr&)>;4. Field Description
| Field | Type | Description |
|---|---|---|
timestamp | double | Timestamp, in s |
data | std::string | Hardware state string, including unknown, initializing, ready_ok, error |
String2HwState() converts the string to a HardwareState: UNKNOWN, STOPPED, ERROR, INITIALIZING, READY_OK.
5. Return Value
The subscription method has no return value; when a new state arrives, the callback is invoked on the DDS receive thread.
6. Prerequisites
- The low-level SDK has been initialized, and the robot hardware or simulation node is publishing
/rt/hardware/state. - Avoid long blocking inside the callback; perform your own synchronization when sharing state across threads.
7. C++ Example
robot.subscribeHardwareState([](const leju::StringDataConstPtr& msg) {
const auto state = leju::String2HwState(msg->data);
std::cout << leju::HardwareState2String(state) << '\n';
});8. Corresponding Repository Examples
- Source:
src/lejusdk/examples/src/hw_state_subscriber.cpp - Compiled program:
hw_state_subscriber
Joint State
1. Function Description
subscribeRobotState() subscribes to robot joint positions, velocities, accelerations, and torques.
2. SDK and Header File
- SDK:
lejusdk-lowlevel - Header file:
<lejusdk-lowlevel/leju_sdk.h>
3. Request or Message Type
void subscribeRobotState(const leju::RobotStateCallback& callback);
using RobotStateCallback =
std::function<void(const leju::RobotStateConstPtr&)>;4. Field Description
| Field | Type | Unit | Description |
|---|---|---|---|
q | std::vector<double> | rad | Joint positions |
v | std::vector<double> | rad/s | Joint velocities |
vd | std::vector<double> | rad/sยฒ | Joint accelerations |
tau | std::vector<double> | Nยทm | Joint torques |
timestamp | double | s | Timestamp |
The array order matches the joint order returned by getMotorNames(). isValid() can check whether the dimensions of the four arrays are consistent.
5. Return Value
The subscription method has no return value; the callback parameter is a read-only shared pointer.
6. Prerequisites
- The state publisher is publishing
/rt/joint_state. - When retaining data outside the callback, copy the required fields or store the shared pointer safely.
7. C++ Example
const auto names = robot.getMotorNames();
robot.subscribeRobotState([names](const leju::RobotStateConstPtr& state) {
if (state->isValid() && !state->q.empty()) {
std::cout << names.front() << ": " << state->q.front() << " rad\n";
}
});8. Corresponding Repository Examples
- Source:
src/lejusdk/examples/src/joint_state_subscriber.cpp - Compiled program:
joint_state_subscriber
IMU Data
1. Function Description
subscribeImuData() subscribes to inertial measurement data, including angular velocity, acceleration with gravity, gravity-free acceleration, and attitude quaternion.
2. SDK and Header File
- SDK:
lejusdk-lowlevel - Header file:
<lejusdk-lowlevel/leju_sdk.h>
3. Request or Message Type
void subscribeImuData(const leju::ImuDataCallback& callback);
using ImuDataCallback =
std::function<void(const leju::ImuDataConstPtr&)>;4. Field Description
| Field | Type | Unit/Order |
|---|---|---|
gyro | std::array<double, 3> | rad/s, [x, y, z] |
acc | std::array<double, 3> | m/sยฒ, includes gravity |
free_acc | std::array<double, 3> | m/sยฒ, gravity removed |
quat | std::array<double, 4> | Quaternion [w, x, y, z] |
timestamp | double | s |
5. Return Value
The subscription method has no return value; the callback is invoked when new data arrives.
6. Prerequisites
- The IMU publisher is publishing
/rt/imu_state. - When computing attitude, parse in
[w, x, y, z]order; do not use it as[x, y, z, w].
7. C++ Example
robot.subscribeImuData([](const leju::ImuDataConstPtr& imu) {
std::cout << "gyro_z=" << imu->gyro[2]
<< ", qw=" << imu->quat[0] << '\n';
});8. Corresponding Repository Examples
- Source:
src/lejusdk/examples/src/imu_data_subscriber.cpp - Compiled program:
imu_data_subscriber
Standard Gamepad Data
1. Function Description
subscribeJoyData() subscribes to Xbox- or PlayStation-style gamepads. This interface differs from the Quest controller interface described later.
2. SDK and Header File
- SDK:
lejusdk-lowlevel - Header file:
<lejusdk-lowlevel/leju_sdk.h>
3. Request or Message Type
void subscribeJoyData(const leju::JoyDataCallback& callback);
using JoyDataCallback = std::function<void(const leju::JoyDataConstPtr&)>;4. Field Description
timestamp: timestamp, in s.axes.left_x,left_y,right_x,right_y: stick axes, range[-1, 1].axes.left_trigger,right_trigger: triggers, range[0, 1].buttons:south,east,west,north,back,guide,start, the left and right stick buttons, shoulder buttons, D-pad, andmisc1/misc2; 0 means not pressed, non-zero means pressed.
5. Return Value
The subscription method has no return value; the callback parameter is JoyDataConstPtr.
6. Prerequisites
leju-joystickor another driver is publishing/rt/joy.- The specific button functions are determined by the current
teleop_bindings.yaml; the SDK data types represent raw input only.
7. C++ Example
robot.subscribeJoyData([](const leju::JoyDataConstPtr& joy) {
std::cout << "left=(" << joy->axes.left_x << ", "
<< joy->axes.left_y << ") start="
<< joy->buttons.start << '\n';
});8. Corresponding Repository Examples
src/leju-joystick/src/leju_joy_autostart_manager.cppsrc/leju-controllers/leju-rl-controller/src/runtime/input/teleop/joy_teleop_adapter.cpp
Quest Controller Data
1. Function Description
subscribeQuestJoystickData() subscribes to the stick, trigger, grip, button press, and touch states of the Quest left and right controllers. publishQuestJoystickData() is intended for data sources such as the Quest UDP bridge program; regular applications mainly subscribe.
2. SDK and Header File
- SDK:
lejusdk-vr - Header file:
<lejusdk-vr/lejusdk_vr.h>
3. Request or Message Type
void subscribeQuestJoystickData(leju::vr::QuestJoystickDataCallback callback);
bool publishQuestJoystickData(const leju::vr::QuestJoystickData& data);4. Field Description
| Field | Type | Description |
|---|---|---|
header_sec, header_nanosec | int32_t, uint32_t | DDS frame timestamp |
left_x, left_y, right_x, right_y | float | Left and right hand stick axes |
left_trigger, right_trigger | float | Left and right hand trigger values |
left_grip, right_grip | float | Left and right hand grip values |
left_first_button_pressed, left_second_button_pressed | bool | Left hand primary/secondary button pressed state |
right_first_button_pressed, right_second_button_pressed | bool | Right hand primary/secondary button pressed state |
*_first_button_touched, *_second_button_touched | bool | Touch state of the corresponding buttons |
5. Return Value
subscribeQuestJoystickData(): no return value.publishQuestJoystickData(): returnstrueon successful publish,falseon failure.
6. Prerequisites
RobanVRAPIhas been initialized successfully.- When subscribing, the Quest bridge program is publishing
/rt/quest/joysticks. - The binding of buttons to control functions is part of the teleoperation configuration, not fixed semantics of
QuestJoystickData.
7. C++ Example
leju::vr::RobanVRAPI vr(leju::RobotVersion::from_env());
if (!vr.initialize()) return 1;
vr.subscribeQuestJoystickData(
[](const leju::vr::QuestJoystickData& joy) {
std::cout << "left stick: " << joy.left_x << ", "
<< joy.left_y << " left grip: "
<< joy.left_grip << '\n';
});8. Corresponding Repository Examples
- Data publishing:
src/leju-remote/src/quest_udp_to_dds_node.cpp - Data subscription:
src/leju-vr-control/src/quest_vr_abs_control_node.cpp - Teleoperation adaptation:
src/leju-controllers/leju-rl-controller/src/runtime/input/teleop/quest_teleop_adapter.cpp
Quest Bone Pose Data
1. Function Description
subscribeQuestBonePoses() subscribes to the positions and quaternion orientations of Quest bone nodes. publishQuestBonePoses() is used on the Quest data bridge side to publish full-frame data.
2. SDK and Header File
- SDK:
lejusdk-vr - Header file:
<lejusdk-vr/lejusdk_vr.h>
3. Request or Message Type
void subscribeQuestBonePoses(leju::vr::QuestBonePosesCallback callback);
bool publishQuestBonePoses(const leju::vr::QuestBonePosesData& data);4. Field Description
QuestBonePosesData fields:
| Field | Type | Description |
|---|---|---|
header_sec, header_nanosec | int32_t, uint32_t | DDS frame timestamp |
timestamp_ms | int64_t | Quest original millisecond timestamp |
is_high_confidence | bool | Whether this frame is high-confidence |
is_hand_tracking | bool | Whether the data comes from hand tracking mode |
poses | std::vector<Pose> | Array of skeleton node poses |
Pose contains the position x/y/z and the quaternion qx/qy/qz/qw, all of which are float. The specific node indices are determined by the upstream Quest protocol and the conversion logic in the repository; do not guess them based on the array length.
5. Return Values
subscribeQuestBonePoses(): no return value.publishQuestBonePoses(): returnstrueon successful publish,falseon failure.
6. Prerequisites
RobanVRAPIhas been successfully initialized.- The Quest bridge program is publishing
/rt/quest/bone_poses. - Before using the poses, check
is_high_confidence, the length ofposes, and the actual node definitions.
7. C++ Example
vr.subscribeQuestBonePoses(
[](const leju::vr::QuestBonePosesData& frame) {
if (!frame.is_high_confidence || frame.poses.empty()) return;
const auto& pose = frame.poses.front();
std::cout << "first pose: " << pose.x << ", "
<< pose.y << ", " << pose.z << '\n';
});8. Corresponding Repository Examples
- Data publishing:
src/leju-remote/src/quest_udp_to_dds_node.cpp - Data subscription:
src/leju-vr-control/src/quest_vr_abs_control_node.cpp - Pose conversion:
src/leju-vr-control/src/quest_to_ik_converter.cpp