AutonomousTask::AutonomousTask() { // Create handles for proxy and robot Robot *lHandle; Proxy *proxy; // Register robot handle while( !(lHandle = Robot::getInstance()) && !( lHandle->IsAutonomous() ) ) { Wait(AUTONOMOUS_WAIT_TIME); } // Register proxy handle while( (proxy = Proxy::getInstance()) == NULL ) { Wait(AUTONOMOUS_WAIT_TIME); } while( lHandle->IsAutonomous() ) { // <<CHANGEME>> // Insert your autonomous logic here // This wait is required, it makes sure no task uses too much memory Wait(AUTONOMOUS_WAIT_TIME); } }
/** * @brief Main thread function for Proxy166. * Runs forever, until MyTaskInitialized is false. * * @todo Update DS switch array */ int Proxy::Main( int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10) { Robot *lHandle = NULL; WaitForGoAhead(); lHandle = Robot::getInstance(); Timer matchTimer; while(MyTaskInitialized) { setNewpress(); if(lHandle->IsOperatorControl() && lHandle->IsEnabled()) { if(manualDSIO) { SetEnhancedIO(); } if(manualJoystick[0]) { SetJoystick(1, stick1); } if(manualJoystick[1]) { SetJoystick(2, stick2); } if(manualJoystick[2]) { SetJoystick(3, stick3); } if(manualJoystick[3]) { SetJoystick(4, stick4); } } if(!lHandle->IsEnabled()) { matchTimer.Reset(); // It became disabled matchTimer.Stop(); set("matchtimer",0); } else { // It became enabled matchTimer.Start(); if(lHandle->IsAutonomous()) { set("matchtimer",max( 15 - matchTimer.Get(),0)); } else { set("matchtimer",max(120 - matchTimer.Get(),0)); } } // The task ends if it's not initialized WaitForNextLoop(); } return 0; }