Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

Commit 849721b

Browse files
committed
Update grabber controls & add use output for purchased driver board
1 parent 60b36a7 commit 849721b

File tree

3 files changed

+37
-29
lines changed

3 files changed

+37
-29
lines changed

Safety/AttitudeManager/Src/attitudeStateClasses.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,26 @@ bool DisarmMode:: isArmed()
322322

323323
void PeripheralControlMode::execute(attitudeManager* attitudeMgr)
324324
{
325+
const uint8_t speed = 10;
325326
PPM_Instructions_t *teleopInstructions = fetchInstructionsMode::GetTeleopInstructions();
326-
if (teleopInstructions->PPMValues[attitudeMgr->grabber->ppmChannel] > 50)
327-
attitudeMgr->grabber->close(50);
328-
else
329-
attitudeMgr->grabber->open(50);
327+
const uint8_t &clawInput = teleopInstructions->PPMValues[attitudeMgr->grabber->ppmClawChannel];
328+
const uint8_t &craneInput = teleopInstructions->PPMValues[attitudeMgr->grabber->ppmCraneChannel];
329+
330+
if (clawInput < 30)
331+
attitudeMgr->grabber->close(speed);
332+
else if (clawInput < 70)
333+
attitudeMgr->grabber->brake();
334+
else
335+
attitudeMgr->grabber->open(speed);
336+
337+
if (craneInput < 30)
338+
attitudeMgr->grabber->lower(speed);
339+
else if (craneInput < 70)
340+
attitudeMgr->grabber->crane_brake();
341+
else
342+
attitudeMgr->grabber->raise(speed);
343+
344+
330345
attitudeMgr->setState(fetchInstructionsMode::getInstance());
331346
}
332347

Safety/Inc/grabber.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Grabber {
2222
PWMChannel *pwm);
2323
Grabber(const Grabber*)=delete;
2424

25+
void brake();
2526
void open(uint8_t speed);
2627
void close(uint8_t speed);
2728

@@ -30,7 +31,8 @@ class Grabber {
3031
void lower(uint8_t speed);
3132
void raise(uint8_t speed);
3233

33-
const uint8_t ppmChannel = 5; // TODO: What channel?
34+
const uint8_t ppmCraneChannel = 6; // TODO: What channel?
35+
const uint8_t ppmClawChannel = 7; // TODO: What channel?
3436

3537
private:
3638
Grabber() {};
@@ -45,8 +47,6 @@ class Grabber {
4547
crane_channel_2(grabber_pwm_channel_2),
4648
pwm(*pwm) {}
4749

48-
bool isOpen = false;
49-
bool isLowered = false;
5050
const uint8_t grabber_channel_1 = 0;
5151
const uint8_t grabber_channel_2 = 0;
5252
const uint8_t crane_channel_1 = 0;

Safety/Src/grabber.cpp

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,37 +47,30 @@ void Grabber::crane_coast() {
4747
// is finished lowering to set the motor into brake mode and update its state
4848
// Unfortunately I dont know what that will look like... It could very well be time based
4949
// need more details from Mech/Electrical
50+
// Update: This will just rely on pilot visual unless otherwise required
5051
void Grabber::lower(uint8_t speed) {
51-
if (!this->isLowered) {
52-
pwm.set(this->crane_channel_1, speed);
53-
pwm.set(this->crane_channel_2, 0);
54-
this->isLowered = true;
55-
}
52+
pwm.set(this->crane_channel_1, speed);
53+
pwm.set(this->crane_channel_2, 0);
5654
}
5755
void Grabber::raise(uint8_t speed) {
58-
if (this->isLowered) {
59-
pwm.set(this->crane_channel_1, 0);
60-
pwm.set(this->crane_channel_2, speed);
61-
this->isLowered = false;
62-
}
56+
pwm.set(this->crane_channel_1, 0);
57+
pwm.set(this->crane_channel_2, speed);
6358
}
6459

6560

66-
//TODO: Still need data from electrical on the input to the motor driver,
67-
// hopefully it is similar to the above
61+
62+
// Using https://media.digikey.com/pdf/Data%20Sheets/Seeed%20Technology/105090004_Web.pdf
63+
void Grabber::brake() {
64+
pwm.set(this->grabber_channel_1, 0);
65+
pwm.set(this->grabber_channel_2, 0);
66+
}
6867
void Grabber::close(uint8_t speed) {
69-
if (!this->isOpen) {
70-
pwm.set(this->grabber_channel_1, speed);
71-
pwm.set(this->grabber_channel_2, 0);
72-
this->isOpen = true;
73-
}
68+
pwm.set(this->grabber_channel_1, speed);
69+
pwm.set(this->grabber_channel_2, 0);
7470
}
7571
void Grabber::open(uint8_t speed) {
76-
if (this->isOpen) {
77-
pwm.set(this->grabber_channel_1, 0);
78-
pwm.set(this->grabber_channel_2, speed);
79-
this->isOpen = false;
80-
}
72+
pwm.set(this->grabber_channel_1, 0);
73+
pwm.set(this->grabber_channel_2, speed);
8174
}
8275

8376
/* Private methods ---------------------------------------------------------*/

0 commit comments

Comments
 (0)