Head, Arm, Waist, and Hand Control Interfaces
This page describes the body-part control interfaces currently exposed for Roban2. For the arms, head, and waist, prefer the body-part trajectory interfaces in lejusdk-vr; for both hands, use HandCmd from lejusdk-lowlevel. RobotCmd is a high-risk low-level all-joint interface; use it only when you genuinely need custom joint control.
Body-Part Control Modes
1. Description
Sets control ownership for the arms, head, or waist. The arms and waist must be switched to kExternal before receiving external trajectories; after use, restore the mode required by your application.
2. SDK and Header
- SDK:
lejusdk-vr - Header:
<lejusdk-vr/lejusdk_vr.h>
3. Request or Message Type
bool setArmMode(leju::vr::ControlMode mode, int timeout_ms = 3000);
bool setHeadMode(leju::vr::ControlMode mode, int timeout_ms = 3000);
bool setWaistMode(leju::vr::ControlMode mode, int timeout_ms = 3000);4. Field Description
ControlMode | Value | Description |
|---|---|---|
kKeepPose | 0 | Hold the current pose |
kAuto | 1 | Automatic control by the RL controller |
kExternal | 2 | Accept external body-part commands |
timeout_ms is the DDS-RPC wait timeout, default 3000 ms.
5. Return Value
Returns true when the server accepts and completes the setting; returns false if the service is unavailable, the call times out, or the setting fails.
6. Prerequisites
RobanVRAPIis initialized and the controller management service is running.- Before switching, confirm that the body part is not executing motion that conflicts with external control.
- You can use
getControllerState()to confirm the resulting mode.
7. C++ Example
leju::vr::RobanVRAPI vr(leju::RobotVersion::from_env());
if (!vr.initialize()) return 1;
if (!vr.setArmMode(leju::vr::ControlMode::kExternal)) return 2;
if (!vr.setWaistMode(leju::vr::ControlMode::kExternal)) return 3;8. Corresponding Repository Example
- Roban arm:
src/lejusdk/examples/src/lejusdk-vr/07_roban_arm.cpp - Waist workflow:
src/lejusdk/examples/src/lejusdk-vr/06_waist_control.cpp - Interactive mode setting:
src/lejusdk/examples/src/lejusdk-vr/08_controller_cli.cpp
06_waist_control.cpp and 08_controller_cli.cpp use the generic KuavoVRAPI demo workflow; Roban2 secondary development should use RobanVRAPI.
Arm Joint Control
1. Description
publishArmJointCmd() publishes 8-dimensional joint trajectory points for both Roban2 arms. subscribeArmJointCmd() can be used to listen to the same trajectory data stream.
2. SDK and Header
- SDK:
lejusdk-vr - Header:
<lejusdk-vr/lejusdk_vr.h>
3. Request or Message Type
bool publishArmJointCmd(const leju::vr::JointTrajectoryPoint& cmd);
void subscribeArmJointCmd(leju::vr::ArmTrajectoryCallback callback);4. Field Description
JointTrajectoryPoint contains:
| Field | Type | Unit |
|---|---|---|
q | std::vector<double> | Target position, rad |
v | std::vector<double> | Target velocity, rad/s |
acc | std::vector<double> | Target acceleration, rad/s² |
The Roban2 arm q order is:
[zarm_l1, zarm_l2, zarm_l3, zarm_l4,
zarm_r1, zarm_r2, zarm_r3, zarm_r4]That is, the 4 left-arm dimensions first, then the 4 right-arm dimensions. v and acc follow the same order.
5. Return Value
publishArmJointCmd(): returnstrueon successful publication,falseon failure.subscribeArmJointCmd(): no return value.
6. Prerequisites
- The arms have been switched to external control via
setArmMode(kExternal). quses the 8-dimensional Roban2 order; providing 8-dimensional data forvandaccis also recommended.- Publish commands continuously as a smooth trajectory; do not jump from the current angle to a large-amplitude target.
7. C++ Example
using leju::vr::ControlMode;
using leju::vr::JointTrajectoryPoint;
if (!vr.setArmMode(ControlMode::kExternal)) return 1;
JointTrajectoryPoint cmd;
cmd.q = {0.0, 0.10, 0.0, -0.20,
0.0, -0.10, 0.0, -0.20};
cmd.v.assign(8, 0.0);
cmd.acc.assign(8, 0.0);
if (!vr.publishArmJointCmd(cmd)) return 2;8. Corresponding Repository Example
src/lejusdk/examples/src/lejusdk-vr/07_roban_arm.cpp
This file explicitly uses RobanVRAPI and the Roban 8-dimensional arm order, so it can serve directly as a reference for the Roban2 workflow.
Head Joint Control
1. Description
publishHeadJointCmd() publishes 2-dimensional joint trajectories for the Roban2 head; subscribeHeadJointCmd() subscribes to head trajectories.
2. SDK and Header
- SDK:
lejusdk-vr - Header:
<lejusdk-vr/lejusdk_vr.h>
3. Request or Message Type
bool publishHeadJointCmd(const leju::vr::JointTrajectoryPoint& cmd);
void subscribeHeadJointCmd(leju::vr::HeadTrajectoryCallback callback);4. Field Description
The JointTrajectoryPoint fields are the same as for the arm interface. The order currently consumed by the Roban2 controller is:
| Index | Joint | Meaning |
|---|---|---|
q[0] | zhead_1_joint | yaw |
q[1] | zhead_2_joint | pitch; a positive value tilts the head down |
5. Return Value
publishHeadJointCmd(): returnstrueon successful publication.subscribeHeadJointCmd(): no return value.
6. Prerequisites
RobanVRAPIis initialized and the control link is running.- The current controller passes head trajectories through directly, and the repository examples do not require switching the head mode first. If your application uses head mode management, confirm the actual mode via
getControllerState(). - Follow the
yaw, pitchorder of the Roban2 controller. The comment order in the generic example05_head_control.cppdoes not apply to the current Roban2 consumer side.
7. C++ Example
leju::vr::JointTrajectoryPoint head;
head.q = {0.15, 0.10}; // yaw 左转,pitch 低头
head.v = {0.0, 0.0};
head.acc = {0.0, 0.0};
if (!vr.publishHeadJointCmd(head)) return 1;8. Corresponding Repository Example
- SDK workflow:
src/lejusdk/examples/src/lejusdk-vr/05_head_control.cpp - Actual Roban2 consumption order:
src/leju-controllers/leju-rl-controller/src/controllers/controller_manager.cpp
05_head_control.cpp uses KuavoVRAPI, and its joint comment order differs from the Roban2 controller; use it only as a reference for the publishing workflow, and do not copy its robot model type or array semantics.
Waist Joint Control
1. Description
publishWaistJointCmd() publishes 1-dimensional yaw trajectories for the Roban2 waist; subscribeWaistJointCmd() subscribes to waist trajectories.
2. SDK and Header
- SDK:
lejusdk-vr - Header:
<lejusdk-vr/lejusdk_vr.h>
3. Request or Message Type
bool publishWaistJointCmd(const leju::vr::JointTrajectoryPoint& cmd);
void subscribeWaistJointCmd(leju::vr::WaistTrajectoryCallback callback);4. Field Description
q[0] is the target waist yaw angle in rad; positive values turn left. v[0] and acc[0] are the target velocity and acceleration, respectively.
5. Return Value
publishWaistJointCmd(): returnstrueon successful publication.subscribeWaistJointCmd(): no return value.
6. Prerequisites
- The waist has been switched to external control via
setWaistMode(kExternal). - The command dimension is 1, and the target is within the feasible range of the real robot.
- When finished, smoothly return the waist to the desired position, then restore
kAutoor the mode required by your application.
7. C++ Example
if (!vr.setWaistMode(leju::vr::ControlMode::kExternal)) return 1;
leju::vr::JointTrajectoryPoint waist;
waist.q = {0.10};
waist.v = {0.0};
waist.acc = {0.0};
if (!vr.publishWaistJointCmd(waist)) return 2;8. Corresponding Repository Example
src/lejusdk/examples/src/lejusdk-vr/06_waist_control.cpp
The waist dimension and workflow in this example can be used as a reference; Roban2 programs should replace KuavoVRAPI with RobanVRAPI.
Hand Position Control
1. Description
publishHandCmd() publishes 12-dimensional finger position targets for both hands.
2. SDK and Header
- SDK:
lejusdk-lowlevel - Header:
<lejusdk-lowlevel/leju_sdk.h>
3. Request or Message Type
bool publishHandCmd(const leju::HandCmd& cmd);4. Field Description
| Field | Type | Description |
|---|---|---|
position | std::vector<double> | Fixed 12 dimensions: the first 6 are the left hand, the last 6 are the right hand; values in [0, 100] |
timestamp | double | Timestamp, unit s |
HandCmd::isValid() only checks that the array has 12 dimensions; the application must still ensure that every value lies in [0, 100]. The public header does not define finger names for the six finger channels, so this document makes no additional assumptions.
5. Return Value
Returns true on successful publication, false on failure.
6. Prerequisites
- The low-level SDK is initialized and the hand command consumer is running.
- Confirm that the end effector actually installed on the device supports this 12-dimensional position command.
- Use small-amplitude changes during initial debugging to avoid pinching people or objects.
7. C++ Example
leju::HandCmd hand;
hand.position = {10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10};
if (!hand.isValid() || !robot.publishHandCmd(hand)) return 1;8. Corresponding Repository Example
Currently, src/lejusdk/examples/ does not provide a standalone publishHandCmd() user example. The interface and the 12-dimensional field definitions are defined by the following public headers:
installed/include/lejusdk-lowlevel/robot_api/robot_base.hinstalled/include/lejusdk-lowlevel/data_types.h
Low-Level All-Joint Control
1. Description
publishRobotCmd() publishes position, velocity, torque, gains, and motor mode to all joints. This interface bypasses the body-part trajectory abstraction and is intended only for advanced development where you understand the full robot joint order and motor control laws.
2. SDK and Header
- SDK:
lejusdk-lowlevel - Header:
<lejusdk-lowlevel/leju_sdk.h>
3. Request or Message Type
bool publishRobotCmd(const leju::RobotCmd& cmd);4. Field Description
| Field | Type | Description |
|---|---|---|
q | std::vector<double> | Target position, rad |
v | std::vector<double> | Target velocity, rad/s |
tau | std::vector<double> | Feedforward torque, N·m |
kp | std::vector<double> | Position gain, N·m/rad |
kd | std::vector<double> | Velocity gain, N·m·s/rad |
modes | std::vector<uint8_t> | MotorControlMode for each joint |
timestamp | double | Timestamp, s |
The modes are CST=0 (torque), CSV=1 (velocity), and CSP=2 (position). In CST mode, kp and kd must be 0. All arrays must match the dimension returned by getMotorNumber() and follow the order returned by getMotorNames().
5. Return Value
Returns true on successful publication, false on failure. A true return only means the DDS publication succeeded; commands take effect only when the hardware state is READY_OK.
6. Prerequisites
- Hardware state has been subscribed and
READY_OKhas been reached. - All arrays have consistent dimensions, and
cmd.isValid()returnstrue. - Command frequency, joint limits, gains, and torque limits have been validated against the hardware configuration in use.
- The real robot has physical protection, an emergency stop, and on-site supervision.
7. C++ Example
const auto count = robot.getMotorNumber();
leju::RobotCmd cmd(count);
for (std::size_t i = 0; i < count; ++i) {
cmd.q[i] = 0.0;
cmd.v[i] = 0.0;
cmd.tau[i] = 0.0;
cmd.kp[i] = 0.0; // 具体增益不在文档中臆造
cmd.kd[i] = 0.0;
cmd.modes[i] = static_cast<uint8_t>(leju::MotorControlMode::CSP);
}
if (!cmd.isValid()) return 1;
// 只有在确认 READY_OK 且填入实机验证过的目标/增益后才发布。8. Corresponding Repository Example
- Complete publishing workflow:
src/lejusdk/examples/src/joint_cmd_publisher.cpp - Comprehensive control workflow:
src/lejusdk/examples/src/kuavo_control_example.cpp
Read the hardware readiness checks, joint order, and timed loop in the repository examples first; do not merely copy a single publishRobotCmd() call.