SPQR-Team-2019-REVAMPED/include/systems/position/positionsys_camera.h

70 lines
1.8 KiB
C
Raw Normal View History

#pragma once
#include "PID_v2.h"
#include "systems/systems.h"
#include "behaviour_control/complementary_filter.h"
#include "behaviour_control/status_vector.h"
//Camera center: those setpoints correspond to what we consider the center of the field
#define CAMERA_CENTER_X 0
#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
2022-07-05 12:02:18 +02:00
#define DIM_X 220
#define DIM_X_HALF 110
#define DIM_Y 240
#define DIM_Y_HALF 120
//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
#define CAMERA_GOAL_X 0
#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
#define DIST_MULT 8
2020-02-26 18:51:46 +01:00
#define VICINITY_DIST_TRESH 2
2021-06-23 17:58:49 +02:00
#define ROUGH_VICINITY_DIST_TRESH 10
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
class PositionSysCamera : public PositionSystem{
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;
2020-02-26 18:51:46 +01:00
void setCameraPID();
void CameraPID();
bool isInTheVicinityOf(int, int);
2021-06-23 17:58:49 +02:00
bool isInRoughVicinityOf(int, int);
bool isAtDistanceFrom(int, int, int);
2020-02-26 18:51:46 +01:00
double Inputx, Outputx, Setpointx, Inputy, Outputy, Setpointy;
int MAX_DIST, vx, vy, axisx, axisy, method;
bool givenMovement;
2020-02-26 18:51:46 +01:00
PID* X;
PID* Y;
ComplementaryFilter* filterDir;
ComplementaryFilter* filterSpeed;
data valid_data;
};