RobotController is a control stack for a 4-DOF Dynamixel robotic arm with gripper, focused on:
- reliable point-to-point motion (
GotoPointfamily) - task-level automation (Task 2/Task 3)
- trajectory execution for manipulation and calligraphy
GotoPoint is the key interface used across tasks. Given a Cartesian target (and tool pose constraints), it computes a feasible joint solution and executes a smooth move.
Why it matters:
- Every high-level behavior (pick/place, gates, drawing) is built from repeated
GotoPointcalls. - It encapsulates IK + trajectory timing + joint-limit safety in one command.
Typical behavior in the controller:
- Validate target reachability and joint limits.
- Solve inverse kinematics (analytical / Jacobian variant depending on mode).
- Generate time-parameterized joint motion (accel, cruise, decel).
- Send synchronized motor commands so joints arrive together.
Related variants used in the project:
GotoPoint_Angle(): Cartesian target + end-effector angle with analytic IK.GotoPoint_Jacobian(): iterative Jacobian/DLS solver for continuous correction.GotoPoint_k_points(): multi-waypoint Cartesian interpolation.
Task functions are where motion primitives become complete robot behaviors.
-
task2a(): deterministic pick-and-place to predefined targets. Emphasis: repeatability and baseline block transport. -
task2b(): extended manipulation logic (orientation/stacking/conditional placement). Emphasis: composing multiple primitives into robust sequences. -
Gate/route tasks (
pass_gate(),pass_all_gates()): navigation through constrained waypoints while maintaining safe approach/clearance. -
Combined routines (for example
imaginaryDragon()): end-to-end scripted demos that chain pickup, transport, drawing, and placement.
Task 3 is the calligraphy pipeline. StrokeUI.py is the authoring/editing tool for stroke trajectories, and the controller executes those trajectories on the robot.
Calligraphy/StrokeUI.py is a Pygame-based stroke editor for JSON trajectory files.
Core capabilities:
- Load/select stroke JSON files from the
Calligraphyfolder. - Visualize each stroke as ordered points and connected segments.
- Select, drag, and numerically edit per-point
x,y,z. - Add or delete points to refine stroke geometry.
- Adjust global layout:
- center all points to
(7, 0) - scale all points about dataset center
- center all points to
- View transforms for editing convenience:
- zoom/pan
- rotate view (
R) - flip Y-axis (
Y)
- Save edits back to JSON.
The editor uses a stroke list, where each stroke contains ordered 3D points:
{
"strokes": [
{
"stroke_id": 1,
"points": [[x, y, z], [x, y, z], ...]
}
]
}Execution meaning:
x, y: planar path of each calligraphy segment.z: pen height/pressure proxy. higherz-> lift/travel, lowerz-> contact/thicker stroke intent.
High-level execution flow:
- Prepare stroke JSON in
StrokeUI.py(shape, spacing, stroke order, lift heights). - Load trajectory in controller (for example through
draw_from_json()). - For each stroke:
- move to pre-stroke safe height,
- descend to writing
z, - trace points in order using
GotoPoint/path traversal, - lift before moving to next stroke.
- Optional full routine (
draw_full()): pick pen, draw all strokes, return pen.
Why this is reliable:
- Stroke order is explicit in JSON.
- Pen-up/pen-down is encoded directly in point
zvalues. - The same
GotoPointsafety/kinematics stack used in manipulation tasks also drives drawing.
- Keep adjacent points dense enough for smooth curves.
- Use clear lift
zbetween disconnected strokes to avoid unwanted marks. - Re-center and scale in
StrokeUI.pybefore execution to match reachable workspace. - Validate first stroke slowly, then increase speed once contact quality is stable.
- Connect Dynamixel motors.
- Verify a simple
GotoPointmove. - Run Task 2 (
task2a/task2b) or Task 3 calligraphy (draw_from_json/draw_full). - Monitor trajectory and adjust stroke JSON in
Calligraphy/StrokeUI.pyas needed.