Question C of the 2022 electric competition - car following driving system - record and experience sharing

foreword

I plan to share the real questions of the electric competition I have done, mainly including those of the control group, the car control problems that have appeared in recent years, the real questions I have done, and the problems and experiences that occurred during the preparation of the electric competition.

This time it bringsQuestion C of the 22-year electric competition - the car follows the driving system. This question specifies the use of TI's single-chip microcomputer to complete the following functions

Using TI's MCU to design a set of car following driving system, which consists of a leading car and a following car. Complete the driving operation on the specified path.

Okay, enough nonsense, let's start


Problem analysis

以下是赛题的任务部分,要求采用TI的MCU,双车跟随,且具有循迹功能,速度在0.3 ~ 1m/s内可调,能在指定路径上完成行驶操作

insert image description here

Okay, let's analyze according to the topic, a few important points

1. 采用TI的MCU 2. 领头小车和跟随小车 3. 具有循迹功能 4. 速度在0.3m/s-1m/s内可调 5. 到达终点时要发出声光提示 6. 可沿内外圈行驶,且内外圈可控 7. 当专家在E端放下等停标志时,小车停车,等待5s后停止 8. 双车之间的通信 9. 具有跟随功能


1. Selection of leading car and follower car

This question requires two cars, and two cars need to be built

This topic recommends using

Three-wheel trolley, the front wheels are universal wheels or bull's-eye wheels, and the rear two wheels are driving wheels

certainly,四轮小车也是可以的,我在做这道题目的时候,采用过前轮为舵机转向,后两轮为驱动轮的方案,效果也相当不错

Many UPs observed in station B also use four-wheeled cars , and the effect looks pretty good.

However, the control degree of the three-wheeled car is less difficult than the latter two models, which is very suitable for entry-level exploration

The control of the three-wheeled car is almost the same, and it can be advanced later. The principle of the four-wheeled car is the same, but there are some more things added.


2、Your MCU

When doing this topic, I did not use TI's MCU, but used Stm32F103RCT6

The TI MCU was learned later. After learning the TI MCU later, it is the same as the 32 in use.

When practicing this question, we don’t need to worry about what kind of MCU it is. What we need to understand is what knowledge points we need for this question. Using a different MCU is just a different way to call peripherals. The internal core principles are the same.

Generally speaking, timers, serial ports, and interrupts are frequently used resources.


3. With tracking function

One of the basic functions of this question is tracking. Everything is carried out on the basis of tracking. According to the question, you can see that it is a black line. The black line tracking is actually the same as the idea of ​​following the red line of the medicine delivery car in the past 21 years. of

The black line has several more options than the red line

The black lines can be used 红外对管for tracking. Yes 采用几路红外对管并排排列, they can be placed on the front of the car. When the car is moving, the position of the car can be corrected in real time according to the status transmitted by the infrared tube.

Put five infrared tubes, give different deviation values ​​according to different states, and then use the PID algorithm according to the deviation to keep the car in the center position at all times to achieve the tracking function

similarOpenMv巡线,灰度巡线

For related information, you can refer to this link. What I have talked about in the 21-year drug delivery car tutorial is all a kind of thinking. After everyone is familiar with it, the tracking is basically done.

Sharing the 21-year electric competition F question-smart drug delivery car-recording and experience sharing


Also, adjust the steering PID to remind you

转向PID只需要调节P和D就行了

Because the requirement of this question is that the speed can be adjusted within 0.3m/s-1m/s, the PID parameters you adjusted initially, when the speed increases, the steering of the subsequent speed may not be able to turn, and may deviate from the At this time, it is recommended to pull the speed to the maximum, then adjust the PID parameters, and use this PID parameter as the final loading value, so that the PID parameters are suitable for steering below the maximum speed

More debugging, generally give a P first, put the car into the track, walk for a while, and reach the largest corner, that is, when the four largest corners are reached, look at the phenomenon, if you can’t turn around, add P, add it to the maximum corner that can be turned quickly At the corner, it is reasonable P

D can be given appropriately to increase quick response


4. The speed can be adjusted within 0.3m/s-1m/s

This is simple, you only need to set a few buttons, the speed of button 1 is 0.3m/s, the speed of button 2 is 0.5m/s...and so on

How to set different speeds?

We are using the speed loop, the desired speed adjusted by PID, we only need to give the desired speed, this is the speed of our car

Press the button, the speed is 0.3m/s, the expected speed is 0.3m/s


5. Sound and light prompt when reaching the end point

How to achieve this, after the camera recognizes the stop line, the car stops

The buzzer sounds and the light turns on


6. It can drive along the inner and outer rings, and the inner and outer rings are controllable

The inner and outer rings are controllable, which is one of the difficulties of this question. The question requires the car to realize the function of overtaking the inner ring
, which requires the car to accurately turn to the inner ring and implement overtaking

How to switch between inner and outer rings?

  1. When doing the question, it was first implemented on the MV side. When the car was running for the second lap, after recognizing the stop line twice, the line on the outer circle was shielded, and the camera was only interested in the inner circle line on the left. At this time , modify the line deviation, and the car turns to the inner track according to the PID algorithm

Later, I found that this method is not very stable, and it may appear that the identification of the stop line is wrong, resulting in incorrect timing of turning into the inner circle, so this method was abandoned.

  1. So it is implemented at the 32 end. When the camera recognizes the stop line twice, the left and right wheels give a differential speed. The speed of the left wheel is smaller than the speed of the right wheel. The trolley then has a leftward deviation, and then quickly Adjust the posture of the car so that it turns into the inner circle and drives

