/**
 * Start a competition.
 * This code needs to track the order of the field starting to ensure that everything happens
 * in the right order. Repeatedly run the correct method, either Autonomous or OperatorControl
 * when the robot is enabled. After running the correct method, wait for some state to change,
 * either the other mode starts or the robot is disabled. Then go back and wait for the robot
 * to be enabled again.
 */
void SimpleRobot::StartCompetition()
{
	RobotMain();
	if ( !m_robotMainOverridden)
	{
		while (Simulator::ShouldContinue())
		{
			Simulator::NextStep(0.0);

			if (IsDisabled())
				continue;

			if (IsAutonomous())
			{
				Autonomous();					// run the autonomous method
				while (IsAutonomous() && !IsDisabled() && Simulator::ShouldContinue()) Wait(.01);
			}
			else
			{
				OperatorControl();				// run the operator control method
				while (IsOperatorControl() && !IsDisabled() && Simulator::ShouldContinue()) Wait(.01);
			}
		}
	}
}
/**
 * Start a competition.
 * This code needs to track the order of the field starting to ensure that everything happens
 * in the right order. Repeatedly run the correct method, either Autonomous or OperatorControl
 * when the robot is enabled. After running the correct method, wait for some state to change,
 * either the other mode starts or the robot is disabled. Then go back and wait for the robot
 * to be enabled again.
 */
void SimpleRobot::StartCompetition()
{
	RobotMain();
	if (!m_robotMainOverridden)
	{
		while (1)
		{
			if (IsDisabled())
			{
				Disabled();
				while (IsDisabled()) Wait(.01);
			}
			else if (IsAutonomous())
			{
				Autonomous();
				while (IsAutonomous() && IsEnabled()) Wait(.01);
			}
			else
			{
				OperatorControl();
				while (IsOperatorControl() && IsEnabled()) Wait(.01);
			}
		}
	}
}
Example #3
0
/**
 * Start a competition.
 * This code needs to track the order of the field starting to ensure that
 * everything happens in the right order. Repeatedly run the correct
 * method, either Autonomous or OperatorControl when the robot is
 * enabled. After running the correct method, wait for some state to
 * change, either the other mode starts or the robot is disabled. Then go
 * back and wait for the robot to be enabled again.
 */
void SimpleRobot::StartCompetition()
{
    RobotMain();
    if (!m_robotMainOverridden)
    {
        while (1)
        {
            while (IsDisabled())
                Wait(.01);      // wait for robot to be enabled

            if (IsAutonomous())
            {
                Autonomous();   // run the autonomous method
                while (IsAutonomous() && !IsDisabled())
                    Wait(.01);
            }
            else
            {
                OperatorControl();      // run the operator control method
                while (IsOperatorControl() && !IsDisabled())
                    Wait(.01);
            }
        }
    }
}
Example #4
0
/**
 * Start a competition.
 * This code needs to track the order of the field starting to ensure that everything happens
 * in the right order. Repeatedly run the correct method, either Autonomous or OperatorControl
 * when the robot is enabled. After running the correct method, wait for some state to change,
 * either the other mode starts or the robot is disabled. Then go back and wait for the robot
 * to be enabled again.
 */
void SimpleRobot::StartCompetition()
{
    RobotMain();
    
    if (!m_robotMainOverridden)
    {
        // first and one-time initialization
        RobotInit();

        while (true)
        {
            if (IsDisabled())
            {
                m_ds->InDisabled(true);
                Disabled();
                m_ds->InDisabled(false);
                while (IsDisabled()) m_ds->WaitForData();
            }
            else if (IsAutonomous())
            {
                m_ds->InAutonomous(true);
                Autonomous();
                m_ds->InAutonomous(false);
                while (IsAutonomous() && IsEnabled()) m_ds->WaitForData();
            }
            else
            {
                m_ds->InOperatorControl(true);
                OperatorControl();
                m_ds->InOperatorControl(false);
                while (IsOperatorControl() && IsEnabled()) m_ds->WaitForData();
            }
        }
    }
}
/**
 * Start a competition.
 * This code needs to track the order of the field starting to ensure that everything happens
 * in the right order. Repeatedly run the correct method, either Autonomous or OperatorControl
 * or Test when the robot is enabled. After running the correct method, wait for some state to
 * change, either the other mode starts or the robot is disabled. Then go back and wait for the
 * robot to be enabled again.
 */
void SampleRobot::StartCompetition()
{
	LiveWindow *lw = LiveWindow::GetInstance();

	SmartDashboard::init();
	NetworkTable::GetTable("LiveWindow")->GetSubTable("~STATUS~")->PutBoolean("LW Enabled", false);

	RobotMain();

	if (!m_robotMainOverridden)
	{
		// first and one-time initialization
		lw->SetEnabled(false);
		RobotInit();

		while (true)
		{
			if (IsDisabled())
			{
				m_ds.InDisabled(true);
				Disabled();
				m_ds.InDisabled(false);
				while (IsDisabled()) sleep(1); //m_ds.WaitForData();
			}
			else if (IsAutonomous())
			{
				m_ds.InAutonomous(true);
				Autonomous();
				m_ds.InAutonomous(false);
				while (IsAutonomous() && IsEnabled()) sleep(1); //m_ds.WaitForData();
			}
            else if (IsTest())
            {
              lw->SetEnabled(true);
              m_ds.InTest(true);
              Test();
              m_ds.InTest(false);
              while (IsTest() && IsEnabled()) sleep(1); //m_ds.WaitForData();
              lw->SetEnabled(false);
            }
			else
			{
				m_ds.InOperatorControl(true);
				OperatorControl();
				m_ds.InOperatorControl(false);
				while (IsOperatorControl() && IsEnabled()) sleep(1); //m_ds.WaitForData();
			}
		}
	}
}
Example #6
0
/**
 * Start a competition.
 * This code needs to track the order of the field starting to ensure that everything happens
 * in the right order. Repeatedly run the correct method, either Autonomous or OperatorControl
 * when the robot is enabled. After running the correct method, wait for some state to change,
 * either the other mode starts or the robot is disabled. Then go back and wait for the robot
 * to be enabled again.
 */
void SimpleRobot::StartCompetition()
{
	nUsageReporting::report(nUsageReporting::kResourceType_Framework, nUsageReporting::kFramework_Simple);

	RobotMain();
	
	if (!m_robotMainOverridden)
	{
		// first and one-time initialization
		RobotInit();

		while (true)
		{
			if (IsDisabled())
			{
				m_ds->InDisabled(true);
				Disabled();
				m_ds->InDisabled(false);
				while (IsDisabled()) m_ds->WaitForData();
			}
			else if (IsAutonomous())
			{
				m_ds->InAutonomous(true);
				Autonomous();
				m_ds->InAutonomous(false);
				while (IsAutonomous() && IsEnabled()) m_ds->WaitForData();
			}
			else
			{
				m_ds->InOperatorControl(true);
				OperatorControl();
				m_ds->InOperatorControl(false);
				while (IsOperatorControl() && IsEnabled()) m_ds->WaitForData();
			}
		}
	}
}