Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
17d2885
added hardware files
Jan 12, 2023
b8d2f6e
changed names of motors
Jan 12, 2023
b64846a
defined
Jan 13, 2023
d0d54e7
labeled buttons
Jan 13, 2023
2a914ec
arm sw, hw, cpp, and IO
Jan 14, 2023
ce32b48
changed file names
AbbeySieg Jan 14, 2023
dcc6c2d
renamed more files
AbbeySieg Jan 14, 2023
e277766
added swerve drive to branch
AbbeySieg Jan 14, 2023
72adfe6
changed hw, actua, and sen names
Jan 16, 2023
7db2094
changed names
Jan 16, 2023
e9bf872
it's being weird
Jan 16, 2023
db16ef7
test commit
X-EX3-X Jan 21, 2023
91016a4
functions added I think
X-EX3-X Jan 21, 2023
c15cb65
last changes for 1-21-23, added parameter,util
X-EX3-X Jan 21, 2023
b7b9314
I update the hardware and software interfaces
Jan 28, 2023
8e06a1e
I changed the software and hardware interfaces and I defined function…
Jan 28, 2023
c102f34
Merge branch 'feat/actual_claw' of https://github.com/Team-OKC-Roboti…
Jan 28, 2023
d43dd10
fleshed out claw subsystem
Jan 28, 2023
df6ec31
Merge branch 'master' into feat/actual_claw
Jan 28, 2023
f8333d7
IT WORKSSSS EVERYTHING WORKSSSSSSSSSSSSSSS
Jan 28, 2023
b2d58fb
fixed include error, added Reset() to claw
Jan 28, 2023
69e94f8
The changes Justin asked for
X-EX3-X Feb 13, 2023
4fa5a99
final changes i think
X-EX3-X Feb 17, 2023
3e6ad25
fixed errors
X-EX3-X Feb 20, 2023
9203b9e
Merge branch 'master' into feat/actual_claw
X-EX3-X Feb 20, 2023
0ee8017
final changes hopefully
X-EX3-X Feb 20, 2023
dfabc38
changing the #include
X-EX3-X Feb 21, 2023
b705eca
solving the case errors
X-EX3-X Feb 21, 2023
3a3b2f5
removed claw files for fix
X-EX3-X Feb 21, 2023
b3e2f7a
added files back
X-EX3-X Feb 21, 2023
ec4a031
change backwards slash to a forwards slash because maybe that's makin…
danielbrownmsm Feb 21, 2023
4ae2d05
fix backward->forward slash in ClawIO.cpp
danielbrownmsm Feb 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 74 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,78 @@
"**/.factorypath": true,
"**/*~": true
},
"C_Cpp.default.configurationProvider": "vscode-wpilib"
"C_Cpp.default.configurationProvider": "vscode-wpilib",
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"cfenv": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"variant": "cpp"
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2023.1.1"
id "edu.wpi.first.GradleRIO" version "2023.2.1"
}

// Define my targets (RoboRIO) and artifacts (deployable files)
Expand Down
29 changes: 29 additions & 0 deletions src/main/cpp/IO/ClawIO.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

#include "io/ClawIO.h"

void ClawIO::Periodic() {
// Process all the inputs and outputs to/from high level software.
VOKC_CALL(ProcessIO());
}

void ClawIO::SimulationPeriodic() {
// SimulationPeriodic
}

bool ClawIO::ProcessIO() {
OKC_CHECK(sw_interface_ != nullptr);
OKC_CHECK(hw_interface_ != nullptr);

// Set the software outputs
// If the encoder should be reset, reset it
if (sw_interface_->reset_claw_open_and_close) {
hw_interface_->claw_open_and_close_encoder->SetPosition (0);
// Lower the encoder reset flag
sw_interface_->reset_claw_open_and_close = false;
}
hw_interface_->claw_open_and_close_motor->Set (sw_interface_->claw_open_and_close_power);
sw_interface_->encoder_reading = hw_interface_->claw_open_and_close_encoder->GetPosition();

return true;
}

