Development of racing car control algorithm based on RT thread

Zhuo Qing 2021-08-13 01:55:47 阅读数:78

本文一共[544]字,预计阅读时长:1分钟~
development racing car control algorithm

School : Zhongyuan Institute of Technology
Team name : Chase deer — I hope the car is OK
The players : Zhang Hengji 、 Wang Jinlong 、 Peng Xiaohui

 

§01 lead said


This paper takes the 16th National College Students' intelligent car competition as the background , The competition was commissioned by the Department of higher education of the Ministry of education , By the teaching guidance sub committee of higher automation specialty of the Ministry of education ( Hereinafter referred to as automation education steering committee ) Host the National College Students' smart car competition .

The national intelligent car competition for college students is a competition based on “ Based on training 、 The key is to participate in 、 Encourage exploration 、 The pursuit of excellence ” For the guiding ideology , Exploratory engineering practice activities for national college students . Its task is to design and manufacture intelligent model vehicles that can drive independently on a specific track and have superior performance , Encourage college students to form teams , Comprehensive use of multidisciplinary knowledge , Put forward 、 analysis 、 Design 、 Develop and study the mechanical structure of intelligent vehicle 、 Electronic circuits 、 Motion control and development and debugging tools , Stimulate college students' interest and potential in engineering technology development and scientific research and exploration , Advocate integrating theory with practice 、 Realistic and pragmatic style of study and the humanistic spirit of teamwork .

In this competition , We use the... Provided by the competition organizing committee B auto salon girls , With TC264 Single chip microcomputer is the core controller , use MOS Tube driven model motor ,MT9V034 Camera as sensor , Independently conceive the speed control and steering control scheme to guide the car model , Identify the travel route according to the specified route . In the report , We passed on the overall plan 、 mechanical 、 Hardware 、 Introduction to algorithms and other aspects , This paper expounds our ideas and innovations in this auto race in detail . Including circuit design 、 Algorithm 、 Mechanical structure, etc , Elaborated our ideas and ideas in detail , It is embodied in the innovative design of the circuit , And unique ideas about algorithms , And the challenge of new elements of the track , It also made us pay a lot of efforts and sweat . This report embodies our hard work and wisdom , It is the result of our joint efforts . Here it is , Share with you , I hope it can provide some help to the majority of smart car lovers .

RT-Thread, The full name is RealTime-Thread, seeing the name of a thing one thinks of its function , It is an embedded real-time multithreaded operating system , One of the basic attributes is support for multitasking , Allowing multiple tasks to run at the same time does not mean that the processor actually performs multiple tasks at the same time . in fact , A processor core in a national college student intelligent car Invitational technical report

You can only run one task at a time , Because the execution time of one task at a time is very short 、 Tasks can be switched quickly through the task scheduler ( The scheduler determines the task to be performed at this moment according to the priority ), Give people the illusion that multiple tasks are running at the same time . stay RT-Thread In the system , Tasks are implemented through threads ,RT-Thread The thread scheduler in is also the task scheduler mentioned above . RT-Thread It's a real-time operating system ( RTOS) kernel 、 Middleware component and developer community in one technology platform , With minimal kernel 、 Stable and reliable 、 Simple and easy to use 、 Highly scalable 、 Rich components and other features . RT-Thread It has the largest embedded open source community in China , At the same time, it is widely used in energy 、 vehicle 、 Medical care 、 Consumer electronics and many other industries , The cumulative installed capacity has reached tens of millions , To be developed independently by Chinese people 、 The most mature and stable open source with the largest installed capacity in China RTOS.

This technical report consists of seven chapters , The first chapter mainly introduces the theme of the smart car race and the contents involved in the technical report ; The second chapter introduces the mechanical structure design and mechanical principle of the vehicle ; The third chapter expounds the system design scheme of the team ; The fourth chapter describes the program framework of the team and the algorithm used ; The fifth chapter introduces the system development and debugging tools used by the team in preparing for the competition ; Chapter 6 introduces the main parameters of the vehicle ; Chapter 7 lists the final summary of this report and the experience of our team in the competition , I hope I can help you .

 

§02 vehicle Body basic structure


One 、 Installation of model steering gear position
According to the rules of the game , This competition uses B Car model matching S-D5 Digital steering gear , Working voltage 4.5-5.5v, With locked rotor protection circuit , Moment 5.0kg, It's more accurate , More accurate positioning , Action speed ≤0.14±0.02sec/60°. See the figure below for specific parameters 2.1

▲ chart 2.1 SD-5 Steering gear parameters

▲ chart 2.1 SD-5 Steering gear parameters

The steering gear directly controls the steering of the car , For the steering of the trolley , It is realized by driving the left and right tie rods by the steering gear . Because the rotation speed and power of the steering gear are certain , To speed up the response of the steering mechanism , The only way is to optimize the installation position of the steering gear and the length of its torque extension rod . Therefore, the position of the steering gear is very important . We use the middle vertical installation method . For the pull rod of the steering gear , In order to make the maximum thrust given by the steering gear when the swing angle is maximum , The pull rod adopts deflection V Word installation .

