Skip to content

Commit

Permalink
Callum & Kavin - Elevator partially working on test board
Browse files Browse the repository at this point in the history
  • Loading branch information
Student committed Dec 9, 2024
1 parent 45129a7 commit f88e2fe
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 18 deletions.
21 changes: 16 additions & 5 deletions src/main/cpp/HAL/Elevator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ Elevator::Elevator()
std::cout << "configured elevator motors" << std::endl;
}

void Elevator::ProfiledMoveToHeight(int shelfNumber)
void ProfiledMoveToHeight(int shelfNumber)
{
// TODO - implement profiled move semantics
std::cout << "elevator performing profiled move to " << shelfNumber << std::endl;
// move elevator to (shelfNumber*15) inches
shelfCurrent = shelfNumber;
//shelfCurrent = shelfNumber;
}

double Elevator::GetHeight()
Expand All @@ -34,6 +34,15 @@ double Elevator::GetHeight()
// }
void Elevator::ProfiledMoveToHeight(bool direction)
{
if(direction) {
m_elevatorMotor.Set(0.5);
} else if (direction) {
m_elevatorMotor.Set(-0.5);
} else {
m_elevatorMotor.Set(0);
}

/*
std::string height_increase;
int shelfNumber = shelfCurrent + 1;
// TODO - make motors go up or down
Expand All @@ -51,17 +60,19 @@ void Elevator::ProfiledMoveToHeight(bool direction)
std::cout << "performed profiled move to " << shelfNumber << std::endl;
std::cout << "elevator moving" << height_increase << std::endl;
}
*/
}

void Elevator::ShiftHeight(bool direction)
void ShiftHeight(bool direction)
{
std::string height_increase;
// TODO - make motors go up or down
if (direction==true){
height_increase = "up";
Elevator::ProfiledMoveToHeight(shelfCurrent+1);
//Elevator::ProfiledMoveToHeight(shelfCurrent+1);
}else{
height_increase = "down";
Elevator::ProfiledMoveToHeight(shelfCurrent-1);
//Elevator::ProfiledMoveToHeight(shelfCurrent-1);
}
std::cout << "elevator moving" << height_increase << std::endl;
}
9 changes: 6 additions & 3 deletions src/main/cpp/InputManager/ElevatorManager.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#include "HAL/Elevator.h"
#include "InputManager/ElevatorManager.h"
#include <iostream>
#include <frc/Timer.h>

ElevatorManager::ElevatorManager()
{

void HandleInput(RobotControlData& control_data) {
}

void ElevatorManager::HandleInput(RobotControlData& control_data) {
if (control_data.elevatorInput.up) {
m_elevator.ProfiledMoveToHeight(true);
} else if(control_data.elevatorInput.down) {
m_elevator.ProfiledMoveToHeight(false);
}
};
void Reset(){
void ElevatorManager::Reset(){
m_elevator.ProfiledMoveToHeight(0);
};
2 changes: 1 addition & 1 deletion src/main/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void Robot::TeleopInit() {

void Robot::TeleopPeriodic() {
controllerInterface.UpdateRobotControlData(_robot_control_data);
Elevator.HandleInput(_robot_control_data);
elevatorManager.HandleInput(_robot_control_data);
clawManager.HandleInput(_robot_control_data);
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/include/ControllerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ class ControllerInterface
ControllerInterface() = default;
~ControllerInterface() = default;
void UpdateRobotControlData(RobotControlData &controlData);
void UpdateElevatorInput(RobotControlData &controlData);
frc::XboxController m_pilot{0};
frc::XboxController m_pilot{0};
frc::XboxController m_copilot{1};

private:
void UpdateSwerveInput(RobotControlData &controlData);
void UpdateClawInput(RobotControlData &controlData);
void UpdateElevatorInput(RobotControlData &controlData);

void UpdateElevatorInput(RobotControlData &controlData);

double m_slowmodefactor = 0.25;
};
4 changes: 2 additions & 2 deletions src/main/include/HAL/Elevator.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <frc/Timer.h>
#include <rev/CANSparkMax.h>
#include <frc/XboxController.h>
#include "RobotControlData.h
#include "RobotControlData.h"

class Elevator
{
Expand All @@ -22,7 +22,7 @@ class Elevator
private:
// Raw set height used by profiled move to set the height
void SetHeight(double desired_height);
rev::CANSparkMax m_elevatorMotor{4, rev::CANSparkMax::MotorType::kBrushless};
rev::CANSparkMax m_elevatorMotor{5, rev::CANSparkMax::MotorType::kBrushless};
frc::Timer m_Timer;

bool m_ElevatorFlag;
Expand Down
3 changes: 1 addition & 2 deletions src/main/include/InputManager/ElevatorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "HAL/Elevator.h"
#include "RobotControlData.h"

Elevator m_elevator = Elevator();

class ElevatorManager
{
Expand All @@ -15,5 +14,5 @@ class ElevatorManager
void Reset();

private:
Elevator _elevator;
Elevator m_elevator;
};
3 changes: 2 additions & 1 deletion src/main/include/Robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <memory>
#include "ControllerInterface.h"
#include "InputManager/ClawManager.h"
#include "InputManager/ElevatorManager.h"
#include "RobotControlData.h"
class Robot : public frc::TimedRobot {
public:
Expand All @@ -29,9 +30,9 @@ class Robot : public frc::TimedRobot {
void SimulationPeriodic() override;
ControllerInterface controllerInterface;
ClawManager clawManager;
ElevatorManager elevatorManager;

private:

frc::SendableChooser<std::string> m_chooser;
const std::string kAutoNameDefault = "Default";
const std::string kAutoNameCustom = "My Auto";
Expand Down

0 comments on commit f88e2fe

Please sign in to comment.