2019-11-18 18:11:26 +01:00
|
|
|
#pragma once
|
2020-02-18 09:37:36 +01:00
|
|
|
|
2020-02-29 22:10:53 +01:00
|
|
|
#include "behaviour_control/data_source.h"
|
2021-04-19 19:16:31 +02:00
|
|
|
#include "behaviour_control/complementary_filter.h"
|
2020-02-18 09:37:36 +01:00
|
|
|
|
2020-01-20 18:57:14 +01:00
|
|
|
#define startp 105
|
|
|
|
#define endp 115
|
2020-02-21 13:37:32 +01:00
|
|
|
#define unkn 116
|
2020-01-27 17:05:39 +01:00
|
|
|
//Coords are mapped from 0 up to this value
|
|
|
|
#define MAP_MAX 100
|
|
|
|
#define HALF_MAP_MAX 50
|
2020-03-02 20:45:48 +01:00
|
|
|
//Imu To Camera Angle Mult
|
|
|
|
#define IMUTOC_AMULT 1
|
2019-11-18 17:15:32 +01:00
|
|
|
|
2021-04-19 19:16:31 +02:00
|
|
|
#define FILTER_DEFAULT_COEFF 0.6
|
|
|
|
#define FILTER_BY_COEFF FILTER_DEFAULT_COEFF
|
|
|
|
#define FILTER_BX_COEFF FILTER_DEFAULT_COEFF
|
|
|
|
#define FILTER_YY_COEFF FILTER_DEFAULT_COEFF
|
|
|
|
#define FILTER_YX_COEFF FILTER_DEFAULT_COEFF
|
|
|
|
|
2021-05-11 15:20:20 +02:00
|
|
|
/*Camera translation: because of mechanical imprecision, the center of the camera and the center of the cone mirror may not coincide
|
|
|
|
To overcome this, each coordinate needs to be shifted by some amount, defined on a per-robot basis that needs to be recalibrated each time.
|
|
|
|
These values need to be subtracted from the coords used in setMoveSetpoints*/
|
2021-05-14 17:53:47 +02:00
|
|
|
|
|
|
|
// Robot without roller
|
|
|
|
// #define CAMERA_TRANSLATION_X 0
|
|
|
|
// #define CAMERA_TRANSLATION_Y 7
|
|
|
|
|
|
|
|
//Robot with roller
|
2021-06-21 11:17:33 +02:00
|
|
|
#define CAMERA_TRANSLATION_X 4
|
2021-05-14 17:53:47 +02:00
|
|
|
#define CAMERA_TRANSLATION_Y 7
|
2021-05-11 15:20:20 +02:00
|
|
|
|
2020-01-29 18:56:49 +01:00
|
|
|
class DataSourceCameraConic : public DataSource{
|
2019-11-18 17:15:32 +01:00
|
|
|
|
|
|
|
public:
|
2020-01-29 18:56:49 +01:00
|
|
|
DataSourceCameraConic(HardwareSerial* ser, int baud);
|
2019-11-18 17:15:32 +01:00
|
|
|
void test() override;
|
2019-11-18 18:11:26 +01:00
|
|
|
void readSensor() override;
|
2020-03-09 17:10:22 +01:00
|
|
|
void computeCoordsAngles();
|
2020-02-18 09:37:36 +01:00
|
|
|
// int getValueAtk(bool);
|
|
|
|
// int getValueDef(bool);
|
2020-01-20 18:43:51 +01:00
|
|
|
|
2020-01-26 20:13:31 +01:00
|
|
|
int yAngle, bAngle, yAngleFix, bAngleFix, yDist, bDist;
|
|
|
|
|
2020-01-20 18:43:51 +01:00
|
|
|
int count = 0, unkn_counter;
|
2020-03-02 18:48:29 +01:00
|
|
|
int xb, yb, xy, yy, true_xb, true_xy, true_yb, true_yy, calc_xb, calc_yb, calc_xy, calc_yy, true_xb_fixed,
|
|
|
|
true_xy_fixed, true_yb_fixed, true_yy_fixed;
|
2020-01-20 18:43:51 +01:00
|
|
|
bool data_received = false, start = false, end = false;
|
|
|
|
|
2021-05-07 21:39:03 +02:00
|
|
|
int goalOrientation, old_goalOrientation, pAtk, pDef;
|
2020-01-22 16:55:55 +01:00
|
|
|
int value;
|
2021-04-19 19:16:31 +02:00
|
|
|
|
|
|
|
ComplementaryFilter *filter_yy, *filter_xy, *filter_yb, *filter_xb, *filter_yy_fix, *filter_xy_fix, *filter_yb_fix, *filter_xb_fix;
|
2019-11-18 17:15:32 +01:00
|
|
|
};
|