Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f18a936129 |
@@ -1,12 +1,5 @@
|
|||||||
# discoverpixy
|
# discoverpixy
|
||||||
A Project with the Pixy cam and the STM32F4 Discovery. The project can also be run on linux/windows using a qt-based emulator.
|
Project with the Pixy cam and the STM32F4 Discovery
|
||||||
|
|
||||||

|
|
||||||
<img src="doc/mainscreen_emulator.png" width="300">
|
|
||||||
<img src="doc/tracking_emulator.png" width="300">
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
Take a look at our [docu.pdf](./doc/docu.pdf) (German)
|
|
||||||
|
|
||||||
## Folder structure
|
## Folder structure
|
||||||
* *common*: device independent code and the "Application" itself
|
* *common*: device independent code and the "Application" itself
|
||||||
|
|||||||
@@ -16,11 +16,15 @@
|
|||||||
#include<stdint.h>
|
#include<stdint.h>
|
||||||
|
|
||||||
// PID tuning factors
|
// PID tuning factors
|
||||||
#define REG_PID_KP (0.5f)
|
#define REG_PID_KP (0.41f)
|
||||||
#define REG_PID_KI (0.001f)
|
#define REG_PID_KI (0.001f)
|
||||||
#define REG_PID_KD (0.001f)
|
#define REG_PID_KD (0.00025f)
|
||||||
#define REG_PID_TA (0.01f)
|
#define REG_PID_TA (0.001f)
|
||||||
|
#define REG_PID_YKOR (0.3f)
|
||||||
|
|
||||||
|
void int_init(void){
|
||||||
|
// TODO Init ports and outputs if needed.
|
||||||
|
}
|
||||||
|
|
||||||
// PID controller implementatoin for the y-axis
|
// PID controller implementatoin for the y-axis
|
||||||
int16_t pixy_PID_Y(int16_t x, int16_t w)
|
int16_t pixy_PID_Y(int16_t x, int16_t w)
|
||||||
@@ -35,7 +39,7 @@ int16_t pixy_PID_Y(int16_t x, int16_t w)
|
|||||||
//----PID-control-------------------------------------------------------------------------
|
//----PID-control-------------------------------------------------------------------------
|
||||||
esum = esum + e; // add e to the current sum
|
esum = esum + e; // add e to the current sum
|
||||||
|
|
||||||
y += REG_PID_KP * e; // add the proportional part to the output
|
y += (REG_PID_KP + REG_PID_YKOR) * e; // add the proportional part to the output
|
||||||
y += REG_PID_KI * REG_PID_TA * esum; // add the integral part to the output
|
y += REG_PID_KI * REG_PID_TA * esum; // add the integral part to the output
|
||||||
y += REG_PID_KD * (e - eold) / REG_PID_TA; // add the differential part to the output
|
y += REG_PID_KD * (e - eold) / REG_PID_TA; // add the differential part to the output
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,41 +1,14 @@
|
|||||||
#ifndef PIXY_CONTROL_H_
|
/*
|
||||||
#define PIXY_CONTROL_H_
|
* pixy_control.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CONTROL_H_
|
||||||
|
#define _CONTROL_H_
|
||||||
|
|
||||||
#include<stdint.h>
|
#include<stdint.h>
|
||||||
|
|
||||||
/**
|
void int_init(void);
|
||||||
* @addtogroup app
|
|
||||||
*/
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup pixy_control Pixy Control Helper
|
|
||||||
* A collection of helper functions that contain PID Control code used for object tracking.
|
|
||||||
*/
|
|
||||||
/*@}*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup pixy_control
|
|
||||||
*/
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute one step of PID regulation for the Y-servo.
|
|
||||||
* @param x desired value (e.g. current y-position of the biggest block)
|
|
||||||
* @param w actual value (e.g desired y-position)
|
|
||||||
* @return The offset which needs to be added to the Y-Servo position
|
|
||||||
*/
|
|
||||||
int16_t pixy_PID_Y(int16_t x, int16_t w);
|
int16_t pixy_PID_Y(int16_t x, int16_t w);
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute one step of PID regulation for the X-servo.
|
|
||||||
* @param x desired value (e.g. current x-position of the biggest block)
|
|
||||||
* @param w actual value (e.g desired x-position)
|
|
||||||
* @return The offset which needs to be added to the X-Servo position
|
|
||||||
*/
|
|
||||||
int16_t pixy_PID_X(int16_t x, int16_t w);
|
int16_t pixy_PID_X(int16_t x, int16_t w);
|
||||||
|
|
||||||
/*@}*/
|
#endif
|
||||||
|
|
||||||
#endif /* PIXY_CONTROL_H_ */
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "pixy_frame.h"
|
#include "pixy_helper.h"
|
||||||
#include "pixy.h"
|
#include "pixy.h"
|
||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -1,30 +1,10 @@
|
|||||||
#ifndef PIXY_FRAME_H
|
#ifndef PIXY_HELPER_H
|
||||||
#define PIXY_FRAME_H
|
#define PIXY_HELPER_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup app
|
|
||||||
*/
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup pixy_helper Pixy Frame Helper
|
|
||||||
* A collection of helper functions that allow receiving and rendering a frame from pixy onto the display.
|
|
||||||
* Furthermore you can select a color in a frame, to use for tracking.
|
|
||||||
*/
|
|
||||||
/*@}*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup pixy_helper
|
|
||||||
*/
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives a fullsized frame from pixy and display's it on the display with the topleft corner at (x,y)
|
* Receives a fullsized frame from pixy and display's it on the display with the topleft corner at (x,y)
|
||||||
* @param x The x-Coordinate of the top left corner
|
* @param x The x-Coordinate of the top left corner
|
||||||
@@ -76,6 +56,4 @@ int pixy_save_cropped_frame(FILE_HANDLE* handle, uint16_t xoffset, uint16_t yoff
|
|||||||
*/
|
*/
|
||||||
int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height);
|
int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height);
|
||||||
|
|
||||||
/*@}*/
|
#endif /* PIXY_HELPER_H */
|
||||||
|
|
||||||
#endif /* PIXY_FRAME_H */
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
#include "pixy.h"
|
#include "pixy.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "pixy_frame.h"
|
#include "pixy_helper.h"
|
||||||
|
|
||||||
static bool pixy_connected = false; //Whether or not the pixy cam is currently connected
|
static bool pixy_connected = false; //Whether or not the pixy cam is currently connected
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
#include "pixy.h"
|
#include "pixy.h"
|
||||||
#include "pixy_frame.h"
|
#include "pixy_helper.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
#include "pixy.h"
|
#include "pixy.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "pixy_frame.h"
|
#include "pixy_helper.h"
|
||||||
|
|
||||||
static volatile enum {detecting, idle,update_servos, update_ledcolor, update_ledcurrent} state; //Current state of the screen state machine
|
static volatile enum {detecting, idle,update_servos, update_ledcolor, update_ledcurrent} state; //Current state of the screen state machine
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
#include "pixy.h"
|
#include "pixy.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "pixy_frame.h"
|
#include "pixy_helper.h"
|
||||||
|
|
||||||
static BUTTON_STRUCT b_back; //Button to navigate back
|
static BUTTON_STRUCT b_back; //Button to navigate back
|
||||||
static BUTTON_STRUCT b_select; //Button to start the color region selection
|
static BUTTON_STRUCT b_select; //Button to start the color region selection
|
||||||
|
|||||||
BIN
doc/docu.odt
BIN
doc/docu.odt
Binary file not shown.
BIN
doc/docu.pdf
BIN
doc/docu.pdf
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 37 KiB |
BIN
doc/pixy.png
BIN
doc/pixy.png
Binary file not shown.
|
Before Width: | Height: | Size: 185 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 57 KiB |
5
emulator/.gitignore
vendored
5
emulator/.gitignore
vendored
@@ -5,9 +5,8 @@ qt/*.o
|
|||||||
qt/*.a
|
qt/*.a
|
||||||
qt/ui_*
|
qt/ui_*
|
||||||
qt/moc_*
|
qt/moc_*
|
||||||
qt/Makefile*
|
qt/Makefile
|
||||||
qt/debug
|
|
||||||
qt/release
|
|
||||||
|
|
||||||
libs/*/obj
|
libs/*/obj
|
||||||
libs/*/*.a
|
libs/*/*.a
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ QT_DIR=./qt
|
|||||||
COMMON_DIR=../common
|
COMMON_DIR=../common
|
||||||
|
|
||||||
#Tools
|
#Tools
|
||||||
CC=gcc #-fdiagnostics=auto
|
CC=gcc -fdiagnostics-color=auto
|
||||||
GDB=gdb
|
GDB=gdb
|
||||||
|
|
||||||
|
|
||||||
@@ -24,22 +24,17 @@ INCLUDES:=$(addprefix -I,$(INCLUDES))
|
|||||||
QT_LIB=$(QT_DIR)/libemulatorqt.a
|
QT_LIB=$(QT_DIR)/libemulatorqt.a
|
||||||
|
|
||||||
|
|
||||||
CPPFLAGS= -march=x86-64 -mtune=generic #-fPIC
|
CPPFLAGS= -march=x86-64 -mtune=generic -fPIC $(INCLUDES)
|
||||||
CPPFLAGS+= $(INCLUDES)
|
CFLAGS= -O0 -g -std=c99
|
||||||
CFLAGS= -O0 -g -std=c99 -mwindows
|
|
||||||
|
|
||||||
|
|
||||||
LIBS= emulatorqt pixy usb-1.0
|
LIBS= pixy usb-1.0 boost_system boost_timer boost_chrono
|
||||||
LIBS+= boost_system-mgw49-mt-1_58 boost_timer-mgw49-mt-1_58 boost_chrono-mgw49-mt-1_58
|
LIBS+=Qt5Core Qt5Gui Qt5Widgets emulatorqt m stdc++
|
||||||
LIBS+= Qt5Core Qt5Gui Qt5Widgets m stdc++
|
|
||||||
|
|
||||||
LDFLAGS= -static-libgcc -static-libstdc++ #-Wl,-t -Wl,--Map=a.map
|
|
||||||
LDFLAGS+= -L$(QT_DIR)
|
LDFLAGS= -L$(QT_DIR) $(addprefix -l,$(LIBS))
|
||||||
LDFLAGS+= -L$(LIB_DIR)/Pixy
|
LDFLAGS+= -L$(LIB_DIR)/Pixy
|
||||||
LDFLAGS+= -L$(LIB_DIR)/boost/lib
|
|
||||||
LDFLAGS+= -LC:/Qt/5.4/mingw491_32/lib
|
|
||||||
LDFLAGS+= -L$(LIB_DIR)/Pixy/windows
|
|
||||||
LDFLAGS+= $(addprefix -l,$(LIBS))
|
|
||||||
|
|
||||||
#Finding Input files
|
#Finding Input files
|
||||||
CFILES=$(shell find . -maxdepth 1 -name '*.c')
|
CFILES=$(shell find . -maxdepth 1 -name '*.c')
|
||||||
@@ -63,7 +58,7 @@ debug: all
|
|||||||
$(GDB) ./build/emulator
|
$(GDB) ./build/emulator
|
||||||
|
|
||||||
$(QT_LIB):
|
$(QT_LIB):
|
||||||
cd $(QT_DIR) && qmake && $(MAKE)
|
cd $(QT_DIR) && qmake &&make
|
||||||
|
|
||||||
#objects to elf
|
#objects to elf
|
||||||
$(BUILD_DIR)/$(TARGET): $(OBJS) $(COMMON_OBJS) $(QT_LIB)
|
$(BUILD_DIR)/$(TARGET): $(OBJS) $(COMMON_OBJS) $(QT_LIB)
|
||||||
@@ -88,7 +83,7 @@ $(OBJ_DIR)/%.o: $(COMMON_DIR)/%.c
|
|||||||
|
|
||||||
#Clean Obj files and builded stuff
|
#Clean Obj files and builded stuff
|
||||||
clean:
|
clean:
|
||||||
cd $(QT_DIR) && $(MAKE) clean && $(RM) Makefile* && $(RM) *.a && $(RMDIR) debug release
|
cd $(QT_DIR) && $(MAKE) clean && $(RM) Makefile && $(RM) *.a
|
||||||
$(RMDIR) $(BUILD_DIR) $(OBJ_DIR)
|
$(RMDIR) $(BUILD_DIR) $(OBJ_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,11 @@ OBJ_DIR=./obj
|
|||||||
#Architecture flags
|
#Architecture flags
|
||||||
|
|
||||||
#Compiler, Linker Options
|
#Compiler, Linker Options
|
||||||
CPPFLAGS=-I$(INC_DIR) -DHOST=1 #-D__LINUX__=1 -DDEBUG=1
|
CPPFLAGS=-I$(INC_DIR) -D__LINUX__=1 -DHOST=1 #-DDEBUG=1
|
||||||
CFLAGS=$(ARCH_FLAGS) -O0 -g #-ffunction-sections -fdata-sections -g
|
CFLAGS=$(ARCH_FLAGS) -O0 -g #-ffunction-sections -fdata-sections -g
|
||||||
#CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
|
#CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
|
||||||
#CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
#CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
CFLAGS+=-I/usr/include/libusb-1.0
|
CFLAGS+=-I/usr/include/libusb-1.0
|
||||||
CFLAGS+=-I../boost/include/
|
|
||||||
CFLAGS+=-I./windows/
|
|
||||||
|
|
||||||
#Finding Input files
|
#Finding Input files
|
||||||
CFILES=$(shell find $(SRC_DIR) -name '*.cpp')
|
CFILES=$(shell find $(SRC_DIR) -name '*.cpp')
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
2
emulator/libs/boost/.gitignore
vendored
2
emulator/libs/boost/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
include
|
|
||||||
lib
|
|
||||||
Binary file not shown.
@@ -1,2 +0,0 @@
|
|||||||
This directory is only needed on windows, and if you do not have boost installed.
|
|
||||||
Extract the rar file here, to get boost 1.58 header files and the libraries that we need for discoverpixy
|
|
||||||
@@ -8,7 +8,7 @@ QT += widgets gui
|
|||||||
|
|
||||||
TARGET = emulatorqt
|
TARGET = emulatorqt
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += staticlib debug
|
CONFIG += staticlib
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
@@ -30,6 +30,3 @@ INCLUDEPATH+= ../../common/lowlevel/ \
|
|||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
|
|
||||||
DESTDIR = $$_PRO_FILE_PWD_ #force windows to not create subfolders
|
|
||||||
|
|
||||||
#QMAKE_CXXFLAGS+= -v
|
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ uint8_t ll_tft_num_fonts() {
|
|||||||
QFont get_font(uint8_t fontnum) {
|
QFont get_font(uint8_t fontnum) {
|
||||||
switch(fontnum) {
|
switch(fontnum) {
|
||||||
case 0:
|
case 0:
|
||||||
return QFont("Courier New",8);
|
return QFont("Monospace",8);
|
||||||
case 1:
|
case 1:
|
||||||
return QFont("Courier New",14);
|
return QFont("DejaVu Sans Mono",14);
|
||||||
default:
|
default:
|
||||||
return QFont();
|
return QFont();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
Prerequisites:
|
|
||||||
- Qt5 for Windows (provides C:\Qt\5.4\mingw491_32 and C:\Qt\Tools\mingw491_32)
|
|
||||||
- Mingw msys-base (provides C:\MinGW\msys\1.0 and make, find )
|
|
||||||
- Boost (check emulator\libs\boost)
|
|
||||||
|
|
||||||
Steps:
|
|
||||||
- Open up the msys shell using the batchfile
|
|
||||||
- Navigate to the emulator folder of the project
|
|
||||||
- Source the qt binaries (qmake, gcc, g++) by executing
|
|
||||||
export PATH=$PATH:/c/Qt/Tools/mingw491_32/bin:/c/Qt/5.4/mingw491_32/bin
|
|
||||||
- navigate to libs/Pixy and execute make
|
|
||||||
- navigate back into the emulator folder and execute make
|
|
||||||
- this should generate you build/emulator.exe
|
|
||||||
|
|
||||||
Starting:
|
|
||||||
- Extract windows_dlls.rar to the build folder
|
|
||||||
- Copy the emulated folder into the build folder
|
|
||||||
- Make sure that you installed the pixy usb driver (e.g. by installing pixymon http://cmucam.org/projects/cmucam5/wiki/Latest_release)
|
|
||||||
- Start emulator.exe
|
|
||||||
|
|
||||||
Pitfalls:
|
|
||||||
- libstdc++ must be provided by qt. do not use one of msys or mingw. you will waste hours with debugging of the make process
|
|
||||||
|
|
||||||
Sources:
|
|
||||||
- libusb for windows was taken from https://github.com/charmedlabs/pixy/tree/master/src/host/windows
|
|
||||||
- Boost was compiled from sources, using http://andres.jaimes.net/718/how-to-install-the-c-boost-libraries-on-windows/ and http://www.boost.org/doc/libs/1_58_0/more/getting_started/windows.html
|
|
||||||
Binary file not shown.
@@ -7,7 +7,7 @@ echo "* Institution: BFH Bern University of Applied Sciences"
|
|||||||
echo "* File: $1"
|
echo "* File: $1"
|
||||||
echo "*"
|
echo "*"
|
||||||
echo "* Version History:"
|
echo "* Version History:"
|
||||||
echo "* Date Autor Email SHA Changes"
|
echo "* Date Autor Email SHA Changes"
|
||||||
|
|
||||||
git log --pretty=format:"* %ad%x09%ae%x09%h%x09%s" --date=short --date-order --no-merges --reverse $1 | grep -v -i "fileheader"
|
git log --pretty=format:"* %ad%x09%ae%x09%h%x09%s" --date=short --date-order --no-merges --reverse $1 | grep -v -i "fileheader"
|
||||||
|
|
||||||
@@ -3,15 +3,14 @@
|
|||||||
|
|
||||||
FILES=`find common/ emulator/ discovery/ -name "*.c" -or -name "*.h" -or -name "*.cpp" | grep -v libs | grep -v /pixy/`
|
FILES=`find common/ emulator/ discovery/ -name "*.c" -or -name "*.h" -or -name "*.cpp" | grep -v libs | grep -v /pixy/`
|
||||||
|
|
||||||
|
|
||||||
for FILE in $FILES; do
|
for FILE in $FILES; do
|
||||||
echo "Adding Header to $FILE"
|
echo "Adding Header to $FILE"
|
||||||
|
|
||||||
#remove old header, and format file with astyle
|
#remove old header
|
||||||
CONTENT=$(perl -0777 -pe 's%^/\*.*?discoverpixy.*?\*/%%igs' $FILE | astyle --options=./utils/style.astylerc)
|
CONTENT=$(perl -0777 -pe 's%^/\*.*?discoverpixy.*?\*/%%igs' $FILE)
|
||||||
|
|
||||||
#add new header
|
#add new header
|
||||||
./utils/genheader.sh $FILE > $FILE
|
./genheader.sh $FILE > $FILE
|
||||||
|
|
||||||
#append file content
|
#append file content
|
||||||
echo "$CONTENT" >> $FILE
|
echo "$CONTENT" >> $FILE
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
# general style
|
|
||||||
--style=1tbs
|
|
||||||
--indent=spaces=4 # default
|
|
||||||
--lineend=linux #only \r as line ending
|
|
||||||
|
|
||||||
# alignment
|
|
||||||
--align-pointer=type #put asterisks to the type. eg. char* a
|
|
||||||
--align-reference=type #put references to the type. eg. int& a
|
|
||||||
|
|
||||||
# padding
|
|
||||||
--break-blocks # insert empty lines between header blocks
|
|
||||||
--unpad-paren # remove extra padding around parens
|
|
||||||
--pad-oper # spaces around operators
|
|
||||||
--pad-header # insert space between header blocks and the following paren
|
|
||||||
--add-brackets # add brackets to one line conditionals
|
|
||||||
Reference in New Issue
Block a user