a bit of recalibration for everything for the presentation game

pull/1/head
ema.coletta@gmail.com 2020-10-31 15:37:38 +01:00
parent f0a8ad6808
commit c0b8771c47
7 changed files with 176 additions and 13 deletions

View File

@ -2,10 +2,16 @@
#include "position/systems.h"
#define CAMERA_CENTER_X 0
#define CAMERA_CENTER_Y 0
//Note: those variables can be changes, and will need to change depending on camera calibration
//Camera center: those setpoints correspond to the center of the field
#define CAMERA_CENTER_X 1
#define CAMERA_CENTER_Y -10
//Camera goal: those setpoints correspond to the position of the center of the goal on the field
#define CAMERA_GOAL_X 0
#define CAMERA_GOAL_Y -13
#define CAMERA_GOAL_Y -20
#define CAMERA_CENTER_Y_ABS_SUM 72
//Actually it's ± MAX_VAL
#define MAX_X 25

View File

@ -17,7 +17,7 @@
#define S4O A2
#define LINE_THRESH_CAM 90
#define EXIT_TIME 100
#define EXIT_TIME 125
#define LINES_EXIT_SPD 350
class LineSysCamera : public LineSystem{

View File

@ -0,0 +1,40 @@
// #pragma once
// #include <Arduino.h>
// #include "behaviour_control/ds_ctrl.h"
// #include "position/systems.h"
// #include "vars.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_CAM 90
// #define EXTIME_CAM 75
// #define LINES_EXIT_SPD_CAM 300
// class LineSysCamera : public LineSystem{
// public:
// LineSysCamera();
// LineSysCamera(vector<DataSource*> in_, vector<DataSource*> out);
// void update() override;
// void test() override;
// void outOfBounds();
// private:
// vector<DataSource*> in, out;
// DataSource* ds;
// bool fboundsX, fboundsY, fboundsOX, fboundsOY, slow;
// int inV, outV, linesensOldX, linesensOldY, value, linetriggerI[4], linetriggerO[4], i;
// unsigned long exitTimer;
// byte linesens;
// };

View File

@ -5,7 +5,7 @@
#include "strategy_roles/game.h"
#define TILT_MULT 1.8
#define TILT_DIST 180
#define TILT_DIST 170
#define CATCH_DIST 150
#define GOALIE_ATKSPD_LAT 320 //255
#define GOALIE_ATKSPD_BAK 350

View File

@ -0,0 +1,116 @@
// #include "sensors/linesys_camera.h"
// #include "position/positionsys_camera.h"
// #include "sensors/sensors.h"
// #include "strategy_roles/games.h"
// using namespace std;
// LineSysCamera::LineSysCamera() {}
// LineSysCamera::LineSysCamera(vector<DataSource*> in_, vector<DataSource*> out_){
// this->in = in_;
// this->out = out_;
// fboundsX = false;
// fboundsY = false;
// slow = false;
// linesensOldX = 0;
// linesensOldY = 0;
// tookLine = false;
// for(int i = 0; i < 4; i++){
// linetriggerI[i] = 0;
// linetriggerO[i] = 0;
// }
// exitTimer = 0;
// linesens = 0;
// }
// void LineSysCamera::update(){
// inV = 0;
// outV = 0;
// tookLine = false;
// for(DataSource* d : in) d->readSensor();
// for(DataSource* d : out) d->readSensor();
// for(auto it = in.begin(); it != in.end(); it++){
// i = it - in.begin();
// ds = *it;
// linetriggerI[i] = ds->getValue() > LINE_THRESH_CAM;
// }
// for(auto it = out.begin(); it != out.end(); it++){
// i = it - out.begin();
// ds = *it;
// linetriggerO[i] = ds->getValue() > LINE_THRESH_CAM;
// }
// for(int i = 0; i < 4; i++){
// inV = inV | (linetriggerI[i] << i);
// outV = outV | (linetriggerO[i] << i);
// }
// if ((inV > 0) || (outV > 0)) {
// if(millis() - exitTimer > EXTIME_CAM) {
// fboundsX = true;
// fboundsY = true;
// }
// exitTimer = millis();
// }
// linesens |= inV | outV;
// outOfBounds();
// }
// void LineSysCamera::outOfBounds(){
// if(fboundsX == true) {
// if(linesens & 0x02) linesensOldX = 2;
// else if(linesens & 0x08) linesensOldX = 8;
// if(linesensOldX != 0) fboundsX = false;
// }
// if(fboundsY == true) {
// if(linesens & 0x01) linesensOldY = 1;
// else if(linesens & 0x04) linesensOldY = 4;
// if(linesensOldY != 0) fboundsY = false;
// }
// if (millis() - exitTimer <= EXTIME_CAM){
// if(linesens > 0) ((PositionSysCamera*)goalie->ps)->goCenter();
// tookLine = true;
// }else{
// linesens = 0;
// linesensOldY = 0;
// linesensOldX = 0;
// }
// }
// void LineSysCamera::test(){
// update();
// DEBUG.print("In: ");
// for(DataSource* d : in){
// d->update();
// DEBUG.print(d->getValue());
// DEBUG.print(" | ");
// }
// DEBUG.print(" |---| ");
// DEBUG.print("Out: ");
// for(DataSource* d : out){
// d->update();
// DEBUG.print(d->getValue());
// DEBUG.print(" | ");
// }
// DEBUG.println();
// for(int i = 0; i < 4; i++){
// DEBUG.print(linetriggerI[i]);
// DEBUG.print(" | ");
// DEBUG.println(linetriggerO[i]);
// }
// DEBUG.println(inV);
// DEBUG.println(outV);
// DEBUG.println();
// }

View File

@ -5,6 +5,7 @@
#include "sensors/sensors.h"
#include "strategy_roles/keeper.h"
#include "strategy_roles/games.h"
#include "position/positionsys_camera.h"
Keeper::Keeper() : Game() {
@ -28,7 +29,7 @@ void Keeper::init(){
void Keeper::realPlay() {
if(ball->ballSeen) keeper();
else drive->prepareDrive(0,0,0);
else ((PositionSysCamera*)ps)->centerGoal();
}
void Keeper::keeper() {

View File

@ -38,8 +38,8 @@ blue_led.on()
##############################################################################
thresholds = [ (50, 98, -2, 30, 57, 113), # thresholds yellow goal
(22, 45, -32, -6, -16, 10)] # thresholds blue goal (6, 31, -15, 4, -35, 0)
thresholds = [ (58, 97, 9, 45, 51, 92), # thresholds yellow goal
(12, 30, -25, 1, -49, -2)] # thresholds blue goal (6, 31, -15, 4, -35, 0)
roi = (0, 6, 318, 152)
@ -59,13 +59,13 @@ clock = time.clock()'''
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.set_contrast(1)
sensor.set_saturation(1)
sensor.set_contrast(3)
sensor.set_saturation(3)
sensor.set_brightness(0)
sensor.set_quality(0)
sensor.set_auto_whitebal(False)
sensor.set_auto_exposure(False, 6500)
sensor.set_auto_gain(True)
sensor.set_auto_exposure(False, 4500)
sensor.set_auto_gain(False, 15)
sensor.skip_frames(time = 300)
clock = time.clock()
@ -84,7 +84,7 @@ while(True):
tt_blue = [(0,999,0,2)] ## creo una lista di tuple per il blue, valore x = 999 : non trovata
img = sensor.snapshot()
for blob in img.find_blobs(thresholds, pixels_threshold=40, area_threshold=50, merge = True):
for blob in img.find_blobs(thresholds, pixels_threshold=30, area_threshold=40, merge = True):
img.draw_rectangle(blob.rect())
img.draw_cross(blob.cx(), blob.cy())