Browse Source

Merge branch 'lukas' into master

master
Lukas Reichwein 4 years ago
parent
commit
4eaa4d5bc1
  1. 1
      .gitignore
  2. 1
      Aufgaben.txt
  3. 42
      Code/Joystick/Joystick.ino
  4. 17
      Code/libraries/Joystick/Joystick.cpp
  5. 22
      Code/libraries/Joystick/Joystick.h
  6. 7
      Code/libraries/Joystick/Motor.cpp
  7. 15
      Code/libraries/Joystick/Motor.h
  8. 67
      Code/libraries/Joystick/Steuerung.cpp
  9. 25
      Code/libraries/Joystick/Steuerung.h
  10. 4
      Code/libraries/README.MD
  11. 276
      Latex/.gitignore
  12. BIN
      Latex/images/fish.png
  13. BIN
      Latex/main.pdf
  14. 139
      Latex/main.tex
  15. 19
      Latex/references.bib
  16. 233
      Latex/structure.tex

1
.gitignore

@ -0,0 +1 @@
Arduino/libraries/*

1
Aufgaben.txt

@ -6,6 +6,7 @@ Komponente | Priorität | wird bearbeitet von
ESC (Motorsteuerung) | hoch | Yves
Servo (Lenkung) | hoch | Yves
Funkkommunikation | hoch | Lukas
Joystickbasiertes lenken (lib) | hoch | Lukas
mechanischer Aufbau | hoch | Yves
MPPT Solarlader | niedrig | nicht in Bearbeitung
Bluetooth Beacon Tracking |

42
Code/Joystick/Joystick.ino

@ -0,0 +1,42 @@
#include <Steuerung.h>
//Informationen Joystick
Joystick *joystick;
const uint16_t xAxisPin = 5;
const uint16_t yAxisPin = 4;
const int16_t lowestJoystickValue = 0;
const int16_t highestJoystickValue = 511;
const int16_t spaceing = 50;
//Informationen linker Motor
Motor *left;
const int16_t lowestPWMValueLeftMotor = -255;
const int16_t highestPWMValueLeftMotor = 255;
//Informationen rechter Motor
Motor *right;
const int16_t lowestPWMValueRightMotor = -255;
const int16_t highestPWMValueRightMotor = 255;
Steuerung *steuerung;
void setup() {
joystick = new Joystick(xAxisPin, yAxisPin, lowestJoystickValue, highestJoystickValue, spaceing);
left = new Motor(lowestPWMValueLeftMotor, highestPWMValueLeftMotor);
right = new Motor(lowestPWMValueRightMotor, highestPWMValueRightMotor);
steuerung = new Steuerung(joystick, left, right);
Serial.begin(9600);
}
void loop() {
steuerung -> updateValues();
//DEBUG
Serial.print("Left motor PWMValue: ");
Serial.println(left -> PWMValue);
Serial.print("Right motor PWMValue: ");
Serial.println(right -> PWMValue);
//SendValues
delay(500);
}

17
Code/libraries/Joystick/Joystick.cpp

@ -0,0 +1,17 @@
#include "Joystick.h"
Joystick::Joystick(uint16_t x_pin, uint16_t y_pin, int16_t lowestValue, int16_t highestValue, uint16_t spaceing) {
this -> x_pin = x_pin;
this -> y_pin = y_pin;
this -> lowestValue = lowestValue;
this -> highestValue = highestValue;
this -> spaceing = spaceing;
}
void Joystick::checkJoystickInput() {
this -> xAxisReading = analogRead(x_pin);
this -> yAxisReading = analogRead(y_pin);
//9-bit reichen, der ADC schafft bestenfalls 8-bit praezision
(this -> xAxisReading) = (this -> xAxisReading) >> 1;
(this -> yAxisReading) = (this -> yAxisReading) >> 1;
}

22
Code/libraries/Joystick/Joystick.h

@ -0,0 +1,22 @@
#ifndef __JOYSTICK__
#define __JOYSTICK__
#include "Motor.h"
class Joystick {
// Pin belegungen
private:
uint16_t x_pin; // Pin Nummer an dem der X-output des Joysticks angebunden ist.
uint16_t y_pin; // Pin Nummer an dem der X-output des Joysticks angebunden ist.
public:
int16_t lowestValue;
int16_t highestValue;
uint16_t spaceing; // Abstand vom mittelpunkt um zappeln zu verhindern.
int16_t xAxisReading;
int16_t yAxisReading;
public:
Joystick(uint16_t x_pin, uint16_t y_pin, int16_t lowestValue, int16_t highestValue, uint16_t spaceing);
void checkJoystickInput();
};
#endif

7
Code/libraries/Joystick/Motor.cpp

@ -0,0 +1,7 @@
#include "Motor.h"
Motor::Motor(int16_t lowestValue, int16_t highestValue) {
this -> highestValue = highestValue;
this -> lowestValue = lowestValue;
this -> PWMValue = 0;
}

15
Code/libraries/Joystick/Motor.h

@ -0,0 +1,15 @@
#ifndef __MOTOR__
#define __MOTOR__
#include <Arduino.h>
class Motor {
public:
int16_t highestValue;
int16_t lowestValue;
int16_t PWMValue;
public:
Motor(int16_t lowestValue, int16_t highestValue);
};
#endif

67
Code/libraries/Joystick/Steuerung.cpp

@ -0,0 +1,67 @@
#include "Steuerung.h"
Steuerung::Steuerung(Joystick* joystick, Motor* left, Motor* right) {
this -> joystick = joystick;
this -> left = left;
this -> right = right;
}
void Steuerung::mapReadingsToMatchPWMValues() {
(this -> xValue) = map(joystick -> xAxisReading, joystick -> lowestValue, joystick -> highestValue, left -> lowestValue, left -> highestValue);
(this -> yValue) = map(joystick -> yAxisReading, joystick -> lowestValue, joystick -> highestValue, right -> highestValue, right -> lowestValue);
}
void Steuerung::applyPWMValuesDependingOnReadings() {
if ((abs(this -> xValue) > (joystick -> spaceing)) || (abs(this -> yValue) > (joystick -> spaceing))) {
if (this -> yValue >= 0) {
if (this -> xValue >= 0) {
//+y , +x
(left -> PWMValue) = this -> yValue;
(right -> PWMValue) = (this -> yValue) - (this -> xValue);
if ((this -> xValue) >= (this -> yValue)) {
(left -> PWMValue) = 255;
(right -> PWMValue) = -255;
}
} else {
//+y , -x
(left -> PWMValue) = this -> yValue;
(right -> PWMValue) = (this -> yValue) + (this -> xValue);
if (abs(this -> xValue) >= (this -> yValue)) {
(left -> PWMValue) = -255;
(right -> PWMValue) = 255;
}
}
} else {
if (this -> xValue >= 0) {
//-y , +x
(left -> PWMValue) = this -> yValue;
(right -> PWMValue) = (this -> yValue) + (this -> xValue);
if (this -> xValue >= abs(this -> yValue)) {
(left -> PWMValue) = 255;
(right -> PWMValue) = -255;
}
} else {
//-y , -x
(left -> PWMValue) = this -> yValue;
(right -> PWMValue) = (this -> yValue) - (this -> xValue);
if (abs(this -> xValue) >= abs(this -> yValue)) {
(left -> PWMValue) = -255;
(right -> PWMValue) = 255;
}
}
}
if (abs(this -> xValue) < (joystick -> spaceing)) {
(left -> PWMValue) = this -> yValue;
(right -> PWMValue) = this -> yValue;
}
} else {
(left -> PWMValue) = 0;
(right -> PWMValue) = 0;
}
}
void Steuerung::updateValues() {
joystick -> checkJoystickInput();
mapReadingsToMatchPWMValues();
applyPWMValuesDependingOnReadings();
}

25
Code/libraries/Joystick/Steuerung.h

@ -0,0 +1,25 @@
#ifndef __STEUERUNG__
#define __STEUERUNG__
#include "Motor.h"
#include "Joystick.h"
class Steuerung {
private:
Joystick* joystick;
Motor* left;
Motor* right;
int16_t xValue;
int16_t yValue;
public:
Steuerung(Joystick* joystick, Motor* left, Motor* right);
void updateValues();
private:
void mapReadingsToMatchPWMValues();
void applyPWMValuesDependingOnReadings();
};
#endif

4
Code/libraries/README.MD

@ -0,0 +1,4 @@
Im Ordner libraries befindet sich die Joystick librarie,
welche in den Ordner ...Arduino/libraries verschoben werden muss.
Die Joystick.ino enthält eine beispielhafte verwendung der lib,
sie kann mittels Arduino IDE Compiliert und auf den Arduino geuploaded werden.

276
Latex/.gitignore

@ -0,0 +1,276 @@
## Core latex/pdflatex auxiliary files:
*.aux
*.lof
*.log
*.lot
*.fls
*.out
*.toc
*.fmt
*.fot
*.cb
*.cb2
.*.lb
## Intermediate documents:
*.dvi
*.xdv
*-converted-to.*
# these rules might exclude image files for figures etc.
# *.ps
# *.eps
# *.pdf
## Generated if empty string is given at "Please type another file name for output:"
.pdf
## Bibliography auxiliary files (bibtex/biblatex/biber):
*.bbl
*.bcf
*.blg
*-blx.aux
*-blx.bib
*.run.xml
## Build tool auxiliary files:
*.fdb_latexmk
*.synctex
*.synctex(busy)
*.synctex.gz
*.synctex.gz(busy)
*.pdfsync
## Build tool directories for auxiliary files
# latexrun
latex.out/
## Auxiliary and intermediate files from other packages:
# algorithms
*.alg
*.loa
# achemso
acs-*.bib
# amsthm
*.thm
# beamer
*.nav
*.pre
*.snm
*.vrb
# changes
*.soc
# comment
*.cut
# cprotect
*.cpt
# elsarticle (documentclass of Elsevier journals)
*.spl
# endnotes
*.ent
# fixme
*.lox
# feynmf/feynmp
*.mf
*.mp
*.t[1-9]
*.t[1-9][0-9]
*.tfm
#(r)(e)ledmac/(r)(e)ledpar
*.end
*.?end
*.[1-9]
*.[1-9][0-9]
*.[1-9][0-9][0-9]
*.[1-9]R
*.[1-9][0-9]R
*.[1-9][0-9][0-9]R
*.eledsec[1-9]
*.eledsec[1-9]R
*.eledsec[1-9][0-9]
*.eledsec[1-9][0-9]R
*.eledsec[1-9][0-9][0-9]
*.eledsec[1-9][0-9][0-9]R
# glossaries
*.acn
*.acr
*.glg
*.glo
*.gls
*.glsdefs
*.lzo
*.lzs
# uncomment this for glossaries-extra (will ignore makeindex's style files!)
# *.ist
# gnuplottex
*-gnuplottex-*
# gregoriotex
*.gaux
*.gtex
# htlatex
*.4ct
*.4tc
*.idv
*.lg
*.trc
*.xref
# hyperref
*.brf
# knitr
*-concordance.tex
# TODO Comment the next line if you want to keep your tikz graphics files
*.tikz
*-tikzDictionary
# listings
*.lol
# luatexja-ruby
*.ltjruby
# makeidx
*.idx
*.ilg
*.ind
# minitoc
*.maf
*.mlf
*.mlt
*.mtc[0-9]*
*.slf[0-9]*
*.slt[0-9]*
*.stc[0-9]*
# minted
_minted*
*.pyg
# morewrites
*.mw
# nomencl
*.nlg
*.nlo
*.nls
# pax
*.pax
# pdfpcnotes
*.pdfpc
# sagetex
*.sagetex.sage
*.sagetex.py
*.sagetex.scmd
# scrwfile
*.wrt
# sympy
*.sout
*.sympy
sympy-plots-for-*.tex/
# pdfcomment
*.upa
*.upb
# pythontex
*.pytxcode
pythontex-files-*/
# tcolorbox
*.listing
# thmtools
*.loe
# TikZ & PGF
*.dpth
*.md5
*.auxlock
# todonotes
*.tdo
# vhistory
*.hst
*.ver
# easy-todo
*.lod
# xcolor
*.xcp
# xmpincl
*.xmpi
# xindy
*.xdy
# xypic precompiled matrices and outlines
*.xyc
*.xyd
# endfloat
*.ttt
*.fff
# Latexian
TSWLatexianTemp*
## Editors:
# WinEdt
*.bak
*.sav
# Texpad
.texpadtmp
# LyX
*.lyx~
# Kile
*.backup
# gummi
.*.swp
# KBibTeX
*~[0-9]*
# TeXnicCenter
*.tps
# auto folder when using emacs and auctex
./auto/*
*.el
# expex forward references with \gathertags
*-tags.tex
# standalone packages
*.sta
# Makeindex log files
*.lpz

BIN
Latex/images/fish.png

After

Width: 211  |  Height: 158  |  Size: 15 KiB

BIN
Latex/main.pdf

139
Latex/main.tex

@ -0,0 +1,139 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Lachaise Assignment
% LaTeX Template
% Version 1.0 (26/6/2018)
%
% This template originates from:
% http://www.LaTeXTemplates.com
%
% Authors:
% Marion Lachaise & François Févotte
% Vel (vel@LaTeXTemplates.com)
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------------------------------------------------------------------------
% PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------
\documentclass{article}
\input{structure.tex} % Include the file specifying the document structure and custom commands
%----------------------------------------------------------------------------------------
% INFORMATION
%----------------------------------------------------------------------------------------
\title{Open Source Roboter Plattform} % Title
\author{Lukas Reichwein\\ Yves Ehrlich\\ Nick Gnoevoj}
\date{University of Applied Science Fulda --- \today} % University, school and/or department name(s) and a date
%----------------------------------------------------------------------------------------
\begin{document}
\maketitle % Print the title
\tableofcontents % Inhaltsverzeichniss, Achtung zweimal Compilerien!
\newpage
%----------------------------------------------------------------------------------------
% INTRODUCTION
%----------------------------------------------------------------------------------------
\section*{Vorwort} % Unnumbered section
Motivation, Basis, Ziel des Projektes.
\newpage
%----------------------------------------------------------------------------------------
% Latex Beispeiele
%----------------------------------------------------------------------------------------
\section{Beispiele für Spezielle LaTeX Strukturen}
\begin{info} % Information block
benutze den Info block um wichtige informationen hervorzuheben.
\end{info}
%----------------------------------------------------------------------------------------
% Beispiel für Pseudo Code.
%----------------------------------------------------------------------------------------
\begin{center}
\begin{minipage}{0.5\linewidth} % Adjust the minipage width to accomodate for the length of algorithm lines
\begin{algorithm}[H]
\KwIn{$(a, b)$, two floating-point numbers} % Algorithm inputs
\KwResult{$(c, d)$, such that $a+b = c + d$} % Algorithm outputs/results
\medskip
\If{$\vert b\vert > \vert a\vert$}{
exchange $a$ and $b$ \;
}
$c \leftarrow a + b$ \;
$z \leftarrow c - a$ \;
$d \leftarrow b - z$ \;
{\bf return} $(c,d)$ \;
\caption{\texttt{FastTwoSum}} % Algorithm name
\label{alg:fastTwoSum} % optional label to refer to
\end{algorithm}
\end{minipage}
\end{center}
%----------------------------------------------------------------------------------------
% Beispiel für Code Snippets.
%----------------------------------------------------------------------------------------
% File contents
\begin{file}[hello.py]
\begin{lstlisting}[language=Python]
#! /usr/bin/python
import sys
sys.stdout.write("Hello World!\n")
\end{lstlisting}
\end{file}
%----------------------------------------------------------------------------------------
% Example for Console Prints (can also be usefull for displaying Serial monitor)
%----------------------------------------------------------------------------------------
% Command-line "screenshot"
\begin{commandline}
\begin{verbatim}
$ chmod +x hello.py
$ ./hello.py
Hello World!S
\end{verbatim}
\end{commandline}
% Warning text, with a custom title
\begin{warn}[Notice:]
Warungen könnten auch nützlich sein, immerhin braucht der RF24 3.3V und nicht 5V
\end{warn}
%----------------------------------------------------------------------------------------
% Beispiel für ein Bild.
%----------------------------------------------------------------------------------------
\begin{figure}[h]
\includegraphics[width=8cm]{fish.png}
\centering
\end{figure}
%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY
%----------------------------------------------------------------------------------------
\bibliographystyle{unsrt}
\bibliography{sample.bib}
%----------------------------------------------------------------------------------------
\end{document}

19
Latex/references.bib

@ -0,0 +1,19 @@
@BOOK{Smith:2012qr,
title = {{B}ook {T}itle},
publisher = {Publisher},
author = {Smith, J.~M. and Jones, A.~B.},
year = {2012},
edition = {7th},
}
@ARTICLE{Smith:2013jd,
author = {Jones, A.~B. and Smith, J.~M.},
title = {{A}rticle {T}itle},
journal = {Journal title},
year = {2013},
volume = {13},
pages = {123-456},
number = {52},
month = {March},
publisher = {Publisher}
}

233
Latex/structure.tex

@ -0,0 +1,233 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Lachaise Assignment
% Structure Specification File
% Version 1.0 (26/6/2018)
%
% This template originates from:
% http://www.LaTeXTemplates.com
%
% Authors:
% Marion Lachaise & François Févotte
% Vel (vel@LaTeXTemplates.com)
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------------------------------------------------------------------------
% PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------
\usepackage[ngerman]{babel} %UMLAUTE
\usepackage{amsmath,amsfonts,stmaryrd,amssymb} % Math packages
\usepackage{enumerate} % Custom item numbers for enumerations
\usepackage[ruled]{algorithm2e} % Algorithms
\usepackage[framemethod=tikz]{mdframed} % Allows defining custom boxed/framed environments
\usepackage{listings} % File listings, with syntax highlighting
\lstset{
basicstyle=\ttfamily, % Typeset listings in monospace font
}
\usepackage{graphicx}
%Path relative to the main .tex file
\graphicspath{ {images/} }
%----------------------------------------------------------------------------------------
% DOCUMENT MARGINS
%----------------------------------------------------------------------------------------
\usepackage{geometry} % Required for adjusting page dimensions and margins
\geometry{
paper=a4paper, % Paper size, change to letterpaper for US letter size
top=2.5cm, % Top margin
bottom=3cm, % Bottom margin
left=2.5cm, % Left margin
right=2.5cm, % Right margin
headheight=14pt, % Header height
footskip=1.5cm, % Space from the bottom margin to the baseline of the footer
headsep=1.2cm, % Space from the top margin to the baseline of the header
%showframe, % Uncomment to show how the type block is set on the page
}
%----------------------------------------------------------------------------------------
% FONTS
%----------------------------------------------------------------------------------------
\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[T1]{fontenc} % Output font encoding for international characters
\usepackage{XCharter} % Use the XCharter fonts
%----------------------------------------------------------------------------------------
% COMMAND LINE ENVIRONMENT
%----------------------------------------------------------------------------------------
% Usage:
% \begin{commandline}
% \begin{verbatim}
% $ ls
%
% Applications Desktop ...
% \end{verbatim}
% \end{commandline}
\mdfdefinestyle{commandline}{
leftmargin=10pt,
rightmargin=10pt,
innerleftmargin=15pt,
middlelinecolor=black!50!white,
middlelinewidth=2pt,
frametitlerule=false,
backgroundcolor=black!5!white,
frametitle={Command Line},
frametitlefont={\normalfont\sffamily\color{white}\hspace{-1em}},
frametitlebackgroundcolor=black!50!white,
nobreak,
}
% Define a custom environment for command-line snapshots
\newenvironment{commandline}{
\medskip
\begin{mdframed}[style=commandline]
}{
\end{mdframed}
\medskip
}
%----------------------------------------------------------------------------------------
% FILE CONTENTS ENVIRONMENT
%----------------------------------------------------------------------------------------
% Usage:
% \begin{file}[optional filename, defaults to "File"]
% File contents, for example, with a listings environment
% \end{file}
\mdfdefinestyle{file}{
innertopmargin=1.6\baselineskip,
innerbottommargin=0.8\baselineskip,
topline=false, bottomline=false,
leftline=false, rightline=false,
leftmargin=2cm,
rightmargin=2cm,
singleextra={%
\draw[fill=black!10!white](P)++(0,-1.2em)rectangle(P-|O);
\node[anchor=north west]
at(P-|O){\ttfamily\mdfilename};
%
\def\l{3em}
\draw(O-|P)++(-\l,0)--++(\l,\l)--(P)--(P-|O)--(O)--cycle;
\draw(O-|P)++(-\l,0)--++(0,\l)--++(\l,0);
},
nobreak,
}
% Define a custom environment for file contents
\newenvironment{file}[1][File]{ % Set the default filename to "File"
\medskip
\newcommand{\mdfilename}{#1}
\begin{mdframed}[style=file]
}{
\end{mdframed}
\medskip
}
%----------------------------------------------------------------------------------------
% NUMBERED QUESTIONS ENVIRONMENT
%----------------------------------------------------------------------------------------
% Usage:
% \begin{question}[optional title]
% Question contents
% \end{question}
\mdfdefinestyle{question}{
innertopmargin=1.2\baselineskip,
innerbottommargin=0.8\baselineskip,
roundcorner=5pt,
nobreak,
singleextra={%
\draw(P-|O)node[xshift=1em,anchor=west,fill=white,draw,rounded corners=5pt]{%
Question \theQuestion\questionTitle};
},
}
\newcounter{Question} % Stores the current question number that gets iterated with each new question
% Define a custom environment for numbered questions
\newenvironment{question}[1][\unskip]{
\bigskip
\stepcounter{Question}
\newcommand{\questionTitle}{~#1}
\begin{mdframed}[style=question]
}{
\end{mdframed}
\medskip
}
%----------------------------------------------------------------------------------------
% WARNING TEXT ENVIRONMENT
%----------------------------------------------------------------------------------------
% Usage:
% \begin{warn}[optional title, defaults to "Warning:"]
% Contents
% \end{warn}
\mdfdefinestyle{warning}{
topline=false, bottomline=false,
leftline=false, rightline=false,
nobreak,
singleextra={%
\draw(P-|O)++(-0.5em,0)node(tmp1){};
\draw(P-|O)++(0.5em,0)node(tmp2){};
\fill[black,rotate around={45:(P-|O)}](tmp1)rectangle(tmp2);
\node at(P-|O){\color{white}\scriptsize\bf !};
\draw[very thick](P-|O)++(0,-1em)--(O);%--(O-|P);
}
}
% Define a custom environment for warning text
\newenvironment{warn}[1][Warning:]{ % Set the default warning to "Warning:"
\medskip
\begin{mdframed}[style=warning]
\noindent{\textbf{#1}}
}{
\end{mdframed}
}
%----------------------------------------------------------------------------------------
% INFORMATION ENVIRONMENT
%----------------------------------------------------------------------------------------
% Usage:
% \begin{info}[optional title, defaults to "Info:"]
% contents
% \end{info}
\mdfdefinestyle{info}{%
topline=false, bottomline=false,
leftline=false, rightline=false,
nobreak,
singleextra={%
\fill[black](P-|O)circle[radius=0.4em];
\node at(P-|O){\color{white}\scriptsize\bf i};
\draw[very thick](P-|O)++(0,-0.8em)--(O);%--(O-|P);
}
}
% Define a custom environment for information
\newenvironment{info}[1][Info:]{ % Set the default title to "Info:"
\medskip
\begin{mdframed}[style=info]
\noindent{\textbf{#1}}
}{
\end{mdframed}
}
Loading…
Cancel
Save