From 995d50998c42efeaef0095769178ac061e25cf3c Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 5 May 2023 18:23:01 +0200 Subject: try different compiler flags --- zumo/makefile | 43 +++++++++++++++++++++++++------- zumo/zumo.mk | 78 ++++++++++++++++++++++++++++++++--------------------------- 2 files changed, 77 insertions(+), 44 deletions(-) diff --git a/zumo/makefile b/zumo/makefile index c388a28..08c01d7 100644 --- a/zumo/makefile +++ b/zumo/makefile @@ -2,33 +2,58 @@ PORT = /dev/ttyUSB0 C++ = avr-g++ CC = avr-gcc -LD = avr-ld +LD = avr-gcc RM = rm -f MCU = atmega32u4 TARGET = main SRCS += main.cpp -CFLAGS += -mcall-prologues -CFLAGS += -mmcu=$(MCU) -CFLAGS += -Os -CFLAGS += -g -CFLAGS += -Wl,-gc-sections -CFLAGS += -Wl,-relax +C_CPP_FLAGS += -mmcu=$(MCU) +C_CPP_FLAGS += -Wl,-gc-sections +SHARED_FLAGS += -Os + +C_CPP_FLAGS += -mcall-prologues +C_CPP_FLAGS += -g +C_CPP_FLAGS += -Wl,-relax +C_CPP_FLAGS += -MMD +C_CPP_FLAGS += -ffunction-sections +C_CPP_FLAGS += -fdata-sections + +LFLAGS += -flto +LFLAGS += -fuse-linker-plugin +LFLAGS += -lc -lm +# LFLAGS += -L/usr/avr/lib/avr5/ -L/usr/lib/gcc/avr/12.2.0/avr5 -lgcc -lm -lc -latmega32u4 +# LFLAGS += -flto -fuse-linker-plugin -mmcu=atmega32u4 -Wl,--gc-sections -Os -lc -lm + + +CFLAGS += -fno-fat-lto-objects +# CFLAGS += -std=gnu11 + +CPPFLAGS += -fpermissive +CPPFLAGS += -fno-exceptions +CPPFLAGS += -fno-threadsafe-statics +CPPFLAGS += -fno-devirtualize +# CPPFLAGS += -std=gnu++11 + + +LFLAGS += $(SHARED_FLAGS) +CFLAGS += $(C_CPP_FLAGS) $(SHARED_FLAGS) +CPPFLAGS += $(C_CPP_FLAGS) $(SHARED_FLAGS) include zumo.mk OBJS := $(patsubst %.c,%.o, $(SRCS)) OBJS := $(patsubst %.cpp,%.o, $(OBJS)) -MAKEFLAGS += -j4 +MAKEFLAGS += -j .PHONY: all clean flash all: $(TARGET).hex %.o: %.cpp - $(C++) $(CFLAGS) -o $@ -c $< + $(C++) $(CPPFLAGS) -o $@ -c $< %.o: %.c $(CC) $(CFLAGS) -o $@ -c $< diff --git a/zumo/zumo.mk b/zumo/zumo.mk index 3645513..f5ab84b 100644 --- a/zumo/zumo.mk +++ b/zumo/zumo.mk @@ -1,31 +1,39 @@ -CFLAGS += -DF_CPU=16000000 -CFLAGS += -I./lib/zumo-32u4-arduino-library/src -CFLAGS += -I./lib/fastgpio-arduino -CFLAGS += -I./lib/pushbutton-arduino -CFLAGS += -I./lib/usb-pause-arduino -CFLAGS += -I./lib/pololu-buzzer-arduino/src -CFLAGS += -I./lib/pololu-hd44780-arduino -CFLAGS += -I./lib/pololu-menu-arduino/src -CFLAGS += -I./lib/pololu-oled-arduino/src -CFLAGS += -I./lib/ArduinoCore-avr/cores/arduino -CFLAGS += -I./lib/ArduinoCore-avr/libraries/HID/src -CFLAGS += -I./lib/ArduinoCore-avr/libraries/SoftwareSerial/src -CFLAGS += -I./lib/ArduinoCore-avr/libraries/SPI/src -CFLAGS += -I./lib/ArduinoCore-avr/libraries/EEPROM/src -CFLAGS += -I./lib/ArduinoCore-avr/libraries/Wire/src -CFLAGS += -I./lib/ArduinoCore-avr/variants/circuitplay32u4 +C_CPP_FLAGS += -DF_CPU=16000000L +C_CPP_FLAGS += -D__PROG_TYPES_COMPAT__ +C_CPP_FLAGS += -DARDUINO=1819 +C_CPP_FLAGS += -DARDUINO_AVR_LEONARDO +C_CPP_FLAGS += -DARDUINO_ARCH_AVR +C_CPP_FLAGS += -DARDUINO_BOARD='"AVR_LEONARDO"' +C_CPP_FLAGS += -DARDUINO_VARIANT='"leonardo"' +C_CPP_FLAGS += -DUSB_VID=0x2341 +C_CPP_FLAGS += -DUSB_PID=0x8036 +C_CPP_FLAGS += -DUSB_PRODUCT='"Arduino Leonardo"' +C_CPP_FLAGS += -DUSB_MANUFACTURER='"Unknown"' -CFLAGS += -L/usr/avr/lib/avr5/ -L/usr/lib/gcc/avr/12.2.0/avr5 -lgcc -lm -lc -latmega32u4 -LFLAGS += -L/usr/avr/lib/avr5/ -L/usr/lib/gcc/avr/12.2.0/avr5 -lgcc -lm -lc -latmega32u4 +C_CPP_FLAGS += -I./lib/zumo-32u4-arduino-library/src +C_CPP_FLAGS += -I./lib/fastgpio-arduino +C_CPP_FLAGS += -I./lib/pushbutton-arduino +C_CPP_FLAGS += -I./lib/usb-pause-arduino +C_CPP_FLAGS += -I./lib/pololu-buzzer-arduino/src +C_CPP_FLAGS += -I./lib/pololu-hd44780-arduino +C_CPP_FLAGS += -I./lib/pololu-menu-arduino/src +C_CPP_FLAGS += -I./lib/pololu-oled-arduino/src +C_CPP_FLAGS += -I./lib/ArduinoCore-avr/cores/arduino +C_CPP_FLAGS += -I./lib/ArduinoCore-avr/libraries/HID/src +C_CPP_FLAGS += -I./lib/ArduinoCore-avr/libraries/SoftwareSerial/src +C_CPP_FLAGS += -I./lib/ArduinoCore-avr/libraries/SPI/src +C_CPP_FLAGS += -I./lib/ArduinoCore-avr/libraries/EEPROM/src +C_CPP_FLAGS += -I./lib/ArduinoCore-avr/libraries/Wire/src +C_CPP_FLAGS += -I./lib/ArduinoCore-avr/variants/leonardo -LIBS += lib/ArduinoCore-avr/cores/arduino/PluggableUSB.cpp +# LIBS += lib/ArduinoCore-avr/cores/arduino/PluggableUSB.cpp LIBS += lib/ArduinoCore-avr/cores/arduino/CDC.cpp LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial.cpp LIBS += lib/ArduinoCore-avr/cores/arduino/USBCore.cpp -# LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial0.cpp -# LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial1.cpp -# LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial2.cpp -# LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial3.cpp +LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial0.cpp +LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial1.cpp +LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial2.cpp +LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial3.cpp LIBS += lib/ArduinoCore-avr/cores/arduino/IPAddress.cpp LIBS += lib/ArduinoCore-avr/cores/arduino/Print.cpp LIBS += lib/ArduinoCore-avr/cores/arduino/Stream.cpp @@ -34,10 +42,20 @@ LIBS += lib/ArduinoCore-avr/cores/arduino/WString.cpp LIBS += lib/ArduinoCore-avr/cores/arduino/abi.cpp LIBS += lib/ArduinoCore-avr/cores/arduino/main.cpp LIBS += lib/ArduinoCore-avr/cores/arduino/new.cpp -LIBS += lib/ArduinoCore-avr/libraries/HID/src/HID.cpp -LIBS += lib/ArduinoCore-avr/libraries/SPI/src/SPI.cpp +# LIBS += lib/ArduinoCore-avr/libraries/HID/src/HID.cpp +# LIBS += lib/ArduinoCore-avr/libraries/SPI/src/SPI.cpp # LIBS += lib/ArduinoCore-avr/libraries/SoftwareSerial/src/SoftwareSerial.cpp LIBS += lib/ArduinoCore-avr/libraries/Wire/src/Wire.cpp +LIBS += lib/ArduinoCore-avr/cores/arduino/WInterrupts.c +LIBS += lib/ArduinoCore-avr/cores/arduino/hooks.c +LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_shift.c +LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_digital.c +LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_analog.c +LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_pulse.c +LIBS += lib/ArduinoCore-avr/cores/arduino/wiring.c +LIBS += lib/ArduinoCore-avr/cores/arduino/Tone.cpp +# LIBS += lib/ArduinoCore-avr/libraries/Wire/src/utility/twi.c + LIBS += lib/pololu-buzzer-arduino/src/PololuBuzzer.cpp LIBS += lib/pushbutton-arduino/Pushbutton.cpp LIBS += lib/zumo-32u4-arduino-library/src/QTRSensors.cpp @@ -50,16 +68,6 @@ LIBS += lib/usb-pause-arduino/USBPause.cpp LIBS += lib/pololu-hd44780-arduino/PololuHD44780.cpp LIBS += lib/fastgpio-arduino/FastGPIO.cpp LIBS += lib/pololu-oled-arduino/src/font.cpp -# LIBS += lib/ArduinoCore-avr/cores/arduino/Tone.cpp -# LIBS += lib/ArduinoCore-avr/libraries/Wire/src/utility/twi.c - -LIBS += lib/ArduinoCore-avr/cores/arduino/WInterrupts.c -LIBS += lib/ArduinoCore-avr/cores/arduino/hooks.c -LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_shift.c -LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_digital.c -LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_analog.c -# LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_pulse.c -LIBS += lib/ArduinoCore-avr/cores/arduino/wiring.c SRCS += $(LIBS) -- cgit v1.2.3 From 2f8d3ac42bb0b5bf644af27b59ee8b02dbb50397 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 10 May 2023 13:24:46 +0200 Subject: add docs folder with pandoc/latex document template --- doc/.gitignore | 17 +++++++++++++++++ doc/base.tex | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/makefile | 20 ++++++++++++++++++++ doc/research.md | 4 ++++ doc/research.tex | 3 +++ 5 files changed, 98 insertions(+) create mode 100644 doc/.gitignore create mode 100644 doc/base.tex create mode 100644 doc/makefile create mode 100644 doc/research.md create mode 100644 doc/research.tex diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 0000000..25dcb3b --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,17 @@ +# latex files +*.aux +*.bbl +*.bcf +*.blg +*.fdb_latexmk +*.fls +*.log +*.out +*.run.xml +*.synctex.gz +*.toc +*.synctex(busy) +*.md.tex + +# ignore output files +*.pdf diff --git a/doc/base.tex b/doc/base.tex new file mode 100644 index 0000000..ecc3c8d --- /dev/null +++ b/doc/base.tex @@ -0,0 +1,54 @@ +\documentclass[11pt, a4paper, english]{article} +\usepackage[margin=1in]{geometry} + +\usepackage{float} +\usepackage{babel} +\usepackage{siunitx} +\usepackage{amsmath} +\usepackage{csquotes} +\usepackage{parskip} +\usepackage{unicode-math} +\usepackage{fontspec} +\usepackage{tabularx} +\usepackage{booktabs} +\usepackage{needspace} +\usepackage{hyperref} +% \usepackage[backend=biber, +% bibencoding=utf8, +% style=apa +% ]{biblatex} + +\setmainfont{TeX Gyre Schola} +\setmathfont{TeX Gyre Schola Math} +\sisetup{ + group-separator = {.}, + output-decimal-marker = {,} +} + +\bigskipamount=7mm +\medskipamount=4mm +\parindent=0mm + +\title{\doctitle} +\author{ + Bjorn Martens\\2187272 + \and + Joshua Regnier\\2183008 + \and + Loek Le Blansch\\2180996 + \and + Niels Stunnebrink\\2184532 +} + +\begin{document} +\begin{titlepage} +\maketitle +\thispagestyle{empty} +\end{titlepage} + +\tableofcontents +\newpage + +\input{\jobname.md.tex} +\end{document} + diff --git a/doc/makefile b/doc/makefile new file mode 100644 index 0000000..9f4dfa0 --- /dev/null +++ b/doc/makefile @@ -0,0 +1,20 @@ +.PHONY: all clean + +TARGET := $(patsubst %.md,%.pdf, $(wildcard *.md)) + +all: $(TARGET) + +garbage = $1.aux $1.bbl $1.bcf $1.blg $1.fdb_latexmk $1.fls $1.log $1.out $1.run.xml $1.synctex.gz $1.toc $1.md.tex + +%.pdf: %.svg + rsvg-convert -f pdf -o $@ $< + +%.pdf: %.tex base.tex %.md.tex + latexmk $< -shell-escape -halt-on-error -lualatex -f -g + +%.md.tex: %.md + pandoc -t latex -o $@ $< + +clean: + $(RM) $(call garbage,research) research.pdf + diff --git a/doc/research.md b/doc/research.md new file mode 100644 index 0000000..1a616f9 --- /dev/null +++ b/doc/research.md @@ -0,0 +1,4 @@ +# test 1 + +this is a test document in markdown that will get converted into latex + diff --git a/doc/research.tex b/doc/research.tex new file mode 100644 index 0000000..af15484 --- /dev/null +++ b/doc/research.tex @@ -0,0 +1,3 @@ +\newcommand\doctitle{Research document} +\input{base.tex} + -- cgit v1.2.3 From 7b76b2c73d53a2ed31e3c887926f44dd02de44d2 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 10 May 2023 15:20:35 +0200 Subject: added research --- doc/base.tex | 6 ++-- doc/research.md | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 96 insertions(+), 4 deletions(-) diff --git a/doc/base.tex b/doc/base.tex index ecc3c8d..9c1c908 100644 --- a/doc/base.tex +++ b/doc/base.tex @@ -6,7 +6,6 @@ \usepackage{siunitx} \usepackage{amsmath} \usepackage{csquotes} -\usepackage{parskip} \usepackage{unicode-math} \usepackage{fontspec} \usepackage{tabularx} @@ -27,7 +26,10 @@ \bigskipamount=7mm \medskipamount=4mm -\parindent=0mm +% \parindent=0mm +\parskip=1ex + +\def\tightlist{} \title{\doctitle} \author{ diff --git a/doc/research.md b/doc/research.md index 1a616f9..ba697a8 100644 --- a/doc/research.md +++ b/doc/research.md @@ -1,4 +1,94 @@ -# test 1 +# Problem statement -this is a test document in markdown that will get converted into latex +The following is the original project description (translated to English): +> I would like to bring to market a vehicle that can drive independently from A +> to B. The vehicle must take into account traffic rules, road signs, traffic +> lights, etc. Research is being conducted using a small cart, the Pololu Zumo +> 32U4, on which a camera module Nicla Vision is mounted. The aim is to +> investigate the most appropriate method of recognizing the road, traffic +> signs and traffic lights. This should be demonstrated with a proof of +> concept. The cart does not need to drive fast, so the image processing does +> not need to be very fast. Assume one frame per second (or faster). + +# TBD: The big question + +## Communication between the Nicla and Zumo + +In order to make the Zumo robot both detect where it is on a road, and steer to +keep driving on said road, some sort of communication needs to exist between +the Nicla and Zumo. As mentioned earlier\footnote{dit is nog niet benoemd}, all +machine vision-related tasks will happen on the Nicla board. Because the Nicla +board is the first to know how much to steer the cart, it makes sense to have +it control the cart by giving the Nicla a 'steering wheel' of sorts. + +This section tries to answer the question "What is the best protocol to use +over the existing UART connection between the Nicla and Zumo?". After a +brainstorm session, we came up with the following specifications for the +communication protocol: + +1. **Low bandwidth** + Less data means more responsive steering +2. **As simple as possible** + The Nicla only needs to control speed and steering +3. **Easy to mock and test** + The cart should be able to be controlled using a mock driver and the Nicla's + output should be testable (preferably using unit tests) +4. **Adaptive to noisy data** + The cart should gradually change speed and steering direction as to not slip + or cause excessive motion blur for the camera module on the Nicla +5. **Adaptive to Nicla failure** + If the Nicla crashes or can't detect anything, it will stop sending control + commands. In this case, the Zumo robot should slowly come to a halt. + +Where possible, it's generally benificial to re-use existing code to save on +time. Existing code exists for a custom binary protocol and a text-based +command protocol. Both of these were designed without bandwidth or latency in +mind, and mostly focus on robustness in the case of temporary disconnects or +noise on the communication lines, so a new protocol needs to be made. + +To address specification 1 and 2, the command length is fixed at 1 byte. This +means that UARTs built-in start/stop bit will take care of message start/end +detection, since most software interfaces for UART (including Arduino) string +multiple sequential messages together even if they're not part of the same UART +packet. + +To mock messages from the Nicla to the Zumo robot, a simple USB serial to UART +cable can be used, along with a small C or Python program to convert +keyboard/mouse input into steering/speed commands. A small software layer can +be implemented on the Nicla to log the semantic meaning of the commands instead +of sending actual UART data when run in a unit test. + +A PID controller can be used to smoothly interpolate between input +speed/steering values. This would also introduce some lag between when the +Nicla knows how much to steer, and when the Zumo actually steered the wanted +amount. Smoothing the speed/steering values does make it virtually impossible +for the Nicla to make it's own input data unusable because of motion blur, so +the lag needs to be handled in some other way as directly controlling speed +values without interpolation would lead to a garbage-in-garbage-out system. The +simplest solution to motion blur is limiting the maximum speed the Zumo robot +can drive at, which is the solution we're going to use as speed is not one of +the criteria of the complete system\footnote{Problem statement +(\ref{problem-statement})}. + +In the case the Nicla module crashes or fails to detect the road or roadsigns, +it will stop sending commands. If the Zumo robot would naively continue at it's +current speed, it could drive itself into nearby walls, shoes, pets, etc. To +make sure the robot doesn't get 'lost', it needs to slow down once it hasn't +received commands for some time. As mentioned in section \ref{TODO}, the Nicla +module is able to process at about 10 frames per second, so 2 seconds is a +reasonable time-out period. + +\def\communicationConclusion{ +The complete protocol will consist of single byte commands. A byte can either +change the cart speed or steering direction, both will apply gradually. When no +commands have been received for more than 2 seconds, the Zumo robot will +gradually slow down until it is stopped. Exact specifications of commands are +provided in the protocol specification document\footnote{dit document bestaat +nog niet}. +} +\communicationConclusion + +## Conclusion + +\communicationConclusion -- cgit v1.2.3 From 0a59a63fc5f4b6bcb50cdf97902c555b2d54e83d Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 11 May 2023 10:29:01 +0200 Subject: rename document and add required sections --- doc/dui.md | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/dui.tex | 3 ++ doc/research.md | 94 --------------------------------------------------- doc/research.tex | 3 -- 4 files changed, 103 insertions(+), 97 deletions(-) create mode 100644 doc/dui.md create mode 100644 doc/dui.tex delete mode 100644 doc/research.md delete mode 100644 doc/research.tex diff --git a/doc/dui.md b/doc/dui.md new file mode 100644 index 0000000..ede73c8 --- /dev/null +++ b/doc/dui.md @@ -0,0 +1,100 @@ +# Introduction + +# Problem statement + +The following is the original project description (translated to English): + +> I would like to bring to market a vehicle that can drive independently from A +> to B. The vehicle must take into account traffic rules, road signs, traffic +> lights, etc. Research is being conducted using a small cart, the Pololu Zumo +> 32U4, on which a camera module Nicla Vision is mounted. The aim is to +> investigate the most appropriate method of recognizing the road, traffic +> signs and traffic lights. This should be demonstrated with a proof of +> concept. The cart does not need to drive fast, so the image processing does +> not need to be very fast. Assume one frame per second (or faster). + +# Specifications + +# Architecture + +# Research + +## Communication between the Nicla and Zumo + +In order to make the Zumo robot both detect where it is on a road, and steer to +keep driving on said road, some sort of communication needs to exist between +the Nicla and Zumo. As mentioned earlier\footnote{dit is nog niet benoemd}, all +machine vision-related tasks will happen on the Nicla board. Because the Nicla +board is the first to know how much to steer the cart, it makes sense to have +it control the cart by giving the Nicla a 'steering wheel' of sorts. + +This section tries to answer the question "What is the best protocol to use +over the existing UART connection between the Nicla and Zumo?". After a +brainstorm session, we came up with the following specifications for the +communication protocol: + +1. **Low bandwidth** + Less data means more responsive steering +2. **As simple as possible** + The Nicla only needs to control speed and steering +3. **Easy to mock and test** + The cart should be able to be controlled using a mock driver and the Nicla's + output should be testable (preferably using unit tests) +4. **Adaptive to noisy data** + The cart should gradually change speed and steering direction as to not slip + or cause excessive motion blur for the camera module on the Nicla +5. **Adaptive to Nicla failure** + If the Nicla crashes or can't detect anything, it will stop sending control + commands. In this case, the Zumo robot should slowly come to a halt. + +Where possible, it's generally benificial to re-use existing code to save on +time. Existing code exists for a custom binary protocol and a text-based +command protocol. Both of these were designed without bandwidth or latency in +mind, and mostly focus on robustness in the case of temporary disconnects or +noise on the communication lines, so a new protocol needs to be made. + +To address specification 1 and 2, the command length is fixed at 1 byte. This +means that UARTs built-in start/stop bit will take care of message start/end +detection, since most software interfaces for UART (including Arduino) string +multiple sequential messages together even if they're not part of the same UART +packet. + +To mock messages from the Nicla to the Zumo robot, a simple USB serial to UART +cable can be used, along with a small C or Python program to convert +keyboard/mouse input into steering/speed commands. A small software layer can +be implemented on the Nicla to log the semantic meaning of the commands instead +of sending actual UART data when run in a unit test. + +A PID controller can be used to smoothly interpolate between input +speed/steering values. This would also introduce some lag between when the +Nicla knows how much to steer, and when the Zumo actually steered the wanted +amount. Smoothing the speed/steering values does make it virtually impossible +for the Nicla to make it's own input data unusable because of motion blur, so +the lag needs to be handled in some other way as directly controlling speed +values without interpolation would lead to a garbage-in-garbage-out system. The +simplest solution to motion blur is limiting the maximum speed the Zumo robot +can drive at, which is the solution we're going to use as speed is not one of +the criteria of the complete system\footnote{Problem statement +(\ref{problem-statement})}. + +In the case the Nicla module crashes or fails to detect the road or roadsigns, +it will stop sending commands. If the Zumo robot would naively continue at it's +current speed, it could drive itself into nearby walls, shoes, pets, etc. To +make sure the robot doesn't get 'lost', it needs to slow down once it hasn't +received commands for some time. As mentioned in section \ref{TODO}, the Nicla +module is able to process at about 10 frames per second, so 2 seconds is a +reasonable time-out period. + +\def\communicationConclusion{ +The complete protocol will consist of single byte commands. A byte can either +change the cart speed or steering direction, both will apply gradually. When no +commands have been received for more than 2 seconds, the Zumo robot will +gradually slow down until it is stopped. Exact specifications of commands are +provided in the protocol specification document\footnote{dit document bestaat +nog niet}. +} +\communicationConclusion + +# Conclusion + +\communicationConclusion diff --git a/doc/dui.tex b/doc/dui.tex new file mode 100644 index 0000000..612ee40 --- /dev/null +++ b/doc/dui.tex @@ -0,0 +1,3 @@ +\newcommand\doctitle{DUI} +\input{base.tex} + diff --git a/doc/research.md b/doc/research.md deleted file mode 100644 index ba697a8..0000000 --- a/doc/research.md +++ /dev/null @@ -1,94 +0,0 @@ -# Problem statement - -The following is the original project description (translated to English): - -> I would like to bring to market a vehicle that can drive independently from A -> to B. The vehicle must take into account traffic rules, road signs, traffic -> lights, etc. Research is being conducted using a small cart, the Pololu Zumo -> 32U4, on which a camera module Nicla Vision is mounted. The aim is to -> investigate the most appropriate method of recognizing the road, traffic -> signs and traffic lights. This should be demonstrated with a proof of -> concept. The cart does not need to drive fast, so the image processing does -> not need to be very fast. Assume one frame per second (or faster). - -# TBD: The big question - -## Communication between the Nicla and Zumo - -In order to make the Zumo robot both detect where it is on a road, and steer to -keep driving on said road, some sort of communication needs to exist between -the Nicla and Zumo. As mentioned earlier\footnote{dit is nog niet benoemd}, all -machine vision-related tasks will happen on the Nicla board. Because the Nicla -board is the first to know how much to steer the cart, it makes sense to have -it control the cart by giving the Nicla a 'steering wheel' of sorts. - -This section tries to answer the question "What is the best protocol to use -over the existing UART connection between the Nicla and Zumo?". After a -brainstorm session, we came up with the following specifications for the -communication protocol: - -1. **Low bandwidth** - Less data means more responsive steering -2. **As simple as possible** - The Nicla only needs to control speed and steering -3. **Easy to mock and test** - The cart should be able to be controlled using a mock driver and the Nicla's - output should be testable (preferably using unit tests) -4. **Adaptive to noisy data** - The cart should gradually change speed and steering direction as to not slip - or cause excessive motion blur for the camera module on the Nicla -5. **Adaptive to Nicla failure** - If the Nicla crashes or can't detect anything, it will stop sending control - commands. In this case, the Zumo robot should slowly come to a halt. - -Where possible, it's generally benificial to re-use existing code to save on -time. Existing code exists for a custom binary protocol and a text-based -command protocol. Both of these were designed without bandwidth or latency in -mind, and mostly focus on robustness in the case of temporary disconnects or -noise on the communication lines, so a new protocol needs to be made. - -To address specification 1 and 2, the command length is fixed at 1 byte. This -means that UARTs built-in start/stop bit will take care of message start/end -detection, since most software interfaces for UART (including Arduino) string -multiple sequential messages together even if they're not part of the same UART -packet. - -To mock messages from the Nicla to the Zumo robot, a simple USB serial to UART -cable can be used, along with a small C or Python program to convert -keyboard/mouse input into steering/speed commands. A small software layer can -be implemented on the Nicla to log the semantic meaning of the commands instead -of sending actual UART data when run in a unit test. - -A PID controller can be used to smoothly interpolate between input -speed/steering values. This would also introduce some lag between when the -Nicla knows how much to steer, and when the Zumo actually steered the wanted -amount. Smoothing the speed/steering values does make it virtually impossible -for the Nicla to make it's own input data unusable because of motion blur, so -the lag needs to be handled in some other way as directly controlling speed -values without interpolation would lead to a garbage-in-garbage-out system. The -simplest solution to motion blur is limiting the maximum speed the Zumo robot -can drive at, which is the solution we're going to use as speed is not one of -the criteria of the complete system\footnote{Problem statement -(\ref{problem-statement})}. - -In the case the Nicla module crashes or fails to detect the road or roadsigns, -it will stop sending commands. If the Zumo robot would naively continue at it's -current speed, it could drive itself into nearby walls, shoes, pets, etc. To -make sure the robot doesn't get 'lost', it needs to slow down once it hasn't -received commands for some time. As mentioned in section \ref{TODO}, the Nicla -module is able to process at about 10 frames per second, so 2 seconds is a -reasonable time-out period. - -\def\communicationConclusion{ -The complete protocol will consist of single byte commands. A byte can either -change the cart speed or steering direction, both will apply gradually. When no -commands have been received for more than 2 seconds, the Zumo robot will -gradually slow down until it is stopped. Exact specifications of commands are -provided in the protocol specification document\footnote{dit document bestaat -nog niet}. -} -\communicationConclusion - -## Conclusion - -\communicationConclusion diff --git a/doc/research.tex b/doc/research.tex deleted file mode 100644 index af15484..0000000 --- a/doc/research.tex +++ /dev/null @@ -1,3 +0,0 @@ -\newcommand\doctitle{Research document} -\input{base.tex} - -- cgit v1.2.3 -- cgit v1.2.3 From 4ab9fb8c71d4f519b62d63a2fcd0d5647bc80539 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 11 May 2023 12:58:16 +0200 Subject: add editorconfig --- .editorconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a9383e8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +insert_final_newline = true + +[*.md] +indent_style = space +indent_size = 2 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 From 6472b77eb6582e5133a28f61a448eb6a00cd25b6 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 14 May 2023 14:05:03 +0200 Subject: initial robot driver code --- zumo/main.cpp | 13 ------------- zumo/protocol.cpp | 37 +++++++++++++++++++++++++++++++++++++ zumo/protocol.h | 35 +++++++++++++++++++++++++++++++++++ zumo/zumo.ino | 31 +++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 13 deletions(-) delete mode 100644 zumo/main.cpp create mode 100644 zumo/protocol.cpp create mode 100644 zumo/protocol.h create mode 100644 zumo/zumo.ino diff --git a/zumo/main.cpp b/zumo/main.cpp deleted file mode 100644 index 23d13db..0000000 --- a/zumo/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include - -void setup() { -} - -void loop() { - ledRed(1); - delay(1000); - ledRed(0); - delay(1000); -} diff --git a/zumo/protocol.cpp b/zumo/protocol.cpp new file mode 100644 index 0000000..a0c72f0 --- /dev/null +++ b/zumo/protocol.cpp @@ -0,0 +1,37 @@ +#include + +#include "protocol.h" + +#define DUI_CMD_NULL 0x00 +#define DUI_CMD_SIGN_START 0x01 +#define DUI_CMD_SIGN_END 0x0f +#define DUI_CMD_STEER_START 0x10 +#define DUI_CMD_STEER_END 0x1f +#define DUI_CMD_SPEED_START 0x20 +#define DUI_CMD_SPEED_END 0xff + +void handle_cmd(unsigned char cmd, dui_state_t *state) { + if (cmd == DUI_CMD_NULL) return; + else if (DUI_CMD_SIGN_START <= cmd && cmd <= DUI_CMD_SIGN_END) { + state->current_sign = (dui_e_sign) (cmd - DUI_CMD_SIGN_START); + } else if (DUI_CMD_STEER_START <= cmd && cmd <= DUI_CMD_STEER_END) { + state->steer = (float) (cmd - DUI_CMD_STEER_START) / (float) (DUI_CMD_STEER_END - DUI_CMD_STEER_START); + } else if (DUI_CMD_SPEED_START <= cmd && cmd <= DUI_CMD_SPEED_END) { + state->speed = ((float) (cmd - DUI_CMD_SPEED_START) / (float) (DUI_CMD_SPEED_START - DUI_CMD_SPEED_END) * (float) 2 - (float) 1); + } +} + +void apply_state(dui_state_t *state) { + const float MAX_MOTOR_DIFF = 0.6f; // 0 to 1 + float motor_l = 0.5f * state->speed * (+1.f * state->steer * MAX_MOTOR_DIFF - MAX_MOTOR_DIFF + 2) * state->speed_mod; + float motor_r = 0.5f * state->speed * (-1.f * state->steer * MAX_MOTOR_DIFF - MAX_MOTOR_DIFF + 2) * state->speed_mod; + + Zumo32U4Motors::setLeftSpeed((int16_t) motor_l); + Zumo32U4Motors::setRightSpeed((int16_t) motor_r); + + // TODO: print sign on OLED screen +} + +unsigned char uart_read() { + return 0x00; +} diff --git a/zumo/protocol.h b/zumo/protocol.h new file mode 100644 index 0000000..662a5ce --- /dev/null +++ b/zumo/protocol.h @@ -0,0 +1,35 @@ +#pragma once + +typedef enum { + DUI_CMD_NULL, + DUI_CMD_SIGN, + DUI_CMD_SPEED, + DUI_CMD_STEER, +} dui_e_cmd; + +typedef enum { + DUI_SIGN_NONE, /** @brief no sign */ + DUI_SIGN_STOP, /** @brief stop (set speed to 0) */ + DUI_SIGN_LEFT, /** @brief turn left (set steer to -1) */ + DUI_SIGN_RIGHT, /** @brief turn right (set steer to +1) */ + DUI_SIGN_SPEED_LIMIT_LOW, /** @brief slow down (speed limit 0.5) */ + DUI_SIGN_SPEED_LIMIT_HIGH, /** @brief full speed (speed limit 1.0) */ + DUI_SIGN_LIGHT_STOP, /** @brief traffic light red (set speed to 0) */ + DUI_SIGN_LIGHT_FLOOR_IT, /** @brief traffic light orange (set speed to 2 temporarily) */ + DUI_SIGN_LIGHT_GO, /** @brief traffic light green (keep current speed) */ +} dui_e_sign; + +typedef struct { + float steer; /** @brief steer value (-1 is left, +1 is right) */ + float speed; /** @brief speed (0-15) */ + dui_e_sign current_sign; /** @brief last seen sign */ + float speed_mod; /** @brief global speed multiplier */ +} dui_state_t; + +/** @brief non blocking read byte */ +unsigned char uart_read(); +/** @brief read and apply cmd to state */ +void handle_cmd(unsigned char cmd, dui_state_t *state); +/** @brief apply state to motors */ +void apply_state(dui_state_t* state); + diff --git a/zumo/zumo.ino b/zumo/zumo.ino new file mode 100644 index 0000000..ed63f6e --- /dev/null +++ b/zumo/zumo.ino @@ -0,0 +1,31 @@ +#include +#include +#include + +#include "protocol.h" + +dui_state_t g_dui_target_state = { + .steer = 1.0f, + .speed = 1.0f, + .current_sign = DUI_SIGN_NONE, + .speed_mod =96.0, +}; +dui_state_t g_dui_current_state = { + .steer = 0, + .speed = 0, + .current_sign = DUI_SIGN_NONE, + .speed_mod = 1.0, +}; + +void setup() { +} + +void loop() { + unsigned char cmd = 0; + while ((cmd = uart_read())) + handle_cmd(cmd, &g_dui_target_state); + + //TODO: PID controllers + sign handlers + + apply_state(&g_dui_target_state); +} -- cgit v1.2.3 From e3c22d70487985a6dcb7a5866c8baeecbbaa4103 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 14 May 2023 15:07:21 +0200 Subject: add PID controller --- zumo/pid.cpp | 36 ++++++++++++++++++++++++++++++++++++ zumo/pid.h | 7 +++++++ zumo/protocol.cpp | 8 +++++--- zumo/zumo.ino | 17 ++++++++++------- 4 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 zumo/pid.cpp create mode 100644 zumo/pid.h diff --git a/zumo/pid.cpp b/zumo/pid.cpp new file mode 100644 index 0000000..594d136 --- /dev/null +++ b/zumo/pid.cpp @@ -0,0 +1,36 @@ +#include "pid.h" + +class PID { +private: + float A0, A1, A2; + float error[3] = {0}; + float dt = 0.010; + float output = 0; + +public: + PID(float P, float I, float D) { + A0 = P + I*dt + D/dt; + A1 = -P - 2*D/dt; + A2 = D/dt; + } + + // https://en.wikipedia.org/wiki/PID_controller#Pseudocode + float iter(float current, float target) { + error[2] = error[1]; + error[1] = error[0]; + error[0] = target - current; + output = output + A0 * error[0] + A1 * error[1] + A2 * error[2]; + return output; + } +}; + +PID speed_pid(0.1, 0.0, 0.0); // TODO: tune these (garbage values) +PID steer_pid(0.1, 0.0, 0.0); +PID speed_mod_pid(1, 1, 1); +void apply_pid(dui_state_t* target, dui_state_t* current) { + current->speed = speed_pid.iter(current->speed, target->speed); + current->steer = steer_pid.iter(current->steer, target->steer); + // current->speed_mod = speed_mod_pid.iter(current->speed_mod, target->speed_mod); + current->speed_mod = target->speed_mod; +} + diff --git a/zumo/pid.h b/zumo/pid.h new file mode 100644 index 0000000..2cdbc91 --- /dev/null +++ b/zumo/pid.h @@ -0,0 +1,7 @@ +#pragma once + +#include "protocol.h" + +/** @brief edit `current` to be closer to `target` using PID controllers */ +void apply_pid(dui_state_t* target, dui_state_t* current); + diff --git a/zumo/protocol.cpp b/zumo/protocol.cpp index a0c72f0..fea8a00 100644 --- a/zumo/protocol.cpp +++ b/zumo/protocol.cpp @@ -2,6 +2,9 @@ #include "protocol.h" +#define DUI_SPEED_MOD 96.0f +#define DUI_MOTOR_DIFF 0.6f + #define DUI_CMD_NULL 0x00 #define DUI_CMD_SIGN_START 0x01 #define DUI_CMD_SIGN_END 0x0f @@ -22,9 +25,8 @@ void handle_cmd(unsigned char cmd, dui_state_t *state) { } void apply_state(dui_state_t *state) { - const float MAX_MOTOR_DIFF = 0.6f; // 0 to 1 - float motor_l = 0.5f * state->speed * (+1.f * state->steer * MAX_MOTOR_DIFF - MAX_MOTOR_DIFF + 2) * state->speed_mod; - float motor_r = 0.5f * state->speed * (-1.f * state->steer * MAX_MOTOR_DIFF - MAX_MOTOR_DIFF + 2) * state->speed_mod; + float motor_l = 0.5f * state->speed * (+1.f * state->steer * DUI_MOTOR_DIFF - DUI_MOTOR_DIFF + 2) * state->speed_mod * DUI_SPEED_MOD; + float motor_r = 0.5f * state->speed * (-1.f * state->steer * DUI_MOTOR_DIFF - DUI_MOTOR_DIFF + 2) * state->speed_mod * DUI_SPEED_MOD; Zumo32U4Motors::setLeftSpeed((int16_t) motor_l); Zumo32U4Motors::setRightSpeed((int16_t) motor_r); diff --git a/zumo/zumo.ino b/zumo/zumo.ino index ed63f6e..f59bd36 100644 --- a/zumo/zumo.ino +++ b/zumo/zumo.ino @@ -3,29 +3,32 @@ #include #include "protocol.h" +#include "pid.h" dui_state_t g_dui_target_state = { .steer = 1.0f, .speed = 1.0f, .current_sign = DUI_SIGN_NONE, - .speed_mod =96.0, + .speed_mod = 1.f, }; dui_state_t g_dui_current_state = { - .steer = 0, - .speed = 0, + .steer = 0.f, + .speed = 1.f, .current_sign = DUI_SIGN_NONE, - .speed_mod = 1.0, + .speed_mod = 1.f, }; void setup() { } void loop() { - unsigned char cmd = 0; + unsigned char cmd = 0x00; while ((cmd = uart_read())) handle_cmd(cmd, &g_dui_target_state); - //TODO: PID controllers + sign handlers + apply_pid(&g_dui_target_state, &g_dui_current_state); - apply_state(&g_dui_target_state); + apply_state(&g_dui_current_state); + + delay(10); } -- cgit v1.2.3 From ff7a914055cf851c994ee037342a331902f84a0c Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 19 May 2023 13:34:31 +0200 Subject: add pidtest --- zumo/.gitignore | 1 + zumo/pid.cpp | 44 +++++++++++++++++++++----------------------- zumo/pid.h | 13 +++++++++++++ zumo/pidtest.cpp | 35 +++++++++++++++++++++++++++++++++++ zumo/pidtest.mk | 21 +++++++++++++++++++++ 5 files changed, 91 insertions(+), 23 deletions(-) create mode 100644 zumo/pidtest.cpp create mode 100644 zumo/pidtest.mk diff --git a/zumo/.gitignore b/zumo/.gitignore index d3e1535..888e905 100644 --- a/zumo/.gitignore +++ b/zumo/.gitignore @@ -3,3 +3,4 @@ main *.hex compile_commands.json .cache +pidtest diff --git a/zumo/pid.cpp b/zumo/pid.cpp index 594d136..9bef08f 100644 --- a/zumo/pid.cpp +++ b/zumo/pid.cpp @@ -1,35 +1,33 @@ #include "pid.h" -class PID { -private: - float A0, A1, A2; - float error[3] = {0}; - float dt = 0.010; - float output = 0; +PID::PID(float P, float I, float D) { + A0 = P + I*dt + D/dt; + A1 = -P - 2*D/dt; + A2 = D/dt; +} -public: - PID(float P, float I, float D) { - A0 = P + I*dt + D/dt; - A1 = -P - 2*D/dt; - A2 = D/dt; - } +// https://en.wikipedia.org/wiki/PID_controller#Pseudocode +float PID::iter(float target) { + error[2] = error[1]; + error[1] = error[0]; + error[0] = target - output; + output = output + A0 * error[0] + A1 * error[1] + A2 * error[2]; + return output; +} - // https://en.wikipedia.org/wiki/PID_controller#Pseudocode - float iter(float current, float target) { - error[2] = error[1]; - error[1] = error[0]; - error[0] = target - current; - output = output + A0 * error[0] + A1 * error[1] + A2 * error[2]; - return output; - } -}; +void PID::reset(float value) { + error[0] = 0.0; + error[1] = 0.0; + error[2] = 0.0; + output = value; +} PID speed_pid(0.1, 0.0, 0.0); // TODO: tune these (garbage values) PID steer_pid(0.1, 0.0, 0.0); PID speed_mod_pid(1, 1, 1); void apply_pid(dui_state_t* target, dui_state_t* current) { - current->speed = speed_pid.iter(current->speed, target->speed); - current->steer = steer_pid.iter(current->steer, target->steer); + current->speed = speed_pid.iter(target->speed); + current->steer = steer_pid.iter(target->steer); // current->speed_mod = speed_mod_pid.iter(current->speed_mod, target->speed_mod); current->speed_mod = target->speed_mod; } diff --git a/zumo/pid.h b/zumo/pid.h index 2cdbc91..fbcd063 100644 --- a/zumo/pid.h +++ b/zumo/pid.h @@ -2,6 +2,19 @@ #include "protocol.h" +class PID { +private: + float A0, A1, A2; + float error[3] = {0}; + float dt = 0.010; + float output = 0; + +public: + PID(float P, float I, float D); + float iter(float target); + void reset(float value); +}; + /** @brief edit `current` to be closer to `target` using PID controllers */ void apply_pid(dui_state_t* target, dui_state_t* current); diff --git a/zumo/pidtest.cpp b/zumo/pidtest.cpp new file mode 100644 index 0000000..f5198bb --- /dev/null +++ b/zumo/pidtest.cpp @@ -0,0 +1,35 @@ +#include +#include + +#include "pid.h" + +std::random_device rd; +std::mt19937 rng(rd()); +std::uniform_real_distribution uni(0,13); + +auto random_integer = uni(rng); + +int main() { + float P, I, D; + do { + // P = uni(rng); + // I = uni(rng); + // D = uni(rng); + P = 10; + I = 0.1; + D = 10; + PID test(P, I, D); + test.reset(0.0); + + float val = 0; + for (unsigned int i = 0; i < 100; i++) val = test.iter(1.0); + // if (val > 0.999 && val < 1.001) { + fprintf(stderr, "P: %.3f :: I: %.3f :: D: %.3f\n", P, I, D); + test.reset(0.0); + for (unsigned int i = 0; i < 100; i++) { + printf("%2.8f\n", test.iter(1.0)); + } + exit(0); + // } + } while (false); +} diff --git a/zumo/pidtest.mk b/zumo/pidtest.mk new file mode 100644 index 0000000..5ffe1e1 --- /dev/null +++ b/zumo/pidtest.mk @@ -0,0 +1,21 @@ +CPP = g++ +LD = g++ +RM = rm -f +CFLAGS = +LFLAGS = +TARGET = pidtest + +SRCS := pidtest.cpp pid.cpp +OBJS := pidtest.o pid.o + +all: pidtest + +%.o: %.cpp + $(CPP) -c $(CFLAGS) $< -o $@ + +$(TARGET): $(OBJS) + $(LD) $^ $(LFLAGS) -o $@ + +clean: + $(RM) $(TARGET) $(OBJS) + -- cgit v1.2.3 From 473ab3fd794d0baddd9a6a29ab25cea3d2217fc8 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 19 May 2023 14:46:06 +0200 Subject: pid tuned --- zumo/pid.cpp | 27 +++++++++++++++++++++++---- zumo/pid.h | 9 +++++---- zumo/pidtest.cpp | 35 +++++++++-------------------------- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/zumo/pid.cpp b/zumo/pid.cpp index 9bef08f..fabe1da 100644 --- a/zumo/pid.cpp +++ b/zumo/pid.cpp @@ -1,9 +1,14 @@ #include "pid.h" PID::PID(float P, float I, float D) { - A0 = P + I*dt + D/dt; - A1 = -P - 2*D/dt; - A2 = D/dt; + A0 = P + I * dt; + A1 = -P; + A0d = D / dt; + A1d = -2 * D / dt; + A2d = D / dt; + tau = D / (P * N); + alpha = dt / (2 * tau); + reset(0.0); } // https://en.wikipedia.org/wiki/PID_controller#Pseudocode @@ -11,7 +16,17 @@ float PID::iter(float target) { error[2] = error[1]; error[1] = error[0]; error[0] = target - output; - output = output + A0 * error[0] + A1 * error[1] + A2 * error[2]; + + output = output + A0 * error[0] + A1 * error[1]; + + d1 = d0; + d0 = A0d * error[0] + A1d * error[1] + A2d * error[2]; + fd1 = fd0; + fd0 = ((alpha) / (alpha + 1)) * (d0 + d1) - ((alpha - 1) / (alpha + 1)) * fd1; + output = output + fd0; + + if (output < -1) output = -1; + if (output > 1) output = 1; return output; } @@ -19,6 +34,10 @@ void PID::reset(float value) { error[0] = 0.0; error[1] = 0.0; error[2] = 0.0; + d0 = 0; + d1 = 0; + fd0 = 0; + fd1 = 0; output = value; } diff --git a/zumo/pid.h b/zumo/pid.h index fbcd063..ef733d6 100644 --- a/zumo/pid.h +++ b/zumo/pid.h @@ -4,10 +4,11 @@ class PID { private: - float A0, A1, A2; - float error[3] = {0}; - float dt = 0.010; - float output = 0; + float A0, A1, A0d, A1d, A2d, tau, alpha, d0, d1, fd0, fd1; + float error[3]; + float output; + const float dt = 1.0; + const float N = 10.0; public: PID(float P, float I, float D); diff --git a/zumo/pidtest.cpp b/zumo/pidtest.cpp index f5198bb..b9ce50b 100644 --- a/zumo/pidtest.cpp +++ b/zumo/pidtest.cpp @@ -3,33 +3,16 @@ #include "pid.h" -std::random_device rd; -std::mt19937 rng(rd()); -std::uniform_real_distribution uni(0,13); - -auto random_integer = uni(rng); - int main() { float P, I, D; - do { - // P = uni(rng); - // I = uni(rng); - // D = uni(rng); - P = 10; - I = 0.1; - D = 10; - PID test(P, I, D); - test.reset(0.0); + P = -0.02; + I = 0.13; + D = -300; + PID test(P, I, D); + test.reset(0.0); - float val = 0; - for (unsigned int i = 0; i < 100; i++) val = test.iter(1.0); - // if (val > 0.999 && val < 1.001) { - fprintf(stderr, "P: %.3f :: I: %.3f :: D: %.3f\n", P, I, D); - test.reset(0.0); - for (unsigned int i = 0; i < 100; i++) { - printf("%2.8f\n", test.iter(1.0)); - } - exit(0); - // } - } while (false); + fprintf(stderr, "P: %.3f :: I: %.3f :: D: %.3f\n", P, I, D); + for (unsigned int i = 0; i < 100; i++) { + printf("%2.8f\n", test.iter(i < 50 ? 1.0 : 0.0)); + } } -- cgit v1.2.3 From ba026d8229744a01818d38552ec7271e689d19eb Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 19 May 2023 14:50:22 +0200 Subject: update pid in arduino sketch --- zumo/pid.cpp | 9 ++++----- zumo/pid.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/zumo/pid.cpp b/zumo/pid.cpp index fabe1da..7c1cbda 100644 --- a/zumo/pid.cpp +++ b/zumo/pid.cpp @@ -41,13 +41,12 @@ void PID::reset(float value) { output = value; } -PID speed_pid(0.1, 0.0, 0.0); // TODO: tune these (garbage values) -PID steer_pid(0.1, 0.0, 0.0); -PID speed_mod_pid(1, 1, 1); +PID speed_pid = PID(); +PID steer_pid = PID(); +PID speed_mod_pid = PID(); void apply_pid(dui_state_t* target, dui_state_t* current) { current->speed = speed_pid.iter(target->speed); current->steer = steer_pid.iter(target->steer); - // current->speed_mod = speed_mod_pid.iter(current->speed_mod, target->speed_mod); - current->speed_mod = target->speed_mod; + current->speed_mod = speed_mod_pid.iter(target->speed_mod); } diff --git a/zumo/pid.h b/zumo/pid.h index ef733d6..beb73ac 100644 --- a/zumo/pid.h +++ b/zumo/pid.h @@ -11,7 +11,7 @@ private: const float N = 10.0; public: - PID(float P, float I, float D); + PID(float P = -0.02, float I = 0.13, float D = -300.0); float iter(float target); void reset(float value); }; -- cgit v1.2.3 From 0b55cbd9b98420f3f2a2b9cfd8d384824c9fd4dc Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 19 May 2023 16:06:40 +0200 Subject: protocol specs --- doc/dui.md | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 2 deletions(-) diff --git a/doc/dui.md b/doc/dui.md index ede73c8..65f242d 100644 --- a/doc/dui.md +++ b/doc/dui.md @@ -17,6 +17,95 @@ The following is the original project description (translated to English): # Architecture +## Nicla/Zumo communication protocol + +The communication protocol used to control the Zumo from the Nicla uses UART to +send ranged numbers in a single byte. Figure \ref{tab:protocol-ranges} shows +which number ranges correspond to which controls. + +\begin{figure}[h] +\centering +\begin{tabular}{rl} +\toprule +\textbf{Description} & \textbf{Range (inclusive)}\\ +\midrule +(unused) & \texttt{0x00}\\ +Signs & \texttt{0x01} - \texttt{0x0f}\\ +Speed & \texttt{0x10} - \texttt{0x1f}\\ +Steering & \texttt{0x20} - \texttt{0xff}\\ +\bottomrule +\end{tabular} +\caption{Protocol command ranges} +\label{tab:protocol-ranges} +\end{figure} + +### Signs + +The Zumo stores the last sign received, and displays it's name on the OLED +display using the lookup table in figure \ref{tab:protocol-signs}. The sign ID +is calculated by subtracting the start offset of the sign command range from +the command as shown in figure \ref{tab:protocol-ranges}. + +\begin{figure}[h] +\centering +\begin{tabular}{ll} +\toprule +\textbf{ID} & \textbf{Name}\\ +\midrule +\texttt{0x00} & (clear sign)\\ +\texttt{0x01} & Stop sign\\ +\texttt{0x02} & Turn left\\ +\texttt{0x03} & Turn right\\ +\texttt{0x04} & Low speed limit\\ +\texttt{0x05} & High speed limit\\ +\texttt{0x06} & Traffic light (red)\\ +\texttt{0x07} & Traffic light (orange)\\ +\texttt{0x08} & Traffic light (green)\\ +\bottomrule +\end{tabular} +\caption{Sign lookup table} +\label{tab:protocol-signs} +\end{figure} + +### Speed + +The speed value ranges from \num{0} to \num{1}, and is converted from the +command using the following formula: + +$$ v(n) = \frac{n - 16}{15} $$ + +### Steering + +The steering value is similar to the speed value, but ranges from \num{-1} +(left) to \num{1} (right). The zumo has a built in "influence" value, which +limits the smallest radius the robot can turn at. The steering value is +converted using the following formula: + +$$ s(n) = \frac{n - 32}{223}\cdot2-1 $$ + +## Zumo internal motor control functions + +The Zumo robot receives a speed and steering value. Because the protocol has a +limited precision due to the low amount of data sent, the following formula is +used to control motor speeds $M_1$ and $M_2$ from steering value $s$ and speed +value $v$. The constant $C_1$ is used to globally limit the speed the robot can +drive at. $C_2$ represents the amount of influence the steering value has on +the corner radius, where \num{0} is no steering at all and \num{1} completely +turns of one motor when steering fully left or right: + +$$ M_{1,2} = \frac{v(\pm s C_2 - C_2 + 2)}{2} C_1 $$ + +By default, $C_1 = \num{96}$ and $C_2 = \num{0.6}$ + +The Zumo firmware also smooths incoming values for $s$ and $v$ using a PID +controller. The default constants for the PID controller used are: + +\begin{align*} +K_p &= -0.02\\ +K_i &= +0.13\\ +K_d &= -300.0 +\end{align*} + # Research ## Communication between the Nicla and Zumo @@ -75,7 +164,7 @@ values without interpolation would lead to a garbage-in-garbage-out system. The simplest solution to motion blur is limiting the maximum speed the Zumo robot can drive at, which is the solution we're going to use as speed is not one of the criteria of the complete system\footnote{Problem statement -(\ref{problem-statement})}. +(section \ref{problem-statement})}. In the case the Nicla module crashes or fails to detect the road or roadsigns, it will stop sending commands. If the Zumo robot would naively continue at it's @@ -86,7 +175,7 @@ module is able to process at about 10 frames per second, so 2 seconds is a reasonable time-out period. \def\communicationConclusion{ -The complete protocol will consist of single byte commands. A byte can either +The complete protocol consists of single byte commands. A byte can either change the cart speed or steering direction, both will apply gradually. When no commands have been received for more than 2 seconds, the Zumo robot will gradually slow down until it is stopped. Exact specifications of commands are -- cgit v1.2.3 From 4d1d629ab7a3bd9d661ec5ed25fcf0b4837b946d Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 21 May 2023 14:05:59 +0200 Subject: more documentation --- assets/.gitignore | 1 + assets/architecture-level-0.pdf | Bin 0 -> 6094 bytes assets/figs.drawio | 47 ++++++++++++++ doc/.gitignore | 2 + doc/base.tex | 24 +++++-- doc/dui.md | 136 +++++++++++++++++++++++++++++++++++----- doc/makefile | 8 +-- doc/refs.bib | 0 8 files changed, 192 insertions(+), 26 deletions(-) create mode 100644 assets/.gitignore create mode 100644 assets/architecture-level-0.pdf create mode 100644 assets/figs.drawio create mode 100644 doc/refs.bib diff --git a/assets/.gitignore b/assets/.gitignore new file mode 100644 index 0000000..cac82ea --- /dev/null +++ b/assets/.gitignore @@ -0,0 +1 @@ +.$* diff --git a/assets/architecture-level-0.pdf b/assets/architecture-level-0.pdf new file mode 100644 index 0000000..48f00a6 Binary files /dev/null and b/assets/architecture-level-0.pdf differ diff --git a/assets/figs.drawio b/assets/figs.drawio new file mode 100644 index 0000000..e7c4c8e --- /dev/null +++ b/assets/figs.drawio @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/.gitignore b/doc/.gitignore index 25dcb3b..e5139ef 100644 --- a/doc/.gitignore +++ b/doc/.gitignore @@ -12,6 +12,8 @@ *.toc *.synctex(busy) *.md.tex +*.lof +*.lot # ignore output files *.pdf diff --git a/doc/base.tex b/doc/base.tex index 9c1c908..edadce3 100644 --- a/doc/base.tex +++ b/doc/base.tex @@ -12,10 +12,13 @@ \usepackage{booktabs} \usepackage{needspace} \usepackage{hyperref} -% \usepackage[backend=biber, -% bibencoding=utf8, -% style=apa -% ]{biblatex} +\usepackage{graphicx} +\usepackage[toc]{glossaries} +\usepackage[backend=biber, + bibencoding=utf8, + style=apa +]{biblatex} +\addbibresource{refs.bib} \setmainfont{TeX Gyre Schola} \setmathfont{TeX Gyre Schola Math} @@ -42,6 +45,13 @@ Niels Stunnebrink\\2184532 } +\newcommand{\req}[1]{$^{\text{\ref{req:#1}}}$} +\newcommand{\up}[1]{$^{\text{#1}}$} +\newcommand{\sub}[1]{$_{\text{#1}}$} + +\floatplacement{figure}{H} +\floatplacement{table}{H} + \begin{document} \begin{titlepage} \maketitle @@ -52,5 +62,11 @@ \newpage \input{\jobname.md.tex} + +% \printbibliography[heading=bibintoc] +% \printglossaries +% \listoftables +% \listoffigures + \end{document} diff --git a/doc/dui.md b/doc/dui.md index 65f242d..f70f4ef 100644 --- a/doc/dui.md +++ b/doc/dui.md @@ -1,29 +1,105 @@ # Introduction -# Problem statement +\ -The following is the original project description (translated to English): +# Problem statement -> I would like to bring to market a vehicle that can drive independently from A -> to B. The vehicle must take into account traffic rules, road signs, traffic -> lights, etc. Research is being conducted using a small cart, the Pololu Zumo -> 32U4, on which a camera module Nicla Vision is mounted. The aim is to -> investigate the most appropriate method of recognizing the road, traffic -> signs and traffic lights. This should be demonstrated with a proof of -> concept. The cart does not need to drive fast, so the image processing does -> not need to be very fast. Assume one frame per second (or faster). +The following is the original project description (translated to English). +References have been added in superscript that link to requirements set in +section \ref{specifications}. + +> I would like to bring to market a vehicle that can drive +> independently\req{autonomous} from A to B. The vehicle must take into account +> traffic rules\req{traffic-rules}, road signs\req{signs}, traffic +> lights\req{traffic-lights}, etc. Research is being conducted using a small +> cart, the Pololu Zumo 32U4\req{zumo}, on which a camera module Nicla +> Vision\req{nicla} is mounted. The aim is to investigate the most appropriate +> method of recognizing the road, traffic signs and traffic lights. This should +> be demonstrated with a proof of concept. The cart does not need to drive +> fast\req{drspeed}, so the image processing\req{mvision} does not need to be +> very fast. Assume one frame per second (or faster)\req{imspeed}. # Specifications +The following is a list of specifications derived from the original project +description in section \ref{problem-statement}. + +\begin{enumerate} + \item \label{req:autonomous} + The vehicle is autonomous + \item + The vehicle can detect how its positioned and orientated relative to a road + \item \label{req:traffic-rules} + The vehicle conforms to the following set of traffic rules + \begin{enumerate} + \item Driving when not on a road is not allowed + \item The vehicle can follow a road by steering itself accordingly + \item Driving off the road is only allowed when necessary for the camera to + keep seeing the road + \end{enumerate} + \item \label{req:traffic-lights} + The vehicle handles traffic lights in the following way + \begin{enumerate} + \item Stop at a red traffic light + \item Speed up at an orange traffic light + \item Continue driving normally at a green traffic light + \end{enumerate} + \item \label{req:signs} + The vehicle acts on traffic signs in the following way + \begin{enumerate} + \item Stop at a stop sign, and continue driving after a few seconds + \item Turn left at a left sign + \item Turn right at a right sign + \item Slow down at a low speed limit sign + \item Speed up to normal speed at a high speed limit sign + \end{enumerate} + \item \label{req:zumo} + The vehicle used is a Pololu Zumo 32U4 + \item \label{req:nicla} + The camera module used is an Arduino Nicla Vision + \item \label{req:mvision} + Computer vision / image processing is used as the only input + \item \label{req:drspeed} + There is no minimum speed the car has to drive at + \item \label{req:imspeed} + The image processing pipeline runs at 1 frame per second or higher + \item + The Zumo displays the name of the last detected sign on it's OLED display +\end{enumerate} + # Architecture +## Overview + +![Architecture overview (level 0) +\label{fig:architecture-level-0}](../assets/architecture-level-0.pdf) + +Figure \ref{fig:architecture-level-0} shows the hardware used in this project. +Both the Pololu Zumo 32U4 (referred to as just "Zumo"), and the Arduino Nicla +Vision ("Nicla") have additional sensors and/or outputs on-board, but are +unused. + +## Distribution of features + +Because creating a software architecture that does all machine vision-related +tasks on the Nicla, and all driving related tasks on the Zumo would create +significant overhead, and because the microcontroller on the Zumo is +significantly harder to debug than the Nicla, a monolithic architecture was +chosen. In this architecture, both the detection of 'traffic objects' and the +decisionmaking on how to handle each object is done on the Nicla board. + +Figure \ref{fig:architecture-level-0} shows that a bidirectional communication +line exists between the Zumo and Nicla. This line is only used to send control +commands to the Zumo. Section \ref{niclazumo-communication-protocol} describes +which commands are sent over these lines. + ## Nicla/Zumo communication protocol The communication protocol used to control the Zumo from the Nicla uses UART to -send ranged numbers in a single byte. Figure \ref{tab:protocol-ranges} shows +send ranged numbers in a single byte. Table \ref{tab:protocol-ranges} shows which number ranges correspond to which controls. -\begin{figure}[h] +\begin{table} \centering \begin{tabular}{rl} \toprule @@ -37,16 +113,16 @@ Steering & \texttt{0x20} - \texttt{0xff}\\ \end{tabular} \caption{Protocol command ranges} \label{tab:protocol-ranges} -\end{figure} +\end{table} ### Signs The Zumo stores the last sign received, and displays it's name on the OLED -display using the lookup table in figure \ref{tab:protocol-signs}. The sign ID +display using the lookup table in table \ref{tab:protocol-signs}. The sign ID is calculated by subtracting the start offset of the sign command range from -the command as shown in figure \ref{tab:protocol-ranges}. +the command as shown in table \ref{tab:protocol-ranges}. -\begin{figure}[h] +\begin{table} \centering \begin{tabular}{ll} \toprule @@ -65,7 +141,7 @@ the command as shown in figure \ref{tab:protocol-ranges}. \end{tabular} \caption{Sign lookup table} \label{tab:protocol-signs} -\end{figure} +\end{table} ### Speed @@ -184,6 +260,32 @@ nog niet}. } \communicationConclusion +## Compiling and linking code for the Zumo + +This section tries to answer the question "What are possible debugging options +for code running on the Zumo robot?". + +Debugging running code can usually be done using an on-device debugger, and a +program that interfaces with the debugger and gcc on a computer. Because gcc +only gives valuable information when it has access to the executable file +running on the microcontroller, an attempt at making a makefile-based toolchain +was made. + +Pololu provides C++ libraries for controlling various parts of the Zumo's +hardware. These libraries make use of functions and classes that are part of +the Arduino core library. The Arduino libraries are all open source, and can in +theory be compiled and linked using make, but this would take more effort than +it's worth, since the Zumo has very little responsibility in the end product. + +\def\buildSystemConclusion{ +Because making a custom build system would take too much time, and because the +Zumo robot's code is very simple, unit tests are used to debug the Zumo's code. +For compiling and uploading the full Zumo firmware, the Arduino IDE is used in +combination with the standard Pololu boards and Libraries. +} +\buildSystemConclusion + # Conclusion \communicationConclusion +\buildSystemConclusion diff --git a/doc/makefile b/doc/makefile index 9f4dfa0..a960c63 100644 --- a/doc/makefile +++ b/doc/makefile @@ -1,10 +1,8 @@ .PHONY: all clean -TARGET := $(patsubst %.md,%.pdf, $(wildcard *.md)) +all: dui.pdf -all: $(TARGET) - -garbage = $1.aux $1.bbl $1.bcf $1.blg $1.fdb_latexmk $1.fls $1.log $1.out $1.run.xml $1.synctex.gz $1.toc $1.md.tex +dui.pdf: ../assets/architecture-level-0.pdf %.pdf: %.svg rsvg-convert -f pdf -o $@ $< @@ -16,5 +14,5 @@ garbage = $1.aux $1.bbl $1.bcf $1.blg $1.fdb_latexmk $1.fls $1.log $1.out $1.run pandoc -t latex -o $@ $< clean: - $(RM) $(call garbage,research) research.pdf + $(RM) dui.aux dui.bbl dui.bcf dui.blg dui.fdb_latexmk dui.fls dui.log dui.out dui.run.xml dui.synctex.gz dui.toc dui.md.tex dui.pdf diff --git a/doc/refs.bib b/doc/refs.bib new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3 From ba4cc491d546767fbb344d279d216cfb5ea0cc1f Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 21 May 2023 14:07:37 +0200 Subject: remove custom build system from zumo folder (not worth) --- .gitmodules | 27 -------------- zumo/.gitignore | 4 --- zumo/lib/ArduinoCore-avr | 1 - zumo/lib/fastgpio-arduino | 1 - zumo/lib/pololu-buzzer-arduino | 1 - zumo/lib/pololu-hd44780-arduino | 1 - zumo/lib/pololu-menu-arduino | 1 - zumo/lib/pololu-oled-arduino | 1 - zumo/lib/pushbutton-arduino | 1 - zumo/lib/usb-pause-arduino | 1 - zumo/lib/zumo-32u4-arduino-library | 1 - zumo/makefile | 74 -------------------------------------- zumo/zumo.mk | 73 ------------------------------------- 13 files changed, 187 deletions(-) delete mode 100644 .gitmodules delete mode 160000 zumo/lib/ArduinoCore-avr delete mode 160000 zumo/lib/fastgpio-arduino delete mode 160000 zumo/lib/pololu-buzzer-arduino delete mode 160000 zumo/lib/pololu-hd44780-arduino delete mode 160000 zumo/lib/pololu-menu-arduino delete mode 160000 zumo/lib/pololu-oled-arduino delete mode 160000 zumo/lib/pushbutton-arduino delete mode 160000 zumo/lib/usb-pause-arduino delete mode 160000 zumo/lib/zumo-32u4-arduino-library delete mode 100644 zumo/makefile delete mode 100644 zumo/zumo.mk diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index a60d698..0000000 --- a/.gitmodules +++ /dev/null @@ -1,27 +0,0 @@ -[submodule "zumo/lib/zumo-32u4-arduino-library"] - path = zumo/lib/zumo-32u4-arduino-library - url = https://github.com/pololu/zumo-32u4-arduino-library -[submodule "zumo/lib/fastgpio-arduino"] - path = zumo/lib/fastgpio-arduino - url = https://github.com/pololu/fastgpio-arduino -[submodule "zumo/lib/pushbutton-arduino"] - path = zumo/lib/pushbutton-arduino - url = https://github.com/pololu/pushbutton-arduino -[submodule "zumo/lib/ArduinoCore-avr"] - path = zumo/lib/ArduinoCore-avr - url = https://github.com/arduino/ArduinoCore-avr -[submodule "zumo/lib/usb-pause-arduino"] - path = zumo/lib/usb-pause-arduino - url = https://github.com/pololu/usb-pause-arduino -[submodule "zumo/lib/pololu-buzzer-arduino"] - path = zumo/lib/pololu-buzzer-arduino - url = https://github.com/pololu/pololu-buzzer-arduino -[submodule "zumo/lib/pololu-hd44780-arduino"] - path = zumo/lib/pololu-hd44780-arduino - url = https://github.com/pololu/pololu-hd44780-arduino -[submodule "zumo/lib/pololu-menu-arduino"] - path = zumo/lib/pololu-menu-arduino - url = https://github.com/pololu/pololu-menu-arduino -[submodule "zumo/lib/pololu-oled-arduino"] - path = zumo/lib/pololu-oled-arduino - url = https://github.com/pololu/pololu-oled-arduino diff --git a/zumo/.gitignore b/zumo/.gitignore index 888e905..e45f7a2 100644 --- a/zumo/.gitignore +++ b/zumo/.gitignore @@ -1,6 +1,2 @@ -main *.o -*.hex -compile_commands.json -.cache pidtest diff --git a/zumo/lib/ArduinoCore-avr b/zumo/lib/ArduinoCore-avr deleted file mode 160000 index 42fa4a1..0000000 --- a/zumo/lib/ArduinoCore-avr +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 42fa4a1ea1b1b11d1cc0a60298e529d37f9d14bd diff --git a/zumo/lib/fastgpio-arduino b/zumo/lib/fastgpio-arduino deleted file mode 160000 index 5853c59..0000000 --- a/zumo/lib/fastgpio-arduino +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5853c593b07730e632127570279e7dea06de1af3 diff --git a/zumo/lib/pololu-buzzer-arduino b/zumo/lib/pololu-buzzer-arduino deleted file mode 160000 index 20ef7b7..0000000 --- a/zumo/lib/pololu-buzzer-arduino +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 20ef7b734814a7c5e9f02f54a2cdd41729759d51 diff --git a/zumo/lib/pololu-hd44780-arduino b/zumo/lib/pololu-hd44780-arduino deleted file mode 160000 index 0a35789..0000000 --- a/zumo/lib/pololu-hd44780-arduino +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0a35789a58ca92ca6f69b63fbc269959b2d18584 diff --git a/zumo/lib/pololu-menu-arduino b/zumo/lib/pololu-menu-arduino deleted file mode 160000 index 8970b8d..0000000 --- a/zumo/lib/pololu-menu-arduino +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8970b8db6e4e80b1c0e95172a87a35410bf593bf diff --git a/zumo/lib/pololu-oled-arduino b/zumo/lib/pololu-oled-arduino deleted file mode 160000 index e6b83b6..0000000 --- a/zumo/lib/pololu-oled-arduino +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e6b83b6c181962ffb98f99a4a4c3fd7cbf7e6707 diff --git a/zumo/lib/pushbutton-arduino b/zumo/lib/pushbutton-arduino deleted file mode 160000 index 442884e..0000000 --- a/zumo/lib/pushbutton-arduino +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 442884e004859ff550d5c0cae70033d7d568fc21 diff --git a/zumo/lib/usb-pause-arduino b/zumo/lib/usb-pause-arduino deleted file mode 160000 index 3f76e48..0000000 --- a/zumo/lib/usb-pause-arduino +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3f76e486460bb351f9738c86595f22db2da34c51 diff --git a/zumo/lib/zumo-32u4-arduino-library b/zumo/lib/zumo-32u4-arduino-library deleted file mode 160000 index f4dfe05..0000000 --- a/zumo/lib/zumo-32u4-arduino-library +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f4dfe054e23176ba445748b4b91f463701e7eb76 diff --git a/zumo/makefile b/zumo/makefile deleted file mode 100644 index 08c01d7..0000000 --- a/zumo/makefile +++ /dev/null @@ -1,74 +0,0 @@ -PORT = /dev/ttyUSB0 - -C++ = avr-g++ -CC = avr-gcc -LD = avr-gcc -RM = rm -f - -MCU = atmega32u4 -TARGET = main -SRCS += main.cpp - -C_CPP_FLAGS += -mmcu=$(MCU) -C_CPP_FLAGS += -Wl,-gc-sections -SHARED_FLAGS += -Os - -C_CPP_FLAGS += -mcall-prologues -C_CPP_FLAGS += -g -C_CPP_FLAGS += -Wl,-relax -C_CPP_FLAGS += -MMD -C_CPP_FLAGS += -ffunction-sections -C_CPP_FLAGS += -fdata-sections - -LFLAGS += -flto -LFLAGS += -fuse-linker-plugin -LFLAGS += -lc -lm -# LFLAGS += -L/usr/avr/lib/avr5/ -L/usr/lib/gcc/avr/12.2.0/avr5 -lgcc -lm -lc -latmega32u4 -# LFLAGS += -flto -fuse-linker-plugin -mmcu=atmega32u4 -Wl,--gc-sections -Os -lc -lm - - -CFLAGS += -fno-fat-lto-objects -# CFLAGS += -std=gnu11 - -CPPFLAGS += -fpermissive -CPPFLAGS += -fno-exceptions -CPPFLAGS += -fno-threadsafe-statics -CPPFLAGS += -fno-devirtualize -# CPPFLAGS += -std=gnu++11 - - -LFLAGS += $(SHARED_FLAGS) -CFLAGS += $(C_CPP_FLAGS) $(SHARED_FLAGS) -CPPFLAGS += $(C_CPP_FLAGS) $(SHARED_FLAGS) - -include zumo.mk - -OBJS := $(patsubst %.c,%.o, $(SRCS)) -OBJS := $(patsubst %.cpp,%.o, $(OBJS)) - -MAKEFLAGS += -j - -.PHONY: all clean flash - -all: $(TARGET).hex - -%.o: %.cpp - $(C++) $(CPPFLAGS) -o $@ -c $< - -%.o: %.c - $(CC) $(CFLAGS) -o $@ -c $< - -$(TARGET): $(OBJS) - $(LD) $(LFLAGS) -o $@ $^ - -$(TARGET).hex: $(TARGET) - avr-objcopy -R .eeprom -O ihex $< $@ - -flash: $(TARGET).hex - avrdude -p $(MCU) -c avr109 -P $(PORT) -U flash:w:$(TARGET).hex - -clean: - $(RM) $(TARGET) $(TARGET).hex $(OBJS) - -compile_commands.json: makefile - compiledb make -Bn diff --git a/zumo/zumo.mk b/zumo/zumo.mk deleted file mode 100644 index f5ab84b..0000000 --- a/zumo/zumo.mk +++ /dev/null @@ -1,73 +0,0 @@ -C_CPP_FLAGS += -DF_CPU=16000000L -C_CPP_FLAGS += -D__PROG_TYPES_COMPAT__ -C_CPP_FLAGS += -DARDUINO=1819 -C_CPP_FLAGS += -DARDUINO_AVR_LEONARDO -C_CPP_FLAGS += -DARDUINO_ARCH_AVR -C_CPP_FLAGS += -DARDUINO_BOARD='"AVR_LEONARDO"' -C_CPP_FLAGS += -DARDUINO_VARIANT='"leonardo"' -C_CPP_FLAGS += -DUSB_VID=0x2341 -C_CPP_FLAGS += -DUSB_PID=0x8036 -C_CPP_FLAGS += -DUSB_PRODUCT='"Arduino Leonardo"' -C_CPP_FLAGS += -DUSB_MANUFACTURER='"Unknown"' - -C_CPP_FLAGS += -I./lib/zumo-32u4-arduino-library/src -C_CPP_FLAGS += -I./lib/fastgpio-arduino -C_CPP_FLAGS += -I./lib/pushbutton-arduino -C_CPP_FLAGS += -I./lib/usb-pause-arduino -C_CPP_FLAGS += -I./lib/pololu-buzzer-arduino/src -C_CPP_FLAGS += -I./lib/pololu-hd44780-arduino -C_CPP_FLAGS += -I./lib/pololu-menu-arduino/src -C_CPP_FLAGS += -I./lib/pololu-oled-arduino/src -C_CPP_FLAGS += -I./lib/ArduinoCore-avr/cores/arduino -C_CPP_FLAGS += -I./lib/ArduinoCore-avr/libraries/HID/src -C_CPP_FLAGS += -I./lib/ArduinoCore-avr/libraries/SoftwareSerial/src -C_CPP_FLAGS += -I./lib/ArduinoCore-avr/libraries/SPI/src -C_CPP_FLAGS += -I./lib/ArduinoCore-avr/libraries/EEPROM/src -C_CPP_FLAGS += -I./lib/ArduinoCore-avr/libraries/Wire/src -C_CPP_FLAGS += -I./lib/ArduinoCore-avr/variants/leonardo - -# LIBS += lib/ArduinoCore-avr/cores/arduino/PluggableUSB.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/CDC.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/USBCore.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial0.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial1.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial2.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/HardwareSerial3.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/IPAddress.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/Print.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/Stream.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/WMath.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/WString.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/abi.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/main.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/new.cpp -# LIBS += lib/ArduinoCore-avr/libraries/HID/src/HID.cpp -# LIBS += lib/ArduinoCore-avr/libraries/SPI/src/SPI.cpp -# LIBS += lib/ArduinoCore-avr/libraries/SoftwareSerial/src/SoftwareSerial.cpp -LIBS += lib/ArduinoCore-avr/libraries/Wire/src/Wire.cpp -LIBS += lib/ArduinoCore-avr/cores/arduino/WInterrupts.c -LIBS += lib/ArduinoCore-avr/cores/arduino/hooks.c -LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_shift.c -LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_digital.c -LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_analog.c -LIBS += lib/ArduinoCore-avr/cores/arduino/wiring_pulse.c -LIBS += lib/ArduinoCore-avr/cores/arduino/wiring.c -LIBS += lib/ArduinoCore-avr/cores/arduino/Tone.cpp -# LIBS += lib/ArduinoCore-avr/libraries/Wire/src/utility/twi.c - -LIBS += lib/pololu-buzzer-arduino/src/PololuBuzzer.cpp -LIBS += lib/pushbutton-arduino/Pushbutton.cpp -LIBS += lib/zumo-32u4-arduino-library/src/QTRSensors.cpp -LIBS += lib/zumo-32u4-arduino-library/src/Zumo32U4IRPulses.cpp -LIBS += lib/zumo-32u4-arduino-library/src/Zumo32U4Encoders.cpp -LIBS += lib/zumo-32u4-arduino-library/src/Zumo32U4IMU.cpp -LIBS += lib/zumo-32u4-arduino-library/src/Zumo32U4Motors.cpp -LIBS += lib/zumo-32u4-arduino-library/src/Zumo32U4ProximitySensors.cpp -LIBS += lib/usb-pause-arduino/USBPause.cpp -LIBS += lib/pololu-hd44780-arduino/PololuHD44780.cpp -LIBS += lib/fastgpio-arduino/FastGPIO.cpp -LIBS += lib/pololu-oled-arduino/src/font.cpp - -SRCS += $(LIBS) - -- cgit v1.2.3 From d777e0c20af8484d130a05e9c18a9ff8b50d9e66 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Sun, 21 May 2023 15:54:15 +0200 Subject: research --- RealTime_pictures/rtCorner.class/00000.jpg | Bin 0 -> 7551 bytes RealTime_pictures/rtCorner.class/00001.jpg | Bin 0 -> 7317 bytes RealTime_pictures/rtCorner.class/00002.jpg | Bin 0 -> 7301 bytes RealTime_pictures/rtCorner.class/00003.jpg | Bin 0 -> 6684 bytes RealTime_pictures/rtCorner.class/00004.jpg | Bin 0 -> 6520 bytes RealTime_pictures/rtCorner.class/00005.jpg | Bin 0 -> 7521 bytes RealTime_pictures/rtCorner.class/00006.jpg | Bin 0 -> 13805 bytes RealTime_pictures/rtCorner.class/00007.jpg | Bin 0 -> 13526 bytes RealTime_pictures/rtCorner.class/00008.jpg | Bin 0 -> 13310 bytes RealTime_pictures/rtCorner.class/00009.jpg | Bin 0 -> 12758 bytes RealTime_pictures/rtCorner.class/00010.jpg | Bin 0 -> 12662 bytes RealTime_pictures/rtCorner.class/00011.jpg | Bin 0 -> 12478 bytes RealTime_pictures/rtCorner.class/00012.jpg | Bin 0 -> 11974 bytes RealTime_pictures/rtCorner.class/00013.jpg | Bin 0 -> 15354 bytes RealTime_pictures/rtIntersection.class/00000.jpg | Bin 0 -> 8258 bytes RealTime_pictures/rtIntersection.class/00001.jpg | Bin 0 -> 7678 bytes RealTime_pictures/rtIntersection.class/00002.jpg | Bin 0 -> 7789 bytes RealTime_pictures/rtIntersection.class/00003.jpg | Bin 0 -> 12968 bytes RealTime_pictures/rtIntersection.class/00004.jpg | Bin 0 -> 13341 bytes RealTime_pictures/rtIntersection.class/00005.jpg | Bin 0 -> 14312 bytes RealTime_pictures/rtIntersection.class/00006.jpg | Bin 0 -> 14386 bytes RealTime_pictures/rtIntersection.class/00007.jpg | Bin 0 -> 16976 bytes RealTime_pictures/rtIntersection.class/00008.jpg | Bin 0 -> 14273 bytes RealTime_pictures/rtStraightLines.class/00000.jpg | Bin 0 -> 10879 bytes RealTime_pictures/rtStraightLines.class/00001.jpg | Bin 0 -> 10915 bytes RealTime_pictures/rtStraightLines.class/00002.jpg | Bin 0 -> 10925 bytes RealTime_pictures/rtStraightLines.class/00003.jpg | Bin 0 -> 9124 bytes RealTime_pictures/rtStraightLines.class/00004.jpg | Bin 0 -> 9062 bytes RealTime_pictures/rtStraightLines.class/00005.jpg | Bin 0 -> 10978 bytes RealTime_pictures/rtStraightLines.class/00006.jpg | Bin 0 -> 10785 bytes RealTime_pictures/rtStraightLines.class/00007.jpg | Bin 0 -> 8198 bytes RealTime_pictures/rtStraightLines.class/00008.jpg | Bin 0 -> 7884 bytes RealTime_pictures/rtStraightLines.class/00009.jpg | Bin 0 -> 7560 bytes RealTime_pictures/rtStraightLines.class/00010.jpg | Bin 0 -> 7445 bytes RealTime_pictures/rtStraightLines.class/00011.jpg | Bin 0 -> 18652 bytes RealTime_pictures/rtStraightLines.class/00012.jpg | Bin 0 -> 15328 bytes RealTime_pictures/rtStraightLines.class/00013.jpg | Bin 0 -> 15455 bytes RealTime_pictures/rtStraightLines.class/00014.jpg | Bin 0 -> 11357 bytes RealTime_pictures/rtStraightLines.class/00015.jpg | Bin 0 -> 10951 bytes RealTime_pictures/rtStraightLines.class/00016.jpg | Bin 0 -> 7599 bytes RealTime_pictures/rtStraightLines.class/00017.jpg | Bin 0 -> 7705 bytes RealTime_pictures/rtStraightLines.class/00018.jpg | Bin 0 -> 16231 bytes RealTime_pictures/rtStraightLines.class/00019.jpg | Bin 0 -> 16725 bytes RealTime_pictures/rtWrongCorner.class/00000.jpg | Bin 0 -> 12378 bytes RealTime_pictures/rtWrongCorner.class/00001.jpg | Bin 0 -> 12925 bytes RealTime_pictures/rtWrongCorner.class/00002.jpg | Bin 0 -> 11356 bytes RealTime_pictures/rtWrongCorner.class/00003.jpg | Bin 0 -> 8574 bytes RealTime_pictures/rtWrongCorner.class/00004.jpg | Bin 0 -> 12059 bytes RealTime_pictures/rtWrongCorner.class/00005.jpg | Bin 0 -> 14825 bytes RealTime_pictures/rtWrongCorner.class/00006.jpg | Bin 0 -> 13316 bytes RealTime_pictures/rtWrongCorner.class/00007.jpg | Bin 0 -> 10868 bytes RealTime_pictures/rtWrongCorner.class/00008.jpg | Bin 0 -> 15580 bytes RealTime_pictures/rtWrongCorner.class/00009.jpg | Bin 0 -> 12635 bytes RealTime_pictures/rtWrongCorner.class/00010.jpg | Bin 0 -> 12163 bytes .../rtWrongIntersection.class/00000.jpg | Bin 0 -> 12658 bytes .../rtWrongIntersection.class/00001.jpg | Bin 0 -> 13233 bytes .../rtWrongIntersection.class/00002.jpg | Bin 0 -> 11826 bytes .../rtWrongStraightLines.class/00000.jpg | Bin 0 -> 13483 bytes .../rtWrongStraightLines.class/00001.jpg | Bin 0 -> 17200 bytes .../rtWrongStraightLines.class/00002.jpg | Bin 0 -> 13989 bytes .../rtWrongStraightLines.class/00003.jpg | Bin 0 -> 13768 bytes .../rtWrongStraightLines.class/00004.jpg | Bin 0 -> 13791 bytes .../rtWrongStraightLines.class/00005.jpg | Bin 0 -> 13563 bytes .../rtWrongStraightLines.class/00006.jpg | Bin 0 -> 16160 bytes .../rtWrongStraightLines.class/00007.jpg | Bin 0 -> 11266 bytes .../rtWrongStraightLines.class/00008.jpg | Bin 0 -> 12132 bytes .../rtWrongStraightLines.class/00009.jpg | Bin 0 -> 12170 bytes .../rtWrongStraightLines.class/00010.jpg | Bin 0 -> 13479 bytes .../rtWrongStraightLines.class/00011.jpg | Bin 0 -> 11710 bytes doc/assets/LSD_straightLines_Pic_0.bmp | Bin 0 -> 72054 bytes doc/assets/LSD_straightLines_Pic_1.bmp | Bin 0 -> 72054 bytes doc/assets/hough_straightLines_Pic_0.bmp | Bin 0 -> 76854 bytes doc/assets/hough_straightLines_Pic_1.bmp | Bin 0 -> 76854 bytes doc/dui.md | 101 +++++++++++++++++++++ 74 files changed, 101 insertions(+) create mode 100644 RealTime_pictures/rtCorner.class/00000.jpg create mode 100644 RealTime_pictures/rtCorner.class/00001.jpg create mode 100644 RealTime_pictures/rtCorner.class/00002.jpg create mode 100644 RealTime_pictures/rtCorner.class/00003.jpg create mode 100644 RealTime_pictures/rtCorner.class/00004.jpg create mode 100644 RealTime_pictures/rtCorner.class/00005.jpg create mode 100644 RealTime_pictures/rtCorner.class/00006.jpg create mode 100644 RealTime_pictures/rtCorner.class/00007.jpg create mode 100644 RealTime_pictures/rtCorner.class/00008.jpg create mode 100644 RealTime_pictures/rtCorner.class/00009.jpg create mode 100644 RealTime_pictures/rtCorner.class/00010.jpg create mode 100644 RealTime_pictures/rtCorner.class/00011.jpg create mode 100644 RealTime_pictures/rtCorner.class/00012.jpg create mode 100644 RealTime_pictures/rtCorner.class/00013.jpg create mode 100644 RealTime_pictures/rtIntersection.class/00000.jpg create mode 100644 RealTime_pictures/rtIntersection.class/00001.jpg create mode 100644 RealTime_pictures/rtIntersection.class/00002.jpg create mode 100644 RealTime_pictures/rtIntersection.class/00003.jpg create mode 100644 RealTime_pictures/rtIntersection.class/00004.jpg create mode 100644 RealTime_pictures/rtIntersection.class/00005.jpg create mode 100644 RealTime_pictures/rtIntersection.class/00006.jpg create mode 100644 RealTime_pictures/rtIntersection.class/00007.jpg create mode 100644 RealTime_pictures/rtIntersection.class/00008.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00000.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00001.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00002.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00003.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00004.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00005.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00006.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00007.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00008.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00009.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00010.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00011.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00012.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00013.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00014.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00015.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00016.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00017.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00018.jpg create mode 100644 RealTime_pictures/rtStraightLines.class/00019.jpg create mode 100644 RealTime_pictures/rtWrongCorner.class/00000.jpg create mode 100644 RealTime_pictures/rtWrongCorner.class/00001.jpg create mode 100644 RealTime_pictures/rtWrongCorner.class/00002.jpg create mode 100644 RealTime_pictures/rtWrongCorner.class/00003.jpg create mode 100644 RealTime_pictures/rtWrongCorner.class/00004.jpg create mode 100644 RealTime_pictures/rtWrongCorner.class/00005.jpg create mode 100644 RealTime_pictures/rtWrongCorner.class/00006.jpg create mode 100644 RealTime_pictures/rtWrongCorner.class/00007.jpg create mode 100644 RealTime_pictures/rtWrongCorner.class/00008.jpg create mode 100644 RealTime_pictures/rtWrongCorner.class/00009.jpg create mode 100644 RealTime_pictures/rtWrongCorner.class/00010.jpg create mode 100644 RealTime_pictures/rtWrongIntersection.class/00000.jpg create mode 100644 RealTime_pictures/rtWrongIntersection.class/00001.jpg create mode 100644 RealTime_pictures/rtWrongIntersection.class/00002.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00000.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00001.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00002.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00003.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00004.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00005.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00006.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00007.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00008.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00009.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00010.jpg create mode 100644 RealTime_pictures/rtWrongStraightLines.class/00011.jpg create mode 100644 doc/assets/LSD_straightLines_Pic_0.bmp create mode 100644 doc/assets/LSD_straightLines_Pic_1.bmp create mode 100644 doc/assets/hough_straightLines_Pic_0.bmp create mode 100644 doc/assets/hough_straightLines_Pic_1.bmp diff --git a/RealTime_pictures/rtCorner.class/00000.jpg b/RealTime_pictures/rtCorner.class/00000.jpg new file mode 100644 index 0000000..884aa69 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00000.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00001.jpg b/RealTime_pictures/rtCorner.class/00001.jpg new file mode 100644 index 0000000..3398cc4 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00001.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00002.jpg b/RealTime_pictures/rtCorner.class/00002.jpg new file mode 100644 index 0000000..01662f9 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00002.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00003.jpg b/RealTime_pictures/rtCorner.class/00003.jpg new file mode 100644 index 0000000..5cee200 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00003.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00004.jpg b/RealTime_pictures/rtCorner.class/00004.jpg new file mode 100644 index 0000000..4be7be9 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00004.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00005.jpg b/RealTime_pictures/rtCorner.class/00005.jpg new file mode 100644 index 0000000..2347c3a Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00005.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00006.jpg b/RealTime_pictures/rtCorner.class/00006.jpg new file mode 100644 index 0000000..6252806 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00006.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00007.jpg b/RealTime_pictures/rtCorner.class/00007.jpg new file mode 100644 index 0000000..344d5f3 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00007.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00008.jpg b/RealTime_pictures/rtCorner.class/00008.jpg new file mode 100644 index 0000000..92ecbf0 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00008.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00009.jpg b/RealTime_pictures/rtCorner.class/00009.jpg new file mode 100644 index 0000000..2956e4a Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00009.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00010.jpg b/RealTime_pictures/rtCorner.class/00010.jpg new file mode 100644 index 0000000..f62bed6 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00010.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00011.jpg b/RealTime_pictures/rtCorner.class/00011.jpg new file mode 100644 index 0000000..d09c141 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00011.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00012.jpg b/RealTime_pictures/rtCorner.class/00012.jpg new file mode 100644 index 0000000..8803827 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00012.jpg differ diff --git a/RealTime_pictures/rtCorner.class/00013.jpg b/RealTime_pictures/rtCorner.class/00013.jpg new file mode 100644 index 0000000..7ec2692 Binary files /dev/null and b/RealTime_pictures/rtCorner.class/00013.jpg differ diff --git a/RealTime_pictures/rtIntersection.class/00000.jpg b/RealTime_pictures/rtIntersection.class/00000.jpg new file mode 100644 index 0000000..9492866 Binary files /dev/null and b/RealTime_pictures/rtIntersection.class/00000.jpg differ diff --git a/RealTime_pictures/rtIntersection.class/00001.jpg b/RealTime_pictures/rtIntersection.class/00001.jpg new file mode 100644 index 0000000..43b0840 Binary files /dev/null and b/RealTime_pictures/rtIntersection.class/00001.jpg differ diff --git a/RealTime_pictures/rtIntersection.class/00002.jpg b/RealTime_pictures/rtIntersection.class/00002.jpg new file mode 100644 index 0000000..4e47b44 Binary files /dev/null and b/RealTime_pictures/rtIntersection.class/00002.jpg differ diff --git a/RealTime_pictures/rtIntersection.class/00003.jpg b/RealTime_pictures/rtIntersection.class/00003.jpg new file mode 100644 index 0000000..fab7ba2 Binary files /dev/null and b/RealTime_pictures/rtIntersection.class/00003.jpg differ diff --git a/RealTime_pictures/rtIntersection.class/00004.jpg b/RealTime_pictures/rtIntersection.class/00004.jpg new file mode 100644 index 0000000..4abc6b5 Binary files /dev/null and b/RealTime_pictures/rtIntersection.class/00004.jpg differ diff --git a/RealTime_pictures/rtIntersection.class/00005.jpg b/RealTime_pictures/rtIntersection.class/00005.jpg new file mode 100644 index 0000000..9f3b772 Binary files /dev/null and b/RealTime_pictures/rtIntersection.class/00005.jpg differ diff --git a/RealTime_pictures/rtIntersection.class/00006.jpg b/RealTime_pictures/rtIntersection.class/00006.jpg new file mode 100644 index 0000000..faf18c0 Binary files /dev/null and b/RealTime_pictures/rtIntersection.class/00006.jpg differ diff --git a/RealTime_pictures/rtIntersection.class/00007.jpg b/RealTime_pictures/rtIntersection.class/00007.jpg new file mode 100644 index 0000000..0bd1a42 Binary files /dev/null and b/RealTime_pictures/rtIntersection.class/00007.jpg differ diff --git a/RealTime_pictures/rtIntersection.class/00008.jpg b/RealTime_pictures/rtIntersection.class/00008.jpg new file mode 100644 index 0000000..621b9cb Binary files /dev/null and b/RealTime_pictures/rtIntersection.class/00008.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00000.jpg b/RealTime_pictures/rtStraightLines.class/00000.jpg new file mode 100644 index 0000000..a1dcf45 Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00000.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00001.jpg b/RealTime_pictures/rtStraightLines.class/00001.jpg new file mode 100644 index 0000000..2600e8c Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00001.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00002.jpg b/RealTime_pictures/rtStraightLines.class/00002.jpg new file mode 100644 index 0000000..3862ec1 Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00002.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00003.jpg b/RealTime_pictures/rtStraightLines.class/00003.jpg new file mode 100644 index 0000000..28e284f Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00003.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00004.jpg b/RealTime_pictures/rtStraightLines.class/00004.jpg new file mode 100644 index 0000000..dfb5be6 Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00004.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00005.jpg b/RealTime_pictures/rtStraightLines.class/00005.jpg new file mode 100644 index 0000000..8ee04d3 Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00005.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00006.jpg b/RealTime_pictures/rtStraightLines.class/00006.jpg new file mode 100644 index 0000000..6adc035 Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00006.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00007.jpg b/RealTime_pictures/rtStraightLines.class/00007.jpg new file mode 100644 index 0000000..87f223d Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00007.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00008.jpg b/RealTime_pictures/rtStraightLines.class/00008.jpg new file mode 100644 index 0000000..b14554e Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00008.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00009.jpg b/RealTime_pictures/rtStraightLines.class/00009.jpg new file mode 100644 index 0000000..c5b474b Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00009.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00010.jpg b/RealTime_pictures/rtStraightLines.class/00010.jpg new file mode 100644 index 0000000..d3cafcf Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00010.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00011.jpg b/RealTime_pictures/rtStraightLines.class/00011.jpg new file mode 100644 index 0000000..c1f8fcf Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00011.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00012.jpg b/RealTime_pictures/rtStraightLines.class/00012.jpg new file mode 100644 index 0000000..7980cf8 Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00012.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00013.jpg b/RealTime_pictures/rtStraightLines.class/00013.jpg new file mode 100644 index 0000000..da59693 Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00013.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00014.jpg b/RealTime_pictures/rtStraightLines.class/00014.jpg new file mode 100644 index 0000000..56f37de Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00014.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00015.jpg b/RealTime_pictures/rtStraightLines.class/00015.jpg new file mode 100644 index 0000000..9fe7082 Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00015.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00016.jpg b/RealTime_pictures/rtStraightLines.class/00016.jpg new file mode 100644 index 0000000..6c62b59 Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00016.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00017.jpg b/RealTime_pictures/rtStraightLines.class/00017.jpg new file mode 100644 index 0000000..23596e6 Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00017.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00018.jpg b/RealTime_pictures/rtStraightLines.class/00018.jpg new file mode 100644 index 0000000..a66742e Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00018.jpg differ diff --git a/RealTime_pictures/rtStraightLines.class/00019.jpg b/RealTime_pictures/rtStraightLines.class/00019.jpg new file mode 100644 index 0000000..23af171 Binary files /dev/null and b/RealTime_pictures/rtStraightLines.class/00019.jpg differ diff --git a/RealTime_pictures/rtWrongCorner.class/00000.jpg b/RealTime_pictures/rtWrongCorner.class/00000.jpg new file mode 100644 index 0000000..9c1b0e1 Binary files /dev/null and b/RealTime_pictures/rtWrongCorner.class/00000.jpg differ diff --git a/RealTime_pictures/rtWrongCorner.class/00001.jpg b/RealTime_pictures/rtWrongCorner.class/00001.jpg new file mode 100644 index 0000000..2ec349b Binary files /dev/null and b/RealTime_pictures/rtWrongCorner.class/00001.jpg differ diff --git a/RealTime_pictures/rtWrongCorner.class/00002.jpg b/RealTime_pictures/rtWrongCorner.class/00002.jpg new file mode 100644 index 0000000..c150ac6 Binary files /dev/null and b/RealTime_pictures/rtWrongCorner.class/00002.jpg differ diff --git a/RealTime_pictures/rtWrongCorner.class/00003.jpg b/RealTime_pictures/rtWrongCorner.class/00003.jpg new file mode 100644 index 0000000..419f645 Binary files /dev/null and b/RealTime_pictures/rtWrongCorner.class/00003.jpg differ diff --git a/RealTime_pictures/rtWrongCorner.class/00004.jpg b/RealTime_pictures/rtWrongCorner.class/00004.jpg new file mode 100644 index 0000000..3b37b05 Binary files /dev/null and b/RealTime_pictures/rtWrongCorner.class/00004.jpg differ diff --git a/RealTime_pictures/rtWrongCorner.class/00005.jpg b/RealTime_pictures/rtWrongCorner.class/00005.jpg new file mode 100644 index 0000000..c1a0e63 Binary files /dev/null and b/RealTime_pictures/rtWrongCorner.class/00005.jpg differ diff --git a/RealTime_pictures/rtWrongCorner.class/00006.jpg b/RealTime_pictures/rtWrongCorner.class/00006.jpg new file mode 100644 index 0000000..28964c5 Binary files /dev/null and b/RealTime_pictures/rtWrongCorner.class/00006.jpg differ diff --git a/RealTime_pictures/rtWrongCorner.class/00007.jpg b/RealTime_pictures/rtWrongCorner.class/00007.jpg new file mode 100644 index 0000000..a7fd550 Binary files /dev/null and b/RealTime_pictures/rtWrongCorner.class/00007.jpg differ diff --git a/RealTime_pictures/rtWrongCorner.class/00008.jpg b/RealTime_pictures/rtWrongCorner.class/00008.jpg new file mode 100644 index 0000000..6ea7ffe Binary files /dev/null and b/RealTime_pictures/rtWrongCorner.class/00008.jpg differ diff --git a/RealTime_pictures/rtWrongCorner.class/00009.jpg b/RealTime_pictures/rtWrongCorner.class/00009.jpg new file mode 100644 index 0000000..44183bf Binary files /dev/null and b/RealTime_pictures/rtWrongCorner.class/00009.jpg differ diff --git a/RealTime_pictures/rtWrongCorner.class/00010.jpg b/RealTime_pictures/rtWrongCorner.class/00010.jpg new file mode 100644 index 0000000..ca5786f Binary files /dev/null and b/RealTime_pictures/rtWrongCorner.class/00010.jpg differ diff --git a/RealTime_pictures/rtWrongIntersection.class/00000.jpg b/RealTime_pictures/rtWrongIntersection.class/00000.jpg new file mode 100644 index 0000000..cb5e29e Binary files /dev/null and b/RealTime_pictures/rtWrongIntersection.class/00000.jpg differ diff --git a/RealTime_pictures/rtWrongIntersection.class/00001.jpg b/RealTime_pictures/rtWrongIntersection.class/00001.jpg new file mode 100644 index 0000000..a316eb7 Binary files /dev/null and b/RealTime_pictures/rtWrongIntersection.class/00001.jpg differ diff --git a/RealTime_pictures/rtWrongIntersection.class/00002.jpg b/RealTime_pictures/rtWrongIntersection.class/00002.jpg new file mode 100644 index 0000000..f4275fb Binary files /dev/null and b/RealTime_pictures/rtWrongIntersection.class/00002.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00000.jpg b/RealTime_pictures/rtWrongStraightLines.class/00000.jpg new file mode 100644 index 0000000..0ce2ce0 Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00000.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00001.jpg b/RealTime_pictures/rtWrongStraightLines.class/00001.jpg new file mode 100644 index 0000000..457bd03 Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00001.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00002.jpg b/RealTime_pictures/rtWrongStraightLines.class/00002.jpg new file mode 100644 index 0000000..70edd62 Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00002.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00003.jpg b/RealTime_pictures/rtWrongStraightLines.class/00003.jpg new file mode 100644 index 0000000..55cb071 Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00003.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00004.jpg b/RealTime_pictures/rtWrongStraightLines.class/00004.jpg new file mode 100644 index 0000000..ff56176 Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00004.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00005.jpg b/RealTime_pictures/rtWrongStraightLines.class/00005.jpg new file mode 100644 index 0000000..c7a8f8a Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00005.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00006.jpg b/RealTime_pictures/rtWrongStraightLines.class/00006.jpg new file mode 100644 index 0000000..3b64636 Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00006.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00007.jpg b/RealTime_pictures/rtWrongStraightLines.class/00007.jpg new file mode 100644 index 0000000..3cf1031 Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00007.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00008.jpg b/RealTime_pictures/rtWrongStraightLines.class/00008.jpg new file mode 100644 index 0000000..ec748ba Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00008.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00009.jpg b/RealTime_pictures/rtWrongStraightLines.class/00009.jpg new file mode 100644 index 0000000..62e4096 Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00009.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00010.jpg b/RealTime_pictures/rtWrongStraightLines.class/00010.jpg new file mode 100644 index 0000000..e75983e Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00010.jpg differ diff --git a/RealTime_pictures/rtWrongStraightLines.class/00011.jpg b/RealTime_pictures/rtWrongStraightLines.class/00011.jpg new file mode 100644 index 0000000..cf3a53f Binary files /dev/null and b/RealTime_pictures/rtWrongStraightLines.class/00011.jpg differ diff --git a/doc/assets/LSD_straightLines_Pic_0.bmp b/doc/assets/LSD_straightLines_Pic_0.bmp new file mode 100644 index 0000000..54018e2 Binary files /dev/null and b/doc/assets/LSD_straightLines_Pic_0.bmp differ diff --git a/doc/assets/LSD_straightLines_Pic_1.bmp b/doc/assets/LSD_straightLines_Pic_1.bmp new file mode 100644 index 0000000..6a7832f Binary files /dev/null and b/doc/assets/LSD_straightLines_Pic_1.bmp differ diff --git a/doc/assets/hough_straightLines_Pic_0.bmp b/doc/assets/hough_straightLines_Pic_0.bmp new file mode 100644 index 0000000..00a5263 Binary files /dev/null and b/doc/assets/hough_straightLines_Pic_0.bmp differ diff --git a/doc/assets/hough_straightLines_Pic_1.bmp b/doc/assets/hough_straightLines_Pic_1.bmp new file mode 100644 index 0000000..d72285d Binary files /dev/null and b/doc/assets/hough_straightLines_Pic_1.bmp differ diff --git a/doc/dui.md b/doc/dui.md index ede73c8..d39e3bf 100644 --- a/doc/dui.md +++ b/doc/dui.md @@ -19,6 +19,104 @@ The following is the original project description (translated to English): # Research +## Detecting lines + +The Zumo robot needs to drive in a road map-like environment where it needs to act like a car. With the nicla vision camera, there needs to be a way for detecting lines in every frame to make the Zumo robot ride between the lines. Read lines from an image there are different algorithms to make it work. We need to make sure that it works on the OpenMV program if we only choose this one. In this research, two techniques are researched: convolution-based and feature-based. + +### Different line detection algorithms. + +#### Hough Transform + +This is a popular algorithm used to detect straight lines in an image. It works by transforming the image from Cartesian space to Hough space, where lines are represented as points. The algorithm then looks for clusters of points in Hough space, which correspond to lines in Cartesian space. + +For more information about Hough Transform algorithms check the below links: + +- [Wiki hough](https://en.wikipedia.org/wiki/Hough_transform ) +- [Science article](https://www.sciencedirect.com/topics/computer-science/hough-transforms) +- [OpenCV Hough](https://docs.opencv.org/3.4/d9/db0/tutorial_hough_lines.html) +- [OpenMV find_lines](https://docs.openmv.io/library/omv.image.html) + +#### EDlines + +EDLines, short for Edge Drawing Lines, is a feature-based algorithm that detects straight lines in an image by tracing along the edges of the image. It works by first extracting edges from the image, then building a graph where each edge is represented by a node. The algorithm then uses a greedy strategy to connect the nodes with high edge strength to form line segments. Finally, it merges line segments that are collinear and close to each other to form longer lines. This algorithm does not require a parameter search or optimization and is known for its robustness against noise and partial occlusion. + +For more information about EDlines algorithms check the below links: + +- [github library](https://github.com/CihanTopal/ED_Lib) +- [Science article](https://www.sciencedirect.com/science/article/abs/pii/S0167865511001772) +- [EDLINES: REAL-TIME LINE SEGMENT DETECTION BY EDGE DRAWING (ED)](https://projet.liris.cnrs.fr/imagine/pub/proceedings/ICIP-2011/papers/1569406487.pdf) +- [OpenCV EDlines doc](https://docs.opencv.org/3.4/d4/d8b/group__ximgproc__edge__drawing.html) + +#### Line Segment Detector + +LSD (Line Segment Detector) is an algorithm used for detecting line segments in an image. It works by analyzing the gradient information in the image and clustering nearby gradients that form a line segment. The algorithm first computes the gradient information for the image using the Gaussian filter. It then performs a series of operations, such as non-maximum suppression and thresholding, to obtain a binary edge map. + +The line segments are detected by applying a series of geometric constraints to the edge map. These constraints include the minimum and maximum length of line segments, the minimum angle between line segments, and the maximum deviation of line segments from a straight line. + +Once the line segments are detected, they are refined using a line merging algorithm combining nearby line segments into longer, more continuous lines. The resulting line segments and their endpoints are returned as the output of the algorithm. + +For more information about Line Segment Detector algorithms check the below links: + +- [LSD: a Line Segment Detector pdf](http://www.ipol.im/pub/art/2012/gjmr-lsd/article.pdf) +- [Working behind LSD](https://saiwa.ai/blog/line-segment-detection-2/) +- [OpenCV LSD doc](https://docs.opencv.org/3.4/db/d73/classcv_1_1LineSegmentDetector.html) +- [OpenMV find_line_segments](https://docs.openmv.io/library/omv.image.html) + +#### Radon transform + +Radon transform is another popular algorithm used for line detection. It works by computing the line integral of an image along different directions. The algorithm rotates the image at different angles and computes the sum of pixel intensities along each line in the image. The result is a two-dimensional matrix called the Radon transform. Peaks in this matrix correspond to the lines in the original image. The algorithm then applies some post-processing steps to identify and extract the lines from the Radon transform. + +For more information about Radon transform algorithms check the below links: + +- [Science article](https://www.sciencedirect.com/science/article/abs/pii/0031320396000155) +- [matlab Radon](https://stackoverflow.com/questions/35412573/radon-transform-line-detection) +- [Matlab elaboration Radon](https://www.kevinpolisano.com/Doctorat/doc-matlab-exemple/radon_lines_detection.html) +- [OpenCV Radon doc](https://docs.opencv.org/4.x/d5/d89/radon__transform_8hpp.html) + +### Which algorithm is suitable for our project? + +We have identified four different types of line detection algorithms that could potentially be used for our project. To decide on the best algorithm, we need to consider various factors such as accuracy, efficiency, and ease of use. While processing time is not a critical factor in our case, we need to ensure that the algorithm we choose meets our requirements and is accessible through the platform we are using, which is currently openMV but may change to openCV in the future. Therefore, our priority is to select an algorithm that is easy to implement, provides accurate results, and is compatible with our platform. + +#### OpenMV + +The only two algorithms that work with OpenMV are Hough Transform, the function find_lines, and Line Segment Detector, also known as find_line_segments. Both of these have their ups and downs and could be used for our project. find_lines has the most ups whereas find_line_segemtns has the most negative. As the result here below is decently optimized, it is first grayscaled, and then canny edge detection is done to it. + +For the test are the straight lines pictures used with different lighting additionality the left lane represents a whitish line and the right lane is drawn with a more darker color. here below are the pictures used: + +![picture 1](../RealTime_pictures/rtstraightLines.class/00000.jpg) + +![picture 2](../RealTime_pictures/rtStraightLines.class/00018.jpg) + +##### find_lines + +The find_lines is a very fast function where you can handle straight lines and other lines with at least 45 FPS or more. Also, have a lot of control over the different types of parameters. + +This is the outcome of picture 1: +![outcome_picture_1](./assets/hough_straightLines_Pic_0.bmp) + +This is the outcome of picture 2: +![outcome_picture_2](./assets/hough_straightLines_Pic_1.bmp) + +As you can see there isn't much of a difference between the two pictures. + +##### find_line_segments + +The find_line_segments is a very slow function where you can find segments from a line. This is a easier to use function because it only has two parameters but the frame rate drops significantly. Additionally, the size of the image to run the algorithm on needs to be smaller because of memory. + +This is the outcome of picture 1: + +![outcome_picture_1](./assets/LSD_straightLines_Pic_0.bmp.bmp) + +This is the outcome of picture 2: + +![outcome_picture_2](./assets/LSD_straightLines_Pic_1.bmp.bmp) + +As you can see there is quite a lot of difference between them. This function needs more refinement but I couldn't find the sweet spot. Also, the right line in different pictures was always the problem, so there needs another solution for this function to work better. + +#### OpenCV + +All the above algorithms could be used with OpenCV, But the Radon transform needs more work than the others with the amount of information in the doc. + ## Communication between the Nicla and Zumo In order to make the Zumo robot both detect where it is on a road, and steer to @@ -98,3 +196,6 @@ nog niet}. # Conclusion \communicationConclusion + + + -- cgit v1.2.3 From 5e2cfc62ca7d724e6f9e2a4081e0cb5f948ffc71 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 21 May 2023 18:06:38 +0200 Subject: merge #1 --- .gitignore | 4 ++ README.md | 5 -- assets/LSD_straightLines_Pic_0.bmp | Bin 0 -> 72054 bytes assets/LSD_straightLines_Pic_1.bmp | Bin 0 -> 72054 bytes assets/hough_straightLines_Pic_0.bmp | Bin 0 -> 76854 bytes assets/hough_straightLines_Pic_1.bmp | Bin 0 -> 76854 bytes doc/assets/LSD_straightLines_Pic_0.bmp | Bin 72054 -> 0 bytes doc/assets/LSD_straightLines_Pic_1.bmp | Bin 72054 -> 0 bytes doc/assets/hough_straightLines_Pic_0.bmp | Bin 76854 -> 0 bytes doc/assets/hough_straightLines_Pic_1.bmp | Bin 76854 -> 0 bytes doc/dui.md | 110 +++++++++++++++---------------- doc/makefile | 8 +++ readme.md | 5 ++ 13 files changed, 72 insertions(+), 60 deletions(-) create mode 100644 .gitignore delete mode 100644 README.md create mode 100644 assets/LSD_straightLines_Pic_0.bmp create mode 100644 assets/LSD_straightLines_Pic_1.bmp create mode 100644 assets/hough_straightLines_Pic_0.bmp create mode 100644 assets/hough_straightLines_Pic_1.bmp delete mode 100644 doc/assets/LSD_straightLines_Pic_0.bmp delete mode 100644 doc/assets/LSD_straightLines_Pic_1.bmp delete mode 100644 doc/assets/hough_straightLines_Pic_0.bmp delete mode 100644 doc/assets/hough_straightLines_Pic_1.bmp create mode 100644 readme.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3f4b7ab --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +assets/LSD_straightLines_Pic_0.png +assets/LSD_straightLines_Pic_1.png +assets/hough_straightLines_Pic_0.png +assets/hough_straightLines_Pic_1.png diff --git a/README.md b/README.md deleted file mode 100644 index 4317e32..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# avans-dui - -d.u.i. (Driving under influence) - -Avans Hogeschool project Vision diff --git a/assets/LSD_straightLines_Pic_0.bmp b/assets/LSD_straightLines_Pic_0.bmp new file mode 100644 index 0000000..54018e2 Binary files /dev/null and b/assets/LSD_straightLines_Pic_0.bmp differ diff --git a/assets/LSD_straightLines_Pic_1.bmp b/assets/LSD_straightLines_Pic_1.bmp new file mode 100644 index 0000000..6a7832f Binary files /dev/null and b/assets/LSD_straightLines_Pic_1.bmp differ diff --git a/assets/hough_straightLines_Pic_0.bmp b/assets/hough_straightLines_Pic_0.bmp new file mode 100644 index 0000000..00a5263 Binary files /dev/null and b/assets/hough_straightLines_Pic_0.bmp differ diff --git a/assets/hough_straightLines_Pic_1.bmp b/assets/hough_straightLines_Pic_1.bmp new file mode 100644 index 0000000..d72285d Binary files /dev/null and b/assets/hough_straightLines_Pic_1.bmp differ diff --git a/doc/assets/LSD_straightLines_Pic_0.bmp b/doc/assets/LSD_straightLines_Pic_0.bmp deleted file mode 100644 index 54018e2..0000000 Binary files a/doc/assets/LSD_straightLines_Pic_0.bmp and /dev/null differ diff --git a/doc/assets/LSD_straightLines_Pic_1.bmp b/doc/assets/LSD_straightLines_Pic_1.bmp deleted file mode 100644 index 6a7832f..0000000 Binary files a/doc/assets/LSD_straightLines_Pic_1.bmp and /dev/null differ diff --git a/doc/assets/hough_straightLines_Pic_0.bmp b/doc/assets/hough_straightLines_Pic_0.bmp deleted file mode 100644 index 00a5263..0000000 Binary files a/doc/assets/hough_straightLines_Pic_0.bmp and /dev/null differ diff --git a/doc/assets/hough_straightLines_Pic_1.bmp b/doc/assets/hough_straightLines_Pic_1.bmp deleted file mode 100644 index d72285d..0000000 Binary files a/doc/assets/hough_straightLines_Pic_1.bmp and /dev/null differ diff --git a/doc/dui.md b/doc/dui.md index a762817..3f72e1c 100644 --- a/doc/dui.md +++ b/doc/dui.md @@ -186,101 +186,101 @@ K_d &= -300.0 ## Detecting lines -The Zumo robot needs to drive in a road map-like environment where it needs to act like a car. With the nicla vision camera, there needs to be a way for detecting lines in every frame to make the Zumo robot ride between the lines. Read lines from an image there are different algorithms to make it work. We need to make sure that it works on the OpenMV program if we only choose this one. In this research, two techniques are researched: convolution-based and feature-based. +The Zumo robot needs to drive in a road map-like environment where it needs to act like a car. With the nicla vision camera, there needs to be a way for detecting lines in every frame to make the Zumo robot ride between the lines. Read lines from an image there are different algorithms to make it work. We need to make sure that it works on the OpenMV program if we only choose this one. In this research, two techniques are researched: convolution-based and feature-based. -### Different line detection algorithms. +### Different line detection algorithms. -#### Hough Transform +#### Hough Transform -This is a popular algorithm used to detect straight lines in an image. It works by transforming the image from Cartesian space to Hough space, where lines are represented as points. The algorithm then looks for clusters of points in Hough space, which correspond to lines in Cartesian space. +This is a popular algorithm used to detect straight lines in an image. It works by transforming the image from Cartesian space to Hough space, where lines are represented as points. The algorithm then looks for clusters of points in Hough space, which correspond to lines in Cartesian space. -For more information about Hough Transform algorithms check the below links: +For more information about Hough Transform algorithms check the below links: -- [Wiki hough](https://en.wikipedia.org/wiki/Hough_transform ) -- [Science article](https://www.sciencedirect.com/topics/computer-science/hough-transforms) -- [OpenCV Hough](https://docs.opencv.org/3.4/d9/db0/tutorial_hough_lines.html) -- [OpenMV find_lines](https://docs.openmv.io/library/omv.image.html) +- [Wiki hough](https://en.wikipedia.org/wiki/Hough_transform ) +- [Science article](https://www.sciencedirect.com/topics/computer-science/hough-transforms) +- [OpenCV Hough](https://docs.opencv.org/3.4/d9/db0/tutorial_hough_lines.html) +- [OpenMV find_lines](https://docs.openmv.io/library/omv.image.html) -#### EDlines +#### EDlines -EDLines, short for Edge Drawing Lines, is a feature-based algorithm that detects straight lines in an image by tracing along the edges of the image. It works by first extracting edges from the image, then building a graph where each edge is represented by a node. The algorithm then uses a greedy strategy to connect the nodes with high edge strength to form line segments. Finally, it merges line segments that are collinear and close to each other to form longer lines. This algorithm does not require a parameter search or optimization and is known for its robustness against noise and partial occlusion. +EDLines, short for Edge Drawing Lines, is a feature-based algorithm that detects straight lines in an image by tracing along the edges of the image. It works by first extracting edges from the image, then building a graph where each edge is represented by a node. The algorithm then uses a greedy strategy to connect the nodes with high edge strength to form line segments. Finally, it merges line segments that are collinear and close to each other to form longer lines. This algorithm does not require a parameter search or optimization and is known for its robustness against noise and partial occlusion. -For more information about EDlines algorithms check the below links: +For more information about EDlines algorithms check the below links: -- [github library](https://github.com/CihanTopal/ED_Lib) -- [Science article](https://www.sciencedirect.com/science/article/abs/pii/S0167865511001772) -- [EDLINES: REAL-TIME LINE SEGMENT DETECTION BY EDGE DRAWING (ED)](https://projet.liris.cnrs.fr/imagine/pub/proceedings/ICIP-2011/papers/1569406487.pdf) -- [OpenCV EDlines doc](https://docs.opencv.org/3.4/d4/d8b/group__ximgproc__edge__drawing.html) +- [github library](https://github.com/CihanTopal/ED_Lib) +- [Science article](https://www.sciencedirect.com/science/article/abs/pii/S0167865511001772) +- [EDLINES: REAL-TIME LINE SEGMENT DETECTION BY EDGE DRAWING (ED)](https://projet.liris.cnrs.fr/imagine/pub/proceedings/ICIP-2011/papers/1569406487.pdf) +- [OpenCV EDlines doc](https://docs.opencv.org/3.4/d4/d8b/group__ximgproc__edge__drawing.html) -#### Line Segment Detector +#### Line Segment Detector -LSD (Line Segment Detector) is an algorithm used for detecting line segments in an image. It works by analyzing the gradient information in the image and clustering nearby gradients that form a line segment. The algorithm first computes the gradient information for the image using the Gaussian filter. It then performs a series of operations, such as non-maximum suppression and thresholding, to obtain a binary edge map. +LSD (Line Segment Detector) is an algorithm used for detecting line segments in an image. It works by analyzing the gradient information in the image and clustering nearby gradients that form a line segment. The algorithm first computes the gradient information for the image using the Gaussian filter. It then performs a series of operations, such as non-maximum suppression and thresholding, to obtain a binary edge map. -The line segments are detected by applying a series of geometric constraints to the edge map. These constraints include the minimum and maximum length of line segments, the minimum angle between line segments, and the maximum deviation of line segments from a straight line. +The line segments are detected by applying a series of geometric constraints to the edge map. These constraints include the minimum and maximum length of line segments, the minimum angle between line segments, and the maximum deviation of line segments from a straight line. -Once the line segments are detected, they are refined using a line merging algorithm combining nearby line segments into longer, more continuous lines. The resulting line segments and their endpoints are returned as the output of the algorithm. +Once the line segments are detected, they are refined using a line merging algorithm combining nearby line segments into longer, more continuous lines. The resulting line segments and their endpoints are returned as the output of the algorithm. -For more information about Line Segment Detector algorithms check the below links: +For more information about Line Segment Detector algorithms check the below links: -- [LSD: a Line Segment Detector pdf](http://www.ipol.im/pub/art/2012/gjmr-lsd/article.pdf) -- [Working behind LSD](https://saiwa.ai/blog/line-segment-detection-2/) -- [OpenCV LSD doc](https://docs.opencv.org/3.4/db/d73/classcv_1_1LineSegmentDetector.html) -- [OpenMV find_line_segments](https://docs.openmv.io/library/omv.image.html) +- [LSD: a Line Segment Detector pdf](http://www.ipol.im/pub/art/2012/gjmr-lsd/article.pdf) +- [Working behind LSD](https://saiwa.ai/blog/line-segment-detection-2/) +- [OpenCV LSD doc](https://docs.opencv.org/3.4/db/d73/classcv_1_1LineSegmentDetector.html) +- [OpenMV find_line_segments](https://docs.openmv.io/library/omv.image.html) -#### Radon transform +#### Radon transform -Radon transform is another popular algorithm used for line detection. It works by computing the line integral of an image along different directions. The algorithm rotates the image at different angles and computes the sum of pixel intensities along each line in the image. The result is a two-dimensional matrix called the Radon transform. Peaks in this matrix correspond to the lines in the original image. The algorithm then applies some post-processing steps to identify and extract the lines from the Radon transform. +Radon transform is another popular algorithm used for line detection. It works by computing the line integral of an image along different directions. The algorithm rotates the image at different angles and computes the sum of pixel intensities along each line in the image. The result is a two-dimensional matrix called the Radon transform. Peaks in this matrix correspond to the lines in the original image. The algorithm then applies some post-processing steps to identify and extract the lines from the Radon transform. -For more information about Radon transform algorithms check the below links: +For more information about Radon transform algorithms check the below links: -- [Science article](https://www.sciencedirect.com/science/article/abs/pii/0031320396000155) -- [matlab Radon](https://stackoverflow.com/questions/35412573/radon-transform-line-detection) -- [Matlab elaboration Radon](https://www.kevinpolisano.com/Doctorat/doc-matlab-exemple/radon_lines_detection.html) -- [OpenCV Radon doc](https://docs.opencv.org/4.x/d5/d89/radon__transform_8hpp.html) +- [Science article](https://www.sciencedirect.com/science/article/abs/pii/0031320396000155) +- [matlab Radon](https://stackoverflow.com/questions/35412573/radon-transform-line-detection) +- [Matlab elaboration Radon](https://www.kevinpolisano.com/Doctorat/doc-matlab-exemple/radon_lines_detection.html) +- [OpenCV Radon doc](https://docs.opencv.org/4.x/d5/d89/radon__transform_8hpp.html) -### Which algorithm is suitable for our project? +### Which algorithm is suitable for our project? -We have identified four different types of line detection algorithms that could potentially be used for our project. To decide on the best algorithm, we need to consider various factors such as accuracy, efficiency, and ease of use. While processing time is not a critical factor in our case, we need to ensure that the algorithm we choose meets our requirements and is accessible through the platform we are using, which is currently openMV but may change to openCV in the future. Therefore, our priority is to select an algorithm that is easy to implement, provides accurate results, and is compatible with our platform. +We have identified four different types of line detection algorithms that could potentially be used for our project. To decide on the best algorithm, we need to consider various factors such as accuracy, efficiency, and ease of use. While processing time is not a critical factor in our case, we need to ensure that the algorithm we choose meets our requirements and is accessible through the platform we are using, which is currently openMV but may change to openCV in the future. Therefore, our priority is to select an algorithm that is easy to implement, provides accurate results, and is compatible with our platform. -#### OpenMV +#### OpenMV -The only two algorithms that work with OpenMV are Hough Transform, the function find_lines, and Line Segment Detector, also known as find_line_segments. Both of these have their ups and downs and could be used for our project. find_lines has the most ups whereas find_line_segemtns has the most negative. As the result here below is decently optimized, it is first grayscaled, and then canny edge detection is done to it. +The only two algorithms that work with OpenMV are Hough Transform, the function find_lines, and Line Segment Detector, also known as find_line_segments. Both of these have their ups and downs and could be used for our project. find_lines has the most ups whereas find_line_segemtns has the most negative. As the result here below is decently optimized, it is first grayscaled, and then canny edge detection is done to it. -For the test are the straight lines pictures used with different lighting additionality the left lane represents a whitish line and the right lane is drawn with a more darker color. here below are the pictures used: +For the test are the straight lines pictures used with different lighting additionality the left lane represents a whitish line and the right lane is drawn with a more darker color. here below are the pictures used: -![picture 1](../RealTime_pictures/rtstraightLines.class/00000.jpg) +![picture 1](../RealTime_pictures/rtStraightLines.class/00000.jpg) -![picture 2](../RealTime_pictures/rtStraightLines.class/00018.jpg) +![picture 2](../RealTime_pictures/rtStraightLines.class/00018.jpg) -##### find_lines +##### find_lines -The find_lines is a very fast function where you can handle straight lines and other lines with at least 45 FPS or more. Also, have a lot of control over the different types of parameters. +The find_lines is a very fast function where you can handle straight lines and other lines with at least 45 FPS or more. Also, have a lot of control over the different types of parameters. -This is the outcome of picture 1: -![outcome_picture_1](./assets/hough_straightLines_Pic_0.bmp) +This is the outcome of picture 1: +![outcome_picture_1](../assets/hough_straightLines_Pic_0.png) -This is the outcome of picture 2: -![outcome_picture_2](./assets/hough_straightLines_Pic_1.bmp) +This is the outcome of picture 2: +![outcome_picture_2](../assets/hough_straightLines_Pic_1.png) -As you can see there isn't much of a difference between the two pictures. +As you can see there isn't much of a difference between the two pictures. -##### find_line_segments +##### find_line_segments -The find_line_segments is a very slow function where you can find segments from a line. This is a easier to use function because it only has two parameters but the frame rate drops significantly. Additionally, the size of the image to run the algorithm on needs to be smaller because of memory. +The find_line_segments is a very slow function where you can find segments from a line. This is a easier to use function because it only has two parameters but the frame rate drops significantly. Additionally, the size of the image to run the algorithm on needs to be smaller because of memory. -This is the outcome of picture 1: +This is the outcome of picture 1: -![outcome_picture_1](./assets/LSD_straightLines_Pic_0.bmp.bmp) +![outcome_picture_1](../assets/LSD_straightLines_Pic_0.png) -This is the outcome of picture 2: +This is the outcome of picture 2: -![outcome_picture_2](./assets/LSD_straightLines_Pic_1.bmp.bmp) +![outcome_picture_2](../assets/LSD_straightLines_Pic_1.png) -As you can see there is quite a lot of difference between them. This function needs more refinement but I couldn't find the sweet spot. Also, the right line in different pictures was always the problem, so there needs another solution for this function to work better. +As you can see there is quite a lot of difference between them. This function needs more refinement but I couldn't find the sweet spot. Also, the right line in different pictures was always the problem, so there needs another solution for this function to work better. -#### OpenCV +#### OpenCV -All the above algorithms could be used with OpenCV, But the Radon transform needs more work than the others with the amount of information in the doc. +All the above algorithms could be used with OpenCV, But the Radon transform needs more work than the others with the amount of information in the doc. ## Communication between the Nicla and Zumo diff --git a/doc/makefile b/doc/makefile index a960c63..3446eeb 100644 --- a/doc/makefile +++ b/doc/makefile @@ -3,6 +3,13 @@ all: dui.pdf dui.pdf: ../assets/architecture-level-0.pdf +dui.pdf: ../assets/LSD_straightLines_Pic_0.png +dui.pdf: ../assets/LSD_straightLines_Pic_1.png +dui.pdf: ../assets/hough_straightLines_Pic_0.png +dui.pdf: ../assets/hough_straightLines_Pic_1.png + +%.png: %.bmp + convert $< $@ %.pdf: %.svg rsvg-convert -f pdf -o $@ $< @@ -15,4 +22,5 @@ dui.pdf: ../assets/architecture-level-0.pdf clean: $(RM) dui.aux dui.bbl dui.bcf dui.blg dui.fdb_latexmk dui.fls dui.log dui.out dui.run.xml dui.synctex.gz dui.toc dui.md.tex dui.pdf + $(RM) ../assets/LSD_straightLines_Pic_0.png ../assets/LSD_straightLines_Pic_1.png ../assets/hough_straightLines_Pic_0.png ../assets/hough_straightLines_Pic_1.png diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..4317e32 --- /dev/null +++ b/readme.md @@ -0,0 +1,5 @@ +# avans-dui + +d.u.i. (Driving under influence) + +Avans Hogeschool project Vision -- cgit v1.2.3 From 9c77d63265256048eebe242dbcecf89cf2ebb994 Mon Sep 17 00:00:00 2001 From: UnavailableDev Date: Mon, 22 May 2023 10:24:04 +0200 Subject: doc merge --- doc/dui.md | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/img/signs.png | Bin 0 -> 376970 bytes docs/imgs/signs.png | Bin 376970 -> 0 bytes 3 files changed, 131 insertions(+) create mode 100644 doc/img/signs.png delete mode 100644 docs/imgs/signs.png diff --git a/doc/dui.md b/doc/dui.md index 3f72e1c..b8354c0 100644 --- a/doc/dui.md +++ b/doc/dui.md @@ -383,10 +383,141 @@ combination with the standard Pololu boards and Libraries. } \buildSystemConclusion +## Traffic Sign Detection (TSD) + +The following chapters will look at the different methods used to detect signs in order to find a suitable solution for this project. + +### Color based + +The distinct color characteristics of traffic signs can attract drivers’ attention and can also provide important cues to design color based detection methods. In the past decades, a large amount of detection methods are designed to detect distinct traffic sign colors such as blue, red and yellow. These methods can be directly used for traffic sign detection, and can also be used for preliminary reduction of the search space, followed by other detection methods + +#### RGB + +One can easily look at the RGB values to detect a certain color. Although the r,g and b values are heavily effected by different illuminations, therefore this isn't a reliable solution in variating lighting conditions. + +An example implementation: + +```py +#Red +if(R >= ThR and G <= thG) + +#Blue +if(B >= thB) + +#Yellow +if((R + G) >= ThY) +``` + +It is possible to enhance the colors with maximum and minimum operations: + +```py +fR(i) = max(0, min(iR − iG, iR − iB)/s), +fB(i) = max(0, min(iB − iR, iB − iG)/s), +fY(i) = max(0, min(iR − iB, iG − iB)/s). +``` + +This method can result in some issues on the blue channel (see source 1 page 86583 for more explanation). As a solution to this issue use the following formula for the blue channel instead: +```py +f′B(i) = max((0, iB − iR)/s). +``` + +#### HSV + +The HSV/HSI color space is more immune to the illumination challenges of RGB. The hue and saturation channels can be calculated using RGB, which increases the processing time. +The following pseudo code shows how to detect the red, blue and yellow colors in this space. + +```python +#Red +if (H <= Th1 or + H >= Th2) + +#Blue +if (H >= Th1 and + H <= Th2) + +#Yellow + +if (H >= Th1 and + H <= Th2 and + H <= Th3) +``` + +#### LAB + +This color space is used for finding uncorrelated color components, the L\*a\*b\* space was used for detecting blue, red, yellow and green colors. + +#### Pixel classification + +This method avoids the use of fixed thresholds that might need adjusting at times. In order to resolve this some authors tried to transfer the problem into pixel classification where a neural network classifies every pixel in the input image, the pixel classification algorithms are often slower than other color extraction methods. + +#### results + +\def\signDetectionColor{ +The above described methods where also applied to a database in order to compare each method. This resulted in the conclusion that, using a normalized RGB space is giving the a mixture of most detections and least false-positve results. See source 1 page 86584 for the full report. +} +\signDetectionColor + +### Shape based + +Common standard shapes of traffic signs are triangle, circle, rectangle, and octagon. Shape characteristics used for shape detection include standard shapes, boundaries, texture, key points, etc. + +#### Hough + +See line detection hough. + + +#### Barnes *Fang et al* (fast radial symmetry) + +Seemingly a 'simpler' method + + +#### Fourier +This method also deals with occlusion and morphing/rotating the shape flat again (when looking at it at an angle). + +#### Key points detection +This, simply put, looks at the edges/corners in order to find an ROI. + +### Color & Shape based +In some methods, the shape detection methods can be combined with color based methods to fulfill the traffic sign detection work. +For example, using a color based detection to find a ROI and using shape detection in that ROI to determine if it is a sign. + +### Neural networks + + +### results + +\def\signDetectionShape{ +Most shape based recognition methods are more complex than using a color based detection. But the method 'Fourier' seems the most useful as it can also deal with rotated and occluded objects. +} +\signDetectionShape + +## Traffic Sign Recognition (TSR) +After traffic sign detection or tracking, traffic sign recognition is performed to classify the detected traffic signs into correct classes. + +![signs example](img/signs.png) + +### Binary tree +The binary-tree-based classification method usually classify traffic signs according to the shapes and colors in a coarse-to-fine tree process. + +### Support Vector Machine (SVM) +As a binary-classification method, SVM classifies traffic signs using one-vs-one or one-vs-others classification process. + +## results + +\def\signRecognition{ +While making a binary tree is seemingly the most simple, yet effective solution. Using the 'Fourier' method is a bit more complex, it may be a better solution (this requires testing). +} +\signRecognition + # Conclusion \communicationConclusion \buildSystemConclusion +\signDetectionColor +\signDetectionShape +\signRecognition +## Sources: +1. [IEEE, Digital Object Identifier June 26, 2019 (pages 86578 - 86596)](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8746141) diff --git a/doc/img/signs.png b/doc/img/signs.png new file mode 100644 index 0000000..8102ac4 Binary files /dev/null and b/doc/img/signs.png differ diff --git a/docs/imgs/signs.png b/docs/imgs/signs.png deleted file mode 100644 index 8102ac4..0000000 Binary files a/docs/imgs/signs.png and /dev/null differ -- cgit v1.2.3 From 4eaf61db971fde2a7d2d9fe2e8bb4022554724da Mon Sep 17 00:00:00 2001 From: UnavailableDev Date: Mon, 22 May 2023 10:24:40 +0200 Subject: old folder deleted --- docs/research_sign_detect.md | 130 ------------------------------------------- 1 file changed, 130 deletions(-) delete mode 100644 docs/research_sign_detect.md diff --git a/docs/research_sign_detect.md b/docs/research_sign_detect.md deleted file mode 100644 index b81ab38..0000000 --- a/docs/research_sign_detect.md +++ /dev/null @@ -1,130 +0,0 @@ - -# List of abriviations - -- ROI (aRea Of Interest) - - - -# The traffic sign problem: - - - -# Traffic Sign Detection (TSD) - -## Color based - -The distinct color characteristics of traffic signs can attract drivers’ attention and can also provide important cues to design color based detection methods. In the past decades, a large amount of detection methods are designed to detect distinct traffic sign colors such as blue, red and yellow. These methods can be directly used for traffic sign detection, and can also be used for preliminary reduction of the search space, followed by other detection methods - -### RGB - -One can easily look at the RGB values to detect a certain color. Although the r,g and b values are heavily effected by different illuminations, therefore this isn't a reliable solution in variating lighting conditions. - -An example implementation: - -```py -#Red -if(R >= ThR and G <= thG) - -#Blue -if(B >= thB) - -#Yellow -if((R + G) >= ThY) - -``` - -It is possible to enhance the colors with maximum and minimum operations: - -``` -fR(i) = max(0, min(iR − iG, iR − iB)/s), -fB(i) = max(0, min(iB − iR, iB − iG)/s), -fY(i) = max(0, min(iR − iB, iG − iB)/s). -``` - -This method can result in some issues on the blue channel (see source 1 page 86583 for more explanation). As a solution to this issue use the following formula for the blue channel instead: -``` -f′B(i) = max(0, iB − iR)/s). -``` - -### HSV - -The HSV/HSI color space is more immune to the illumination challenges of RGB. The hue and saturation channels can be calculated using RGB, which increases the processing time. - -The following pseudo code shows how to detect the red, blue and yellow colors in this space. - -```python -#Red -if (H <= Th1 or - H >= Th2) - -#Blue -if (H >= Th1 and - H <= Th2) - -#Yellow - -if (H >= Th1 and - H <= Th2 and - H <= Th3) - -``` - -### LAB - -This color space is used for finding uncorrelated color components, the L\*a\*b\* space was used for detecting blue, red, yellow and green colors. - - -### Pixel classification - -This method avoids the use of fixed thresholds that might need adjusting at times. In order to resolve this some authors tried to transfer the problem into pixel classification where a neural network classifies every pixel in the input image, the pixel classification algorithms are often slower than other color extraction methods. - -### results - -The above described methods where also applied to a database in order to compare each method. This resulted in the conclusion that using a normalized RGB space is giving the most accurate results. See source 1 page 86584 for the full report. - -## Shape based - -Common standard shapes of traffic signs are triangle, circle, rectangle, and octagon. Shape characteristics used for shape detection include standard shapes, boundaries, texture, key points, etc. - -### Hough - - - -### Barnes *Fang et al* (fast radial symmetry) -Seemingly a 'simpler' method - - - -### Fourier -This method also deals with occlusion and morphing the shape flat again (when looking at it at an angle). - - -### Key points detection -This, simply put, looks at the edges/corners in order to find an ROI. - -## Color & Shape based -In some methods, the shape detection methods can be combined with color based methods to fulfill the traffic sign detection work. - -For example, using a color based detection to find a ROI and using shape detection in that ROI to determine if it is a sign. - - -## Neural networks - - - -# Traffic Sign Recognition (TSR) -After traffic sign detection or tracking, traffic sign recognition is performed to classify the detected traffic signs into correct classes. - -![signs example](imgs/signs.png) - -## Binary tree -The binary-tree-based classification method usually classify traffic signs according to the shapes and colors in a coarse-to-fine tree process. - -## Support Vector Machine (SVM) -As a binary-classification method, SVM classifies traffic signs using one-vs-one or one-vs-others classification process. - - - -# Sources: - -1. [IEEE, Digital Object Identifier June 26, 2019 (pages 86578 - 86596)](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8746141) \ No newline at end of file -- cgit v1.2.3 From 6daf8036c1342899196b2f7830ae5a18f0918d07 Mon Sep 17 00:00:00 2001 From: UnavailableDev Date: Mon, 22 May 2023 10:26:37 +0200 Subject: *file in wrong dir fixed --- assets/signs.png | Bin 0 -> 376970 bytes doc/dui.md | 2 +- doc/img/signs.png | Bin 376970 -> 0 bytes 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 assets/signs.png delete mode 100644 doc/img/signs.png diff --git a/assets/signs.png b/assets/signs.png new file mode 100644 index 0000000..8102ac4 Binary files /dev/null and b/assets/signs.png differ diff --git a/doc/dui.md b/doc/dui.md index b8354c0..cbe99e9 100644 --- a/doc/dui.md +++ b/doc/dui.md @@ -494,7 +494,7 @@ Most shape based recognition methods are more complex than using a color based d ## Traffic Sign Recognition (TSR) After traffic sign detection or tracking, traffic sign recognition is performed to classify the detected traffic signs into correct classes. -![signs example](img/signs.png) +![signs example](../assets/signs.png) ### Binary tree The binary-tree-based classification method usually classify traffic signs according to the shapes and colors in a coarse-to-fine tree process. diff --git a/doc/img/signs.png b/doc/img/signs.png deleted file mode 100644 index 8102ac4..0000000 Binary files a/doc/img/signs.png and /dev/null differ -- cgit v1.2.3