Make A Police Light Or Breathing Light; Multi-Threading Introduction; Realization Of Police Lights / Breathing Lights - ADEEPT AWR Wheeled Robot Manual

4wd smart robot kit compatible with raspberry pi 4 3 model b+ b, opencv target tracking
Table of Contents

Advertisement

75

14 Make A Police Light or Breathing Light

14.1 Multi-threading Introduction

● This chapter introduces the use of multi-threading to achieve some effects related to WS2812 LED
lights. Multi-threading is a commonly used operation in robot projects. Because robots have high requirements
for real-time response, when performing a certain task, try not to block main thread communication.
● Multi-threading is similar to executing multiple different programs or tasks simultaneously.
Multi-threading has the following advantages:
·Using threads can put long-running tasks in the background for processing.
· To improve the operating efficiency of the program, the subsequent real-time video and OpenCV
processing of video frames use multi-threading to greatly increase the frame rate.
· The encapsulated multi-threaded task is more convenient to call, similar to the 10.3 non-blocking
control method is to use multi-threaded encapsulated control method
●We use Python's threading library to provide thread-related work. Threads are the smallest unit of work
in an application. The current version of Python does not provide multi-thread priority, thread group, and thread
cannot be stopped, suspended, resumed and interrupted.

14.2 Realization of Police Lights / Breathing Lights

●We use the following code to achieve multi-threaded control of LED lights, and when the LED does not
change, keep the thread blocked, so as not to waste CPU resources.
● The wait () method is used here to block the thread, from the realization of the need to control the
thread.
import
time
import
sys
from
rpi_ws281x
import
import
threading
*

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the AWR Adeept Wheeled Robot and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Picar-b

Table of Contents

Save PDF