Skip to content

Commit

Permalink
log desired states (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
5690Programmers authored Jun 15, 2024
1 parent fb0bd1f commit 3d1039f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/cpp/subsystems/DriveSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ DriveSubsystem::DriveSubsystem(PhotonVisionEstimators* vision)
nt::NetworkTableInstance::GetDefault()
.GetStructArrayTopic<frc::SwerveModuleState>("/SwerveStates")
.Publish();
m_desiredPublisher =
nt::NetworkTableInstance::GetDefault()
.GetStructArrayTopic<frc::SwerveModuleState>("/SwerveDesiredStates")
.Publish();
}

void DriveSubsystem::SimulationPeriodic() {
Expand Down Expand Up @@ -190,8 +194,13 @@ void DriveSubsystem::logDrivebase() {
m_rearLeft.GetState(), m_rearRight.GetState()};
std::span<frc::SwerveModuleState, 4> states(states_vec.begin(),
states_vec.end());
std::vector desired_vec = {m_frontLeft.GetDesiredState(), m_frontRight.GetDesiredState(),
m_rearLeft.GetDesiredState(), m_rearRight.GetDesiredState()};
std::span<frc::SwerveModuleState, 4> desiredStates(desired_vec.begin(),
desired_vec.end());

m_publisher.Set(states);
m_desiredPublisher.Set(desiredStates);
}

void DriveSubsystem::AddVisionMeasurement(const frc::Pose2d& visionMeasurement,
Expand Down
1 change: 1 addition & 0 deletions src/main/include/subsystems/DriveSubsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class DriveSubsystem : public frc2::SubsystemBase {
VisionConstants::kDrivetrainStd,
VisionConstants::kVisionStd};
nt::StructArrayPublisher<frc::SwerveModuleState> m_publisher;
nt::StructArrayPublisher<frc::SwerveModuleState> m_desiredPublisher;

// Pose viewing
frc::Field2d m_field;
Expand Down

0 comments on commit 3d1039f

Please sign in to comment.