Two 、 Front wheel alignment

After many attempts and references , For front wheel alignment , We finally adopted “ Front wheel camber , Kingpin inclination ” Structure .、

Kingpin caster angle refers to the included angle between the longitudinal plane of the vehicle body and the vertical line of the ground , Pictured 2.1 Shown , Kingpin caster angle can produce a torque opposite to the steering, so that the wheel has the ability of automatic return , Generally, the greater the caster angle of the kingpin , The higher the speed , The stronger the automatic return ability of the front wheel . But the caster angle of the kingpin is too large , It will cause excessive front wheel alignment , Causing heavy steering . Found during debugging , We found that when the speed increased , Increasing caster angle is not necessarily a good thing , But with appropriate adjustments , It can stabilize the body to a certain extent .

Front wheel toe in refers to looking down from the front of the car , The included angle between the center line of the tire and the longitudinal axis of the vehicle is called toe in angle . The toe in angle at the front end of the tire centerline is the positive toe in angle , On the contrary, it is a negative toe in angle . The total toe in value is equal to the sum of the toe in values of the two wheels , That is, the included angle between the axes of two wheels .

Toe in is used to eliminate the adverse consequences caused by wheel camber . The camber of the wheel makes the front wheels open to both sides , Unable to roll out due to axle restraint , This causes the wheels to roll and slip, increasing wear . With toe in, the rolling direction of the wheel is close to the front at every moment , The pressure of the outer bearing of the wheel hub and the wear of the tire are reduced .

The camber of the front wheels is necessary to ensure the handling and stability of the vehicle , Also, the front wheels will not produce negative camber under any working conditions of the vehicle , Ensure safe operation . When the front wheels have camber angle , The vertical reaction of the ground to the wheel will produce an axial split , The purpose is to eliminate all kinds of gaps , Make the inner and outer tapered roller shafts with different sizes on the steering knuckle shaft bear the force as much as possible on the bearing , Reduce the axial force of the steering knuckle nut , Prevent the nut from loosening and causing the front wheel to fly out . When the wheels lean out , The wheels on both sides tend to separate outward . Due to axle constraints , The wheels will continue to slide sideways relative to the road surface , So as to accelerate tire wear . In order to compensate for the adverse consequences of extraversion , Therefore, the front wheel has toe in , With the front toe in , It can make the rolling direction of the wheel close to the front at every moment , This can not only ensure the stability of the vehicle running in a straight line , It can also ensure normal tire wear .

3、 ... and 、 Rear wheel differential adjustment

After experiments, we found that : If the differential is too tight , That is, when the speed of the two tires is very close , It's easy for the inner wheel to slip when turning , This produces sideslip , Slide the car off the track . When the differential is too loose , Will cause two wheels to slip on the straight ( The motor is not centered on the rear axle ), Greatly reduces the driving capacity of the car . Therefore, the differential adjustment should be appropriate , Will make the straight drive strong and stable , It's easy to turn a corner .

Because when the car turns , The turning radius of the inside and outside wheels is different , The turning radius of the outer wheel shall be greater than that of the inner wheel , This requires that the speed of the outer wheel is higher than that of the inner wheel when cornering . The function of the differential is to meet the requirements of different wheel speeds on both sides of the car when turning , Here's the picture 2-2 Shown .

▲ chart 2.2 Rear wheel mounting

▲ chart 2.2 Rear wheel mounting

Four 、 Battery placement and chassis adjustment

When turning at high speed, the centripetal force required is relatively large , At the same time, due to inertia, the car is easy to overturn to one side . In order to avoid this kind of thing , We lowered the rear chassis of the car , So as to reduce the center of gravity of the whole vehicle , Prevent the car from overturning . But because there can be sloping roads during the game , Including uphill and downhill roads , Therefore, the chassis height of the rear wheels should not be too low , This is to make the car go uphill smoothly without rubbing the track due to the chassis .

We put the camera in the front of the whole car . Place the battery close to the motor , Why put the battery here is because the center of gravity of the whole car is close to the middle , We fix the circuit board on the chassis , The whole main control contains all modules , It saves space and reduces the center of gravity . Pictured 2-3.

▲ chart 2.3 Battery layout

▲ chart 2.3 Battery layout

5、 ... and 、 Encoder installation

The encoder supply voltage shall not exceed the allowable voltage , Do not apply excessive force to the encoder shaft, resulting in shaft deformation , The encoder signal line should be fixed on the encoder shell with adhesive tape to avoid the signal line falling off due to pulling during long-term use .

6、 ... and 、 Camera installation

Camera as sensor , Its installation is the most important . After many installation experiments ,, We put the camera in the front of the whole car , Because the rules require that the camera height does not exceed 10cm, So only a thick carbon rod was used to fix the camera , In order to prevent serious visual field distortion . We chose 130° My camera lens . Pictured 2-4 Shown .

