Skip to content

Wheel Control — Python Example ​

Source: rbq_sdk/python/example/sport/rbq_wheel.py

Python port of the C++ Wheel Control. Spins the four wheels of an RBQ wheel robot (RBQ-W) from app slot 21 by publishing MotionRef_ on rt/rbq/ref/motion/_21 after taking ownership of the wheel joints only, then releases them.

How it works ​

  1. Reads interface and optional torque kd seconds from the command line.
  2. Calls ChannelFactoryInitialize(0, interface), then creates ChannelPublisher("rt/rbq/ref/motion/_21", MotionRef_), ChannelPublisher("rt/rbq/cmd/motion/owner/_21", JointOwnershipCmd_) and ChannelSubscriber("rt/rbq/ref/motion/_0", MotionRef_) for the reference the robot applies.
  3. Waits ~0.5 s for DDS discovery, publishes a first zero-torque reference, then sends JointOwnershipCmd_ with whl_joint = [True] * 4.
  4. Publishes whl_joint at 500 Hz with kp = 0, the given kd and a torque ramped from 0 over 0.5 s, printing the applied wheel reference every 0.5 s.
  5. When time is up (or on Ctrl+C) it sets the torque to 0 for 0.5 s, then publishes kp = kd = torque = 0 and exits.

A free wheel settles at velocity = torque / kd [rad/s]. Gains are physical values on both CAN FD and classic CAN robots — Network converts them for the board. It runs next to Low Level (Python), which uses slot 20.

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_py importable — see Python SDK Overview.
  • The robot stack running on the same DDS interface.
  • An RBQ wheel robot (RBQ-W), standing. In the simulator start Motion and MuJoCo with --wheel (bash scripts/sim.bash --robot wheel).

Run ​

bash
cd RBQ/rbq_sdk/python/example/sport
python3 rbq_wheel.py [networkInterface] [torque] [kd] [seconds]

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

# Backward, 1 rad/s, for 5 s:
python3 rbq_wheel.py eth0 -0.5 0.5 5

All arguments are positional, so the interface must be the first argument.

Arguments, defaults and what happens after the example exits are the same as in the C++ version. Use the interface that reaches the robot — lo when running on the robot PC, your NIC from another host.

Example output ​

[rbq_wheel] wheel ownership requested (app 21)
[rbq_wheel] applied: HRW(tq=0.00 kd=0.500) HLW(tq=0.00 kd=0.500) FRW(tq=0.00 kd=0.500) FLW(tq=0.00 kd=0.500)
[rbq_wheel] applied: HRW(tq=1.00 kd=0.500) HLW(tq=1.00 kd=0.500) FRW(tq=1.00 kd=0.500) FLW(tq=1.00 kd=0.500)
[rbq_wheel] done - wheels released (kp = kd = torque = 0)

Wheel order is HRW HLW FRW FLW (joints 12–15). On a classic CAN robot kd shows the board-rounded value, e.g. 0.501.

This user manual is intended for RBQ users.