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.
How It Works
Section titled “How It Works”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]
Using the Web Interface
Section titled “Using the Web Interface”The built-in web application includes a horizontal drag canvas. After connecting via WiFi:
- Open the arm’s IP address in a browser
- Navigate to the horizontal drag control
- Click and drag to move the arm tip in the XY plane
- The Z height remains fixed at the current position
Python GUI Implementation
Section titled “Python GUI Implementation”You can build a custom drag interface using Python with Tkinter:
import tkinter as tkimport requestsimport 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 gridfor 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 crosshaircanvas.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()Coordinate Mapping
Section titled “Coordinate Mapping”The arm’s workspace origin is at the base. The XY mapping depends on your canvas size and desired range:
| Canvas Region | Arm Direction |
|---|---|
| Left | -Y (arm right) |
| Right | +Y (arm left) |
| Up | +X (arm forward) |
| Down | -X (arm backward) |
Rate Limiting
Section titled “Rate Limiting”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.