Skip to content

Commit 46d5623

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master'
2 parents cff2e99 + 19397c3 commit 46d5623

File tree

6 files changed

+75
-46
lines changed

6 files changed

+75
-46
lines changed

2024/prototype/intake_mechanisms/include/Iclimb.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
class Iclimb {
1010
public:
1111
/**
12-
* Makes the climb hooks activate and go up. The hooks are down by
13-
* default and we don't need them during auton, so there is no need to
14-
* make the hooks go back down after the piston is activated.
15-
* Additionally, since the piston is activated to make the hooks go up,
16-
* the set boolean will always be true. Lastly, the button only needs to
17-
* be pressed once, even though the function is being called over and
18-
* over again in the teleop function.
12+
* This code was initially for the climb hooks, which have been defeatured.
13+
* Now, the climb pneumatics are being used for a doinker. The doinker is a
14+
* hammer on the front right of the robot that can come down and grab onto
15+
* mobile goals for the robot to drag around.
16+
*
17+
* @param active true to deploy the doinker, false to retract it
1918
*/
20-
virtual void activateClimb() = 0;
19+
virtual void activateClimb(bool active) = 0;
2120
};

2024/prototype/intake_mechanisms/include/autonomous_task_tree.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,17 @@ class MobileGoalIntakeTask: public WaitMillisecondsTask {
259259
bool clamp_;
260260
};
261261

262+
class DeployDoinkerTask: public WaitMillisecondsTask {
263+
public:
264+
DeployDoinkerTask(Iclimb& doinker, bool clamp);
265+
266+
bool done() const;
267+
268+
void start();
269+
270+
private:
271+
Iclimb& doinkerObject;
272+
bool clamp_;
273+
};
274+
262275
#endif // (ifndef __AUTONOMOUS_TASK_TREE_H_INCLUDED__)

2024/prototype/intake_mechanisms/include/prototypes.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class PivotRampPrototype : public Idrive, public Iintake, public Ilift,
4949
* setLiftRotationsDebug()).
5050
* @param pneumaticsClamp A digital_out object connected to a double
5151
* solenoid for controlling pneumatic mobile goal grabber.
52-
* @param pneumaticsClimb A digital_out object connected to the
53-
* pneumatics responsible for the climb hooks.
52+
* @param pneumaticsDoinker A digital_out object connected to the
53+
* pneumatics responsible for the doinker.
5454
* @param limitSwitch A limit switch at the bottom of the lift that will
5555
* transition us out of the MOBILE_GOAL_DOWN state into the
5656
* DEFAULT_STATE.
@@ -60,7 +60,7 @@ class PivotRampPrototype : public Idrive, public Iintake, public Ilift,
6060
const std::vector<vex::motor>& right_motors_,
6161
const std::vector<vex::motor>& intake, const std::vector<vex::motor>& lift,
6262
double rotationsToTop, const vex::digital_out& pneumaticsClamp,
63-
const vex::digital_out& pneumaticsClimb, const vex::limit& limitSwitch);
63+
const vex::digital_out& pneumaticsDoinker, const vex::limit& limitSwitch);
6464

6565
/**
6666
* Drive the robot at the given speeds.
@@ -138,7 +138,7 @@ class PivotRampPrototype : public Idrive, public Iintake, public Ilift,
138138
*/
139139
void clamp(bool active);
140140

141-
void activateClimb();
141+
void activateClimb(bool active);
142142

143143
private:
144144
std::vector<vex::motor> left_motors;
@@ -151,7 +151,7 @@ class PivotRampPrototype : public Idrive, public Iintake, public Ilift,
151151

152152
public: // Temporary for testing
153153
vex::digital_out pneumaticClamp;
154-
vex::digital_out pneumaticClimb;
154+
vex::digital_out pneumaticDoinker;
155155
vex::limit limitSwitch;
156156
};
157157

2024/prototype/intake_mechanisms/src/autonomous_task_tree.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,26 @@ bool DriveStraightTask::done() const {
393393
}
394394

395395
bool MobileGoalIntakeTask::done() const {
396-
397396
bool result = WaitMillisecondsTask::done();
398-
399397
return result;
400398
}
399+
400+
// Definitions for DeployDoinkerTask
401+
DeployDoinkerTask::DeployDoinkerTask(Iclimb& doinker, bool clamp) :
402+
WaitMillisecondsTask(0), doinkerObject{doinker}, clamp_(clamp) {
403+
modifyTaskName("DeployDoinkerTask");
404+
}
405+
406+
void DeployDoinkerTask::start() {
407+
WaitMillisecondsTask::start();
408+
// redefining the doinker port here to avoid memory errors as described
409+
// with MobileGoalIntakeTask
410+
vex::triport::port DOINKER_PORT = Seventeen59A.ThreeWirePort.D;
411+
digital_out pneumaticDoinker(DOINKER_PORT);
412+
pneumaticDoinker.set(clamp_);
413+
}
414+
415+
bool DeployDoinkerTask::done() const {
416+
bool result = WaitMillisecondsTask::done();
417+
return result;
418+
}

