-
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.
- Loading branch information
Showing
5 changed files
with
104 additions
and
0 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
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,59 @@ | ||
// Copyright (c) FRC 2053. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the MIT License file in the root of this project | ||
|
||
#include "subsystems/ClimberSubsystem.h" | ||
|
||
#include <frc2/command/Commands.h> | ||
|
||
#include "frc/smartdashboard/SmartDashboard.h" | ||
#include "wpi/sendable/SendableBuilder.h" | ||
#include <frc/DataLogManager.h> | ||
|
||
ClimberSubsystem::ClimberSubsystem() { | ||
ConfigureMotor(); | ||
} | ||
|
||
void ClimberSubsystem::ConfigureMotor() { | ||
ctre::phoenix6::configs::TalonFXConfiguration climberConfig{}; | ||
|
||
climberConfig.MotorOutput.NeutralMode = | ||
ctre::phoenix6::signals::NeutralModeValue::Brake; | ||
|
||
ctre::phoenix::StatusCode leftclimberConfigResult = | ||
leftClimberMotor.GetConfigurator().Apply(climberConfig); | ||
|
||
frc::DataLogManager::Log( | ||
fmt::format("Configured left climber motor. Result was: {}\n", | ||
leftclimberConfigResult.GetName())); | ||
|
||
ctre::phoenix::StatusCode rightClimberConfigResult = | ||
rightClimberMotor.GetConfigurator().Apply(climberConfig); | ||
|
||
frc::DataLogManager::Log( | ||
fmt::format("Configured right climber motor. Result was: {}\n", | ||
rightClimberConfigResult.GetName())); | ||
} | ||
|
||
frc2::CommandPtr ClimberSubsystem::ManualControl( | ||
std::function<double()> left, std::function<double()> right) { | ||
return frc2::cmd::RunEnd( | ||
[this, left, right] { | ||
leftClimberMotor.Set(left()); | ||
rightClimberMotor.Set(right()); | ||
}, | ||
[this] { | ||
leftClimberMotor.Set(0); | ||
rightClimberMotor.Set(0); | ||
}, | ||
{this}); | ||
} | ||
|
||
// This method will be called once per scheduler run | ||
void ClimberSubsystem::Periodic() { | ||
|
||
} | ||
|
||
void ClimberSubsystem::SimulationPeriodic() { | ||
|
||
} |
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,10 @@ | ||
#pragma once | ||
|
||
namespace consts { | ||
namespace climber { | ||
namespace can_ids { | ||
inline constexpr int LEFT_MOTOR = 22; | ||
inline constexpr int RIGHT_MOTOR = 23; | ||
} // namespace can_ids | ||
} | ||
} |
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,31 @@ | ||
// Copyright (c) FRC 2053. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the MIT License file in the root of this project | ||
|
||
#pragma once | ||
|
||
#include <frc2/command/CommandPtr.h> | ||
#include <frc2/command/SubsystemBase.h> | ||
#include <ctre/phoenix6/TalonFX.hpp> | ||
|
||
#include <functional> | ||
#include <memory> | ||
|
||
#include "constants/ClimberConstants.h" | ||
|
||
class ClimberSubsystem : public frc2::SubsystemBase { | ||
public: | ||
ClimberSubsystem(); | ||
|
||
void ConfigureMotor(); | ||
|
||
void Periodic() override; | ||
void SimulationPeriodic() override; | ||
frc2::CommandPtr ManualControl(std::function<double()> left, | ||
std::function<double()> right); | ||
private: | ||
ctre::phoenix6::hardware::TalonFX leftClimberMotor{consts::climber::can_ids::LEFT_MOTOR, | ||
"rio"}; | ||
ctre::phoenix6::hardware::TalonFX rightClimberMotor{consts::climber::can_ids::RIGHT_MOTOR, | ||
"rio"}; | ||
}; |