2022 Electric Design Provincial Competition Sui Sui Nian [Question C, small car, province one]

broken thoughts

The preparation for the electronic competition is mainly concentrated in July, and the competition will be played directly after doing three questions back and forth. Our preparations were indeed sufficient. By 10 o'clock in the morning on the day of the competition, we had solved the basic code problems such as Bluetooth communication and MSP432 , and then the car PD algorithm and lap logic problems.
E-sports gave me the most fulfilling summer vacation since the whole university. The teacher just points to the end every time, and most of the time is thinking about it by himself. Thank you CSDN very much, most of the things learned in the entire electric game are on CSDN. In order to express my gratitude, and unwilling to be reconciled to only one award certificate left in one month's results, I plan to write the knowledge I learned this month into a blog. On the one hand, I will record my learning so as not to forget it (maybe I will come back next year), on the other hand, I will communicate with you Exchange, hope to collide with more sparks.

Preparation

It was around the beginning of school, around March and April, when I formed a team with He Lao and Brother Haoran who was engaged in smart cars, and my strength was stable. At that time, I worked with a grandma at station b, and made a tracing car . At that time, I bought a lot of modules, used the smallest system board of c8t6 , ​​and started to learn Keil . At that time, the study was in a chaotic state. I couldn't learn the registers and firmware library, and I didn't understand the principle. Brother Haoran later said that it is enough to get started directly with the hal library . But the hal library of Wildfire at station b feels like it’s still a firmware library, which is very confusing. After reading it, I still don’t know how to write it. I found the little bee later, a feeling of seeing each other late, it is very clear, it is very suitable for getting started, but the peripherals are a little bit less. Then follow another video to write the code of MPU6050 , which is the real introduction.
Later, the schoolwork pressure was relatively high, and everyone started to get busy, so the matter of the electronic competition was put on hold for the time being.
But thanks to Brother Haoran, we didn't seem to have any fruitful preparations in the early stage, and we provided a lot of help for the preparations and competitions in the future.

20 days of training

It is more training than training. The teacher gives the topic and we do it ourselves. Here is mainly to write about the experience, and the specific topic ideas should be written in another blog. Brother Haoran had to leave our team because of other tasks, and later invited Brother Bo to do it together. We practiced three topics: graphics acquisition and indication system , car tracking + vision , car tracking + vision + car meeting .

Graphical Acquisition and Pointing System

The meaning of the title is mainly to obtain the graphic shape, square or circle, through vision, and then the laser pointer can circle around the black line or white line at the set position and stop. The play part is to recognize the shape and size of the graph and give the area of ​​the graph, recognize the circular and rectangular maze and realize the maze.
Schematic diagram of graphics acquisition and indication system
Altinsert image description here
I entered openmv from this topic . Openmv is indeed a very powerful and easy-to-use camera. Openmv was used in the three practice questions, so by the time of the competition, openmv has been used very proficiently.
When doing this topic, He Lao and I basically know how to use Keil . Brother Bo came into contact with it relatively late, and he used win11, and encountered a lot of trouble in installing the driver.
The teacher has sent several cameras, including pixy and ov5640 , but there are very few routines and tutorials that can be found, and ov5640 needs to be programmed from the bottom. After struggling for about three days, I decided to spend huge sums of money to buy openmv.
In addition, Mr. He found that the hal library has too few routines. He had studied the firmware library for a month before and knew how easy it is to use. So he spent two days packaging the firmware library, which we call the hel library (helao library). The following small car question calls the hel library and writes it quickly. At this stage , openmv and single-chip communication modules , ultrasonic ranging modules , and stepper motor modules
have been resolved . I encountered a lot of problems in the middle, such as the connection between the stepper motor and the motor driver, one day it suddenly stopped moving, and I checked it all afternoon and found that a wire was broken; for example, the camera could not see the laser pointer, and found openmv to adjust the threshold in a fit of anger The coup and so on. This stage uses

The smallest core board of stm32f407 , 32-bit processor, can handle floating-point numbers better than f103, and leads out many pins, which is very suitable for the situation with many peripherals.

smart car

The second question is the track of the car. Because I just got started with the car, there are not many fancy running methods. I just run along the black line. The faster the better, stop after one lap or two laps. During this period, you need to recognize the graphics and numbers on the ground , sound and light prompts.
insert image description here
At this stage, the encoder has not been touched yet, so we can only count the approximate PWM waves to judge whether a circle is completed. The geared DC motor is used, the whole car looks cumbersome and does not run fast.
The main vision is very painful. The color threshold changes when the light changes in the afternoon and evening, and the angle of the camera affects the judgment of rectangles, circles, and triangles. Later, I consulted another group of students and learned something that I didn’t see on the official website, called solidity . If you have the opportunity to write this question in detail, let’s talk about it in detail. The digital recognition has not been done, and the time is not enough.
This topic also uses openmv for tracking . The field of vision is divided into three sections to identify the black line, find the offset angle, pass it to the microcontroller, and then use the PD algorithm to give the PWM wave to achieve the purpose of tracking. Now that I want to go back, the car is not going very smoothly, probably because the parameters of the PD have not been adjusted properly.
Two days before acceptance, a piece of 407 was burned. On the night of the burn, Mr. He held the car and looked at the battery and 407 repeatedly. It seemed that he had aged several years in one night. Later, He Lao said that it may be because the serial port and the compiler were plugged into 407 at the same time, and it burned.

