本文整理汇总了Java中com.qualcomm.robotcore.eventloop.opmode.LinearOpMode类的典型用法代码示例。如果您正苦于以下问题:Java LinearOpMode类的具体用法?Java LinearOpMode怎么用?Java LinearOpMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LinearOpMode类属于com.qualcomm.robotcore.eventloop.opmode包,在下文中一共展示了LinearOpMode类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shootBall
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; //导入依赖的package包/类
public void shootBall(LinearOpMode opMode) {
shootBalls(true);
waitFor(opMode, RobotConstants.shotWaitPeriod);
intakeBalls(true);
waitFor(opMode, 3);
intakeBalls(false);
shootBalls(false);
}
示例2: shootDoubleBall
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; //导入依赖的package包/类
public void shootDoubleBall(LinearOpMode opMode) {
shootBalls(true);
waitFor(opMode, RobotConstants.shotWaitPeriod);
intakeBalls(true);
waitFor(opMode, 5);
intakeBalls(false);
shootBalls(false);
}
示例3: waitFor
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; //导入依赖的package包/类
private void waitFor(LinearOpMode opMode, int sec) {
long millis = sec * 1000;
long stopTime = System.currentTimeMillis() + millis;
while(opMode.opModeIsActive() && System.currentTimeMillis() < stopTime) {
try {
opMode.waitOneFullHardwareCycle();
} catch(Exception ex) {}
}
}
示例4: initAutoOp
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; //导入依赖的package包/类
/**
* Initializes all drive and ball motors in USING ENCODERS mode
* @param hwMap
*/
public void initAutoOp(LinearOpMode opMode, HardwareMap hwMap) {
this.hwMap = hwMap;
initDrive();
initBall();
// initCap();
// initServos();
// initSensors();
for(DcMotor driveMotor : driveMotors) {
driveMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
opMode.idle();
driveMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
driveMotor.setDirection(DcMotorSimple.Direction.FORWARD);
driveMotor.setPower(0);
}
for(DcMotor ballMotor : ballMotors) {
ballMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
opMode.idle();
ballMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
ballMotor.setDirection(DcMotorSimple.Direction.FORWARD);
ballMotor.setPower(0);
}
// cap.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
// cap.setDirection(DcMotorSimple.Direction.FORWARD);
// cap.setPower(0);
}
示例5: waitForBeaconDetection
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; //导入依赖的package包/类
public static int waitForBeaconDetection(LinearOpMode opMode, Image img,
VuforiaTrackableDefaultListener beacon,
CameraCalibration camCal, long timeOut) {
int config = NOT_VISIBLE;
long beginTime = System.currentTimeMillis();
while (config == NOT_VISIBLE && System.currentTimeMillis() - beginTime < timeOut && opMode.opModeIsActive()) {
config = getBeaconConfig(img, beacon, camCal);
opMode.idle();
}
return config;
}
示例6: check
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; //导入依赖的package包/类
@Override
public boolean check(Thread opModeThread, OpMode currentOpMode) {
return currentOpMode instanceof LinearOpMode &&
((LinearOpMode) currentOpMode).isStopRequested();
}
示例7: walkMenuTree
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; //导入依赖的package包/类
/**
* This method traverses the menu tree from the given root menu displaying each menu and waiting for the user
* to respond to a menu. After the user responded to a menu, it will go to the next menu in the tree. If the
* user cancels the menu, it will go back to the parent menu where it came from. If there is no next menu, the
* traversal is ended. Note: this is a static method, meaning you can call it without a menu instance. Also note
* that this is a blocking call so this should not be called in a multitasking robot loop such as in the execution
* of a state machine. To use the menus in a multitasking environment, you must use the runMenus() method instead.
*
* @param rootMenu specifies the root of the menu tree.
* @param opmode specifies the linear opmode that calls this.
*/
public static void walkMenuTree(FtcMenu rootMenu, LinearOpMode opmode)
{
setRootMenu(rootMenu);
rootMenu.displayMenu();
while (!runMenus() && !opmode.isStopRequested())
{
TrcUtil.sleep(LOOP_INTERVAL);
}
}