In the development of quadruped robots, humanoid robots, or high-performance robotic arms, traditional independent position/velocity/torque control modes are often unable to meet the demands of high-frequency whole-body dynamic control due to communication frame rate limitations. As a result, MIT Mode has become the preferred control method for developers.
This tutorial will guide you step by step through configuring and controlling the CubeMars AK60-6 (KV80) Robotic Actuator in MIT Mode using C++ over a CAN bus. By following this guide, you will master the core logic of the underlying communication protocol and unlock the actuator's high-response, low-latency control performance.
Before writing your C++ code, please make sure you have prepared the following hardware and software environment:
Core Hardware: CubeMars AK60-6 (KV80) Robotic Actuator, a reliable CAN communication interface (such as a USB-to-CAN adapter, CANoe, or a development board with a CAN interface).
Software Environment: A C++ compiler (such as GCC or MSVC), along with a third-party CAN communication library (such as PCAN-Basic, SocketCAN, etc.).
Utility Software: CubeMars official configuration software (used for initial parameter configuration).
Before writing any code, it's important to understand why MIT Mode is used. Traditional control modes can only send one parameter at a time (such as position or velocity). In contrast, MIT Mode allows the following five key parameters to be packed into a single standard 8-byte CAN frame:
Target Position
Target Velocity
Target Torque (Torque / Kt × I)
Position PD Gain (Kp)
Velocity PD Gain (Kd)
This unified message structure greatly reduces communication latency and serves as the foundation for high-frequency robot locomotion control and compliant force control.
Before running the code, make sure the actuator is properly connected and configured:
Hardware Wiring: Connect the CAN_H and CAN_L terminals of your CAN interface to the CAN_H and CAN_L terminals of the AK60-6 actuator respectively. Make sure all devices share a common ground.
Configuration via CubeMars Software: Connect to the actuator using the CubeMars configuration software. Set the actuator's CAN ID to your desired value (for example, 0x01) and remember it, as it will be used in your C++ program. Set the Baud Rate to 1 Mbps (1000 kbps), which is the recommended baud rate for MIT Mode. Click the "Enter MIT Mode" button. Once enabled successfully, the actuator shaft will exhibit noticeable electromagnetic resistance when rotated by hand.
In a C++ environment, the control logic for the AK60-6 can be divided into the following three key steps (please download the attachment below for the complete project code and data conversion functions):
Send the Enable Command: After entering MIT Mode, the actuator remains in a protected state by default. Before sending any control commands, you must first send a dedicated Enable frame (typically an 8-byte frame filled with 0x00, or another protocol-defined Enable frame) to unlock the actuator. Only after hearing the confirmation beep is the actuator successfully enabled.
Floating-Point to Unsigned Integer Data Packing: This is the most important algorithm in the MIT Mode C++ implementation. Since CAN frames can only transmit integer bytes, physical values (such as a target position of -12.5 rad) must be mapped into 16-bit or 12-bit unsigned integers.
Logic: Use the linear mapping function float_to_uint(x, x_min, x_max, bits).
Operation: Clamp the target position, velocity, torque, Kp, and Kd within the actuator's allowable range, then convert them proportionally into the corresponding hexadecimal values.
Assemble and Send the 8-Byte CAN Frame: Pack the five integer parameters obtained in the previous step into an 8-byte (64-bit) array according to the bit layout specified by the CubeMars communication protocol. Finally, use your CAN library to send the frame to the actuator using the configured CAN ID. Upon receiving the frame, the actuator immediately parses and executes the command.
After compiling and flashing/running your C++ program, power on the AK60-6 actuator. Run your C++ application, and you should see the actuator respond smoothly and rapidly according to the target position, velocity, and torque values specified in your code. You can also dynamically adjust the values of Kp and Kd to directly experience changes in actuator stiffness and compliance.
Q1: The actuator doesn't respond or reports an error after sending CAN frames?
A: Please check the following:
Has the Enable command been successfully sent?
Does the CAN ID in your C++ code exactly match the actuator's configured CAN ID?
Are the command values within the limits defined by the protocol (such as P_MAX and V_MAX)? Values outside the allowed range will cause the actuator to reject the command.
Q2: How should byte order (Byte Order) be handled in the code?
A: The CubeMars CAN protocol typically uses Big-Endian byte order. When constructing the 8-byte CAN frame in C++, pay close attention to the order of the most significant byte (MSB) and least significant byte (LSB). Incorrect byte ordering will result in incorrect position and torque values. Please strictly follow the byte layout specified in the Communication Protocol Manual.
Q3: How do I calibrate the Zero Position of the actuator?
A: In MIT Mode, send the dedicated CAN command for Set Current Position as Zero (refer to the Communication Protocol Manual for the specific CAN ID and data frame). The actuator will record the current rotor position as the mechanical zero position. It is recommended to perform this calibration during every system initialization after power-up.
With its compact 60 mm flange size and outstanding dynamic performance, the AK60-6 (KV80) is an ideal choice for lightweight robotic arms, gimbal systems, and quadruped robot leg joints.
[Learn more about the CubeMars AK60-6 (KV80), including detailed specifications and dimensions.]