Skip to content

Commit

Permalink
added field to dash
Browse files Browse the repository at this point in the history
  • Loading branch information
r4stered committed Nov 1, 2024
1 parent ee8503b commit c5306ae
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
19 changes: 19 additions & 0 deletions elastic-layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,25 @@
"topic": "/CameraPublisher/str_fr_cam-processed",
"period": 0.06
}
},
{
"title": "Field",
"x": 512.0,
"y": 0.0,
"width": 896.0,
"height": 704.0,
"type": "Field",
"properties": {
"topic": "/SmartDashboard/Field",
"period": 0.06,
"field_game": "Crescendo",
"robot_width": 0.868426,
"robot_length": 0.85725,
"show_other_objects": true,
"show_trajectories": true,
"robot_color": 4286120191,
"trajectory_color": 4294967295
}
}
]
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/cpp/str/SwerveDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <str/DriverstationUtils.h>
#include <frc/DataLogManager.h>
#include <frc/smartdashboard/SmartDashboard.h>

#include "constants/Constants.h"
#include "str/Math.h"
Expand Down Expand Up @@ -59,6 +60,7 @@ SwerveDrive::SwerveDrive() {
}

lastOdomUpdateTime = frc::Timer::GetFPGATimestamp();
frc::SmartDashboard::PutData(&field);
}

void SwerveDrive::ResetPose(const frc::Pose2d& resetPose) {
Expand Down Expand Up @@ -205,6 +207,7 @@ void SwerveDrive::UpdateNTEntries() {
estimatorPub.Set(GetPose());
//isSlippingPub.Set(IsSlipping());
odomUpdateRatePub.Set(odomUpdateRate.value());
field.SetRobotPose(GetPose());
}

void SwerveDrive::SimulationPeriodic() {
Expand Down
3 changes: 3 additions & 0 deletions src/main/include/str/SwerveDrive.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "constants/SwerveConstants.h"
#include "str/SwerveModule.h"
#include <frc/smartdashboard/Field2d.h>

namespace str {
class SwerveDrive {
Expand Down Expand Up @@ -164,6 +165,8 @@ class SwerveDrive {
units::second_t lastOdomUpdateTime;
units::hertz_t odomUpdateRate;

frc::Field2d field{};

std::shared_ptr<nt::NetworkTable> nt{
nt::NetworkTableInstance::GetDefault().GetTable("SwerveDrive")};
nt::BooleanPublisher isSlippingPub{
Expand Down

0 comments on commit c5306ae

Please sign in to comment.