2024/prototype/intake_mechanisms/src/main.cpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ PivotRampPrototype makePivotRampPrototype() {
139139
vex::triport::port CLIMB_PORT = Seventeen59A.ThreeWirePort.G;
140140
digital_out pneumaticClimb(CLIMB_PORT);
141141

142+
vex::triport::port DOINKER_PORT = Seventeen59A.ThreeWirePort.D;
143+
digital_out pneumaticDoinker(DOINKER_PORT);
144+
142145
vex::triport::port SWITCH_PORT = Seventeen59A.ThreeWirePort.B;
143146
vex::limit limitSwitch(SWITCH_PORT);
144147

@@ -148,7 +151,7 @@ PivotRampPrototype makePivotRampPrototype() {
148151
liftMotors,
149152
rotationsToTop,
150153
pneumaticClamp,
151-
pneumaticClimb,
154+
pneumaticDoinker,
152155
limitSwitch);
153156
p.setLiftHeights({
154157
// These values have been determined experimentally.
@@ -175,13 +178,18 @@ void updateClampState(ImobileGoalIntake& p) {
175178
}
176179
}
177180
/**
178-
* Encapsulates climb functionality for teleop in one function.
181+
* Encapsulates doinker functionality for teleop in one function.
179182
* @param p a reference to an Iclimb instance (the prototype)
180183
*/
181-
void updateClimbState(Iclimb& p) {
184+
void updateDoinkerState(Iclimb& p) {
182185
bool buttonDown = Controller.ButtonX.pressing();
186+
bool buttonUp = Controller.ButtonY.pressing();
187+
183188
if (buttonDown) {
184-
p.activateClimb();
189+
p.activateClimb(true);
190+
}
191+
if (buttonUp) {
192+
p.activateClimb(false);
185193
}
186194
}
187195

@@ -252,31 +260,22 @@ void autonomous() {
252260
// // Leg 6: Driving forward to reach the wall and scoring the autonomous win point.
253261
// addTask(Q, R);
254262

255-
// This is a fallback task tree to use in case fullAutonRootTask is not tested before competition
256-
//auto simpleRootTask = make_shared<TurnTask>(36.56, gyro, prototype);
257-
258-
auto rootTask = make_shared<WaitMillisecondsTask>(0);
259-
auto driveTask1 = make_shared<DriveStraightTask>(-20, prototype);
263+
// This is a trajectory that
264+
auto singleRingRootTask = make_shared<WaitMillisecondsTask>(0);
265+
auto driveBackward = make_shared<DriveStraightTask>(-20, prototype);
260266
auto clampTask = make_shared<MobileGoalIntakeTask>(prototype, true);
261-
auto turnTask = make_shared<TurnTask>(-45, inertialSensor, prototype);
262-
auto driveTask2 = make_shared<DriveStraightTask>(10, prototype);
263267
auto intakeTask = make_shared <IntakeMillisecondsTask>(prototype, 1000, 1);
264-
//auto turnTest = make_shared<TurnTask>(90, inertialSensor, prototype);
265-
// auto DriveTask = make_shared<TestDriveTask>(2, prototype);
266-
// auto stopTask = make_shared<DriveStraightTask>(0, prototype);
267-
// addTask(rootTask, DriveTask);
268-
// addTask(DriveTask, stopTask);
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);
277-
268+
269+
// This trajectory's purpose is to do something else
270+
auto goalRushRootTask = make_shared<WaitMillisecondsTask>(0);
271+
auto driveForward = make_shared<DriveStraightTask>(20, prototype);
272+
auto doinkerDown = make_shared<DeployDoinkerTask>(prototype, true);
273+
// auto intakeTask = make_shared <IntakeMillisecondsTask>(prototype, 1000, 1);
274+
// auto driveBack = make_shared<DriveStraightTask>(10, prototype);
275+
276+
278277
// execute(fullAutonRootTask);
279-
execute(rootTask);
278+
execute(singleRingRootTask);
280279
}
281280

282281
/**
@@ -303,7 +302,7 @@ void teleop() {
303302
updateClampState(prototype);
304303

305304
// Allows controlling the climb hooks.
306-
updateClimbState(prototype);
305+
updateDoinkerState(prototype);
307306

308307
// // Allow the driver to control the lift position.
309308
bool buttonUp = Controller.ButtonUp.pressing();

2024/prototype/intake_mechanisms/src/prototypes.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ PivotRampPrototype::PivotRampPrototype(const std::vector<vex::motor>& left_motor
9191
const std::vector<vex::motor>& right_motors_,
9292
const std::vector<vex::motor>& intake_, const std::vector<vex::motor>& lift_,
9393
double rotToTop, const vex::digital_out& pneumaticClamp_,
94-
const vex::digital_out& pneumaticClimb_, const vex::limit& limitSwitch_)
94+
const vex::digital_out& pneumaticDoinker_, const vex::limit& limitSwitch_)
9595
: left_motors(left_motors_), right_motors(right_motors_),
9696
intake_motors(intake_), lift_motors(lift_), rotationsToTop(rotToTop), pneumaticClamp(pneumaticClamp_),
97-
pneumaticClimb(pneumaticClimb_), limitSwitch(limitSwitch_) {
97+
pneumaticDoinker(pneumaticDoinker_), limitSwitch(limitSwitch_) {
9898
// Where we are right now -- the initialLiftPosition -- will now
9999
// correspond to an encoder value of zero.
100100
for_each(lift_motors.begin(), lift_motors.end(), [](motor& current_motor) {
@@ -234,6 +234,6 @@ void PivotRampPrototype::clamp(bool active) {
234234
this->pneumaticClamp.set(active);
235235
}
236236

237-
void PivotRampPrototype::activateClimb() {
238-
this->pneumaticClimb.set(true);
237+
void PivotRampPrototype::activateClimb(bool active) {
238+
this->pneumaticDoinker.set(active);
239239
}

0 commit comments

Comments
 (0)