Check Robot Wiring
The robot's wiring must be exactly the same as shown in the diagram, and the relevant circuit requirements must be consistent.
Open RoboTamerSdk4Qmini/include/user/Motor_thread.hpp and modify the four serial port IDs corresponding to the USB to Quad 485 adapter. You can view the specific IDs via ls /dev/serial/by-id. Replace the ****** part in the code below with the actual ID. Note that if there are multiple serial ports, identify them according to the naming pattern.
std::vector<SerialGroup> serialGroups = {
{"/dev/serial/by-id/usb-FTDI_USB__-__Serial_Converter_FT******-if03-port0", { 0, 5 }}, // CH4
{"/dev/serial/by-id/usb-FTDI_USB__-__Serial_Converter_FT******-if02-port0", { 1, 6 }}, // CH3
{"/dev/serial/by-id/usb-FTDI_USB__-__Serial_Converter_FT******-if00-port0", { 2, 3, 4 }}, // CH1
{"/dev/serial/by-id/usb-FTDI_USB__-__Serial_Converter_FT******-if01-port0", { 7, 8, 9 }} // CH2
};2
3
4
5
6
Result:
IMU Configuration
The original robot IMU has issues. We replaced it with the N100 model IMU. Therefore, we need to modify the IMU data output port specified in RoboTamerSdk4Qmini.
Open the ~/RoboTamerSdk4Qmini/include/user/IMU/imu_receiver.py file and modify the ID corresponding to the N100 IMU. You can view the specific ID via ls /dev/serial/by-id:
Replace port in the code below with the actual ID. Note that you should identify it according to the naming pattern:
Permission Management
We need to grant the lckfb user access permission to all /dev devices used. We use udev rules to achieve this, so that we can implement specific rules for specific devices.
- Use
ls -l /dev/serial/by-idto check what the relevant interfaces are:
You can see the following correspondence:
- The interface corresponding to
USB to Quad 485 AdapteristtyUSB0 ~ ttyUSB3 - The interface corresponding to
N100 IMUisttyUSB4
- Create the
/etc/udev/rules.d/99-robot.rulesfile and write the following content:
Modify the relevant parameters based on the displayed information. Since the
USB to Quad 485 AdapterandN100 IMUcorrespond to interfacesttyUSB0 ~ ttyUSB4, the parameters are consistent, so just write one rule.
KERNEL=="ttyUSB*", MODE="0666"- Apply the configuration:
sudo udevadm control --reload-rules
sudo udevadm trigger2
Modify Communication Interface
Open ~/RoboTamerSdk4Qmini/source/run_interface.cpp. This file needs to change eth0 to lo. Use local loopback for operations, which makes it much more convenient!
This initializes the DDS middleware (Unitree uses CycloneDDS). The Ethernet port only tells DDS which network interface to use for node discovery and communication. DDS is used here for:
- Gamepad/Joystick input (
xRockerGamepad.InitDdsModel())- Publish/Subscribe to
rt/lowcmdandrt/lowstatetopics (for monitoring or other nodes)
lckfb@localhost:~/RoboTamerSdk4Qmini$ git diff /home/lckfb/RoboTamerSdk4Qmini/source/run_interface.cpp
diff --git a/source/run_interface.cpp b/source/run_interface.cpp
index bf9ecdc..2966f0c 100644
--- a/source/run_interface.cpp
+++ b/source/run_interface.cpp
@@ -1,8 +1,8 @@
#include "user/custom.hpp"
int main(int argc, char const *argv[]) {
- std::cout << "Usage networkInterface: " << "eth0 of Q1 robot " << std::endl;
- std::string networkInterface = "eth0";
+ std::cout << "Usage networkInterface: " << "lo of Q1 robot " << std::endl;
+ std::string networkInterface = "lo";
G1 g1(networkInterface, false);
while (true) sleep(10);2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joint Zero Calibration
- Disconnect the Qmini power supply. When all joint motor green indicator lights are off, use a USB cable to separately power the main control computer (LCSC-TaishanPi-3M-RK3576)
- Log in to the main control computer via SSH and modify the
~/RoboTamerSdk4Qmini/include/user/Motor_Thread.hppfile:
std::array<float, 10> Startq = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };- Save and recompile
# Enter the build directory
cd ~/RoboTamerSdk4Qmini/build
# Build the project
cmake -DPLATFORM=arm64 .. && make -j22
3
4
5
- After compilation is complete, turn on the
PS4controller and connect Bluetooth. - Refer to the zero position calibration pose in the
Qminimanual (both legs rotated outward and lifted backward, each joint reaching its limit) and remember: whenever the Qmini is powered off, you must place it in this pose before powering on again:
- Power on the joints (Keep the robot in the zero position calibration pose, do not move it!!!)
- Execute operations (Keep the robot in the zero position calibration pose, do not move it!!!):
- Switch to the
cd ~/RoboTamerSdk4Qmini/bindirectory- Run
sudo ip link set lo multicast onto enable MULTICAST = DDS process mutual recognition handshake mechanism- Create the log directory
mkdir -p /home/lckfb/robot-logs- Run
./run_interface 2>&1 | tee /home/lckfb/robot-logs/tmp_run_interface_$(date +%Y%m%d_%H%M%S).log- When the values stabilize, copy any set of
qvalues, for example:
Copy the values inside [], comment out the current Startq, and paste the copied 10 numbers as the new q values, for example:
You can also check the log
/home/lckfb/robot-logs/to find theqvalues, select one set of values to copy.
//std::array<float, 10> Startq = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
std::array<float, 10> Startq = { 0.119672, 0.212419, 0.58618, 0.493727, 0.115964, 0.562708, 0.00526843, 0.476245, 0.0409862, 0.664455 };2
- Save and recompile:
# Enter the build directory
cd ~/RoboTamerSdk4Qmini/build
# Build the project
cmake -DPLATFORM=arm64 .. && make -j22
3
4
5
- Power off the motor, then power on the motor again (Every time you power on, you must use the fixed pose to power on). Switch to the
cd ~/RoboTamerSdk4Qmini/bindirectory and run./run_interface 2>&1 | tee /home/lckfb/robot-logs/run_interface_$(date +%Y%m%d_%H%M%S).log. At this point, you will find that the newly printed values are almost all close to zero, indicating zero position calibration is complete, for example:
q: -0.00480433 0.00978649 0.00518107 0.00503349 0.00371964 0.00483339 -0.00739716 -0.00747706 0.00818987 0.0111182- Congratulations, you have completed zero calibration. From now on, every time you power on, you must use the fixed pose to power on (Robot Zero Position Calibration Pose Diagram)!
Testing
- Open
~/RoboTamerSdk4Qmini/source/user/custom.cppand enable the relevantrpyoutput:
- Recompile
# Enter the build directory
cd ~/RoboTamerSdk4Qmini/build
# Build the project
cmake -DPLATFORM=arm64 .. && make -j22
3
4
5
- Adjust the robot to the Robot Zero Position Calibration Pose and power on. Run the program
cd ~/RoboTamerSdk4Qmini/bin && sudo ./run_interface. Then, randomly shake the robot body. If you find that theimu'srpychanges with the body shaking and produces corresponding changes, it passes the test!