Skip to content

Horizontal Drag

Horizontal drag mode provides an intuitive XY-plane control interface. The arm tip follows mouse movements projected onto a horizontal surface at the arm’s current Z height.

The control interface maps 2D mouse coordinates to the arm’s XY plane. As you drag on the canvas, the arm tip moves to match — staying at a constant height while tracking left/right and forward/backward.

graph LR
    A[Mouse XY] --> B[Scale to Workspace]
    B --> C[Set Z = constant]
    C --> D["T:104 XYZT Command"]
    D --> E[Arm Moves in XY Plane]

The built-in web application includes a horizontal drag canvas. After connecting via WiFi:

  1. Open the arm’s IP address in a browser
  2. Navigate to the horizontal drag control
  3. Click and drag to move the arm tip in the XY plane
  4. The Z height remains fixed at the current position

You can build a custom drag interface using Python with Tkinter:

import tkinter as tk
import requests
import json
ARM_IP = "192.168.4.1"
Z_HEIGHT = 100 # Fixed Z height in mm
def send_position(x, y):
cmd = {"T": 104, "x": x, "y": y, "z": Z_HEIGHT, "t": 3.14, "spd": 0.5}
try:
requests.get(f"http://{ARM_IP}/js?json={json.dumps(cmd)}", timeout=0.5)
except requests.exceptions.Timeout:
pass # Non-blocking — arm may be mid-motion
def on_drag(event):
# Map canvas coordinates to arm workspace
# Canvas: 0-400px → Arm: -200 to +200 mm
x = (event.x - 200) * 1.0
y = (200 - event.y) * 1.0
send_position(x, y)
root = tk.Tk()
root.title("RoArm-M2-S Horizontal Drag")
canvas = tk.Canvas(root, width=400, height=400, bg="#1c1917")
canvas.pack()
# Draw grid
for i in range(0, 401, 50):
canvas.create_line(i, 0, i, 400, fill="#292524")
canvas.create_line(0, i, 400, i, fill="#292524")
# Center crosshair
canvas.create_line(200, 0, 200, 400, fill="#d97706", width=1)
canvas.create_line(0, 200, 400, 200, fill="#d97706", width=1)
canvas.bind("<B1-Motion>", on_drag)
root.mainloop()

The arm’s workspace origin is at the base. The XY mapping depends on your canvas size and desired range:

Canvas RegionArm Direction
Left-Y (arm right)
Right+Y (arm left)
Up+X (arm forward)
Down-X (arm backward)

Sending commands too fast can overwhelm the ESP32’s HTTP server. A 50ms minimum interval between commands works well — about 20 updates per second. The firmware buffers the latest received command and executes it, so dropped intermediate positions don’t cause issues.


Horizontal drag concept from the Waveshare Wiki.