sensors: add the robot identifier switch

and add test for switches
pull/1/head
EmaMaker 2021-04-19 16:05:42 +02:00
parent 2b40f56bdd
commit 5e88a21293
4 changed files with 23 additions and 9 deletions

View File

@ -35,4 +35,5 @@ s_extr DataSourceCameraConic* camera;
s_extr DriveController* drive;
s_extr DataSourceBT* bt;
s_extr int role;
s_extr int role;
s_extr int robot_indentifier;

View File

@ -14,8 +14,8 @@ the new setup is the one commented, leds have to be written
in the 32U4 code*/
#define BUZZER 6
#define SWITCH_1 39
#define SWITCH_2 38
#define SWITCH_3 33
#define SWITCH_SX 39
#define SWITCH_DX 38
#define SWITCH_ID 33
extr float sins[360], cosins[360];

View File

@ -2,8 +2,9 @@
#include "sensors/sensors.h"
void initSensors(){
pinMode(SWITCH_1, INPUT);
pinMode(SWITCH_2, INPUT);
pinMode(SWITCH_DX, INPUT);
pinMode(SWITCH_SX, INPUT);
pinMode(SWITCH_ID, INPUT);
drive = new DriveController(new Motor(12, 11, 4, 55), new Motor(25, 24, 5, 135), new Motor(27, 26, 2, 225), new Motor(29, 28, 3, 305));
//drive = new DriveController(new Motor(12, 11, 2, 45),new Motor(25, 24, 5, 135), new Motor(27, 26, 6, 225), new Motor(21, 22, 23, 315));
@ -17,8 +18,9 @@ void initSensors(){
}
void updateSensors(){
role = digitalRead(SWITCH_1);
camera->goalOrientation = digitalRead(SWITCH_2);
role = digitalRead(SWITCH_DX);
camera->goalOrientation = digitalRead(SWITCH_SX);
robot_indentifier = digitalRead(SWITCH_ID);
compass->update();
ball->update();

View File

@ -79,7 +79,17 @@ void TestMenu::testMenu()
case '8':
DEBUG.println("Camera tilt Test");
drive->resetDrive();
drive->prepareDrive(0, 0, (CURRENT_DATA_READ.angleAtkFix + 360) % 360);
drive->prepareDrive(0, 0, CURRENT_DATA_READ.angleAtkFix);
break;
case '9':
DEBUG.println("Switches as seen from behind:");
DEBUG.print("Right switch (role): ");
DEBUG.println(role);
DEBUG.print("Left switch (goalOrientation): ");
DEBUG.println(camera->goalOrientation);
DEBUG.print("Robot Identifier: ");
DEBUG.println(robot_indentifier);
delay(50);
break;
case 'u':
DEBUG.println("32u4 receive Test");
@ -118,6 +128,7 @@ void TestMenu::testMenu()
DEBUG.println("6)Camera test");
DEBUG.println("7)Line Sensors camera test");
DEBUG.println("8)Camera tilt test");
DEBUG.println("9)Switches test");
DEBUG.println("u)Read Serial messages from 32u4");
DEBUG.println("s)Send test to 32u4 status LEDs");
flagtest = false;