forked from FRC830/2024Robot
-
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.
* created elevator code structure * added more funtions to ElevatorHAL * Fix Compilation - Mentor Nick * added MoveHeightBy function. * Elevator Code Expanded (but to be improved) * [Nick] Fix compile errors * callum removed extra HAL folders, developed elevator functions * updated internal elevator logic, and controller interfacing for elevator callum * Started claw program base * Added changes to ClawHAL * Fix Compilation - Mentor Nick * Put ClawHAL into RobotControlData.h * Kavin worked on the claw and combining the files * [Nick] Fix Compile Errors * Lucas Alex and Aiza made the claw work * made the claw work correctly --------- Co-authored-by: Jack Jin <79951112+Rvistix@users.noreply.github.com> Co-authored-by: RandomPerson5125 <murkavin@gmail.com> Co-authored-by: Student <student@ratpack> Co-authored-by: TheCrudeOilBro <lucasyuan1981@gmail.com> Co-authored-by: HugoHead <deanmartin@830>
- Loading branch information
1 parent
25fdffa
commit 353e17a
Showing
13 changed files
with
198 additions
and
26 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 |
---|---|---|
@@ -1,31 +1,104 @@ | ||
#include "HAL/Claw.h" | ||
#include <iostream> | ||
|
||
// Claw movements | ||
|
||
Claw::Claw() | ||
{ | ||
// TODO - configure mechanism | ||
motor1.SetIdleMode(rev::CANSparkMax::IdleMode::kBrake); | ||
|
||
std::cout << "configured claw mechanism" << std::endl; | ||
} | ||
|
||
|
||
void ManualMovePivot(double speed) | ||
{ | ||
// Set specific usar input | ||
} | ||
double GetAngle() | ||
{ | ||
// Uses the claws usar input to take action | ||
return 0.0; | ||
} | ||
|
||
|
||
void ProfiledMoveToAngle(double angle) | ||
{ | ||
// Uses the claws usar input take action | ||
} | ||
|
||
|
||
double GetSpeed() | ||
{ | ||
|
||
return 0.0; | ||
//m_intakeSpeed; | ||
} | ||
|
||
|
||
void SetPosition() | ||
{ | ||
// Return to starting position | ||
} | ||
|
||
|
||
void PublishDebugInfo() | ||
{ | ||
} | ||
|
||
|
||
void ResetProfiledMoveState() | ||
{ | ||
//m_profileState = 0; | ||
} | ||
|
||
void Claw::Clasp() | ||
{ | ||
if (_signal != 1) | ||
{ | ||
std::cout << "claw is clasping" << std::endl; | ||
_signal = 1; | ||
} | ||
// if (_signal != 1) | ||
// { | ||
|
||
// _signal = 1; | ||
// } | ||
std::cout << "claw is clasping" << std::endl; | ||
motor1.Set(0.1); | ||
// TODO - implement mechanism to clasp | ||
|
||
} | ||
void Claw::Stop() | ||
{ | ||
motor1.Set(0); | ||
} | ||
/*int Claw::LauncherHAL() | ||
{ | ||
// Put together the compontent | ||
} | ||
*/ | ||
|
||
|
||
void SetClawSpeed(double speed) | ||
{ | ||
// Handle any usar input to take this action compontent | ||
} | ||
|
||
double GetClawSpeed() | ||
{ | ||
return 0; | ||
} | ||
|
||
void RunIntake(double speed) | ||
{ | ||
// Set motors to connect to certain speed | ||
} | ||
|
||
void Claw::Unclasp() | ||
{ | ||
if (_signal != 2) | ||
{ | ||
std::cout << "claw is unclasping" << std::endl; | ||
_signal = 2; | ||
} | ||
|
||
// if (_signal != 2) | ||
// { | ||
// std::cout << "claw is unclasping" << std::endl; | ||
// _signal = 2; | ||
// } | ||
std::cout << "claw is unclasping" << std::endl; | ||
motor1.Set(-0.1); | ||
// TODO - implement mechanism to clasp | ||
} |
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 |
---|---|---|
@@ -1,29 +1,47 @@ | ||
#include "HAL/Elevator.h" | ||
#include <iostream> | ||
#include <frc/Timer.h> | ||
|
||
|
||
Elevator::Elevator() | ||
{ | ||
m_profileState = 0; | ||
m_Timer = frc::Timer(); | ||
// TODO - configure motors | ||
std::cout << "configured elevator motors" << std::endl; | ||
} | ||
|
||
void Elevator::ProfiledMoveToHeight(double desired_height) | ||
void Elevator::ProfiledMoveToHeight(int shelfNumber) | ||
{ | ||
// TODO - implement profiled move semantics | ||
std::cout << "elevator performing profiled move to " << desired_height << std::endl; | ||
SetHeight(desired_height); | ||
std::cout << "elevator performing profiled move to " << shelfNumber << std::endl; | ||
// move elevator to (shelfNumber*15) inches | ||
shelfCurrent = shelfNumber; | ||
} | ||
|
||
double Elevator::GetHeight() | ||
{ | ||
// TODO - read motors for height | ||
// get data from motors | ||
std::cout << "elevator height measured as 0.0 inches" << std::endl; | ||
return 0.0f; | ||
} | ||
|
||
void Elevator::SetHeight(double desired_height) | ||
//setHeight switched to ProfiledMoveToHeight | ||
// void Elevator::SetHeight(double desired_height) | ||
// { | ||
// // TODO - set motors to go to height | ||
// std::cout << "elevator setting height to " << desired_height << std::endl; | ||
// } | ||
void Elevator::ShiftHeight(bool direction) | ||
{ | ||
// TODO - set motors to go to height | ||
std::cout << "elevator setting height to " << desired_height << std::endl; | ||
} | ||
std::string height_increase; | ||
// TODO - make motors go up or down | ||
if (direction==true){ | ||
height_increase = "up"; | ||
Elevator::ProfiledMoveToHeight(shelfCurrent+1); | ||
}else{ | ||
height_increase = "down"; | ||
Elevator::ProfiledMoveToHeight(shelfCurrent-1); | ||
} | ||
std::cout << "elevator moving" << height_increase << std::endl; | ||
|
||
} |
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,24 @@ | ||
#include "HAL/Claw.h" | ||
#include "InputManager/ClawManager.h" | ||
|
||
|
||
void ClawManager::HandleInput(RobotControlData& control_data) { | ||
if (control_data.clawInput.open){ | ||
m_claw.Unclasp(); | ||
} else if(control_data.clawInput.closed){ | ||
m_claw.Clasp(); | ||
} | ||
else | ||
{ | ||
m_claw.Stop(); | ||
} | ||
|
||
} | ||
void ClawManager::Reset(){ | ||
// No sensor, no reset | ||
} | ||
|
||
ClawManager::ClawManager() | ||
{ | ||
|
||
} |
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 "HAL/Elevator.h" | ||
#include "InputManager/ElevatorManager.h" | ||
#include <iostream> | ||
#include <frc/Timer.h> | ||
|
||
|
||
void HandleInput(RobotControlData& control_data) { | ||
if (control_data.elevatorInput.up) { | ||
m_elevator.ShiftHeight(true); | ||
}else if(control_data.elevatorInput.down) { | ||
m_elevator.ShiftHeight(false); | ||
} | ||
}; | ||
void Reset(){ | ||
m_elevator.ProfiledMoveToHeight(0); | ||
}; |
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
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 |
---|---|---|
@@ -1,21 +1,29 @@ | ||
#pragma once | ||
|
||
#include <frc/Timer.h> | ||
#include <rev/CANSparkMax.h> | ||
#include <frc/XboxController.h> | ||
|
||
|
||
|
||
class Elevator | ||
{ | ||
public: | ||
Elevator(); | ||
~Elevator() = default; | ||
|
||
// Functions that make using the elevator simple | ||
void ProfiledMoveToHeight(double desired_height); | ||
void ProfiledMoveToHeight(int shelf); | ||
void ShiftHeight(bool direction); | ||
|
||
double GetHeight(); | ||
int m_profileState = 0; | ||
|
||
private: | ||
|
||
// Raw set height used by profiled move to set the height | ||
void SetHeight(double desired_height); | ||
|
||
// TODO - define motors | ||
rev::CANSparkMax m_elevatorMotor{9, rev::CANSparkMax::MotorType::kBrushless}; | ||
frc::Timer m_Timer; | ||
int shelfCurrent; | ||
|
||
}; |
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
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