#include "stdafx.h" int main() { //Init our robot Robot* localRobot = new Robot(); //Init Engines for(uint8 i = IO_ENGINE_START; i < IO_ENGINE_END; i++) { Engine* newEngine = new Engine(i); localRobot->AddModule(newEngine); newEngine = NULL; } //Init Dribbler for(uint8 i = IO_DRIBBLER_START; i < IO_DRIBBLER_END; i++) { Dribbler* newDribbler = new Dribbler(i); localRobot->AddModule(newDribbler); newDribbler = NULL; } //Init Kicker for(uint8 i = IO_KICKER_START; i < IO_KICKER_END; i++) { Kicker* newKicker = new Kicker(i); localRobot->AddModule(newKicker); newKicker = NULL; } //Init Sensors for(uint8 i = IO_SENSOR_START; i < IO_SENSOR_END; i++) { switch(i) { //Create correct type of sensor case IO_SENSOR_IR_0_DEG: case IO_SENSOR_IR_30_DEG: case IO_SENSOR_IR_60_DEG: case IO_SENSOR_IR_100_DEG: case IO_SENSOR_IR_180_DEG: case IO_SENSOR_IR_260_DEG: case IO_SENSOR_IR_300_DEG: case IO_SENSOR_IR_330_DEG: { IR_Sensor* newSensor = new IR_Sensor(i); localRobot->AddModule(newSensor); newSensor = NULL; break; } case IO_SENSOR_DISTANCE_0_DEG: case IO_SENSOR_DISTANCE_90_DEG: case IO_SENSOR_DISTANCE_180_DEG: case IO_SENSOR_DISTANCE_270_DEG: { Distance_Sensor* newSensor = new Distance_Sensor(i); localRobot->AddModule(newSensor); newSensor = NULL; break; } case IO_SENSOR_MOUSE_LEFT: case IO_SENSOR_MOUSE_RIGHT: { Mouse_Sensor* newSensor = new Mouse_Sensor(i); localRobot->AddModule(newSensor); newSensor = NULL; break; } //Other cases default: { Sensor* newSensor = new Sensor(i); localRobot->AddModule(newSensor); newSensor = NULL; break; } } } //Init Leds for(uint8 i = IO_LED_START; i < IO_LED_END; i++) { Led* newLed = new Led(i); localRobot->AddModule(newLed); newLed = NULL; } //Init Displays for(uint8 i = IO_DISPLAY_START; i < IO_DISPLAY_END; i++) { Display* newDisplay = new Display(i); localRobot->AddModule(newDisplay); newDisplay = NULL; } //Init Keyboards for(uint8 i = IO_KEYBOARD_START; i < IO_KEYBOARD_END; i++) { Keyboard* newKeyboard = new Keyboard(i); localRobot->AddModule(newKeyboard); newKeyboard = NULL; } //Init Position Tracker for(uint8 i = IO_POSITION_TRACKER_START; i < IO_POSITION_TRACKER_END; i++) { Position_Tracker* newPositionTracker = new Position_Tracker(i); localRobot->AddModule(newPositionTracker); newPositionTracker = NULL; } //Init Ball Tracker for(uint8 i = IO_BALL_TRACKER_START; i < IO_BALL_TRACKER_END; i++) { Ball_Tracker* newBallTracker = new Ball_Tracker(i); localRobot->AddModule(newBallTracker); newBallTracker = NULL; } //Init Navigators for(uint8 i = IO_NAVIGATOR_START; i < IO_NAVIGATOR_END; i++) { Navigator* newNavigator = new Navigator(i); localRobot->AddModule(newNavigator); newNavigator = NULL; } IR_Sensor* ourSensor = NULL; uint16 value = 0; int8 value2 = 0; Display* ourDisplay = localRobot->GetModule(IO_DISPLAY_MAIN); Keyboard* ourKeyboard = localRobot->GetModule(IO_KEYBOARD_MAIN); uint32 i = 1; Navigator* ourNavigator = localRobot->GetModule(IO_NAVIGATOR_MAIN); float rotation = 0; ourDisplay->Print("Starting...", 1, 1); //Run while(true) { uint8 someInput = ourKeyboard->GetInput(); switch(someInput) { case 1: ourNavigator->Drive(225.0f * PI / 180.0f, rotation, 200, rotation); break; case 2: ourNavigator->Drive(180.0f * PI / 180.0f, rotation, 200, rotation); break; case 3: ourNavigator->Drive(135.0f * PI / 180.0f, rotation, 200, rotation); break; case 4: ourNavigator->Drive(270.0f * PI / 180.0f, rotation, 200, rotation); break; case 5: ourNavigator->Stop(); break; case 6: ourNavigator->Drive(90.0f * PI / 180.0f, rotation, 200, rotation); break; case 7: ourNavigator->Drive(315.0f * PI / 180.0f, rotation, 200, rotation); break; case 8: ourNavigator->Drive(0.0f * PI / 180.0f, rotation, 200, rotation); break; case 9: ourNavigator->Drive(45.0f * PI / 180.0f, rotation, 200, rotation); break; case 10: rotation -= 10; break; case 12: rotation += 10; break; } msleep(50);/* ourDisplay->Clear(); ourDisplay->Print(i++); ourSensor = localRobot->GetModule(IO_SENSOR_IR_0_DEG); value = ourSensor->GetIRIntensity(); ourDisplay->Print(value, 1, 2); ourDisplay->Print(";"); ourSensor = localRobot->GetModule(IO_SENSOR_IR_30_DEG); value = ourSensor->GetIRIntensity(); ourDisplay->Print(value); ourDisplay->Print(";"); ourSensor = localRobot->GetModule(IO_SENSOR_IR_60_DEG); value = ourSensor->GetIRIntensity(); ourDisplay->Print(value); ourDisplay->Print(";"); ourSensor = localRobot->GetModule(IO_SENSOR_IR_100_DEG); value = ourSensor->GetIRIntensity(); ourDisplay->Print(value); ourDisplay->Print(";"); ourSensor = localRobot->GetModule(IO_SENSOR_IR_180_DEG); value = ourSensor->GetIRIntensity(); ourDisplay->Print(value, 1, 3); ourDisplay->Print(";"); ourSensor = localRobot->GetModule(IO_SENSOR_IR_260_DEG); value = ourSensor->GetIRIntensity(); ourDisplay->Print(value); ourDisplay->Print(";"); ourSensor = localRobot->GetModule(IO_SENSOR_IR_300_DEG); value = ourSensor->GetIRIntensity(); ourDisplay->Print(value); ourDisplay->Print(";"); ourSensor = localRobot->GetModule(IO_SENSOR_IR_330_DEG); value = ourSensor->GetIRIntensity(); ourDisplay->Print(value); ourDisplay->Print(";");*/ localRobot->Update(); //ourDisplay->PrintFloat(ourBallTracker->GetBallDirection(), 1, 4); } //Cleanup delete localRobot; localRobot = NULL; }