Skip to content

Commit

Permalink
Logging of ATVision poses
Browse files Browse the repository at this point in the history
  • Loading branch information
tssmith7 committed Nov 10, 2023
1 parent ab743a9 commit 37bf7d1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/cpp/commands/autonomous/BalanceAuto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// For more information, see:
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
BalanceAuto::BalanceAuto(Drivetrain* drive, ArmSubsystem* arm, GrabberSubsystem* grabber) {
frc::Pose2d redAllianceTargetPoints[2] = { drive->redAllianceGridPoints[3], drive->redAllianceGridPoints[5] };
frc::Pose2d blueAllianceTargetPoints[2] = { drive->blueAllianceGridPoints[3], drive->blueAllianceGridPoints[5] };
// frc::Pose2d redAllianceTargetPoints[2] = { drive->redAllianceGridPoints[3], drive->redAllianceGridPoints[5] };
// frc::Pose2d blueAllianceTargetPoints[2] = { drive->blueAllianceGridPoints[3], drive->blueAllianceGridPoints[5] };
fmt::print("BalanceAuto::BalanceAuto\n");

units::meter_t auto_drive_distance = 2.25_m;
Expand Down
4 changes: 2 additions & 2 deletions src/main/cpp/commands/autonomous/PlaceOnlyAuto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
// For more information, see:
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
PlaceOnlyAuto::PlaceOnlyAuto( Drivetrain *drive, ArmSubsystem *arm, GrabberSubsystem *grabber ) {
frc::Pose2d redAllianceTargetPoints[2] = { drive->redAllianceGridPoints[3], drive->redAllianceGridPoints[5] };
frc::Pose2d blueAllianceTargetPoints[2] = { drive->blueAllianceGridPoints[3], drive->blueAllianceGridPoints[5] };
// frc::Pose2d redAllianceTargetPoints[2] = { drive->redAllianceGridPoints[3], drive->redAllianceGridPoints[5] };
// frc::Pose2d blueAllianceTargetPoints[2] = { drive->blueAllianceGridPoints[3], drive->blueAllianceGridPoints[5] };
fmt::print( "PlaceOnlyAuto::PlaceOnlyAuto\n" );
// If on blue side, do blue auto
if ( drive->GetPose().X() < 7.5_m ) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/cpp/subsystems/Limelight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
#include <iostream>

#include <frc/Timer.h>
#include <frc/DataLogManager.h>

#include "subsystems/Limelight.h"

Limelight::Limelight()
{
m_poseLogEntry = wpi::log::DoubleArrayLogEntry( frc::DataLogManager::GetLog(), "/ATVision/Robot2D" );

// frc::SmartDashboard::PutData("Field2", &m_field);
}

Expand Down Expand Up @@ -56,6 +59,10 @@ bool Limelight::getFieldAprilTagPose( frc::Pose2d&april_tag_pose, units::second_
// See https://docs.limelightvision.io/en/latest/apriltags_in_3d.html#using-wpilib-s-pose-estimator
timestamp = frc::Timer::GetFPGATimestamp() - units::second_t{ botpose[6]/1000.0 };

m_poseLogEntry.Append( { april_tag_pose.X().value(),
april_tag_pose.Y().value(),
april_tag_pose.Rotation().Degrees().value() }, timestamp.value() );

return true;
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/include/subsystems/Limelight.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include <frc/geometry/Pose2d.h>
#include <frc/geometry/Rotation2d.h>
#include <frc2/command/SubsystemBase.h>

#include <wpi/DataLog.h>

#include "Constants.h"

class Limelight : public frc2::SubsystemBase {
Expand Down Expand Up @@ -46,4 +49,5 @@ class Limelight : public frc2::SubsystemBase {
frc::Pose2d l_Pose;
units::degree_t rZ;
frc::Pose2d t_speeds;
wpi::log::DoubleArrayLogEntry m_poseLogEntry;
};

0 comments on commit 37bf7d1

Please sign in to comment.