How to drive the arm with a controller, run the self-running demo, show the doctor-view camera and connect the real arm. Set up and build the ground station first, using BuildInstructions.md.
Safety. Everything here runs on simulated drives unless you choose a real drive
bus with drive_interface. Powered tests need a lead present, low speeds and the
hardware emergency stop within reach. The checks below have been tested with
simulated drives only, so they are not a safety case for the powered arm.
teleop:=true drives the arm with an Xbox or PS5 DualSense controller through
simulated CAN drives. Nothing reaches hardware unless you choose a drive bus, as
described in Real arm. The controller mapping is in
waybionic_teleop/config/xbox_teleop.yaml, and the joint-to-drive map (MKS
SERVO42D/57D CAN IDs, the 26:1 and 3:1 gear ratios and the wrist differential) is
in waybionic_teleop/config/arm_drives.yaml.
-
Connect the controller, then start the ground station with teleop from the repository root:
docker compose run --rm --build --service-ports wslg-teleop
-
In a second PowerShell window, start the controller bridge from the repository root. It needs only Python 3, with no extra packages:
cd waybionic_teleop python -m waybionic_teleop.xinput_bridge
The bridge sends the controller state to the container on 127.0.0.1:47300/udp.
Press Ctrl+C in each window to stop.
-
Pair the controller in Windows Bluetooth settings or connect it by USB, then start the same
wslg-teleopcommand as for the Xbox controller. -
In a second PowerShell window, use Python 3.13 or older, install Pygame once, and start the SDL bridge:
python -m pip install pygame==2.6.1 cd waybionic_teleop python -m waybionic_teleop.sdl_bridge
Wait for Controller ready before pressing Options. The bridge waits for every
control to be released when the controller connects or reconnects.
- Rumble over Bluetooth: restart the bridge with
python -m waybionic_teleop.sdl_bridge --bluetooth-rumble. This uses SDL extended reports, which can stop other DirectInput apps from using the controller until you turn it off and on. USB rumble doesn't need this option. - Several controllers: the bridge uses the first one it recognizes; pick another
with
--index 1. - Not detected over Bluetooth: try USB, and tell a lead which connection worked.
Run only one Windows bridge at a time. The self-running demo opens the Xbox bridge, so close its window before starting the SDL bridge.
- Native ROS: with the controller plugged in, run
ros2 launch waybionic_bringup ground_station.launch.py teleop:=true. - Docker: plug the controller in by USB, then run
./scripts/linux-gui.sh --controller. The container gets only the game controllers listed as/dev/input/by-id/*-event-joystick, not your keyboard or mouse. After unplugging or reconnecting the controller, stop the container and start it again. Bluetooth controllers aren't listed there, so use USB.
| Input | Action |
|---|---|
| Start (Xbox Menu button, three lines) | Enable or disable; the arm starts disabled |
| B | Stop and hold the current pose |
| Y | Switch group: base (joints 1-3), upper (joints 2-5), Cartesian (tool tip) or incision |
| Base group: left stick | Base yaw (left/right; right turns joint 1 positive, counter-clockwise from above) and shoulder (up/down) |
| Base group: right stick up/down | Elbow (up lifts the elbow, joint 3 negative) |
| Upper group: left stick | Shoulder (left/right) and elbow (up/down; up lifts the elbow, joint 3 negative, as in the base group) |
| Upper group: right stick | Wrist roll (left/right; right turns joint 5 positive, counter-clockwise from above at the zero pose) and wrist pitch (up/down; up turns joint 4 negative) |
| Cartesian group: left stick | Tool tip left/right and forward/back, in straight lines |
| Cartesian group: right stick | Tool roll (left/right) and tool tip up/down |
| Cartesian group: LB (hold) | Move along one axis only: the stick direction pushed furthest |
| Cartesian group: D-pad left/right | Tilt the tool about its tip; the tip stays still |
| Incision group: left stick up/down | Insert or withdraw the tool along its own axis |
| Incision group: right stick up/down | Tilt the tool about the incision point |
| Incision group: right stick left/right | Tool roll |
| RT / LT | Close / open the placeholder end effector |
| D-pad up/down | Speed: 10, 25, 50 or 100% of 60 deg/s, or of 50 mm/s and 30 deg/s of tilt in the Cartesian and incision groups |
| A (hold) | Return to the zero pose (not in the incision group) |
On a PS5 DualSense, Options replaces Start, Circle replaces B, Triangle replaces Y, Cross replaces A, and the triggers are L2/R2. The sticks, D-pad and shoulder buttons are in the same places.
Check a new controller with each row above, and check that it rumbles when a move stops at a limit. Then turn it off while teleop is enabled: the arm must hold its pose and show disabled, and after reconnecting, teleop must stay disabled until you release the controls and press Start again.
The RViz camera follows the tool as the arm moves. Drag to orbit and scroll to
zoom, or add follow_camera:=false to the launch command for a fixed view.
Starting and stopping.
- Start is refused until the sticks are centred and the triggers and motion buttons are released. After Y changes group with motion held, the new group waits until the controls are neutral.
- Stick and trigger movement inside the 15% deadzone is ignored, so a trigger that doesn't fully return doesn't move the tool.
- When the bridge reports that the controller disconnected, every control is released, so the arm slows to a stop. After 0.5 s without controller input, teleop disables and holds the arm. Reconnect and press Start to continue.
Limits. When a move stops at a limit, the controller rumbles briefly, at most
once a second, and the RViz label turns red and names the cause, for example
STOPPED-joint_3 or OUT-OF-REACH. If the drives stop the arm while teleop is
still enabled, for example after rejecting a target or losing encoder feedback, the
label shows DRIVES-STOPPED and the drives' reason; press B, then Start, to
continue. Rumble works with a controller plugged into the ground station and
through either Windows bridge.
The drives.
- The simulated drives accept complete, finite joint commands only after receiving a valid URDF and a fresh teleop enable, which teleop repeats on every update. If the enable stops for 0.5 s, or the host pauses past the 500 ms drive heartbeat, the drives stop, and teleop must be disabled and Start pressed again.
- A zero-velocity command, including B and the controller timeout, sends each moving drive an MKS F5 frame with zero speed and acceleration. An out-of-range encoder target stops every drive rather than only part of the arm.
- Drive speed is capped at 600 RPM (
max_rpm); the MKS manual warns against immediate software stops above 1000 RPM. Each drive also runs no faster than 1.5 times its commanded speed plus 1 RPM, and teleop never advances its targets by more than two updates at once, so after a pause the drives don't catch up faster than the teleop speed limits. - The diagnostics panel shows the command gate, the teleop state, each joint, each drive's last CAN frame and the simulated bus load.
The Cartesian group computes its next setpoint with the same limit-aware solver used for the current tool-tip pose. Diagonal moves are limited to the same 50 mm/s as moves along one axis. The simulated drives are given speeds that make them arrive together. Tilt moves the shoulder, elbow and wrist around the tool tip. Roll spins about the tool axis; a downward-pointing blade keeps its heading in this model.
The incision group is for working through a keyhole. The incision point is where the tip was when you selected the group, shown as a pink dot in RViz. The tool always passes through that point, whether you insert, withdraw or tilt it, and the return to the zero pose is off so the tool is never dragged sideways through the incision. With five joints, the tool can only tilt in the arm's vertical plane.
- Y doesn't leave the incision group while the tool is inserted past the incision point; withdraw it first.
- Selecting the group again keeps the incision point while the tool axis still passes within 2 mm of it; otherwise it sets a new one at the tip.
- If the arm is re-enabled with the tool axis within 2 mm of the incision point, the point moves onto the axis instead of the arm moving. Further away, the group stops rather than pull the tool back: press Y, withdraw the tool in another group, then select the incision group again.
The current arm URDF has provisional joint limits, and the collision checks model each link as a box. Don't change a wrist bound or power the motors until Mechanical identifies the URDF joint and measures its signed travel from upright zero, including any cable or gear stop.
Every group stops a move before any part of the arm comes within 10 mm of the table
or folds into the arm's own base. You can see the boxes by ticking
Collision Enabled on RViz's RobotModel display. The tool's box is a placeholder
around the RViz jaws, which reach 30 mm past tool_link, until the real tool is
modelled; a longer tool needs a longer box.
- When a move stops, the diagnostics panel names the part, for example
At limit: forearm_link: table. - If the arm stands on a raised mount, set
table_heightinwaybionic_teleop/config/xbox_teleop.yamlto the table's height above the bottom of the base.collision_clearancein the same file sets the 10 mm margin. - If the arm is already touching something, the only moves allowed are ones that back out of it. A move that presses any contact further in is refused, even if it would ease another contact at the same time.
- A
robot_descriptionwithout a collision box for the base, shoulder, upper arm, forearm, wrist, wrist roll or tool leaves teleop disabled, and the diagnostics panel names the missing links. - Reloading the description while teleop is enabled disables teleop and holds the arm, and the drives stop, so release Start and press it again.
If the arm stops responding or keeps moving after you release the sticks, and the bridge's axis values stop changing, Windows has stopped updating the controller. The bridge keeps sending the last state it read, so the controller can't stop the arm, not even with B.
- Press Ctrl+C in the bridge window. With no controller input, teleop disables and holds the arm after 0.5 s.
- Turn the controller off and on, or unplug and replug it.
- Start the bridge again and press Start.
Real drives need a stop that doesn't depend on the controller.
autoplay:=true plays a scripted demo as soon as the ground station is ready, and
again whenever the controller has been left alone for 30 seconds. The arm lifts,
draws a square and a vertical line with the tool tip, and tilts the tool about its
tip, with the path and a caption in RViz. Touching any button, stick or trigger
stops the demo and leaves teleop disabled; press Start to drive the arm yourself.
The demo runs only with simulated drives.
- Windows: double-click
scripts\windows-demo.cmd. It starts Docker Desktop if needed, opens the controller bridge in its own window if Python 3 is installed, and starts the ground station. Press Ctrl+C in its window to stop. - Linux:
ros2 launch waybionic_bringup ground_station.launch.py teleop:=true autoplay:=true
Until the doctor's camera is chosen, a USB webcam stands in for it. camera_bridge
captures the webcam on the computer it's plugged into and sends JPEG frames to the
ground station, each stamped with its capture time. The ground station publishes
them on /doctor_view/left/image_raw/compressed with
/doctor_view/left/camera_info. The diagnostics panel's camera.doctor_view row
shows the frame rate and the delay from capture to arrival: mean, minimum, maximum
and jitter.
-
Install OpenCV for the bridge with
python -m pip install opencv-python. Use Python 3.13 or newer if you can: older versions read the clock in 15.6 ms steps on Windows, which adds up to 15.6 ms to the measured delay. -
Start the ground station with the camera port, from the repository root:
docker compose run --rm --build -p 127.0.0.1:47310:47310 wslg ros2 launch waybionic_bringup ground_station.launch.py camera:=true camera_bind:=0.0.0.0
-
In a second PowerShell window, start the bridge from the repository root:
cd waybionic_camera python -m waybionic_camera.camera_bridge -
Tick Doctor View in RViz's Displays panel.
Run ros2 launch waybionic_bringup ground_station.launch.py camera:=true, then,
from waybionic_camera, run python3 -m waybionic_camera.camera_bridge. The
bridge needs python3-opencv.
--camera 1uses another camera.--width 1280 --height 720changes the resolution.- On Windows,
--backend dshowoften opens a webcam faster.
-
What the panel measures: from when OpenCV hands the bridge a frame to when it reaches ROS. It leaves out the time inside the camera and on the display.
-
Full delay: point the camera at a millisecond stopwatch on the same screen as RViz, and compare the live stopwatch with the one in the Doctor View.
-
Every frame: add
camera_log:=with a CSV path to log each frame's capture time, arrival time and delay.framecounts the frames that arrived, so a dropped frame shows as a longer gap incaptured_s. With native ROS, any path works, such ascamera_log:=/tmp/camera.csv. In Docker,--rmdeletes the container's files when it stops, so log to a mounted Windows folder. This writescamera.csvtocamera-logsin your user folder:docker compose run --rm --build -p 127.0.0.1:47310:47310 -v "$HOME\camera-logs:/camera-logs" wslg ros2 launch waybionic_bringup ground_station.launch.py camera:=true camera_bind:=0.0.0.0 camera_log:=/camera-logs/camera.csv
-
Clocks: the bridge stamps frames with the camera computer's clock, so the two clocks must agree. Docker Desktop keeps them within a few milliseconds. If the delay looks negative, or keeps growing after the PC sleeps, restart Docker Desktop.
The controller plugs into the computer, not the Arduino. The computer runs teleop,
the Cartesian moves, the joint limits and collision checks, the RViz twin and the
monitor, then sends MKS frames through the carrier board: a UNO R4 WiFi with a
TJA1051T transceiver running waybionic_can/arduino/carrier_bridge. The carrier
only passes frames between USB and the CAN bus, and reports its own status.
controller -> computer (ROS 2) -> USB, 1 Mbaud -> carrier -> CAN, 1 Mbit/s -> 5 MKS drives
waybionic_teleop/config/arm_drives.yaml maps the joints to the drives: CAN IDs 1
to 5 (base yaw, shoulder, elbow, wrist left, wrist right), 26:1 cycloidal reducers
on the first three joints and 3:1 belts on the two wrist motors. Its tool drive
(CAN ID 6) is a placeholder with no hardware behind it, and the host waits for every
drive in the list, so remove tool from drives before driving the real arm.
On a real bus, every drive joint needs a URDF limit before the host holds or moves
anything (unmodeled_joints applies to simulation only).
Before the drives are first powered: Mechanical confirms each joint's signed travel from the zero pose against the URDF limits, including any cable or gear stop, and someone shows that the E-stop cuts power to the drives. Start with the motors unloaded, and keep the E-stop within reach.
The computer running ROS needs the carrier or a USB CAN adapter. Docker Desktop on
Windows and macOS can't reach USB devices, so use native ROS on macOS
(RoboStack) or Linux, or
Docker on Linux with --network host for a SocketCAN adapter.
Do the macOS setup first, then run these from the repository root.
-
Flash the carrier once, and again after carrier firmware changes. Plug in only the carrier, so its port is the only
/dev/cu.usbmodem*, or setWAYBIONIC_CARRIER=/dev/cu.usbmodem.... This uploadscarrier_bridge_mcp2515, for the arm's MCP2515 module;./scripts/macos.sh flash carrier_bridgeis only for a carrier using the R4's own CAN with a TJA1051T. The wrong sketch leaves every drive silent.brew install arduino-cli ./scripts/macos.sh flash
-
Set up each drive once, alone on the bus: give it its CAN ID (they all ship as 1), then switch it to 1 Mbit/s. The carrier keeps its first bit rate until it resets, so replug it, connect every drive, and check they all answer.
./scripts/macos.sh drives set-id 1 3 # for example the elbow ./scripts/macos.sh drives set-bitrate 3 1000000 # after every drive is switched: replug the carrier ./scripts/macos.sh drives --bitrate 1000000 scan
-
Start the ground station. With
toolremoved fromdrivesinarm_drives.yaml, put the arm in the zero pose (upright, as RViz shows it before anything moves), and run the command below. A controller plugged into the Mac, by USB or Bluetooth, drives the arm and its twin together../scripts/macos.sh arm
-
Zero the drives in a second Terminal, with teleop still disabled, then press Start on the controller:
./scripts/macos.sh run ros2 service call /sim_arm_drives/zero std_srvs/srv/Trigger
armsaves the zero in~/.waybionic/drive_zero.yaml. While the drives stay powered, the nextarmkeeps it, so the arm needs no zero pose and no service call: wait forEvery drive kept its zero, then press Start. After the drives lose power, zero again. See Zeroing and stops. -
Check each joint at the slowest speed in the
uppergroup. If a drive turns the wrong way, negate itsfactorsinarm_drives.yamland rebuild. Then move each joint a known angle, such as 10 degrees in RViz, and measure it on the arm; a different angle means itsgear_ratiois wrong.
The controller can stay with an operator on another computer. On the operator's Windows computer, point the controller bridge at the Mac's address:
cd waybionic_teleop
python -m waybionic_teleop.xinput_bridge --host 192.168.1.20On the Mac, listen on the network:
./scripts/macos.sh arm joy_source:=udp joy_udp_bind:=0.0.0.0The receiver takes controller packets from any computer that can reach its port, so do this only on a private network.
With the carrier, set up the drives as in step 2 above, with mks_setup, then
launch:
ros2 run waybionic_teleop mks_setup --channel /dev/ttyACM0 scan
ros2 launch waybionic_bringup ground_station.launch.py teleop:=true drive_interface:=slcan drive_channel:=/dev/ttyACM0With a SocketCAN adapter (candleLight firmware):
sudo ip link set can0 up type can bitrate 1000000
ros2 launch waybionic_bringup ground_station.launch.py teleop:=true drive_interface:=socketcan drive_channel:=can0Without hardware, mks_drive_sim answers on a CAN interface the way the drives
do, so the host can be tested end to end over virtual CAN:
sudo ip link add dev vcan0 type vcan && sudo ip link set up vcan0
ros2 run waybionic_teleop mks_drive_sim --interface socketcan --channel vcan0In a second terminal, launch with drive_interface:=socketcan drive_channel:=vcan0
and zero as below. CI runs waybionic_teleop/test/test_can_drives.py over vcan0.
The encoders count from where the drives were powered on, so the host publishes no joint states and moves nothing until the arm is zeroed. Put the arm in the zero pose (the pose RViz shows before anything moves), leave teleop disabled, and run:
ros2 service call /sim_arm_drives/zero std_srvs/srv/TriggerThen press Start. Real drives take commands through the same gate as the simulated ones. Every drive stops, and the arm must be zeroed again, when:
- a drive stops answering, for example because the E-stop cut its power or the carrier was unplugged (unless the zero is saved and the drive kept it, as below);
- a drive's encoder count jumps further than
max_rpmallows between two readings, as after a brief power loss; - a drive reports a failed move (as when its stall protection releases the motor) or an end-limit stop;
- a drive stays more than
following_error_countsfrom its target forfollowing_error_ticksticks. Both are provisional values inarm_drives.yaml.
A saved zero. With drive_zero_state:=<file> (./scripts/macos.sh arm uses
~/.waybionic/drive_zero.yaml), each zero is saved to the file once every drive has
reported it. A restart of the station, or a drive that answers again after it went
quiet, keeps the zero of each drive that shows it didn't lose power since. MKS firmware
V1.0.9 reports that in two reads, checked on the bench on all four drives:
- The zero status (3Bh) says whether the drive was zeroed since power-on. Power-on clears it, and the host's setup frames don't.
- The raw encoder (35h) counts from power-on, and a zero leaves it alone. So it minus
the zeroed count (31h) stays the same from one zero until the drive loses power. A
zero made elsewhere, such as by
mks_setup, changes it.
A drive whose status shows no zero, or whose offset is more than 16 counts from the saved one, isn't zeroed, and the log says why. A new zero, a failed move and a following error delete the file.
A drive that turns more than following_error_counts after its stop, for
following_error_ticks ticks, also stops every drive, with teleop enabled or not. That
drive gets another stop. The arm keeps its zero, since that drive's encoder still counts
true.
When the stick reverses a joint, its drive stops and settles (typically 17 ms, at most about 40 ms on the bench) before it turns back. MKS firmware V1.0.9 keeps a target sent while the drive is reversing, and now and then one sent mid-stroke, and runs back to it, up to 12°, at the next stop. So right behind every stop of a running move, including a Start or B press, the drive also gets a 60 rpm move to where it's to stay. That's the end of its last move, at most two ticks of travel ahead. The move is sent again every tick for 0.25 s. On the bench this kept every stop within 0.1° of base travel. See F5h on firmware V1.0.9.
Once the carrier's E-stop sense is wired, pressing the E-stop also stops every drive at once, and Start is refused until it's released. If the joint commands stop for 0.5 s, every drive stops where it is, and if the host stops, the drives' heartbeat stops them.
The carrier answers a frame it can't pass on yet with BELL. The host sends a refused move, stop or setup frame again on the next tick, and a refused zero while the zero service waits. A refused stop frame is sent again on every tick, and Start is refused until it has gone out. After any stop, disable teleop and press Start again.
Powered hand-guiding is not enabled yet. A stopped drive holds position; disabling teleop does not release it or turn a push into a movement command.
The intended workflow is an explicitly selected Hand Guide mode: a deliberate push starts bounded assistance, then release and stillness for a provisional two seconds capture the new holding position. This changes the holding target, not the calibrated zero. Stop must leave the mode disarmed rather than let another push restart it.
The existing-hardware approach is being evaluated with passive encoder recordings before adding assistance. Encoder displacement and position error are not force measurements: gravity, friction, settling and externally applied pressure can all affect them. Initial base-pressure recordings showed a small, direction-dependent response that did not consistently separate from untouched encoder jitter.
The drive's 0.00err display is motor-shaft angular error, not by itself a fault code.
CAN command 39h reads signed 32-bit position error: 51200 units per motor turn
(not the encoder's 16384 counts per turn). To read it without changing motor settings,
first stop the ground station so only one process owns the carrier, then run:
./scripts/macos.sh drives read-error 3This reads the elbow (CAN ID 3). It reports motor degrees, not joint degrees or force; the display and CAN readback should be compared before using the signal for hand-guiding. Motor-generated tracking error must not be mistaken for continued hand pressure.
An elbow press-hold-release recording received all 1424 requested 39h replies.
Using the manual's scale, it captured brief excursions of +1.73 and -4.25 motor
degrees, with near-zero error between them and after release. The operator also
observed Err returning toward zero while still pressing. Thus zero error does not
prove pressure was released, and an opposite-sign transient must not automatically
trigger assistance in the opposite direction. These observations do not validate an
active hand-guiding controller.
For the configured MKS SR_vFOC mode, the V1.0.9 manual describes Ma as the maximum
operating current, and its configuration readback is not measured load current.
Hold Ma does not apply in vFOC mode (manual sections 3.2-3.4 and 5.1.10).
Reducing current or changing drive PID gains is not a validated hand-guiding shortcut,
particularly for joints supporting the arm's weight.
Gravity compensation like Seeed's reBot-DevArm (a torque feed-forward from the arm's model, so the arm floats under the hand) needs torque-controlled actuators. The MKS drives accept only position and speed commands and report no current or torque, so it is not possible on this arm without different motors or a force/torque sensor.
Bench test of a sensorless workaround, base yaw (CAN ID 1, no gravity load), firmware
V1.0.9, factory vFOC gains Kp=220, Ki=100, Kd=270, Kv=320 on every drive: writing Ki=0
or Ki=1 with 96h returns "set success", but 00 96 00 still reads Ki=100, also after
disabling and re-enabling the drive. Held pushes decayed back to near-zero 39h error
within 1-3 seconds with and without the write, so the position error cannot stand in
for a torque sensor. The drives were restored to Ki=100 and read back.
With teleop:=true, the diagnostics panel shows live rows:
| Row | Shows |
|---|---|
controller.link |
Remote controller only: whether the bridge, the controller and its input are live, plus packet rate, loss, jitter, longest gap and network round trip; warns past 2% loss, a 100 ms gap or a 50 ms round trip |
teleop.input |
Whether controller input is arriving; teleop disables itself after 0.5 s without it |
arm.command_gate |
Whether the drives take teleop's commands, or why they stopped |
can.carrier |
The carrier's USB link (reopened every second if unplugged), E-stop and supply (once wired), CAN controller errors, and frames the carrier refused |
can.bus |
Frames per second and bus load |
drive.* |
Each drive's reply state and encoder, and its health: OK, FOLLOWING_ERROR, STALLED, NOT_RESPONDING or DISABLED, with its following error and reply age |
arm.* |
Each joint against its target, and whether the arm is zeroed or its saved zero is being checked |
To try each drive fault in simulation, see recording drive health sessions in the diagnostics guide.