Skip to content

Commit dfbf047

Browse files
committed
Fixed a memory error that occured with
IntakeMillisecondsTask - For whatever reason, IntakeMillisecondsTask was throwing a memory error every time it was used in the auton task tree. The error was narrowed down to being present in the clamp function, which has no apparent errors. To solve the problem, we created a new digital_out object linked to the DOUBLE_SOLENOID_PORT that we control directly instead of passing in a copy of pnuematicClamp. We can only blame the issue on VEX's faulty API. - Also laid out the auton trajectory, all the functions are in the right sequence but we need to figure out the correct values to pass into the DriveStraightTasks and the TurnTasks - Lastly, I slowed down the motor speeds in DriveStraightTask to ensure that the robot does not slip off the line and get off-course
1 parent b7148a1 commit dfbf047

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

2024/prototype/intake_mechanisms/src/autonomous_task_tree.cpp

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

155155
void DriveStraightTask::start() {
156156
startingRotations = drive.getRotations();
157-
drive.drive(sign(distanceToDriveCm), 0.0);
157+
drive.drive(sign(distanceToDriveCm) * 0.18, 0.0);
158158
}
159159

160160
bool DriveStraightTask::done() const {
@@ -382,9 +382,19 @@ bool DriveStraightTask::done() const {
382382

383383
void MobileGoalIntakeTask::start() {
384384
WaitMillisecondsTask::start();
385-
mobileGoalIntakeObject.clamp(clamp_);
385+
//The only reason we are redefining the clamp port here is because the
386+
//VEX API doesn't like it when we use copy constructors repeatedly. This
387+
//is a confusing situation that we can't explain, unfortunately, so we
388+
//have no choice but to redeclare the port again.
389+
vex::triport::port DOUBLE_SOLENOID_PORT = Seventeen59A.ThreeWirePort.C;
390+
digital_out foo(DOUBLE_SOLENOID_PORT);
391+
foo.set(true);
392+
386393
}
387394

388395
bool MobileGoalIntakeTask::done() const {
389-
return WaitMillisecondsTask::done();
396+
397+
bool result = WaitMillisecondsTask::done();
398+
399+
return result;
390400
}

2024/prototype/intake_mechanisms/src/main.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,24 @@ void autonomous() {
256256
//auto simpleRootTask = make_shared<TurnTask>(36.56, gyro, prototype);
257257

258258
auto rootTask = make_shared<WaitMillisecondsTask>(0);
259-
auto turnTest = make_shared<TurnTask>(90, inertialSensor, prototype);
259+
auto driveTask1 = make_shared<DriveStraightTask>(-20, prototype);
260+
auto clampTask = make_shared<MobileGoalIntakeTask>(prototype, true);
261+
auto turnTask = make_shared<TurnTask>(-45, inertialSensor, prototype);
262+
auto driveTask2 = make_shared<DriveStraightTask>(10, prototype);
263+
auto intakeTask = make_shared <IntakeMillisecondsTask>(prototype, 1000, 1);
264+
//auto turnTest = make_shared<TurnTask>(90, inertialSensor, prototype);
260265
// auto DriveTask = make_shared<TestDriveTask>(2, prototype);
261266
// auto stopTask = make_shared<DriveStraightTask>(0, prototype);
262267
// addTask(rootTask, DriveTask);
263268
// addTask(DriveTask, stopTask);
264-
addTask(rootTask, turnTest);
269+
addTask(rootTask, driveTask1);
270+
addTask(driveTask1, clampTask);
271+
addTask(clampTask, turnTask);
272+
addTask(turnTask, driveTask2);
273+
addTask(turnTask, intakeTask);
274+
// addTask(clampTask, turnTask);
275+
// addTask(turnTask, driveTask2);
276+
// addTask(driveTask2, intakeTask);
265277

266278
// execute(fullAutonRootTask);
267279
execute(rootTask);

0 commit comments

Comments
 (0)