2021-03-22 14:03:53 +01:00
|
|
|
#pragma once
|
2020-02-29 22:10:53 +01:00
|
|
|
|
2021-03-22 14:03:53 +01:00
|
|
|
#include "PID_v2.h"
|
2021-04-14 15:00:43 +02:00
|
|
|
#include "behaviour_control/complementary_filter.h"
|
2021-05-10 20:34:20 +02:00
|
|
|
#include "behaviour_control/status_vector.h"
|
2022-07-07 21:55:41 +02:00
|
|
|
#include "systems/systems.h"
|
2020-02-21 13:37:32 +01:00
|
|
|
|
2022-07-07 21:55:41 +02:00
|
|
|
// Camera center: those setpoints correspond to what we consider the center of the field
|
2021-03-01 19:00:45 +01:00
|
|
|
#define CAMERA_CENTER_X 0
|
2022-07-03 12:52:04 +02:00
|
|
|
#define CAMERA_CENTER_Y 0
|
2022-07-07 21:55:41 +02:00
|
|
|
// left and right limits of a goal
|
2022-07-03 12:52:04 +02:00
|
|
|
#define CAMERA_GOAL_MAX_X 8
|
|
|
|
#define CAMERA_GOAL_MIN_X (-8)
|
|
|
|
|
2022-07-07 21:55:41 +02:00
|
|
|
// dimensions of the field, kinda empirical
|
|
|
|
#define DIM_X 80
|
|
|
|
#define DIM_X_HALF 40
|
|
|
|
#define DIM_Y 140
|
|
|
|
#define DIM_Y_HALF 70
|
2020-10-31 15:37:38 +01:00
|
|
|
|
2022-07-07 21:55:41 +02:00
|
|
|
// where is the center of a goal blob as seen by openmv on the field. For atk goal it's positive, for def goal it's negative
|
2021-03-22 14:03:53 +01:00
|
|
|
#define CAMERA_GOAL_X 0
|
2022-07-03 12:52:04 +02:00
|
|
|
#define CAMERA_GOAL_Y DIM_Y_HALF
|
|
|
|
#define CAMERA_GOAL_ATK_Y CAMERA_GOAL_Y
|
|
|
|
#define CAMERA_GOAL_DEF_Y (-CAMERA_GOAL_Y)
|
|
|
|
|
2022-07-07 21:55:41 +02:00
|
|
|
// hipotenuse of dimensions of field
|
|
|
|
#define MAX_DIST_EXPERIMENTAL 94
|
2021-02-22 18:43:43 +01:00
|
|
|
|
2021-06-23 23:31:20 +02:00
|
|
|
#define DIST_MULT 8
|
2020-02-26 18:51:46 +01:00
|
|
|
|
2021-06-21 11:17:33 +02:00
|
|
|
#define VICINITY_DIST_TRESH 2
|
2021-06-23 17:58:49 +02:00
|
|
|
#define ROUGH_VICINITY_DIST_TRESH 10
|
2021-06-20 23:32:45 +02:00
|
|
|
|
2022-06-09 10:03:48 +02:00
|
|
|
#define Kpx 2.5
|
|
|
|
#define Kix 0.1
|
2020-02-26 18:51:46 +01:00
|
|
|
#define Kdx 0
|
2022-06-09 10:03:48 +02:00
|
|
|
#define Kpy 3.5
|
|
|
|
#define Kiy 0.1
|
2020-02-26 18:51:46 +01:00
|
|
|
#define Kdy 0
|
2020-02-21 13:37:32 +01:00
|
|
|
|
2022-07-07 21:55:41 +02:00
|
|
|
class PositionSysCamera : public PositionSystem
|
|
|
|
{
|
2020-02-26 18:51:46 +01:00
|
|
|
|
2022-07-07 21:55:41 +02:00
|
|
|
public:
|
|
|
|
PositionSysCamera();
|
|
|
|
void goCenter() override;
|
|
|
|
void centerGoal() override;
|
|
|
|
void setMoveSetpoints(int x, int y);
|
|
|
|
void addMoveOnAxis(int x, int y);
|
|
|
|
void update() override;
|
|
|
|
void test() override;
|
|
|
|
void setCameraPID();
|
|
|
|
void CameraPID();
|
|
|
|
bool isInTheVicinityOf(int, int);
|
|
|
|
bool isInRoughVicinityOf(int, int);
|
|
|
|
bool isAtDistanceFrom(int, int, int);
|
2020-02-21 13:37:32 +01:00
|
|
|
|
2022-07-07 21:55:41 +02:00
|
|
|
double Inputx, Outputx, Setpointx, Inputy, Outputy, Setpointy;
|
|
|
|
int MAX_DIST, vx, vy, axisx, axisy, method;
|
|
|
|
bool givenMovement;
|
|
|
|
PID *X;
|
|
|
|
PID *Y;
|
|
|
|
ComplementaryFilter *filterDir;
|
|
|
|
ComplementaryFilter *filterSpeed;
|
2021-05-10 20:34:20 +02:00
|
|
|
|
2022-07-07 21:55:41 +02:00
|
|
|
data valid_data;
|
2020-02-21 13:37:32 +01:00
|
|
|
};
|