33 changes: 33 additions & 0 deletions src/main/cpp/Paramaters.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "Parameters.h"

namespace RobotParams {
toml::table parameters;

// Save parameter file location.
std::string param_file =
frc::filesystem::GetDeployDirectory() + "/parameters.toml";

bool LoadParameters(const std::string &path) {
// Load the parameters from a file.
try {
parameters = toml::parse_file(path.c_str());
} catch (const toml::parse_error &err) {
std::cerr << "Parsing failed:\n" << err << "\n";
return false;
}

return true;
}

bool SaveParameters(const std::string &path) {
// Output the parameters table to the file.
std::ofstream file;
file.open(path, std::ofstream::out | std::ofstream::trunc);
file << parameters << std::flush;
file.close();

return true;
}

} // namespace RobotParams

21 changes: 21 additions & 0 deletions src/main/cpp/Utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "Utils.h"

namespace TeamOKC {
// TODO: make this a templated function.
bool Clamp(const double &lower, const double &upper, double *value) {
OKC_CHECK(value != nullptr);

// Ensure value is not lower than the minimum or higher than the
// maximum. If it is out of the bounds, set it to the boundary value it
// violates.
if (*value < lower) {
*value = lower;
} else if (*value > upper) {
*value = upper;
} else {
// Nothing to do here, value is within the range.
}

return true;
}
} // namespace TeamOKC
21 changes: 21 additions & 0 deletions src/main/cpp/subsystems/claw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "subsystems/Claw.h"

bool Claw::Init(){
return true;
}

bool Claw::ResetPositionEncoder(){
return true;
}
bool Claw::ResetPositionPID(){
return true;
}
bool Claw::SetPosition(){
// SetPosition (30); //cone
// SetPosition (0); //close
// SetPosition (50);//cube
return true;
}
bool Claw::Reset(){
return true;
}
28 changes: 28 additions & 0 deletions src/main/include/Parameters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

#pragma once

#include <fstream>
#include <string.h>

#include <frc/Filesystem.h>

#include "Utils.h"
#include "third_party/toml.hpp"

namespace RobotParams {
extern toml::table parameters;
extern std::string param_file;

bool LoadParameters(const std::string &path);
bool SaveParameters(const std::string &path);

template <typename T>
T GetParam(const std::string_view &path, T default_val) {
return parameters.at_path(path).value_or(default_val);
}

template <typename T> bool SetParam(const std::string_view &path, T value) {
parameters.insert_or_assign(path, value);
return true;
}
} // namespace RobotParams
46 changes: 45 additions & 1 deletion src/main/include/RobotContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

#include <frc2/command/Command.h>


#include "frc/Joystick.h"
#include "frc2/command/button/JoystickButton.h"

