Skip to content

Commit

Permalink
callum - changed elevator logic, added correct motor and updated swer…
Browse files Browse the repository at this point in the history
…ve speed
  • Loading branch information
Student authored and nick-mcgill committed Dec 11, 2024
1 parent bbc95ca commit 33e765b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
33 changes: 26 additions & 7 deletions src/main/cpp/HAL/Elevator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ Elevator::Elevator()
std::cout << "configured elevator motors" << std::endl;
}

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;
}


double Elevator::GetHeight()
{
Expand All @@ -34,13 +28,28 @@ double Elevator::GetHeight()
// }
void Elevator::ProfiledMoveToHeight(int direction)
{
m_Timer.Start();
while (m_Timer.Get()<=3_s) {
if (m_Timer.Get()<1_s){
m_elevatorMotor.Set(m_Timer.Get()/1_s);
} else if (m_Timer.Get()>2_s) {
--speedMult;
}
m_elevatorMotor.Set(m_Timer.Get()/1_s);
}
m_elevatorMotor.Set(0);
m_Timer.Stop();
m_Timer.Reset();
speedMult=0;
/*
if(direction==1) {
m_elevatorMotor.Set(0.05);
} else if (direction==-1) {
m_elevatorMotor.Set(-0.05);
} else {
m_elevatorMotor.Set(0);
}
*/

/*
std::string height_increase;
Expand All @@ -62,6 +71,16 @@ void Elevator::ProfiledMoveToHeight(int direction)
}
*/
}
void Elevator::MoveElevator(int direction)
{
if(direction==1) {
m_elevatorMotor.Set(0.05);
} else if (direction==-1) {
m_elevatorMotor.Set(-0.05);
} else {
m_elevatorMotor.Set(0);
}
}

void ShiftHeight(bool direction)
{
Expand Down
8 changes: 4 additions & 4 deletions src/main/include/HAL/Elevator.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <frc/Timer.h>
#include <rev/CANSparkMax.h>
#include <ctre/phoenix6/TalonFX.hpp>
#include <frc/XboxController.h>
#include "RobotControlData.h"

Expand All @@ -21,10 +21,10 @@ class Elevator

private:
// Raw set height used by profiled move to set the height
void SetHeight(double desired_height);
rev::CANSparkMax m_elevatorMotor{5, rev::CANSparkMax::MotorType::kBrushless};
void MoveElevator(int direction);
ctre::phoenix6::hardware::TalonFX m_elevatorMotor{5};
frc::Timer m_Timer;

int speedMult=0;
bool m_ElevatorFlag;
int m_ElevatorState;
bool m_PrevElevatorFlag;
Expand Down
2 changes: 1 addition & 1 deletion src/main/include/SwerveConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const bool GYRO_INVERTED = true;
const frc::Rotation2d GYRO_ZERO_HEADING{units::degree_t{0.0f}};

// --------------------------Swerve---------------------------
const double MAX_DRIVE_SPEED_FPS = 18.0;
const double MAX_DRIVE_SPEED_FPS = 5.0;
const double MAX_ANGULAR_VELOCITY_DEGPS = 540.0;
const double CONTROLLER_DEADZONE = 0.1;
const int TURN_MOTOR_CURRENT_LIMIT = 20;
Expand Down

0 comments on commit 33e765b

Please sign in to comment.