forked from FIRST-Tech-Challenge/FtcRobotController
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestOpMode.java
48 lines (40 loc) · 1.52 KB
/
TestOpMode.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package org.firstinspires.ftc.teamcode;
import com.qualcomm.hardware.lynx.LynxCommExceptionHandler;
import com.qualcomm.hardware.lynx.LynxModule;
import com.qualcomm.hardware.lynx.commands.core.LynxGetMotorChannelModeCommand;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.util.ElapsedTime;
import org.checkerframework.checker.units.qual.A;
import org.firstinspires.ftc.teamcode.Wrappers.CoolEncoder;
import org.firstinspires.ftc.teamcode.Wrappers.CoolMotor;
import java.util.ArrayList;
import java.util.List;
@TeleOp(name = "bru")
public class TestOpMode extends OpMode {
CoolMotor motor1, motor2;
CoolEncoder encoder;
ElapsedTime timer = new ElapsedTime();
List<LynxModule> hubs= new ArrayList<>();
@Override
public void init() {
encoder = new CoolEncoder(hardwareMap, "mfl");
motor1 = new CoolMotor(hardwareMap, "mfr");
motor2 = new CoolMotor(hardwareMap, "mbl");
timer.startTime();
timer.reset();
hubs = hardwareMap.getAll(LynxModule.class);
for (LynxModule hub : hubs) hub.setBulkCachingMode(LynxModule.BulkCachingMode.MANUAL);
}
@Override
public void loop() {
int nr = encoder.getCurrentPosition();
motor1.setPower(0.01);
motor2.setPower(0.01);
motor1.update();
motor2.update();
telemetry.addData("hz",1.0/timer.seconds());
timer.reset();
for (LynxModule hub: hubs) hub.clearBulkCache();
}
}