This repository has been archived by the owner on Apr 15, 2024. It is now read-only.
forked from CurtinFRC/2024-Crescendo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Alpha Arm vers 1 * Alpha Arm ver 1 w/ explicit * Alpha arm v1 formatting * Alpha arm w/ wrist v1 * formatted * Alpha arm v1 with ports * Working alpha arm no encoders --------- Co-authored-by: Isaac Turner <spacey_sooty@outlook.com>
- Loading branch information
1 parent
b4ac6b3
commit ec9fdc5
Showing
7 changed files
with
212 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) 2023-2024 CurtinFRC | ||
// Open Source Software, you can modify it according to the terms | ||
// of the MIT License at the root of this project | ||
|
||
#include "AlphaArm.h" | ||
|
||
AlphaArm::AlphaArm(AlphaArmConfig config) : _config(config) {} | ||
|
||
AlphaArmConfig AlphaArm::GetConfig(){ | ||
return _config; | ||
} | ||
|
||
void AlphaArm::OnUpdate(units::second_t dt){ | ||
switch(_state){ | ||
case AlphaArmState::kIdle: | ||
|
||
//_config.alphaArmGearbox.motorController->SetVoltage(0_V); | ||
//_config.wristGearbox.motorController->SetVoltage(0_V); | ||
_setAlphaArmVoltage = 0_V; | ||
_setWristVoltage = 0_V; | ||
|
||
break; | ||
case AlphaArmState::kRaw: | ||
_setAlphaArmVoltage = _rawArmVoltage; | ||
_setWristVoltage = _rawWristVoltage; | ||
_config.alphaArmGearbox.motorController->SetVoltage(_rawArmVoltage); | ||
_config.wristGearbox.motorController->SetVoltage(_rawWristVoltage); | ||
|
||
break; | ||
case AlphaArmState::kForwardWrist: | ||
_config.wristGearbox.motorController->SetVoltage(3_V); | ||
_setWristVoltage = 3_V; | ||
|
||
case AlphaArmState::kReverseWrist: | ||
_config.wristGearbox.motorController->SetVoltage(-3_V); | ||
_setWristVoltage = -3_V; | ||
default: | ||
std::cout << "oops, wrong state" << std::endl; | ||
break; | ||
|
||
} | ||
//transmission translate | ||
// _config.armGearBox.motorController->SetVoltage(setAlphaArmVoltage); | ||
//_config.alphaArmGearbox.motorController->SetVoltage(setAlphaArmVoltage); | ||
//_config.wristGearbox.motorController->SetVoltage(setWristVoltage); | ||
_config.alphaArmGearbox.motorController->SetVoltage(_setAlphaArmVoltage); | ||
_config.wristGearbox.motorController->SetVoltage(_setWristVoltage); | ||
|
||
//_config.wristGearbox.motorController->SetVoltage(_setVoltage); | ||
} | ||
|
||
void AlphaArm::SetState(AlphaArmState state) { | ||
_state = state; | ||
} | ||
|
||
// void AlphaArm::SetRaw(units::volt_t voltage){ | ||
// _rawArmVoltage = voltage; | ||
// _rawWristVoltage = voltage; | ||
// } | ||
|
||
void AlphaArm::SetArmRaw(units::volt_t voltage){ | ||
_rawArmVoltage = voltage; | ||
} | ||
|
||
void AlphaArm::setWristRaw(units::volt_t voltage){ | ||
_rawWristVoltage = voltage; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2023-2024 CurtinFRC | ||
// Open Source Software, you can modify it according to the terms | ||
// of the MIT License at the root of this project | ||
|
||
#include "AlphaArmBehaviour.h" | ||
|
||
#include <frc/XboxController.h> | ||
|
||
AlphaArmManualControl::AlphaArmManualControl(AlphaArm* alphaArm, frc::XboxController* codriver) | ||
: _alphaArm(alphaArm), _codriver(codriver) { | ||
Controls(alphaArm); | ||
} | ||
|
||
void AlphaArmManualControl::OnTick(units::second_t dt) { | ||
if (_codriver->GetXButtonPressed()) { | ||
if (_rawControl == true) { | ||
_rawControl = false; | ||
} else { | ||
_rawControl = true; | ||
} | ||
} | ||
|
||
if (_rawControl) { | ||
_alphaArm->SetState(AlphaArmState::kRaw); | ||
_alphaArm->SetArmRaw(_codriver->GetRightY() * 6_V); | ||
_alphaArm->setWristRaw(_codriver->GetLeftY() * -6_V); | ||
} else { | ||
if (_codriver->GetRightBumperPressed()){ | ||
_alphaArm->SetState(AlphaArmState::kForwardWrist); | ||
} | ||
if (_codriver->GetLeftBumperPressed()){ | ||
_alphaArm->SetState(AlphaArmState::kReverseWrist); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) 2023-2024 CurtinFRC | ||
// Open Source Software, you can modify it according to the terms | ||
// of the MIT License at the root of this project | ||
|
||
#pragma once | ||
#include <frc/DigitalInput.h> | ||
|
||
#include "Wombat.h" | ||
|
||
struct AlphaArmConfig { | ||
wom::Gearbox alphaArmGearbox; | ||
wom::Gearbox wristGearbox; | ||
|
||
}; | ||
|
||
enum class AlphaArmState { | ||
kIdle, | ||
kIntakeAngle, | ||
kAmpAngle, | ||
kSpeakerAngle, | ||
kForwardWrist, | ||
kReverseWrist, | ||
kRaw | ||
}; | ||
|
||
class AlphaArm : public::behaviour::HasBehaviour{ | ||
public: | ||
explicit AlphaArm(AlphaArmConfig config); | ||
|
||
void OnUpdate(units::second_t dt); | ||
void SetArmRaw(units::volt_t voltage); | ||
void setWristRaw(units::volt_t voltage); | ||
void SetState(AlphaArmState state); | ||
AlphaArmConfig GetConfig(); | ||
//void SetRaw(units::volt_t voltage); | ||
|
||
private: | ||
AlphaArmConfig _config; | ||
AlphaArmState _state = AlphaArmState::kIdle; | ||
units::volt_t _setAlphaArmVoltage = 0_V; | ||
units::volt_t _setWristVoltage = 0_V; | ||
|
||
units::volt_t _rawArmVoltage = 0_V; | ||
units::volt_t _rawWristVoltage = 0_V; | ||
|
||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) 2023-2024 CurtinFRC | ||
// Open Source Software, you can modify it according to the terms | ||
// of the MIT License at the root of this project | ||
|
||
#pragma once | ||
|
||
#pragma once | ||
#include <frc/XboxController.h> | ||
|
||
#include "AlphaArm.h" | ||
#include "Wombat.h" | ||
|
||
class AlphaArmManualControl : public behaviour::Behaviour { | ||
public: | ||
explicit AlphaArmManualControl(AlphaArm* alphaArm, frc::XboxController* codriver); | ||
void OnTick(units::second_t dt); | ||
|
||
private: | ||
AlphaArm* _alphaArm; | ||
frc::XboxController* _codriver; | ||
// units::volt_t _rightStick = ((_codriver->GetRightY()>0.05 || _codriver->GetRightY() < -0.05 | ||
// )?_codriver->GetRightY():0) * 2_V; | ||
bool _rawControl; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters