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"
|
2020-11-04 17:46:14 +01:00
|
|
|
#include "systems/systems.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"
|
2020-02-21 13:37:32 +01:00
|
|
|
|
2021-03-01 19:00:45 +01:00
|
|
|
//Camera center: those setpoints correspond to what we consider the center of the field
|
|
|
|
#define CAMERA_CENTER_X 0
|
2022-07-03 12:52:04 +02:00
|
|
|
#define CAMERA_CENTER_Y 0
|
|
|
|
//left and right limits of a goal
|
|
|
|
#define CAMERA_GOAL_MAX_X 8
|
|
|
|
#define CAMERA_GOAL_MIN_X (-8)
|
|
|
|
|
|
|
|
//dimensions of the field, for how we scale it
|
|
|
|
#define DIM_X 50
|
|
|
|
#define DIM_X_HALF 25
|
|
|
|
#define DIM_Y 80
|
|
|
|
#define DIM_Y_HALF 40
|
2020-10-31 15:37:38 +01:00
|
|
|
|
2022-07-03 12:52:04 +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)
|
|
|
|
|
|
|
|
//hipotenuse of dimensions of field
|
|
|
|
#define MAX_DIST_EXPERIMENTAL 94
|
2020-10-31 15:37:38 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
class PositionSysCamera : public PositionSystem{
|
|
|
|
|
|
|
|
public:
|
|
|
|
PositionSysCamera();
|
2020-12-23 21:16:50 +01:00
|
|
|
void goCenter() override;
|
|
|
|
void centerGoal() override;
|
2020-03-12 12:09:13 +01:00
|
|
|
void setMoveSetpoints(int x, int y);
|
|
|
|
void addMoveOnAxis(int x, int y);
|
2020-02-21 13:37:32 +01:00
|
|
|
void update() override;
|
|
|
|
void test() override;
|
2020-02-26 18:51:46 +01:00
|
|
|
void setCameraPID();
|
|
|
|
void CameraPID();
|
2021-06-20 23:32:45 +02:00
|
|
|
bool isInTheVicinityOf(int, int);
|
2021-06-23 17:58:49 +02:00
|
|
|
bool isInRoughVicinityOf(int, int);
|
2021-06-26 12:50:27 +02:00
|
|
|
bool isAtDistanceFrom(int, int, int);
|
2020-02-26 18:51:46 +01:00
|
|
|
|
|
|
|
double Inputx, Outputx, Setpointx, Inputy, Outputy, Setpointy;
|
2022-07-03 12:52:04 +02:00
|
|
|
int MAX_DIST, vx, vy, axisx, axisy, method;
|
2020-03-12 12:09:13 +01:00
|
|
|
bool givenMovement;
|
2020-02-26 18:51:46 +01:00
|
|
|
PID* X;
|
|
|
|
PID* Y;
|
2021-04-14 15:00:43 +02:00
|
|
|
ComplementaryFilter* filterDir;
|
|
|
|
ComplementaryFilter* filterSpeed;
|
2020-02-21 13:37:32 +01:00
|
|
|
|
2021-05-10 20:34:20 +02:00
|
|
|
data valid_data;
|
|
|
|
|
2020-02-21 13:37:32 +01:00
|
|
|
};
|