self-driving car

When I did this question, it was less than a week before the competition. We switched to race sized cars, two very light cars with encoders that automatically count the number of turns of the wheel, can be used as a speed PD, and also count the number of laps driven. This topic requires that the car can track clockwise and counterclockwise, and in the improvement requirements, the two cars should meet smoothly in the left area.
insert image description here
This tracking is different from tracking, it is wired on both sides and blank in the middle. Looking very much like Freescale's track, we looked for Brother Haoran overnight. Using the black lines on both sides to plan the route will have limitations, and finally use the tracking of the second exercise. The space is limited and will not be expanded for the time being.
It took a long time to tune the car for this topic, so it's better not to have three people around the car to tune it together, because the efficiency is low. When running this car, it was mainly He Lao and I who were adjusting, so I asked Boge to package the Bluetooth communication, and then learn MSP. Who would have thought that this unintentional move would actually play the most important role in the provincial competition? The most critical role! ! Although the car with MSP has not run yet.
insert image description here

I started trying to do number recognition, and bought two K210s back and forth. The effect of using openmv for digital recognition is not good. We bought openmvh7, which is openmv4, which does not have the powerful machine learning function of 4plus. I spent two days in jail and labeled more than 2,000 data sets, but the final recognition effect was not satisfactory. I bought K210 and trained more than 500 images. Except that the frame rate is a bit low, the recognition accuracy rate is still very high. But it is true that K210 is not as sensitive to color as openmv.

provincial race

For a long time after the competition topic was announced, I joked with the two of them that it seemed that I had nothing to do, so I will write a report. It is true that this topic does not seem to have a lot of visual content, and the two of them have been struggling with MSP432 and Bluetooth communication all morning, and I am helping to borrow equipment to do chores. This bifurcation is actually very easy to do. Based on the previous tracking, each part of the field of vision was originally looking for one largest color block, but now it is changed to look for two largest color blocks, which are divided into left and right to calculate the offset angle respectively. Take the right offset angle directly when walking the outer circle, and directly take the left side when walking the inner circle. The stop line is also easy to do, and the area of ​​the color block is greater than a certain value, which is considered a stop line. I took a trick while waiting for the stop line, because it would confuse the stop line, so I simply didn’t distinguish it. The first time I stopped for five seconds, the second time I stopped directly.
insert image description here
On the first morning we achieved Bluetooth communication . Thanks to Boge's packaged MSP , even if we don't know MSP, we can directly call the functions packaged by Boge to write logic. It is really a waste of time for us to switch the car at night, and it is too difficult for the car to track in such a dim environment in the corridor.
In the case that most of the logic codes have not been completed, the most efficient should be one person to switch the car, one person to write the code later, and one person to modify the code . Of course, this is just my idea, and it is not easy to maintain, because once the car runs better, I can’t help but run over to see it, and chat for a few more words, and I don’t know where to write when I come back.
We did not use photoelectric tracking, and the frame rate of the camera can reach 60fps, which is enough. I didn’t use ultrasonic distance measurement either, I used the 3D distance measurement AprilTag module that comes with openmv, but in fact, the distance between the two cars is less than 20cm to see the complete AprilTag code. Therefore, it is more clever to use the previous color block recognition, and I will talk about it in detail later.
insert image description here

On the last day, I ran out of requirements 1 and 2 after one o'clock in the morning. As a result, one of them couldn't run after seven o'clock, and the wheels kept slipping. After changing the wheels, replace the motor, and replace the motor with the motor drive. The motor drive of the main car should be able to drive the geared motor, but it is too late to buy it. The L298N seems to be unable to drive a geared DC motor. The teacher asked us to change the 15V motor and burned another L298N. Later, the teacher sent Freescale's motor driver. It seemed that it was past ten o'clock, and it was too late to make troubles. So I gave up the speed requirement of the fourth question and changed back to the previous light and light car. The two cars started running again, it was past twelve o'clock. I didn’t feel like eating lunch anymore, so I immediately re-adjusted the parameters and wrote the fourth question. It was about three o’clock. The first, second, and fourth questions were basically done, and I started to adjust the third question. The third question was a bug, and it was okay to look at the code, so I gritted my teeth and rewrote an open-loop one. At that time, my mind was not clear all night long. Sitting in front of the computer, I had ideas but couldn't write them out. Find He Lao and hand over the code to him to continue writing. In the end it still didn't come out.
insert image description here

Before the box was sealed, our car was still running around without being seen by the camera. The day of acceptance was very stressful. When debugging, the stop line can't be seen, and it runs away in the corner. It was discovered in time that it was a reflective problem, and it went smoothly afterwards.

write at the end

Originally, because of staying in school for the summer vacation, the whole person was very sad. During the training, the atmosphere in the whole laboratory was excellent, and each group was studying very seriously. It is no exaggeration to say that a course taken in a semester is not necessarily comparable to a month at best. Although the small car question is said to be very complicated, but if I have to do it again, I will choose the small car. Every bit of our progress can be reflected in the car, which is shown to us unabashedly. The sense of accomplishment and gratification is indescribable.

Guess you like

Origin blog.csdn.net/weixin_52385589/article/details/126221044