Skip to main content

HexArth Motion Control

Robot Motion Control

This tutorial explains in detail the meanings of JSON commands for robot motion control, covering vector motion control, attitude angle rotation control, and self-balancing control commands. For joint angle control, it introduces single-joint control using both degree and radian units. For 3D Cartesian coordinate control, it focuses on independent coordinate control of each leg's endpoint position of the hexapod robot.

CMD_MOVE_INIT - Move to Initial Position

{"T":100}
  • 100: Indicates that this command is CMD_MOVE_INIT, which moves all joints of the robot to the initial position. Normally, the robot automatically moves to the initial position upon boot.

CMD_SPEED_CTRL - Set Motion Speed Control

{ "T": 1, "X": 0.02, "Y": 0.02, "Yaw": 0.0 }
  • 1: Indicates that this command is CMD_SPEED_CTRL, used to set the robot's movement speed.
  • X: Represents the robot's forward/backward speed, ranging from -0.07 to +0.07 (m/s). Positive values mean forward, negative values mean backward.
  • Y: Represents the robot's left/right movement speed, ranging from -0.07 to +0.07 (m/s). Positive values mean leftward, negative values mean rightward.
  • Yaw: Represents the robot's in-place rotation speed, ranging from -0.6 to +0.6 (rad/s). Positive values mean turning left, negative values mean turning right.

CMD_AMP_CTRL - Set Attitude Angle Rotation Control

{ "T": 3, "r": 0.1, "p": 0.0, "y": 0.0, "f": 1 }
  • 3: Indicates that this command is CMD_AMP_CTRL, used to set the amplitude and period of the robot's attitude angle rotation.
  • r: Represents the amplitude of rotation around the X-axis, ranging from 0.0 to 0.3.
  • p: Represents the amplitude of rotation around the Y-axis, ranging from 0.0 to 0.3.
  • y: Represents the amplitude of rotation around the Z-axis, ranging from 0.0 to 0.3.
  • f: Represents the period of the robot's attitude angle rotation, ranging from 0.0 to 0.4.

CMD_BALANCED_ENABLE - Set Self-Balancing Mode

{ "T": 4, "cmd": 1 }
  • 4: Indicates that this command is CMD_BALANCED_ENABLE, used to enable/disable the robot's self-balancing mode.
  • cmd: Represents the setting parameter for the robot's self-balancing mode. 1 enables self-balancing mode, 0 disables it (self-balancing mode is mutually exclusive with other motion controls; when enabled, other motion controls cannot be executed).

CMD_DEFAULTZ - Set Body Height

{ "T": 5, "cmd": -80.83 }
  • 5: Indicates that this command is CMD_DEFAULTZ, used to set the robot's body height.
  • cmd: The body height to be set. The initial body height is -83.18 (in mm), with a range of -140.83 to -60.83.

CMD_XYZT_CLAWS_CTRL - Single Leg Endpoint Position Control (Inverse Kinematics)

{ "T": 701, "leg": 0, "x": -0.18, "y": -109.69, "z": -80.83 }
  • 701: Indicates that this command is CMD_XYZT_CLAWS_CTRL, used to control the position of a single leg of the robot.
  • leg: Represents the leg number, ranging from 0 to 5. The front-right leg is number 0, and the numbers increase clockwise on the right side; the front-left leg is number 3, and the numbers increase counterclockwise on the left side.
  • x, y, z: Specific positions on each axis, in mm.

CMD_RAD_CLAWS_CTRL - Single Leg Joint Control (Radian Units)

{ "T": 702, "leg": 0, "coxa": 0, "femur": 0, "tibia": 1.57 }
  • 702: Indicates that this command is CMD_RAD_CLAWS_CTRL, used to control the joint positions of a single leg of the robot.
  • leg: Represents the leg number, ranging from 0 to 5. The front-right leg is number 0, and the numbers increase clockwise on the right side; the front-left leg is number 3, and the numbers increase counterclockwise on the left side.
  • coxa: Rotation angle of the coxa joint. Due to different installation orientations of the legs on the hexapod robot, the initial angle and rotation range of each coxa joint vary. For the front-right leg and rear-left leg, the initial coxa angle is -0.5235 rad, with a rotation range of -1.134 rad to 0 rad. For the front-left leg and rear-right leg, the initial coxa angle is 0.5235 rad, with a rotation range of 0 rad to 1.134 rad. For the middle legs, the initial coxa angle is 0 rad, with a rotation range of -0.7853 rad to 0.7853 rad.
  • femur: Rotation angle of the femur (upper leg) joint. The initial angle is 0.5235 rad, with a rotation range of 0 rad to 1.57 rad. Increasing the angle moves the joint downward; decreasing moves it upward.
  • tibia: Rotation angle of the tibia (lower leg) joint. The initial angle is 2.619 rad, with a rotation range of 0 rad to 3.1415 rad. Increasing the angle moves the joint downward; decreasing moves it upward.

CMD_ANGLE_CLAWS_CTRL - Single Leg Joint Control (Degree Units)

{ "T": 703, "leg": 0, "coxa": 0, "femur": 0, "tibia": 90 }
  • 703: Indicates that this command is CMD_ANGLE_CLAWS_CTRL, used to control the joint positions of a single leg of the robot.
  • leg: Represents the leg number, ranging from 0 to 5. The front-right leg is number 0, and the numbers increase clockwise on the right side; the front-left leg is number 3, and the numbers increase counterclockwise on the left side.
  • coxa: Rotation angle of the coxa joint. Due to different installation orientations of the legs on the hexapod robot, the initial angle and rotation range of each coxa joint vary. For the front-right leg and rear-left leg, the initial coxa angle is -30°, with a rotation range of -65° to 0°. For the front-left leg and rear-right leg, the initial coxa angle is 30°, with a rotation range of 0° to 65°. For the middle legs, the initial coxa angle is 0°, with a rotation range of -45° to 45°.
  • femur: Rotation angle of the femur (upper leg) joint. The initial angle is 30°, with a rotation range of 0° to -90°. Increasing the angle moves the joint downward; decreasing moves it upward.
  • tibia: Rotation angle of the tibia (lower leg) joint. The initial angle is 150°, with a rotation range of 0° to 180°. Increasing the angle moves the joint downward; decreasing moves it upward.