Quasics2016Code/SimpleRobot/src/Commands/DriveForDistance.cpp
// Called repeatedly when this Command is scheduled to run
Called repeatedly when this Command is scheduled to run
Called repeatedly when this Command is scheduled to run
void DriveForDistance::Execute() {
    if (Robot::driveSystem->GetEncoderDistance(DriveSystem::kLeft)
            >= m_distanceMeters) {
        Robot::driveSystem->StopEverything();
    }
    else if (Robot::driveSystem->GetEncoderDistance(DriveSystem::kLeft)
             >= m_distanceMeters - .5) {
        Robot::driveSystem->MoveLeft(m_powerPercent / 2);
        Robot::driveSystem->MoveRight(m_powerPercent / 2);
    }
    else {
        Robot::driveSystem->MoveLeft(m_powerPercent);
        Robot::driveSystem->MoveRight(m_powerPercent);
    }
}
void DriveForDistance :: Execute ( ) { if ( Robot :: driveSystem -> GetEncoderDistance ( DriveSystem :: kLeft ) >= m_distanceMeters ) { Robot :: driveSystem -> StopEverything ( ) ; } else if ( Robot :: driveSystem -> GetEncoderDistance ( DriveSystem :: kLeft ) >= m_distanceMeters - .5 ) { Robot :: driveSystem -> MoveLeft ( m_powerPercent / 2 ) ; Robot :: driveSystem -> MoveRight ( m_powerPercent / 2 ) ; } else { Robot :: driveSystem -> MoveLeft ( m_powerPercent ) ; Robot :: driveSystem -> MoveRight ( m_powerPercent ) ; } }
Called repeatedly when this Command is scheduled to run
Called repeatedly when this Command is scheduled to run