This repository was archived by the owner on Dec 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
225 lines (184 loc) · 6.89 KB
/
Copy pathmain.cpp
File metadata and controls
225 lines (184 loc) · 6.89 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#include "main.h"
#define DIGITAL_SENSOR_PORT 'A'
//#include "autoSelect/selection.h"
/**
Notes about how to use and upload this code
Made using PROS, probably will not work without it installed https://pros.cs.purdue.edu/
You will need to make a project, replace main.cpp in src/ with this file, then you can compile it
Wiring:
1, 2 - Left motors
3, 4 - Right motors
5 - Lift
All operator control code (pretty much everything) is in the operator_control function at the bottom
If you need to reverse something, put a minus after the = where the code says to set the speed
If you need anything majorly changed, please open an issue on Github: https://github.com/NULL0404/vexrobotics/
It's a private repository, you will need to log in and or have me add you to the repo, dm me on discord
**/
void initialize() {
// selector::init();
}
/**
* Runs while the robot is in the disabled state of Field Management System or
* the VEX Competition Switch, following either autonomous or opcontrol. When
* the robot is enabled, this task will exit.
*/
void disabled() {}
/**
* Runs after initialize(), and before autonomous when connected to the Field
* Management System or the VEX Competition Switch. This is intended for
* competition-specific initialization routines, such as an autonomous selector
* on the LCD.
*
* This task will exit when the robot is enabled and autonomous or opcontrol
* starts.
*/
void competition_initialize() {}
/**
* Runs the user autonomous code. This function will be started in its own task
* with the default priority and stack size whenever the robot is enabled via
* the Field Management System or the VEX Competition Switch in the autonomous
* mode. Alternatively, this function may be called in initialize or opcontrol
* for non-competition testing purposes.
*
* If the robot is disabled or communications is lost, the autonomous task
* will be stopped. Re-enabling the robot will restart the task, not re-start it
* from where it left off.
*/
void autonomous() {
/*
* Note: This autonomous code is UNTESTED and was created prior to robot construction.
* Make sure the code is up to date by using 'git pull'
*
* This should go forward, grab the ring holder, and retreat. Variables to be changed
*/
pros::Controller master(pros::E_CONTROLLER_MASTER); // Controller setup
pros::Motor left_mtr1(1); // Left motor setup, (port)
pros::Motor left_mtr2(2);
pros::Motor left_mtr3(3);
pros::Motor right_mtr4(8); // Right motor setup, (port)
pros::Motor right_mtr5(9);
pros::Motor right_mtr6(10);
pros::Motor lift_mtr8(4); // Lift motor setup, (port)
pros::Motor lift_mtr9(5);
// lift_mtr8 = -50;
// lift_mtr9 = 50; // Ensure the lift starts lowering, just in case it is in a higher position
left_mtr1 = 100; // Move forward on all motors at speed 100
left_mtr2 = 100;
left_mtr3 = 100;
right_mtr4 = -100;
right_mtr5 = -100;
right_mtr6 = -100;
pros::delay(2000); // Wait 2 seconds
left_mtr1 = 0; // Stop all motors
left_mtr2 = 0;
left_mtr3 = 0;
right_mtr4 = 0;
right_mtr5 = 0;
right_mtr6 = 0;
lift_mtr8 = 0;
lift_mtr9 = 0;
pros::delay(20); // Small delay to let everything stop before lifting
lift_mtr8 = 100; // Lift
lift_mtr8 = -100;
pros::delay(500); // Delay to let the lift lift
lift_mtr8 = 0; // stop lifting
lift_mtr9 = 0;
left_mtr1 = -100; // Move back on all motors at speed -100
left_mtr2 = -100;
left_mtr3 = -100;
right_mtr4 = 100;
right_mtr5 = 100;
right_mtr6 = 100;
pros::delay(2000); // Same delay as earlier, hopefully this puts us where we need to be
left_mtr1 = 0; // Stop all motors
left_mtr2 = 0;
left_mtr3 = 0;
right_mtr4 = 0;
right_mtr5 = 0;
right_mtr6 = 0;
lift_mtr8 = 0;
lift_mtr9 = 0;
}
/**
* Runs the operator control code. This function will be started in its own task
* with the default priority and stack size whenever the robot is enabled via
* the Field Management System or the VEX Competition Switch in the operator
* control mode.
*
* If no competition control is connected, this function will run immediately
* following initialize().
*
* If the robot is disabled or communications is lost, the
* operator control task will be stopped. Re-enabling the robot will restart the
* task, not resume it from where it left off.
*/
void opcontrol() {
pros::Controller master(pros::E_CONTROLLER_MASTER); // Controller setup
pros::Motor left_mtr1(1); // Left motor setup, (port)
pros::Motor left_mtr2(2);
pros::Motor left_mtr3(3);
pros::Motor right_mtr4(8); // Right motor setup, (port)
pros::Motor right_mtr5(9);
pros::Motor right_mtr6(10);
pros::Motor lift_mtr8(4); // Lift motor setup, (port)
pros::Motor lift_mtr9(5);
while (true) {
// Fetch controller
int left = master.get_analog(ANALOG_LEFT_Y) * 2;
int right = master.get_analog(ANALOG_RIGHT_Y) * 2;
/* To be rebind to another button, both bumpers and triggers will be used for the lift
bool buttoon = master.get_digital(DIGITAL_L1);
if (buttoon = true) {
int linux = 0.3 ;
}
else {
int linux = 1 ;
}
*/ int linux = 1;
left_mtr1 = left ; // Sets motor speed for 'left'
left_mtr2 = left ;
left_mtr3 = left ;
right_mtr4 =- right ; // Sets motor speed for 'right'
right_mtr5 =- right ;
right_mtr6 =- right ;
if (master.get_digital(DIGITAL_R1)) {
lift_mtr8 = 100;
lift_mtr9 = -100;
}
else if (master.get_digital(DIGITAL_R2)) {
lift_mtr8 = -100;
lift_mtr9 = 100; }
else {
lift_mtr8 = 3;
lift_mtr9 = -3;
}
#define DIGITAL_SENSOR_PORTA 'A'
pros::ADIDigitalOut pistonA (DIGITAL_SENSOR_PORTA);
pistonA.set_value(true);
#define DIGITAL_SENSOR_PORTB 'B'
pros::ADIDigitalOut pistonB (DIGITAL_SENSOR_PORTB);
pistonB.set_value(true);
#define DIGITAL_SENSOR_PORTC 'C'
pros::ADIDigitalOut pistonC (DIGITAL_SENSOR_PORTC);
pistonC.set_value(true);
#define DIGITAL_SENSOR_PORTD 'D'
pros::ADIDigitalOut pistonD (DIGITAL_SENSOR_PORTD);
pistonD.set_value(true);
#define DIGITAL_SENSOR_PORTE 'E'
pros::ADIDigitalOut pistonE (DIGITAL_SENSOR_PORTE);
pistonE.set_value(true);
#define DIGITAL_SENSOR_PORTF 'F'
pros::ADIDigitalOut pistonF (DIGITAL_SENSOR_PORTF);
pistonF.set_value(true);
#define DIGITAL_SENSOR_PORTG 'G'
pros::ADIDigitalOut pistonG (DIGITAL_SENSOR_PORTG);
pistonG.set_value(true);
#define DIGITAL_SENSOR_PORTH 'H'
pros::ADIDigitalOut pistonH (DIGITAL_SENSOR_PORTH);
pistonH.set_value(true);
}
}
// Reverse the above motors by putting a - after the =
// don't compile and upload with sudo, it won't work i think or something
// remember to use pros make all to compile before using pros upload to upload
// I eat poop when I am fungrty