This scheme has been tested, and the effect is good, and the success rate is quite high, so as to realize the controllability of the inner and outer rings.


7. When the expert puts down the waiting stop sign at the E end, the car stops and waits for 5 seconds before stopping

This is the task of the MV side. When the waiting sign is recognized, judge according to the sign bit sent back by the MV, and then continue driving after waiting for 5 seconds.

This small question requires a speed of 1m/s. 1m/s is super fast on this small track. When we debugged, we found that after the speed was fast, the accuracy of camera recognition was greatly reduced. At that time, it seemed that Whether it is template matching or neural network, the effect is still not ideal

There is nothing to adjust later, mainly the camera, which needs to be adjusted more


8. Communication between two vehicles

According to the instructions, all operations in the whole process can only be completed on the leading car, which has a start button and a setting button, and the following car only has a power-on switch
insert image description here

That is to say, the leading car is the communication master, and the following car is the communication slave. The master always sends data, and the slave always receives the data sent by the master.

Here we use the bluetooth module HC-05, bluetooth is still very easy to use, after configuration, just use it directly every time you use it, just distinguish between the master and the slave

Tell me about your specific ideas,主车设置按键,按下按键设置速度和题目模式,此时按下按键后,通过蓝牙主机发送数据给从机,告诉从机此时的行驶速度和题目模式,按下确认键后,两小车开始行进


9. With follow function

This is also a small difficulty,The following car should keep a distance of 20cm from the leading car, and the car should not collide with the lead car during the whole process
insert image description here

Here, we adopt HC-SR04超声波模块, according to the ultrasonic detection distance of the front car, change the speed of the car in real time, so as to achieve the purpose of controlling the distance

Here, what we used at the beginning is that when the distance is less than a certain threshold, the speed of the car –, when it is greater than a certain threshold, the speed of the car is ++, always keep 20cm

So, after debugging, I found that the effect is not very good. I can barely follow hahaha, and can also accelerate and decelerate. Generally speaking, the robustness of the program is not good.

The ideal situation is that you are far away from the car in front, speed up, get very close, slow down, then keep a certain distance, get very close, and immediately go back

After improvement later, I know, in fact, the PID algorithm can be used according to the distance change of the ultrasonic module,Enter as期望的跟随距离/小车当前得跟随距离outputyes小车的速度

This kind of follow-up effect is very good, but it is not added in the source code. You can try it. I know a better follow-up solution.


Debugging experience sharing

This question seems to be looking for the black line, it's simple

But when doing it, I still found a lot of problems

Let's share the debugging experience

1. Calculation of speed

The speed I calculated is RPM为单位的based on the number of pulses that the car makes a revolution and the number of pulses currently read by the car. You can refer to the comment area of ​​this article I wrote before to find out how to convert the pulse number of the car to Convert to RPM

Stm32-use TB6612 to drive motor and encoder to measure speed

Here we recommend Lunqu's MG310 motor. This motor has a maximum speed of 500 rpm. A small motor can barely run to 1m/s after testing.

At least the first few questions are definitely enough, you can also choose other motors


2. Main program logic

The main program logic of this question is quite simple.Press the button to set the speed and mode, press the confirmation button and the car starts to drive

The following is the writing of some mode functions. According to the mode selection of the button pressed, select the corresponding mode function, and stop when encountering the stop line


3. Switching between inner and outer rings

It is estimated that the adjustment is not good at once, and the inner and outer rings were stuck for us for a long time.

You see, when the stop line is recognized twice, you have to go forward for a while, which is the intersection point of the inner and outer circles . At this time, the exchange of the inner and outer circles starts, so 这个距离可以采取记脉冲的方式,也可以采用延时的方式let’s solve it. When the number of pulses is reached, or the delay time is up After that, give a differential speed immediately, and the car turns to the inner circle

This distance or delay time needs to be carefully grasped.


4, communication

Not much to say about this,初次建议首先使用串口,连接两个蓝牙,分别插到电脑,打开上位机,互相发送数据,成功后,就说明蓝牙配置完成

insert image description here

If there is a problem later, it is a problem with the program. Find the cause from the inside of the program, and exclude the hardware cause

Below are the Bluetooth pairing steps
insert image description here
insert image description here
insert image description here

insert image description here


5. Follow function

As for this, the above-mentioned ultrasonic PID following is learned later and has not been debugged yet, but I think it is a very good solution, and the following effect should be very good

For details, you can also refer to the tutorials of other big guys, which are very good.


Summarize

This question looks simple, but there are several difficulties, not just a simple trace, there are many small details

You can make your own first car based on the experience sharing above and the analysis of the competition questions for reference.

经过这道题目后,多磨磨,将会对以下几种知识点熟练运用并掌握嘞

  • Common Tracking Scheme
  • Basic use of ultrasound
  • Use of wireless communication modules
  • Gaming experience get, experience value +1

I hope my sharing is helpful to you. Similarly, I have also open sourced the code for this question. You can refer to it for learning


open source link

You can refer to study

Everyone can visit and download by themselves

下方为gitee开源链接,请大家点一个star,谢谢

oufen / Question C of the 2022 Electric Competition - Car Following System

Guess you like

Origin blog.csdn.net/cyaya6/article/details/132311280