Skip to content

Commit 1dde15f

Browse files
committed
We fixed auton
1 parent 7ef8559 commit 1dde15f

File tree

2 files changed

+106
-36
lines changed

2 files changed

+106
-36
lines changed

2024/prototype/intake_mechanisms/src/autonomous_task_tree.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ DriveStraightTask::DriveStraightTask(double desiredDistanceCentimeters,
154154

155155
void DriveStraightTask::start() {
156156
startingRotations = drive.getRotations();
157-
drive.drive(sign(distanceToDriveCm) * 0.18, 0.0);
157+
//Michal, forward/backward speed value, multiplier should be less than 1
158+
drive.drive(sign(distanceToDriveCm) * 0.27, 0.0);
158159
}
159160

160161
bool DriveStraightTask::done() const {
@@ -312,16 +313,19 @@ bool DriveStraightTask::done() const {
312313
Task("v"), desiredAngleDegrees_{desiredAngleDegrees}, drive_{drive} {
313314
}
314315

316+
//Michal, edit the second argument in the drive function to edit the turn
317+
//speed, should be between 0 and 1
315318
void GoodTurnTask::start(){
316-
drive_.drive(0.0, 0.1);
319+
drive_.resetEncoders();
320+
drive_.drive(0.0, sign(desiredAngleDegrees_) * 0.3);
317321
}
318322

319323
bool GoodTurnTask::done() const {
320324
double currentRotations = drive_.getRotations();
321325
Controller.Screen.setCursor(1,1);
322326
Controller.Screen.print(currentRotations);
323327

324-
if(currentRotations >= desiredAngleDegrees_ * 0.0178 / 3) {
328+
if(abs(currentRotations) >= abs(desiredAngleDegrees_ * 0.0178 / 3)) {
325329
drive_.drive(0.0, 0.0);
326330
return true;
327331
} else {

2024/prototype/intake_mechanisms/src/main.cpp

Lines changed: 99 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -260,56 +260,122 @@ void autonomous() {
260260
// // Leg 6: Driving forward to reach the wall and scoring the autonomous win point.
261261
// addTask(Q, R);
262262

263-
// This is a trajectory that we can use for either positive or negative
264-
// corner, we will choose based on game strategy before a match
265-
//
266-
// We will use the single ring trajectory if our alliance member has a similar
267-
// ~3-point scoring auton
268-
auto singleRingRootTask = make_shared<WaitMillisecondsTask>(0);
269-
auto driveBackward = make_shared<DriveStraightTask>(-20, prototype);
270-
auto clampTask = make_shared<MobileGoalIntakeTask>(prototype, true);
271-
auto intakeTask = make_shared <IntakeMillisecondsTask>(prototype, 1000, -1);
272-
273-
// This trajectory will be used when our alliance partner either has a
274-
// full-blown 12 point auton or no auton at all, also will depend on the other
275-
// team's history of auton points
276-
//
277-
// This trajectory works only on the positive corner
278-
auto goalRushRootTask = make_shared<WaitMillisecondsTask>(0);
279-
auto A = make_shared<DriveStraightTask>(105, prototype);
280-
auto B = make_shared<DeployDoinkerTask>(prototype, true);
281-
auto C = make_shared<WaitMillisecondsTask>(500);
282-
auto D = make_shared<DriveStraightTask>(-105, prototype);
283-
auto E = make_shared<DeployDoinkerTask>(prototype, false);
284-
auto F = make_shared<GoodTurnTask>(80, prototype);
285-
auto G = make_shared<DriveStraightTask>(-45, prototype);
286-
auto H = make_shared<MobileGoalIntakeTask>(prototype, true);
287-
auto I = make_shared<IntakeMillisecondsTask>(prototype, 1000, -1);
263+
// This trajectory works only on the red negative corner
264+
auto REDNegative = make_shared<WaitMillisecondsTask>(0);
265+
auto A1 = make_shared<DriveStraightTask>(-80, prototype);
266+
auto B1 = make_shared<MobileGoalIntakeTask>(prototype, true);
267+
auto C1 = make_shared<IntakeMillisecondsTask>(prototype, 5000, -1);
268+
auto D1 = make_shared<GoodTurnTask>(45, prototype);
269+
auto E1 = make_shared<DriveStraightTask>(50, prototype);
270+
auto F1 = make_shared<GoodTurnTask>(190, prototype);
271+
auto G1 = make_shared<DriveStraightTask>(100, prototype);
272+
273+
auto BLUENegative = make_shared<WaitMillisecondsTask>(0);
274+
auto A3 = make_shared<DriveStraightTask>(-80, prototype);
275+
auto B3 = make_shared<MobileGoalIntakeTask>(prototype, true);
276+
auto C3 = make_shared<IntakeMillisecondsTask>(prototype, 7000, -1);
277+
auto D3 = make_shared<GoodTurnTask>(-45, prototype);
278+
auto E3 = make_shared<DriveStraightTask>(50, prototype);
279+
auto F3 = make_shared<GoodTurnTask>(-190, prototype);
280+
auto G3 = make_shared<DriveStraightTask>(100, prototype);
281+
282+
// This trajectory works only on the red positive corner
283+
auto REDgoalRushPositiveRootTask = make_shared<WaitMillisecondsTask>(0);
284+
auto A = make_shared<DriveStraightTask>(65, prototype);
285+
auto B = make_shared<IntakeMillisecondsTask>(prototype, 600, -1);
286+
auto C = make_shared<DriveStraightTask>(60, prototype);
287+
auto D = make_shared<DriveStraightTask>(-30, prototype);
288+
auto E = make_shared<GoodTurnTask>(-33, prototype);
289+
auto F = make_shared<DriveStraightTask>(37, prototype);
290+
auto G = make_shared<DeployDoinkerTask>(prototype, true);
291+
auto H = make_shared<WaitMillisecondsTask>(100);
292+
auto I = make_shared<DriveStraightTask>(-60, prototype);
293+
auto J = make_shared<GoodTurnTask>(60, prototype);
294+
auto K = make_shared<DeployDoinkerTask>(prototype, false);
295+
auto L = make_shared<GoodTurnTask>(40, prototype);
296+
auto M = make_shared<DriveStraightTask>(-80, prototype);
297+
auto N = make_shared<MobileGoalIntakeTask>(prototype, true);
298+
auto O = make_shared<IntakeMillisecondsTask>(prototype, 2500, -1);
299+
auto P = make_shared<DriveStraightTask>(70, prototype);
300+
301+
auto BLUEgoalRushPositiveRootTask = make_shared<WaitMillisecondsTask>(0);
302+
auto A2 = make_shared<DriveStraightTask>(60, prototype);
303+
auto B2 = make_shared<IntakeMillisecondsTask>(prototype, 500, -1);
304+
auto C2 = make_shared<DriveStraightTask>(60, prototype);
305+
auto D2 = make_shared<DeployDoinkerTask>(prototype, true);
306+
auto E2 = make_shared<WaitMillisecondsTask>(100);
307+
auto F2 = make_shared<DriveStraightTask>(-90, prototype);
308+
auto G2 = make_shared<GoodTurnTask>(-120, prototype);
309+
auto H2 = make_shared<DeployDoinkerTask>(prototype, false);
310+
auto I2 = make_shared<GoodTurnTask>(-40, prototype);
311+
auto J2 = make_shared<DriveStraightTask>(-70, prototype);
312+
auto K2 = make_shared<MobileGoalIntakeTask>(prototype, true);
313+
auto L2 = make_shared<IntakeMillisecondsTask>(prototype, 4500, -1);
314+
auto M2 = make_shared<GoodTurnTask>(-100, prototype);
315+
auto N2 = make_shared<DriveStraightTask>(40, prototype);
316+
317+
288318
// auto intakeTask = make_shared <IntakeMillisecondsTask>(prototype, 1000, 1);
289319
// auto driveBack = make_shared<DriveStraightTask>(10, prototype);
290320

291321
auto testRootTask = make_shared<WaitMillisecondsTask>(0);
292322
auto testTurn = make_shared<GoodTurnTask>(90, prototype);
293323

294-
addTask(singleRingRootTask, driveBackward);
295-
addTask(driveBackward, clampTask);
296-
addTask(clampTask, intakeTask);
297-
298-
addTask(goalRushRootTask, A);
324+
addTask(REDNegative, A1);
325+
addTask(A1, B1);
326+
addTask(B1, C1);
327+
addTask(B1, D1);
328+
addTask(D1, E1);
329+
addTask(E1, F1);
330+
addTask(F1, G1);
331+
332+
addTask(BLUENegative, A3);
333+
addTask(A3, B3);
334+
addTask(B3, C3);
335+
addTask(B3, D3);
336+
addTask(D3, E3);
337+
addTask(E3, F3);
338+
addTask(F3, G3);
339+
340+
addTask(REDgoalRushPositiveRootTask, A);
299341
addTask(A, B);
300-
addTask(B, C);
342+
addTask(A, C);
301343
addTask(C, D);
302344
addTask(D, E);
303345
addTask(E, F);
304346
addTask(F, G);
305347
addTask(G, H);
306348
addTask(H, I);
349+
addTask(I, J);
350+
addTask(J, K);
351+
addTask(J, L);
352+
addTask(L, M);
353+
addTask(M, N);
354+
addTask(M, O);
355+
356+
addTask(BLUEgoalRushPositiveRootTask, A2);
357+
addTask(A2, B2);
358+
addTask(A2, C2);
359+
addTask(C2, D2);
360+
addTask(D2, E2);
361+
addTask(E2, F2);
362+
addTask(F2, G2);
363+
addTask(G2, H2);
364+
addTask(G2, I2);
365+
addTask(I2, J2);
366+
addTask(J2, K2);
367+
addTask(K2, L2);
368+
addTask(K2, M2);
369+
addTask(M2, N2);
370+
307371

308372
addTask(testRootTask, testTurn);
309373

310374
// execute(fullAutonRootTask);
311-
execute(goalRushRootTask);
312-
// execute(singleRingRootTask);
375+
execute(REDgoalRushPositiveRootTask);
376+
// execute(BLUEgoalRushPositiveRootTask);
377+
// execute(REDNegative); //Michal Look Here
378+
// execute(BLUENegative);
313379
// execute(testRootTask);
314380
}
315381

0 commit comments

Comments
 (0)