Skip to content

Commit

Permalink
Implemented #927 and added default constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis-Leyva committed Dec 15, 2024
1 parent 026b33d commit 98f5aa7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include "pathplanner/lib/util/swerve/SwerveSetpointGenerator.h"

SwerveSetpointGenerator::SwerveSetpointGenerator() {
this->config = nullptr;
this->maxSteerVelocity = 0_rad_per_s;
}

SwerveSetpointGenerator::SwerveSetpointGenerator(RobotConfig *config,
units::radians_per_second_t maxSteerVelocity) {
this->config = config;
Expand Down Expand Up @@ -213,10 +218,12 @@ SwerveSetpoint SwerveSetpointGenerator::generateSetpoint(
chassisForceVec = chassisForceVec + moduleForceVec;

// Calculate the torque this module will apply to the chassis
frc::Rotation2d angleToModule = config->moduleLocations[m].Angle();
frc::Rotation2d theta = moduleForceVec.Angle() - angleToModule;
chassisTorque += forceAtCarpet * config->modulePivotDistance[m]
* theta.Sin();
if (!epsilonEquals(0, moduleForceVec.Norm().value())) {
frc::Rotation2d angleToModule = config->moduleLocations[m].Angle();
frc::Rotation2d theta = moduleForceVec.Angle() - angleToModule;
chassisTorque += forceAtCarpet * config->modulePivotDistance[m]
* theta.Sin();
}
}

frc::Translation2d chassisAccelVec = chassisForceVec / config->mass.value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ using namespace pathplanner;
class SwerveSetpointGenerator {
public:

/**
* Create a new swerve setpoint generator
*/
SwerveSetpointGenerator();

/**
* Create a new swerve setpoint generator
*
Expand Down

0 comments on commit 98f5aa7

Please sign in to comment.