当前位置: 首页>>代码示例>>C++>>正文


C++ Drive::autoDrive方法代码示例

本文整理汇总了C++中Drive::autoDrive方法的典型用法代码示例。如果您正苦于以下问题:C++ Drive::autoDrive方法的具体用法?C++ Drive::autoDrive怎么用?C++ Drive::autoDrive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drive的用法示例。


在下文中一共展示了Drive::autoDrive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AutonomousPeriodic

/**
 * Periodic code for autonomous mode should go here.
 *
 * Use this method for code which will be called periodically at a regular
 * rate while the robot is in autonomous mode.
 */
void RobotDemo::AutonomousPeriodic() 
{
	shooter->handle();
	intake->handle();
	
	switch(curAutoState)
	{
	case AUTO_EXTEND:
		if(curAutoState != preAutoState)
		{			
			preAutoState = curAutoState;
			
			intake->move(INTAKE_EXTEND_POWER);
			printf("extending, pre %d, cur %d, \n", preAutoState, curAutoState);
		}
		
		if(intake->getCurrentPosition() >= EXTENDER_MAX_DISTANCE)
		{
			intake->move(STOP);
			curAutoState = AUTO_DRIVE;
			printf("pre %d, cur %d, stopped extender \n", preAutoState, curAutoState);
		}
		break;
	
	case AUTO_DRIVE:
		if(curAutoState != preAutoState)
		{
			preAutoState = curAutoState;
			
			drive->InitAutoDrive(AUTO_DRIVE_DISTANCE_RIGHT, 
					AUTO_DRIVE_DISTANCE_LEFT, 
					AUTO_DRIVE_SPEED);
			printf("We're moving! pre %d, cur %d, \n", preAutoState, curAutoState);
		}
/*		if(HotAutoSensor->Get())
		{
			HotAutoStarts = true;
		}
*/		
		if(drive->autoDrive() == true)
		{
			curAutoState = AUTO_STOP_DRIVING;
		}
		break;
		
	case AUTO_STOP_DRIVING:
		if(curAutoState != preAutoState)
		{
			preAutoState = curAutoState;
			printf("now stopping pre %d, cur %d, \n", preAutoState, curAutoState);
			
			drive->TeleopDrive(AUTO_STOPPING_SPEED_LEFT, AUTO_STOPPING_SPEED_RIGHT);
		}
		
		if(drive->getSpeed() > 0.01)
		{
			drive->TeleopDrive(AUTO_STOPPED_SPEED_LEFT, AUTO_STOPPED_SPEED_RIGHT);
//			if(HotAutoStarts || HotAutoTimer->Get() > 5.0)
//			{
			curAutoState = AUTO_SHOOT;
//			}
		}
		break;
		
	case AUTO_SHOOT:
		if(curAutoState != preAutoState)
		{
			preAutoState = curAutoState;
			
			printf("now shooting pre %d, cur %d, \n", preAutoState, curAutoState);
			shooter->initShot(SHOT_HIGH_ANGLE, SHOT_HIGH_SPEED);
		}
		
		if(!shooter->isShooting())
		{
			curAutoState = AUTO_STOP;
		}
		break;
/*		
	case AUTO_MOBILITY:
		if(curAutoState != preAutoState)
		{
			drive->InitAutoDrive(AUTO_SETUP_SHOT_DISTANCE_RIGHT, 
					AUTO_SETUP_SHOT_DISTANCE_LEFT, 
					AUTO_SETUP_SHOT_SPEED);
		}
		
		if(drive->autoDrive())
		{
			curAutoState = AUTO_STOP;
		}
		break;
*/		
	case AUTO_STOP:
//.........这里部分代码省略.........
开发者ID:Manchester-Central,项目名称:CHAOS-Archived-Code,代码行数:101,代码来源:MyRobot.cpp


注:本文中的Drive::autoDrive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。