⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simplecrobot.cpp

📁 good luck to everyone!
💻 CPP
字号:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.							  */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
/*----------------------------------------------------------------------------*/

#include "SimpleCRobot.h"

#include "Timer.h"
#include "Utility.h"

static SimpleCRobot *simpleCRobot = NULL;

/**
 * The simple robot constructor.
 * The constructor, besides doing the normal constructor stuff, also calls the
 * Initialize() C function where sensors can be set up immediately after the power
 * is turned on.
 */
SimpleCRobot::SimpleCRobot()
{
	simpleCRobot = this;
	Initialize();
}

/**
 * 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 SimpleCRobot::StartCompetition()
{
	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);
		}
	}
}

bool IsAutonomous()
{
	wpi_assert(simpleCRobot != NULL);
	return simpleCRobot->IsAutonomous();
}

bool IsOperatorControl()
{
	wpi_assert(simpleCRobot != NULL);
	return simpleCRobot->IsOperatorControl();
}

bool IsDisabled()
{
	wpi_assert(simpleCRobot != NULL);
	return simpleCRobot->IsDisabled();
}

void SetWatchdogEnabled(bool enable)
{
	simpleCRobot->GetWatchdog().SetEnabled(enable);
}

void SetWatchdogExpiration(float time)
{
	simpleCRobot->GetWatchdog().SetExpiration(time);
}

void WatchdogFeed()
{
	simpleCRobot->GetWatchdog().Feed();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -