-
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.
Implemented ClimberHAL, ClimberManager (#22)
* Implemented ClimberHAL, ClimberManager * Resolved comments, changed kCoast to kBrake for climberConfig, updated CAN id of ClimberMotor to 50 (needs to set later) * resolved some comments, started reworking climber code -callum * reworked/completed the climber system -callum * changes for climber based on feedback * [nick] Fix merge conflict * from testing climber on robot --------- Co-authored-by: Student <ratpack-student@gmail.com> Co-authored-by: Me <108602466+TheSiddyBoi@users.noreply.github.com> Co-authored-by: TheSiddyBoi <sid.pandit04@gmail.com>
- Loading branch information
1 parent
1ca0a94
commit 4f80e39
Showing
10 changed files
with
152 additions
and
4 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,30 @@ | ||
#include "HAL/ClimberHAL.h" | ||
#include <rev/config/SparkMaxConfig.h> | ||
#include "ratpack/SparkMaxDebugMacro.h" | ||
#include "MechanismConfig.h" | ||
|
||
Climber::Climber() | ||
{ | ||
rev::spark::SparkMaxConfig climber_config{}; | ||
climber_config.closedLoop.SetFeedbackSensor(rev::spark::ClosedLoopConfig::FeedbackSensor::kPrimaryEncoder); | ||
climber_config.closedLoop.Pidf(ratbot::ClimberConfig::P,ratbot::ClimberConfig::I,ratbot::ClimberConfig::D,ratbot::ClimberConfig::F); | ||
climber_config.encoder.VelocityConversionFactor(ratbot::ClimberConfig::VEL_CONV_FACTOR); | ||
climber_config.Inverted(ratbot::ClimberConfig::INVERTED); | ||
climber_config.SetIdleMode(ratbot::ClimberConfig::IDLE_MODE); | ||
climber_config.SmartCurrentLimit(ratbot::ClimberConfig::CURRENT_LIM); | ||
climber_config.VoltageCompensation(ratbot::VOLTAGE_COMPENSATION); | ||
|
||
START_RETRYING(CLIMBER_CONFIG) | ||
m_climberMotor.Configure(climber_config, rev::spark::SparkMax::ResetMode::kResetSafeParameters, rev::spark::SparkMax::PersistMode::kPersistParameters); | ||
END_RETRYING | ||
} | ||
|
||
void Climber::SetClimberSpeed(double speed) | ||
{ | ||
m_climberMotor.Set(speed); | ||
} | ||
|
||
double Climber::GetClimberPosition() | ||
{ | ||
return m_climberMotor.GetEncoder().GetPosition(); | ||
} |
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,16 @@ | ||
#include "InputManager/ClimberManager.h" | ||
|
||
|
||
void ClimberManager::HandleInput(RobotControlData &robotControlData) | ||
{ | ||
|
||
if(m_matchTimer.HasElapsed(105_s)) | ||
{ | ||
m_Climber.SetClimberSpeed(robotControlData.climberInput.ClimberSpeed); | ||
} | ||
} | ||
|
||
void ClimberManager::ResetState(){ | ||
m_matchTimer.Reset(); | ||
m_matchTimer.Start(); | ||
} |
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
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,28 @@ | ||
#pragma once | ||
#include "RobotControlData.h" | ||
#include <frc/smartdashboard/SmartDashboard.h> | ||
#include <frc/DigitalInput.h> | ||
#include <rev/SparkMax.h> | ||
#include <rev/SparkAbsoluteEncoder.h> | ||
#include <rev/SparkClosedLoopController.h> | ||
#include <frc/trajectory/TrapezoidProfile.h> | ||
#include <units/length.h> | ||
#include <units/velocity.h> | ||
#include <units/angle.h> | ||
#include <units/acceleration.h> | ||
#include <units/angular_velocity.h> | ||
#include <units/angular_acceleration.h> | ||
|
||
class Climber | ||
{ | ||
public: | ||
Climber(); | ||
~Climber() = default; | ||
double GetClimberPosition(); | ||
void SetClimberSpeed(double speed); | ||
|
||
private: | ||
rev::spark::SparkMax m_climberMotor{30, rev::spark::SparkMax::MotorType::kBrushless}; | ||
rev::spark::SparkClosedLoopController m_climberMotorPID = m_climberMotor.GetClosedLoopController(); | ||
rev::spark::SparkAbsoluteEncoder m_climberMotorAbsEncoder = m_climberMotor.GetAbsoluteEncoder(); | ||
}; |
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,18 @@ | ||
#pragma once | ||
|
||
#include "HAL/ClimberHAL.h" | ||
#include "RobotControlData.h" | ||
#include <frc/Timer.h> | ||
|
||
|
||
class ClimberManager | ||
{ | ||
public: | ||
ClimberManager() = default; | ||
~ClimberManager() = default; | ||
void ResetState(); | ||
void HandleInput(RobotControlData &robotControlData); | ||
private: | ||
Climber m_Climber; | ||
frc::Timer m_matchTimer; | ||
}; |
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
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