/**
* This class is where the bulk of the robot should be declared. Since
Expand All @@ -26,4 +27,47 @@ class RobotContainer {


void ConfigureButtonBindings();

std::shared_ptr<frc::Joystick> gamepad1_;
std::shared_ptr<frc::Joystick> gamepad2_;

std::shared_ptr<frc2::JoystickButton> driver_a_button_;
std::shared_ptr<frc2::JoystickButton> driver_b_button_;
std::shared_ptr<frc2::JoystickButton> driver_back_button_;
std::shared_ptr<frc2::JoystickButton> driver_left_bumper_;
std::shared_ptr<frc2::JoystickButton> driver_right_bumper_;

std::shared_ptr<frc2::JoystickButton> manip_a_button_;
std::shared_ptr<frc2::JoystickButton> manip_b_button_;
std::shared_ptr<frc2::JoystickButton> manip_left_stick_button_;
std::shared_ptr<frc2::JoystickButton> manip_right_stick_button;

std::shared_ptr<frc2::JoystickButton> manip_trigger_button_;
std::shared_ptr<frc2::JoystickButton> manip_left_button_;
std::shared_ptr<frc2::JoystickButton> manip_bottom_right_button_;
std::shared_ptr<frc2::JoystickButton> manip_top_right_button_;
std::shared_ptr<frc2::JoystickButton> manip_botton_left_button_;
std::shared_ptr<frc2::JoystickButton> manip_top_left_button_;

std::shared_ptr<frc2::JoystickButton> manip_seven_button_;
std::shared_ptr<frc2::JoystickButton> manip_eight_button_;
std::shared_ptr<frc2::JoystickButton> manip_nine_button_;
std::shared_ptr<frc2::JoystickButton> manip_ten_button_;
std::shared_ptr<frc2::JoystickButton> manip_eleven_button_;
std::shared_ptr<frc2::JoystickButton> manip_twelve_button_;

std::shared_ptr<frc2::JoystickButton> manip_A_button_;
std::shared_ptr<frc2::JoystickButton> manip_B_button_;
std::shared_ptr<frc2::JoystickButton> manip_X_button_;
std::shared_ptr<frc2::JoystickButton> manip_Y_button_;
std::shared_ptr<frc2::JoystickButton> manip_RB_button_;
std::shared_ptr<frc2::JoystickButton> manip_LB_button_;
std::shared_ptr<frc2::JoystickButton> manip_RT_button_;
std::shared_ptr<frc2::JoystickButton> manip_LT_button_;
std::shared_ptr<frc2::JoystickButton> manip_back_button_;
std::shared_ptr<frc2::JoystickButton> manip_start_button_;
std::shared_ptr<frc2::JoystickButton> manip_mode_button_;

};


61 changes: 61 additions & 0 deletions src/main/include/Utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

#pragma once

#include <iostream>

// Despite what VS Code highlighting might suggest, this uses __FUNCTION__ when
// compiliing using Visual Studio on Windows, and otherwise uses
// __PRETTY_FUNCTION__
#if !defined(__PRETTY_FUNCTION__) && !defined(__GNUC__)
#define __SHOW_LINE_INFO__ __FUNCTION__
#else
#define __SHOW_LINE_INFO__ __PRETTY_FUNCTION__
#endif

#define OKC_CALL(res) \
if (!(res)) { \
std::cerr << "OKC_CHECK FAIL [" << __FILE__ << ":" << __LINE__ \
<< "] - " << __SHOW_LINE_INFO__ << std::endl; \
return false; \
}

#define OKC_CHECK(check) \
if (!(check)) { \
std::cerr << "OKC_CHECK FAIL [" << __FILE__ << ":" << __LINE__ \
<< "] - " << __SHOW_LINE_INFO__ << std::endl; \
return false; \
}

#define OKC_CHECK_MSG(check, msg) \
if (!(check)) { \
std::cerr << "OKC_CHECK FAIL [" << __FILE__ << ":" << __LINE__ \
<< "] - " << __SHOW_LINE_INFO__ << ": " << msg << std::endl; \
return false; \
}

#define VOKC_CALL(res) \
if (!(res)) { \
std::cerr << "OKC_CHECK FAIL [" << __FILE__ << ":" << __LINE__ \
<< "] - " << __SHOW_LINE_INFO__ << std::endl; \
return; \
}

#define VOKC_CHECK(check) \
if (!(check)) { \
std::cerr << "OKC_CHECK FAIL [" << __FILE__ << ":" << __LINE__ \
<< "] - " << __SHOW_LINE_INFO__ << std::endl; \
return; \
}

#define VOKC_CHECK_MSG(check, msg) \
if (!(check)) { \
std::cerr << "OKC_CHECK FAIL [" << __FILE__ << ":" << __LINE__ \
<< "] - " << __SHOW_LINE_INFO__ << ": " << msg << std::endl; \
return; \
}

namespace TeamOKC {

bool Clamp(const double &lower, const double &upper, double *value);

}
Loading