This repository was archived by the owner on Apr 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobot.java-2-10-17
More file actions
161 lines (131 loc) · 3.87 KB
/
Copy pathRobot.java-2-10-17
File metadata and controls
161 lines (131 loc) · 3.87 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package org.usfirst.frc.team6763.robot;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Encoder;
//Imports the other files needed by the program
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
//Imports the other files needed by the program
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class Robot extends IterativeRobot {
RobotDrive myRobot = new RobotDrive(0, 2);
Joystick stick = new Joystick(0);
Timer timer = new Timer();
//DigitalInput LimitSwitch;
//DigitalInput LimitSwitch1;
Encoder rightEncoder;
Encoder leftEncoder;
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
@Override
public void robotInit() {
//LimitSwitch = new DigitalInput(0);
//LimitSwitch1 = new DigitalInput(1);
rightEncoder = new Encoder(1, 0);
rightEncoder.setReverseDirection(true);
leftEncoder = new Encoder (3, 2);
leftEncoder.setReverseDirection(false);
}
/**
* This function is run once each time the robot enters autonomous mode
*/
@Override
public void autonomousInit() {
timer.reset();
timer.start();
}
/**
* This function is called periodically during autonomous
*/
@Override
public void autonomousPeriodic() {
// Drive for 2 seconds
/*
if (timer.get() < 2.0) {
myRobot.drive(-0.5, 0.1); // drive forwards half speed
} else if (timer.get() > 2.0 && timer.get() < 5.75) {
myRobot.drive(-0.5, 0.5); // drive right
} else if (timer.get() > 5.75 && timer.get() < 7.75) {
myRobot.drive(-0.5, 0.1); // drive forward
} else {
myRobot.drive(0.0, 0.0); // stop
}
*/
//myRobot.tankDrive(-0.6, -0.5612);
/*
myRobot.tankDrive(0.6, 0.6);
System.out.println("Right Encoder = " + rightEncoder.getRate());
System.out.println("Left Encoder = " + leftEncoder.getRate());
//System.out.println("RightEncoder = " + rightEncoder.get());
//System.out.println("LeftEncoder = " + leftEncoder.get());
*/
if (rightEncoder.get() < 9750)
{
myRobot.tankDrive(-0.6, -0.5612);
System.out.println("encoder count" + rightEncoder.get());
} else
{
myRobot.tankDrive(0, 0);
}
if (leftEncoder.get() < 9750)
{
myRobot.tankDrive(-0.6, -0.5612);
System.out.println("encoder count" + leftEncoder.get());
} else
{
myRobot.tankDrive(0, 0);
}
}
/**
* This function is called once each time the robot enters tele-operated
* mode
*/
@Override
public void teleopInit() {
}
/**
* This function is called periodically during operator control
*/
@Override
public void teleopPeriodic() {
myRobot.arcadeDrive(stick);
/*
if (LimitSwitch.get()) {
myRobot.drive(0.0 ,0.0);
}
if (LimitSwitch1.get()) {
myRobot.drive(0.0 ,0.0);
}
*/
}
/**
* This function is called periodically during test mode
*/
@Override
public void testPeriodic() {
LiveWindow.run();
}
public void disabledPeriodic(){
System.out.println("RightEncoder = " + rightEncoder.get());
System.out.println("LeftEncoder = " + leftEncoder.get());
}
}