Project Introduction
A four-legged robot dog based on Chuanzhi Hi3861 module. The legs are composed of a total of 8 mg90s servos, each leg has two degrees of freedom. Based on the inverse solution of kinematics, it can realize rich action modes. Bluetooth remote control and preliminary verification of face following functions have been added.
References
The original project and tutorials come from the Lichuang open source community, and the self-made version has been open sourced to the above platforms.
circuit design
Main component selection
- Main control: Hi3861 module
- Power supply: 7.4V 2s battery power supply, with 3P charging interface
- Power management: 5v step-down dcdc or LDO (LM1084) + AMS1117-3.3
- IO interface: 16 servo interfaces
- Expand IO: mpu6050+ultrasonic sensor+Bluetooth serial port
- TypeC+CH340 serial port download circuit
- switch
- Power Indicator
- Diode power isolation
- Servo: mg90s 180 degrees, 8 pcs
Connection pin assignment
Servo drive IIC
GPIO10 --> SDA
GPIO9 --> SCL
ultrasonic sensor
GPIO07 -->trig
GPIO08 -->echo
All the remaining IOs are led out, and the 3.3V and 5V power interfaces are led out at the same time to facilitate the power supply of external modules.
PCB design
Design files can be found in Lichuang EDA project files.
structural design
See attachment for solidworks modeling files硬件部分/hardware/structure
Structural optimization
- The volume of the sole of the foot is expanded to increase friction.
- Added side and bottom slots to reduce overall weight and facilitate expansion module installation
Fastener selection
- M2 screw nut
- M2.5 10 nut
- M2.5 16 screw nut
- M3 15 double-pass copper pillar
- M3 40 double-pass copper pillar
- M3 nut
3D printing
Use the light-curing printing provided by Jialichuang 3D Monkey, the material is SLA photosensitive resin
software design
motion planning
Parameter calibration
//leg redefine
// left front leg
#defineLF_A 12
#defineLF_B 13
// left back leg
#defineLB_A 2
#defineLB_B 3
// right front leg
#defineRF_A 11
#defineRF_B 10
// right back leg
#defineRB_A 5
#define RB_B 4
Leg parameter length measurements (to the right is the positive direction, with the right front leg as the standard)
The actual leg length measurement after installation is inconsistent with the software default length and needs to be modified based on the actual situation.
Inverse solution algorithm verification
The inverse solution code is provided in the open source project file, and the core function is the dog_leg_move() function. It is necessary to modify the corresponding parameters according to the actual design situation. Extract the inverse solution operation code and run the test in dec c++. According to the actual test results, adjust the algorithm. On the one hand, the alpha and beta positions need to be exchanged, and the beta angle output differs by 180 degrees. On the other hand, the angle output result must be modified. , the final verification situation is as shown below, and the inverse solution result is very accurate. The modified code has been placed in the attachment and can be viewed by yourself.
gait design
Use the above-mentioned adapted inverse solution algorithm to plan the motion path. The input data of each motion path is the end coordinate set. After solution, it will be passed to the steering gear to execute the corresponding angle.
step on
The designed motion position coordinates are (0, 60) --> (0, 70), set a certain periodic cyclic motion, and the stepping speed is determined by this period. Design a simple gait: move diagonally at the same time, up and down on the same side.
locomotion gait
Use the gait simulator to set up and export the two-dimensional array of the end trajectory, and execute it in a loop. Because what you get is coordinate data, you need to choose to export path trajectory data instead of path point data.
- Forward and backward: diagonal movement is performed simultaneously, and backward movement is in the opposite direction.
- Left and right steering: The movement method is the same as the front and rear direction, but the left and right gait distance is adjusted, similar to differential steering.
- Entertainment action design:
Hongmeng Development Environment
- Main compilation directives
hb set //Initialize the development environment and operate the source code once
hb clean //Clear compilation
hb build //compile
Development Notes
Based on Hongmeng lightweight system kernel LiteOS-M, it can adopt development methods under various subsystems and real-time operating system frameworks.
A task thread was created during development, and all functions are implemented in this thread. For usage, please refer to the main control board information provided at the beginning of the article.
Hi3861 serial port driver development
It was planned to use the serial port to realize the circuit connection with the module, but the actual debugging could not be completed. The following information is for reference only.
- Use serial port 1 and connect:
GPIO6--UART1_TX
GPIO5--UART1_RX
K210 identification and following
K210 is an AI processing chip with superior performance. It is equipped with Canaan’s self-developed KPU neural network processor and supports various mainstream network models. In the test, the K210 maix M1n module designed by sipeed was selected and developed using the MicroPython-based MaixPy IDE, which is relatively easy to get started.
Run the face detection model
The face detection model is based on the yoloV2 framework. After burning the model and running the recognition program, the measured detection frame rate can reach 10+fps, and the effect is remarkable.
GPIO8--TX
GPIO21--RX
Serial port output result: (151, 135, 24, 33) (x, y, w, h) x: horizontal axis, y: vertical axis
Since the Hi3861 serial communication debugging was unsuccessful, the IO port level was used to transmit data instead.
k210--Hi3861
08--05
21--06
07--14
15--11
ESP32 Bluetooth remote control program
ESP32 program
Developed based on the Arduino environment, it receives control instructions sent by the mobile phone and passes them to the main control chip through the IO port control.
The mobile phone connects to the ESP32 via Bluetooth and sends control instructions with the help of a customized Bluetooth assistant.
Submit code instructions
Main control code
The Hi3861 part is developed using genkipi open source firmware. The following two files are modified (note the file path). See the attachment `software part/software/final_code/app`
ESP32 code
see attached软件部分/software/esp32_control
K210 code
see attached软件部分/software/k210
Can directly burn firmware
A total of 11 versions of the debugger firmware are recorded, see软件部分/software/bin
Inverse kinematics solution test code
Compile using devcpp environment and run directly, see attachment软件部分/software/inverse_test