Skip to content

Arm Control

The arm accepts motion commands in three coordinate spaces: individual joint radians, joint degrees, and Cartesian XYZ coordinates. All commands use the JSON protocol over serial, HTTP, or ESP-NOW.

graph LR
    A[JSON Command] --> B{Control Mode}
    B -->|T:101/102| C[Joint Radian]
    B -->|T:121/122| D[Joint Degree]
    B -->|T:103/104| E[XYZ Cartesian]
    C --> F[Inverse Kinematics]
    D --> F
    E --> F
    F --> G[Servo Bus]
    G --> H[Joint Motion]

Move the arm to its default (home) position:

{"T":100}

This moves all joints to their initial positions without interpolation — the arm moves directly to the target.

Move one joint at a time. Angles are in radians (π ≈ 3.14159 = 180°).

{"T":101,"joint":1,"rad":0,"spd":0,"acc":10}
ParameterDescription
joint1=Base, 2=Shoulder, 3=Elbow, 4=End-effector
radTarget angle in radians
spdSpeed (steps/s). 0 = maximum speed
accAcceleration (steps/s²)

Control all four joints simultaneously:

{"T":102,"base":0,"shoulder":0,"elbow":1.57,"hand":1.57,"spd":0,"acc":10}

Same as radian control, but input is in degrees:

{"T":121,"joint":1,"angle":0,"spd":10,"acc":10}
ParameterDescription
joint1=Base, 2=Shoulder, 3=Elbow, 4=End-effector
angleTarget angle in degrees
spdSpeed (degrees/s)
accAcceleration (degrees/s²), max 22.5
{"T":122,"b":0,"s":0,"e":90,"h":180,"spd":10,"acc":10}

Move along one Cartesian axis:

{"T":103,"axis":2,"pos":0,"spd":0.25}
AxisDefault PositionDescription
1 (x)235.11 mmForward/backward
2 (y)0 mmLeft/right
3 (z)234.79 mmUp/down
4 (t)1.57 radEnd-effector angle

Move to an XYZ position with end-effector angle, with interpolation:

{"T":104,"x":235,"y":0,"z":234,"t":3.14,"spd":0.25}

Move to the target position immediately, without path interpolation:

{"T":1041,"x":235,"y":0,"z":234,"t":3.14}

Read the current arm position:

{"T":105}

Returns:

FieldDescription
x, y, zCurrent Cartesian position (mm)
tEnd-effector angle (radians)
torBBase joint torque
torSShoulder joint torque
torEElbow joint torque

Start continuous motion along an axis — useful for jogging:

{"T":123,"m":0,"axis":0,"cmd":1,"spd":3}
ParameterValues
m0 = angle mode, 1 = XYZT mode
cmd0 = stop, 1 = increase, 2 = decrease
axisJoint or axis index
spdMovement speed

Setting spd to 0 in radian-mode commands (T:101, T:102) tells the servo to move at maximum speed. For XYZ commands, spd is in mm/step of interpolation — lower values mean faster movement.

Adjust the PID parameters for a specific joint:

{"T":108,"joint":3,"p":16,"i":0}

Default values:

  • Servo default: P=32, I=0
  • RoArm-M2 default: P=16, I=8 (when PID mode is on)

Reset all PID values to defaults:

{"T":109}

Redefine the forward direction (x-axis) of the arm:

{"T":110,"xAxisAngle":0}

This rotates the Cartesian coordinate frame without physically moving the arm — useful when the arm is mounted at an angle on a mobile platform.

Enable compliance mode where the arm yields to external forces:

Start (set torque limits per joint):

{"T":112,"mode":1,"b":60,"s":110,"e":50,"h":50}

Stop (restore full torque):

{"T":112,"mode":0,"b":1000,"s":1000,"e":1000,"h":1000}

Control reference from firmware source json_cmd.h and Waveshare Wiki.