Skip to content

Wheel Control — C++ Example ​

Source: rbq_sdk/cpp/example/src/rbq/rbq_wheel.cpp

Spins the four wheels of an RBQ wheel robot (RBQ-W) from an external app. It takes ownership of the wheel joints only, so the legs stay with the robot's own controller and it keeps standing. It drives the wheels for a few seconds, then releases them.

How it works ​

  1. Reads interface and optional torque kd seconds from the command line.
  2. Initializes the DDS ChannelFactory on the given interface and creates, for app slot 21, a Publisher<MotionRef_> on rt/rbq/ref/motion/_21 and a Publisher<JointOwnershipCmd_> on rt/rbq/cmd/motion/owner/_21. It also subscribes to rt/rbq/ref/motion/_0, the reference the robot actually applies.
  3. Waits ~500 ms for DDS discovery, publishes a first zero-torque reference, then sends JointOwnershipCmd_ with whl_joint[] = true (leg_joint[] stays false).
  4. Publishes whl_joint[] at 500 Hz with kp = 0, the given kd and a torque ramped from 0 over 0.5 s. Every 0.5 s it prints the applied wheel reference.
  5. When time is up it sets the torque to 0 for 0.5 s, then publishes kp = kd = torque = 0 and exits.

With kp = 0 the wheel board applies torque − kd × velocity, so a free wheel settles at velocity = torque / kd [rad/s]. The defaults give 2 rad/s.

Gains are sent as physical values (Nm/rad, Nm·s/rad) on both CAN FD and classic CAN robots. The on-robot Network converts them for the board, so classic CAN robots round them to the board's gain step (e.g. kd 0.5 → 0.5007).

rbq_low_level uses app slot 20, so the two examples can run together: legs from one app, wheels from the other.

WARNING

On the ground the robot rolls while the wheels turn. Give it room, start with a small torque, and keep the remote E-Stop at hand.

Prerequisites ​

  • RBQ SDK built and installed — see C++ SDK Overview.
  • The robot stack running and reachable on the same DDS interface.
  • An RBQ wheel robot (RBQ-W), standing. On a robot without wheels the command has no effect. In the simulator start Motion and MuJoCo with --wheel (bash scripts/sim.bash --robot wheel).

Build ​

From rbq_sdk/cpp/example/:

bash
bash scripts/setup.bash
bash scripts/build.bash

Binary: bin/rbq_wheel

Run ​

bash
./bin-x86_64/rbq_wheel [interface] [torque] [kd] [seconds]

# 2 rad/s forward for 3 s (the defaults) — the interface always comes first:
./bin-x86_64/rbq_wheel eth0

# Backward, 1 rad/s, for 5 s:
./bin-x86_64/rbq_wheel eth0 -0.5 0.5 5

All arguments are positional, so the interface must be the first argument. Use the interface that reaches the robot — lo when running on the robot PC, your NIC from another host.

ArgMeaningDefault
interfaceCycloneDDS interface (lo on the robot / NIC from another host)—
torquefeed-forward wheel torque [Nm], |torque| ≤ 101.0
kdwheel damping [Nm·s/rad], 0 < kd ≤ 60.5
secondshow long to drive before releasing the wheels3

Out-of-range values print the usage and exit without sending anything.

After the example exits, the wheels stay with app 21 at zero gains, so they turn freely. Standing up again or changing gait does not give them back to the robot. Restart the robot stack when the robot's own controller needs the wheels again.

Example output ​

[rbq_wheel] wheel ownership requested (app 21)
[rbq_wheel] applied: HRW(tq=0 kd=3.5) HLW(tq=0 kd=3.5) FRW(tq=0 kd=3.5) FLW(tq=0 kd=3.5)
[rbq_wheel] applied: HRW(tq=0.996 kd=0.5) HLW(tq=0.996 kd=0.5) FRW(tq=0.996 kd=0.5) FLW(tq=0.996 kd=0.5)
[rbq_wheel] applied: HRW(tq=1 kd=0.5) HLW(tq=1 kd=0.5) FRW(tq=1 kd=0.5) FLW(tq=1 kd=0.5)
[rbq_wheel] done - wheels released (kp = kd = torque = 0)

The first line shows the robot's own wheel gains before the hand-over. Wheel order is HRW HLW FRW FLW (joints 12–15).

This user manual is intended for RBQ users.