Lines not working well, fixed missing initializations that caused the code to crash

code_midgen
EmaMaker 2019-12-05 11:53:01 +01:00
parent 9c3ea8d602
commit 39cbeb1e59
122 changed files with 405 additions and 152 deletions

25
.vscode/settings.json vendored
View File

@ -20,6 +20,29 @@
"vector": "cpp", "vector": "cpp",
"string_view": "cpp", "string_view": "cpp",
"initializer_list": "cpp", "initializer_list": "cpp",
"*.tcc": "cpp" "*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"fstream": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp"
} }
} }

View File

@ -1,39 +0,0 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

View File

@ -1,22 +0,0 @@
#include "data_source.h"
#include "vars.h"
#include <Arduino.h>
#include <vector>
using namespace std;
class DataSourceController {
public:
DataSourceController();
DataSourceController(vector<DataSource*>);
public:
void update();
void test();
void postProcess();
void readSensor();
void getValue();
vector<DataSource*> ds;
};

View File

@ -4,10 +4,10 @@
#include "motor.h" #include "motor.h"
//PID Constants //PID Constants
#define KP 0.9
#define KI 0 #define KP 1.2
#define KD 1.1 #define KI 0
#define DEADZONE_MIN 25 #define KD 0.7
class DriveController{ class DriveController{
@ -21,6 +21,10 @@ class DriveController{
float updatePid(); float updatePid();
float torad(float f); float torad(float f);
int vxp, vyp, vxn, vyn;
bool canUnlock;
elapsedMillis unlockTime;
private: private:
Motor* m1; Motor* m1;
Motor* m2; Motor* m2;

23
include/ds_ctrl.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include "data_source.h"
#include "vars.h"
#include <Arduino.h>
#include <vector>
using namespace std;
class DataSourceCtrl {
public:
DataSourceCtrl();
DataSourceCtrl(vector<DataSource*>);
public:
virtual void update();
virtual void test();
virtual void postProcess();
virtual void read();
vector<DataSource*> ds;
};

40
include/ds_ctrl_lines.h Normal file
View File

@ -0,0 +1,40 @@
#pragma once
#include "ds_ctrl.h"
#include "data_source.h"
#include "vars.h"
#include <Arduino.h>
#define S1I A14
#define S1O A15
#define S2I A16
#define S2O A17
#define S3I A20
#define S3O A0
#define S4I A1
#define S4O A2
#define LINE_THRESH 90
#define EXTIME 100
class DataSourceCtrlLines : public DataSourceCtrl {
public:
DataSourceCtrlLines();
DataSourceCtrlLines(vector<DataSource*> in_, vector<DataSource*> out);
void read() override;
void postProcess() override;
void outOfBounds();
void handleIntern();
void handleExtern();
int getValue();
void test() override;
private:
vector<DataSource*> in, out;
DataSource* ds;
bool fboundsX, fboundsY, fboundsOX, fboundsOY, slow;
int inV, outV, inVOldX, inVOldY, value, linetriggerI[4], linetriggerO[4], i;
elapsedMillis exitTimer;
int outDir, outVel;
};

View File

@ -3,8 +3,9 @@
#include "data_source_ball.h" #include "data_source_ball.h"
#include "data_source_camera.h" #include "data_source_camera.h"
#include "data_source_us.h" #include "data_source_us.h"
#include "ds_ctrl_lines.h"
#include "motor.h" #include "motor.h"
#include "data_source_controller.h" #include "ds_ctrl.h"
#include "drivecontroller.h" #include "drivecontroller.h"
#ifdef SENSORS_CPP #ifdef SENSORS_CPP
@ -19,6 +20,10 @@ void updateSensors();
extr DataSource* compass; extr DataSource* compass;
extr DataSource* ball; extr DataSource* ball;
extr DataSource* camera; extr DataSource* camera;
//extr DataSource* us; extr DataSourceCtrl* usCtrl;
extr DataSourceController* usCtrl; extr DataSourceCtrlLines* linesCtrl;
extr DriveController* drive; extr DriveController* drive;
extr vector<DataSource*> lIn;
extr vector<DataSource*> lOut;
extr vector<DataSource*> dUs;

View File

@ -1,8 +1,10 @@
#pragma once #pragma once
#define DEBUG_PRINT Serial #define DEBUG Serial
#define LED_R 20 #define LED_R 20
#define LED_Y 17 #define LED_Y 17
#define LED_G 13 #define LED_G 13
#define BUZZER 30 #define BUZZER 30
#define SWITCH_SX 28 #define SWITCH_SX 28
#define SWITCH_DX 29 #define SWITCH_DX 29

0
lib/Adafruit-GFX/.gitignore vendored Executable file → Normal file
View File

0
lib/Adafruit-GFX/.travis.yml Executable file → Normal file
View File

0
lib/Adafruit-GFX/Adafruit_GFX.cpp Executable file → Normal file
View File

0
lib/Adafruit-GFX/Adafruit_GFX.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Adafruit_SPITFT.cpp Executable file → Normal file
View File

0
lib/Adafruit-GFX/Adafruit_SPITFT.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Adafruit_SPITFT_Macros.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMono12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMono18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMono24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMono9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoBold12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoBold18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoBold24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoBold9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoBoldOblique9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoOblique12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoOblique18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoOblique24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeMonoOblique9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSans12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSans18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSans24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSans9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansBold12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansBold18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansBold24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansBold9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansBoldOblique12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansBoldOblique18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansBoldOblique24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansBoldOblique9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansOblique12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansOblique18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansOblique24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSansOblique9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerif12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerif18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerif24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerif9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifBold12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifBold18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifBold24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifBold9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifBoldItalic9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifItalic12pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifItalic18pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifItalic24pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/FreeSerifItalic9pt7b.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/Org_01.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/Picopixel.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/Tiny3x3a2pt7b Executable file → Normal file
View File

0
lib/Adafruit-GFX/Fonts/TomThumb.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/README.md Executable file → Normal file
View File

View File

0
lib/Adafruit-GFX/fontconvert/Makefile Executable file → Normal file
View File

0
lib/Adafruit-GFX/fontconvert/fontconvert.c Executable file → Normal file
View File

0
lib/Adafruit-GFX/fontconvert/fontconvert_win.md Executable file → Normal file
View File

0
lib/Adafruit-GFX/fontconvert/makefonts.sh Executable file → Normal file
View File

0
lib/Adafruit-GFX/gfxfont.h Executable file → Normal file
View File

0
lib/Adafruit-GFX/glcdfont.c Executable file → Normal file
View File

0
lib/Adafruit-GFX/library.properties Executable file → Normal file
View File

0
lib/Adafruit-GFX/license.txt Executable file → Normal file
View File

0
lib/Adafruit_BNO055/Adafruit_BNO055.cpp Executable file → Normal file
View File

0
lib/Adafruit_BNO055/Adafruit_BNO055.h Executable file → Normal file
View File

0
lib/Adafruit_BNO055/OBJLoader/OBJLoader.txt Executable file → Normal file
View File

0
lib/Adafruit_BNO055/OBJLoader/OBJLoader.zip Executable file → Normal file
View File

0
lib/Adafruit_BNO055/README.md Executable file → Normal file
View File

0
lib/Adafruit_BNO055/examples/bunny/bunny.ino Executable file → Normal file
View File

0
lib/Adafruit_BNO055/examples/rawdata/rawdata.ino Executable file → Normal file
View File

View File

0
lib/Adafruit_BNO055/examples/sensorapi/sensorapi.ino Executable file → Normal file
View File

0
lib/Adafruit_BNO055/library.properties Executable file → Normal file
View File

0
lib/Adafruit_BNO055/utility/imumaths.h Executable file → Normal file
View File

0
lib/Adafruit_BNO055/utility/matrix.h Executable file → Normal file
View File

0
lib/Adafruit_BNO055/utility/quaternion.h Executable file → Normal file
View File

0
lib/Adafruit_BNO055/utility/vector.h Executable file → Normal file
View File

0
lib/Adafruit_Sensor-master/.gitignore vendored Executable file → Normal file
View File

0
lib/Adafruit_Sensor-master/Adafruit_Sensor.h Executable file → Normal file
View File

0
lib/Adafruit_Sensor-master/README.md Executable file → Normal file
View File

0
lib/Adafruit_Sensor-master/library.properties Executable file → Normal file
View File

0
lib/Adafruit_VL53L0X/README.md Executable file → Normal file
View File

Some files were not shown because too many files have changed in this diff Show More