Vertical Drag
Vertical drag mode complements horizontal drag by mapping mouse movements to the YZ (side-view) plane. The arm tip moves up/down and left/right while the forward reach stays fixed.
How It Works
Section titled “How It Works”The interface maps 2D mouse coordinates to the arm’s YZ plane. The X position (forward reach) stays constant while Y and Z track the mouse.
graph LR
A[Mouse XY] --> B[Scale to Workspace]
B --> C[Set X = constant]
C --> D["T:104 XYZT Command"]
D --> E[Arm Moves in YZ Plane]
Use Cases
Section titled “Use Cases”Vertical drag is particularly useful for:
- Shelf operations: Reach to a fixed depth, then navigate between shelf levels
- Wall-mounted tasks: Move the arm along a vertical surface
- Stacking: Maintain constant reach while varying height and lateral position
Python GUI Implementation
Section titled “Python GUI Implementation”Similar to horizontal drag, but mapping the canvas to Y and Z axes:
import tkinter as tkimport requestsimport json
ARM_IP = "192.168.4.1"X_REACH = 235 # Fixed forward reach in mm
def send_position(y, z): cmd = {"T": 104, "x": X_REACH, "y": y, "z": z, "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
def on_drag(event): # Canvas X → Arm Y (lateral), Canvas Y → Arm Z (height) y = (event.x - 200) * 1.0 z = (400 - event.y) * 0.75 # Scale to 0-300mm height range send_position(y, z)
root = tk.Tk()root.title("RoArm-M2-S Vertical Drag")
canvas = tk.Canvas(root, width=400, height=400, bg="#1c1917")canvas.pack()
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")
canvas.create_line(200, 0, 200, 400, fill="#d97706", width=1)canvas.create_line(0, 300, 400, 300, fill="#d97706", width=1) # Ground level
canvas.bind("<B1-Motion>", on_drag)root.mainloop()Combining Horizontal and Vertical
Section titled “Combining Horizontal and Vertical”You can run both interfaces simultaneously — one window controls XY position, another controls YZ. The last-received command wins, so alternate between them rather than dragging both at once.
A more advanced approach: use horizontal drag for coarse positioning, then switch to vertical drag for height adjustment. The web interface supports toggling between both modes.
Vertical drag concept from the Waveshare Wiki.