Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/drive straight #78

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
b640df0
code for new intake with wrist (#58)
danielbrownmsm Mar 23, 2023
3dd924a
feat/field-oriented-scoring (#62)
danielbrownmsm Mar 24, 2023
9759771
fix arm offset
danielbrownmsm Mar 25, 2023
1a284b5
Feat/wrist intake (#63)
danielbrownmsm Mar 25, 2023
25d4aeb
Merge branch 'scoring-integration' of https://github.com/Team-OKC-Rob…
danielbrownmsm Mar 25, 2023
298a021
fix intake wrist tilt encoder port
danielbrownmsm Mar 26, 2023
48aaeed
log the intake tilt output, setpoint, and sensor reading
danielbrownmsm Mar 26, 2023
b6f74a7
field-oriented intake tilting commands
danielbrownmsm Mar 26, 2023
0050fb7
wrap the tilt encoder because the zero-point is in a really annoying …
danielbrownmsm Mar 26, 2023
c7245a3
log the intake wrist values, and show them on shuffleboard,
danielbrownmsm Mar 26, 2023
917d674
if arm is close to 0 and trying to go to 0 then prevent it from oscil…
danielbrownmsm Mar 26, 2023
e5f1f32
reset gyro command bound to A-button
danielbrownmsm Mar 26, 2023
04c215f
added wrist setpoint to shuffleboard
danielbrownmsm Mar 26, 2023
e8aad74
made intake faster
danielbrownmsm Mar 26, 2023
5a33808
Merge branch 'master' into scoring-integration
danielbrownmsm Mar 26, 2023
895e017
started work on a command to pause auton execution for the arm
danielbrownmsm Mar 26, 2023
df3645d
Merge branch 'scoring-integration' of https://github.com/Team-OKC-Rob…
danielbrownmsm Mar 26, 2023
0408639
wrist setpoint on shuffleboard
danielbrownmsm Mar 27, 2023
fb8667c
fix extend thresholds/setpoints because we replaced the gearboxes
danielbrownmsm Mar 27, 2023
7b05742
intake wrist tilt tuning and fixing
danielbrownmsm Mar 27, 2023
3e82c1b
code no workey tilt then move claw arm thingy
danielbrownmsm Mar 27, 2023
563bdf3
Improved and Tuned Arm and Added ff to arm control
deadlyvortex Mar 28, 2023
7342a3c
fix arm setpoint, fix some intake setpoints, make the intake a little…
danielbrownmsm Mar 28, 2023
f466b8c
don't have the intake tilt to a 0 position inside the robot because w…
danielbrownmsm Mar 28, 2023
3cf9026
fix that last commit
danielbrownmsm Mar 28, 2023
cf670b0
log
danielbrownmsm Mar 28, 2023
61d5a25
make rhe a button have field-oriented human player station presets (t…
danielbrownmsm Mar 29, 2023
9e2d332
start work on a python arm vizualization script
danielbrownmsm Mar 30, 2023
24f12b4
Merge branch 'master' into Arm-Improvement-and-Tuning
danielbrownmsm Mar 30, 2023
53fa082
Merge branch 'feat/gyro-reset-button' into feat/GKC
danielbrownmsm Mar 30, 2023
5dd0f70
Merge branch 'Arm-Improvement-and-Tuning' into feat/GKC
danielbrownmsm Mar 30, 2023
deb2258
Merge branch 'feat/arm_viz' into feat/GKC
danielbrownmsm Mar 30, 2023
a0e9de3
made log-processing script only display the graphs if it's being run …
danielbrownmsm Mar 30, 2023
83f834e
expanded the arm-viz script so now we can actually visualize the arm …
danielbrownmsm Mar 30, 2023
ed4e7fc
add drawing the arm setpoint to the arm-viz script
danielbrownmsm Mar 30, 2023
fd3791f
fixed auton making the wrist go the wrong way
danielbrownmsm Mar 30, 2023
53faa18
raised intake power
danielbrownmsm Mar 30, 2023
c3c07dd
don't build unit tests at competition for faster deploy times
danielbrownmsm Mar 30, 2023
40a6894
fix setpoints
danielbrownmsm Mar 30, 2023
c924468
raise intake power, lower driving speed
danielbrownmsm Mar 30, 2023
ed27019
fix all the autos to use intake position
danielbrownmsm Mar 30, 2023
2804388
current limiting for intake
danielbrownmsm Mar 30, 2023
b81cee9
invert drive stick because it's going the wrong way
danielbrownmsm Mar 30, 2023
f5b2440
parameter tuning
danielbrownmsm Mar 30, 2023
0a8add1
palm the cube instead of intake it (we can't pick up cones from the g…
danielbrownmsm Mar 30, 2023
f61fdfa
actually use the length setpoint instead of moving both with the enco…
danielbrownmsm Mar 31, 2023
757c9c3
auto-balance tuning, invert strafing too, don't break our tilt at the…
danielbrownmsm Mar 31, 2023
d71c212
practice match logs
danielbrownmsm Mar 31, 2023
a00ebe4
competition logs
danielbrownmsm Mar 31, 2023
b9ecff9
honeslty not sure what I changed, don't care, also removed a bunch of…
danielbrownmsm Mar 31, 2023
080c5fa
Merge branch 'master' into feat/GKC
danielbrownmsm Apr 4, 2023
d588269
Merge branch 'feat/GKC' of https://github.com/Team-OKC-Robotics/FRC-2…
danielbrownmsm Apr 4, 2023
03fc265
drive straight in auto
danielbrownmsm Apr 8, 2023
b7a41eb
update to 2023.4.3
danielbrownmsm Apr 8, 2023
6039cd9
Merge branch 'master' into feat/drive-straight
danielbrownmsm Apr 8, 2023
012b99d
added straight drive to auto drive command
Apr 8, 2023
fafeaa4
Merge branch 'feat/drive-straight' of https://github.com/Team-OKC-Rob…
Apr 8, 2023
8e3acbd
enable unit tests
danielbrownmsm Apr 8, 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
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.4.2"
id "edu.wpi.first.GradleRIO" version "2023.4.3"
}

// Define my targets (RoboRIO) and artifacts (deployable files)
Expand Down
Binary file added logs/FRC_20230330_183315_MOKC_P4.wpilog
Binary file not shown.
Binary file added logs/FRC_20230330_191637_MOKC_P8.wpilog
Binary file not shown.
Binary file added logs/FRC_20230331_140811_MOKC_Q2.wpilog
Binary file not shown.
Binary file added logs/FRC_20230331_150043_MOKC_Q8.wpilog
Binary file not shown.
Binary file added logs/FRC_20230331_160108_MOKC_Q13.wpilog
Binary file not shown.
Binary file added logs/FRC_20230331_181809_MOKC_Q23.wpilog
Binary file not shown.
20 changes: 10 additions & 10 deletions src/main/cpp/autos/ScorePreloadedAuto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ ScorePreloadedAuto::ScorePreloadedAuto(std::shared_ptr<SwerveDrive> swerve, std:
double score_position = RobotParams::GetParam("arm.score_high.intake_setpoint", 0.0);

AddCommands(
IntakeCommand(intake, -0.1), // hold the cube/cone in
ArmSetStateCommand(arm, TeamOKC::ArmState(extend, degrees)),
frc2::WaitCommand(units::second_t(3.0)), // wait for the command to finish
frc2::WaitCommand(units::second_t(1.5)), // wait for the command to finish
IntakeCommand(intake, 0.3), // drop the cube
frc2::WaitCommand(units::second_t(0.5)), // wait for cube to be dropped
IntakeCommand(intake, 0), // stop the intake
ArmSetStateCommand(arm, TeamOKC::ArmState(1, 0)), // bring the arm back in the robot
frc2::WaitCommand(units::second_t(2)), // wait a second
AutoDriveCommand(swerve, 4.7, 1) // back slowly away
// IntakeCommand(intake, -0.1), // hold the cube/cone in
// ArmSetStateCommand(arm, TeamOKC::ArmState(extend, degrees)),
// frc2::WaitCommand(units::second_t(3.0)), // wait for the command to finish
// frc2::WaitCommand(units::second_t(1.5)), // wait for the command to finish
// IntakeCommand(intake, 0.3), // drop the cube
// frc2::WaitCommand(units::second_t(0.5)), // wait for cube to be dropped
// IntakeCommand(intake, 0), // stop the intake
// ArmSetStateCommand(arm, TeamOKC::ArmState(1, 0)), // bring the arm back in the robot
// frc2::WaitCommand(units::second_t(2)), // wait a second
AutoDriveCommand(swerve, 2.0, 1, 0) // back slowly away
);
}
6 changes: 3 additions & 3 deletions src/main/cpp/autos/ScoreTwoAuto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ ScoreTwoAuto::ScoreTwoAuto(std::shared_ptr<SwerveDrive> swerve, std::shared_ptr<
IntakeCommand(intake, 0), // stop the intake
ArmSetStateCommand(arm, TeamOKC::ArmState(1, 0)), // bring the arm back in the robot
frc2::WaitCommand(units::second_t(2)), // wait a second
AutoDriveCommand(swerve, 5, 1), // back slowly away
AutoDriveCommand(swerve, 5, 1, 0), // back slowly away
ArmSetStateCommand(arm, TeamOKC::ArmState(negative_pickup_extend, negative_pickup_degrees)), // get ready to pick another one up
IntakeCommand(intake, -0.3), // suck the cube in
AutoDriveCommand(swerve, 0.5, 0.2), // drive into the cube
AutoDriveCommand(swerve, 0.5, 0.2, 0), // drive into the cube
IntakeCommand(intake, -0.1), // just hold the cube in, not too much power
ArmSetStateCommand(arm, TeamOKC::ArmState(extend, degrees)), // set the arm to score high
AutoDriveCommand(swerve, -5, 0.5), // drive back to the station
AutoDriveCommand(swerve, -5, 0.5, 0), // drive back to the station
IntakeCommand(intake, 1.0) // spit the cube out really hard, hopefully it lands in the right spot
// and we should be out of time, really.
);
Expand Down
6 changes: 4 additions & 2 deletions src/main/cpp/commands/swerve/AutoDriveCommand.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

#include "commands/swerve/AutoDriveCommand.h"

AutoDriveCommand::AutoDriveCommand(std::shared_ptr<SwerveDrive> swerve, double dist, double max_speed) {
AutoDriveCommand::AutoDriveCommand(std::shared_ptr<SwerveDrive> swerve, double dist, double max_speed, double heading) {
swerve_ = swerve;
dist_ = dist;
max_speed_ = max_speed;
heading_ = heading;


if (swerve_ != nullptr) {
this->AddRequirements(swerve_.get());
Expand All @@ -22,7 +24,7 @@ void AutoDriveCommand::Initialize() {
}

void AutoDriveCommand::Execute() {
VOKC_CALL(swerve_->DriveAuto(max_speed_));
VOKC_CALL(swerve_->DriveAuto(max_speed_, heading_));
}

void AutoDriveCommand::End(bool interrupted) {
Expand Down
64 changes: 25 additions & 39 deletions src/main/cpp/subsystems/SwerveDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,23 @@ bool SwerveDrive::AtDistSetpoint(bool *at) {
return true;
}

bool SwerveDrive::DriveAuto(double max_speed) {
bool SwerveDrive::DriveAuto(double max_speed, double heading) {
OKC_CHECK(this->interface_ != nullptr);

double dist = 0;
OKC_CALL(this->left_front_module_->GetDistance(&dist));

double drive_power = this->dist_pid_->Calculate(dist);

this->interface_->left_front_drive_motor_output = drive_power;
this->interface_->left_back_drive_motor_output = drive_power;
this->interface_->right_front_drive_motor_output = drive_power;
this->interface_->right_back_drive_motor_output = drive_power;
double gyro_reading = 0.0;
OKC_CALL(this->GetHeading(&gyro_reading));

double turn_power = this->heading_pid_->Calculate(gyro_reading);

this->interface_->left_front_drive_motor_output = drive_power + turn_power;
this->interface_->left_back_drive_motor_output = drive_power + turn_power;
this->interface_->right_front_drive_motor_output = drive_power - turn_power;
this->interface_->right_back_drive_motor_output = drive_power - turn_power;

// clamp the speed
TeamOKC::Clamp(-max_speed, max_speed, &this->interface_->left_front_drive_motor_output);
Expand All @@ -342,17 +347,24 @@ bool SwerveDrive::DriveAuto(double max_speed) {


// just drive straight
OKC_CALL(this->left_front_module_->SetAngle(0));
OKC_CALL(this->left_back_module_->SetAngle(0));
OKC_CALL(this->right_front_module_->SetAngle(0));
OKC_CALL(this->right_back_module_->SetAngle(0));
OKC_CALL(SetSteerOutput(heading));

return true;
}

bool SwerveDrive::SetSteerOutput(double angle) {
OKC_CHECK(interface_ != nullptr);

OKC_CALL(this->left_front_module_->SetAngle(angle));
OKC_CALL(this->left_back_module_->SetAngle(angle));
OKC_CALL(this->right_front_module_->SetAngle(angle));
OKC_CALL(this->right_back_module_->SetAngle(angle));

OKC_CALL(this->left_front_module_->GetSteerOutput(&this->interface_->left_front_steer_motor_output));
OKC_CALL(this->left_back_module_->GetSteerOutput(&this->interface_->left_back_steer_motor_output));
OKC_CALL(this->right_front_module_->GetSteerOutput(&this->interface_->right_front_steer_motor_output));
OKC_CALL(this->right_back_module_->GetSteerOutput(&this->interface_->right_back_steer_motor_output));


return true;
}

Expand All @@ -365,15 +377,7 @@ bool SwerveDrive::AutoBalance(double sign) {
this->interface_->right_back_drive_motor_output = run_up_speed_ * sign;

// and keep our wheels straight
OKC_CALL(this->left_front_module_->SetAngle(0.0));
OKC_CALL(this->left_back_module_->SetAngle(0.0));
OKC_CALL(this->right_front_module_->SetAngle(0.0));
OKC_CALL(this->right_back_module_->SetAngle(0.0));

OKC_CALL(this->left_front_module_->GetSteerOutput(&this->interface_->left_front_steer_motor_output));
OKC_CALL(this->left_back_module_->GetSteerOutput(&this->interface_->left_back_steer_motor_output));
OKC_CALL(this->right_front_module_->GetSteerOutput(&this->interface_->right_front_steer_motor_output));
OKC_CALL(this->right_back_module_->GetSteerOutput(&this->interface_->right_back_steer_motor_output));
OKC_CALL(SetSteerOutput(0.0));

// once we've tilted enough, then we can move on to climbing slower to avoid rocketing over the thing
if (this->interface_->imu_pitch > tilted_threshold_*sign) {
Expand All @@ -387,16 +391,7 @@ bool SwerveDrive::AutoBalance(double sign) {
this->interface_->right_back_drive_motor_output = tilted_speed_ * sign;

// keep the wheels straight
OKC_CALL(this->left_front_module_->SetAngle(0.0));
OKC_CALL(this->left_back_module_->SetAngle(0.0));
OKC_CALL(this->right_front_module_->SetAngle(0.0));
OKC_CALL(this->right_back_module_->SetAngle(0.0));

OKC_CALL(this->left_front_module_->GetSteerOutput(&this->interface_->left_front_steer_motor_output));
OKC_CALL(this->left_back_module_->GetSteerOutput(&this->interface_->left_back_steer_motor_output));
OKC_CALL(this->right_front_module_->GetSteerOutput(&this->interface_->right_front_steer_motor_output));
OKC_CALL(this->right_back_module_->GetSteerOutput(&this->interface_->right_back_steer_motor_output));

OKC_CALL(SetSteerOutput(0.0));

// once we've tipped over the station, then we need to drive backwards a little bit
if (interface_->imu_pitch < reverse_threshold_*sign) {
Expand All @@ -409,16 +404,7 @@ bool SwerveDrive::AutoBalance(double sign) {
this->interface_->right_front_drive_motor_output = drive_backward_speed_ * sign;
this->interface_->right_back_drive_motor_output = drive_backward_speed_ * sign;

OKC_CALL(this->left_front_module_->SetAngle(0.0));
OKC_CALL(this->left_back_module_->SetAngle(0.0));
OKC_CALL(this->right_front_module_->SetAngle(0.0));
OKC_CALL(this->right_back_module_->SetAngle(0.0));

OKC_CALL(this->left_front_module_->GetSteerOutput(&this->interface_->left_front_steer_motor_output));
OKC_CALL(this->left_back_module_->GetSteerOutput(&this->interface_->left_back_steer_motor_output));
OKC_CALL(this->right_front_module_->GetSteerOutput(&this->interface_->right_front_steer_motor_output));
OKC_CALL(this->right_back_module_->GetSteerOutput(&this->interface_->right_back_steer_motor_output));

OKC_CALL(SetSteerOutput(0.0));

// and then if we're balanced, go ahead and stop us
if (abs(interface_->imu_pitch) < pitch_threshold_*sign) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/include/commands/swerve/AutoDriveCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AutoDriveCommand
*
* @param swerve The swerve drive used by this command.
*/
explicit AutoDriveCommand(std::shared_ptr<SwerveDrive> swerve, double dist, double max_speed);
explicit AutoDriveCommand(std::shared_ptr<SwerveDrive> swerve, double dist, double max_speed, double heading);

void Initialize() override;
void Execute() override;
Expand All @@ -30,4 +30,6 @@ class AutoDriveCommand
std::shared_ptr<SwerveDrive> swerve_;
double dist_;
double max_speed_;
double heading_;

};
3 changes: 2 additions & 1 deletion src/main/include/subsystems/SwerveDrive.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ class SwerveDrive : public frc2::SubsystemBase {

bool InitAuto(TeamOKC::Pose pos, bool keep_heading);
bool SetDistance(double dist);
bool DriveAuto(double max_speed);
bool DriveAuto(double max_speed, double heading);
bool AtDistSetpoint(bool *at);
bool SetSteerOutput(double angle);

bool AutoBalance(double sign);
bool AtBalanceSetpoint(bool *at);
Expand Down