▲ chart 2.4 Camera installation

▲ chart 2.4 Camera installation

7、 ... and 、 Tire maintenance and use

This competition B2 The car model is made of rubber with engraved tread , The main problems exposed in the process of use are : The tire material is hard , Not enough grip . So we replaced the softer tire 、 Better grip B3 The tire of the model car .

Since the rules do not allow any treatment to change the performance of the tire , Therefore, during debugging , We try to choose symmetry 、 Round tires ; Change the front wheel inclination as much as possible , The contact area between the tire and the ground is maximized under various working conditions ; Try to avoid contact between the four wheels and the ground during the time without commissioning , Wrap... In plastic wrap , Ensure that the shape of the tire does not change .

8、 ... and 、 The appearance of the model car

1、 Car body appearance


2、 The control strategy adopted by the intelligent vehicle

Due to the requirements of the basic four-wheel group of this competition , The car finally decided to focus on the camera , And supplemented by electromagnetic control . Worried about the environment of the game and the poor adaptability of the camera , A purely electromagnetic control program is also prepared .

Nine 、 Camera selection

The camera uses MT9V03X Digital smart car camera for total drilling wind , This camera has global shutter high dynamics , Auto exposure , The number of frames is adjustable , Output as grayscale image .

The image passes through MT9V03X Camera for acquisition , The collected image is 50188, Intercept as 5094, And binarization by Otsu method , The number of frames is adjusted by the maximum exposure time , The final adjusted frame rate is about 200 frame / second ; Set auto exposure and auto gain to adapt to different light intensity environments .

Ten 、 electromagnetism

The car is equipped with five inductors , Induction track alternating magnetic field , Produce an induced electromotive force , The subsequent circuit selects the frequency of some columns of induced electromotive force 、 Zoom in 、 detection , Get the stable signal and input it to the single chip microcomputer to identify the track information , Send acceleration and deceleration signals to the motor 、 The steering gear goes straight and turns .

The car adopts the arrangement of three horizontal and two vertical . It can better adapt to different track types , Effectively deal with the connection between straight and curve .

When installing inductors, pay attention to the adjacent two inductors. Do not install them too close , At least two centimeters away , Otherwise mutual inductance will occur , The specific phenomenon is that the vehicle body will vibrate when crossing the cross , Seriously, it will cause the cross to rush straight out of the track .

 

§03 control System software design


One 、PID Control algorithm

In engineering practice , The most widely used regulator control law is proportion 、 integral 、 Differential control is abbreviated as PID control , also called PID Adjust the .PID The controller has been around since it came out 70 Years of history , It's simple in structure 、 Good stability 、 Work reliably 、 Easy to adjust and become one of the main industrial control technology . When the structure and parameters of the controlled object can not be fully mastered , Or when we can't get an accurate mathematical model , When other technologies of control theory are difficult to adopt , The structure and parameters of the system controller must be determined by experience and on-site debugging , This is the time to apply PID Control technology is the most convenient . That is, when we do not fully understand a system and the controlled object , Or when the system parameters cannot be obtained by effective measurement means , Most suitable for PID control technology .PID control , There are also PI and PD control .PID The controller is a kind of linear controller , It forms a control deviation according to the given value and the actual output value . The ratio of the deviation §、 integral (I) And differential (D) The control quantity is composed of linear combination , Control the controlled object , Therefore calls PID controller , The principle block diagram is shown in Fig 3-1-1 Shown .

▲ chart 3.1.1 PID Schematic diagram of controller

▲ chart 3.1.1 PID Schematic diagram of controller

PID The functions of each correction link of the controller are as follows :
Proportion link : Timely and proportionally reflect the deviation signal of the control system , Once deviation occurs , The controller immediately produces a control effect , To reduce deviation . Integral link : Mainly used to eliminate static error , Improve the tolerance of the system . The strength of the integral action depends on the integral time constant , The bigger it is , The weaker the integral , On the contrary, the stronger .
Differential link : It can reflect the change trend of deviation signal ( Rate of change ), And before the deviation signal becomes too large , Introduce an effective early correction signal into the system , So as to speed up the action speed of the system , Reduce the adjustment time .

Numbers PID Control algorithms are usually divided into positional PID Control algorithm and incremental PID Control algorithm .

Two 、 Positional PID

Because computer control is a kind of sampling control , It can only calculate the control quantity according to the deviation of sampling time , Instead of continuously outputting control quantities like analog control , Continuous control . Because of this characteristic ( type 1-2) The integral and differential terms in cannot be used directly , Must be discretized . The method of discretization is : With T As a sampling period , k As sampling sequence number , Then the discrete sampling time kT Corresponding to continuous time t, The rectangular method is used to approximate the numerical integral instead of the integral , The first order backward difference approximation is used to replace the differential equation , The following approximate transformations can be made :


● Related chart Links :

版权声明:本文为[Zhuo Qing]所创,转载请带上原文链接,感谢。 https://car.inotgo.com/2021/08/20210813015444495h.html