Skip to content

Commit

Permalink
reworked climber to use falcons
Browse files Browse the repository at this point in the history
  • Loading branch information
r4stered committed Oct 23, 2024
1 parent edfb8a2 commit 8728453
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/cpp/RobotContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ void RobotContainer::ConfigureBindings() {
}
));

//driverController.POVDown().WhileTrue(climberSubsystem.ManualControl([] { return 1; }, [] { return -1; }));

(driverController.LeftTrigger() && frc2::RobotModeTriggers::Teleop()).OnTrue(IntakeNote());
(!driverController.LeftTrigger() && !intakeSubsystem.TouchedNote() && frc2::RobotModeTriggers::Teleop())
.OnTrue(frc2::cmd::Sequence(intakeSubsystem.Stop(),
Expand Down
59 changes: 59 additions & 0 deletions src/main/cpp/subsystems/ClimberSubsystem.cpp
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() {

}
2 changes: 2 additions & 0 deletions src/main/include/RobotContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "str/Vision.h"
#include "subsystems/FeederSubsystem.h"
#include "subsystems/SwerveSubsystem.h"
#include "subsystems/ClimberSubsystem.h"

class RobotContainer {
public:
Expand Down Expand Up @@ -43,6 +44,7 @@ class RobotContainer {
ShooterSubsystem shooterSubsystem;
IntakeSubsystem intakeSubsystem;
FeederSubsystem feederSubsystem;
//ClimberSubsystem climberSubsystem;
str::Vision vision;
str::NoteVisualizer noteVisualizer;

Expand Down
10 changes: 10 additions & 0 deletions src/main/include/constants/ClimberConstants.h
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
}
}
31 changes: 31 additions & 0 deletions src/main/include/subsystems/ClimberSubsystem.h
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"};
};

0 comments on commit 8728453

Please sign in to comment.