Skip to content

Driver Network Table #29

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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion src/main/cpp/RobotContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <frc2/command/StartEndCommand.h>
#include <frc2/command/WaitUntilCommand.h>

#include <networktables/NetworkTableInstance.h>

#include "commands/AimCommand.h"
#include "commands/AimShootCommand.h"
#include "commands/SimpleDriveCommand.h"
Expand Down Expand Up @@ -68,6 +70,7 @@ RobotContainer::RobotContainer () {
frc2::CommandScheduler::GetInstance().RegisterSubsystem(m_PowerCellCounter);

InitAutonomousChooser();
// Remember to put this in the driver table later?
frc::SmartDashboard::PutData("Auto Modes", &m_DashboardAutoChooser);

// Configure the button bindings
Expand Down Expand Up @@ -343,5 +346,6 @@ void RobotContainer::ReportSelectedAuto () {
name = m_DashboardAutoChooser.GetDefaultName();
}

frc::SmartDashboard::PutString("Robot sees autonomous", name);
auto drivetable = nt::NetworkTableInstance::GetDefault().GetTable(NetTabs::DriveTeamTable);
drivetable->PutString("Robot Sees AutoMode:", name);
}
5 changes: 4 additions & 1 deletion src/main/cpp/subsystems/Climb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <ctre/phoenix/motorcontrol/ControlMode.h>
#include <frc/smartdashboard/SmartDashboard.h>
#include <networktables/NetworkTableInstance.h>

#include <algorithm>

Expand All @@ -11,7 +12,9 @@
Climb::Climb () {}

void Climb::Periodic () {
frc::SmartDashboard::PutBoolean("Winch Locked", m_IsWinchLocked);
auto drivetable = nt::NetworkTableInstance::GetDefault().GetTable(NetTabs::DriveTeamTable);
drivetable->PutBoolean("Winch Locked", m_IsWinchLocked);
drivetable->PutBoolean("Climb Piston Extended", m_IsPistonExtended);
}

void Climb::PistonExtend () {
Expand Down
10 changes: 6 additions & 4 deletions src/main/cpp/subsystems/Shooter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,16 @@ void Shooter::SetLimelightLight (bool on) {
}

void Shooter::TrackingPeriodic (TrackingMode mode) {
auto drivetable = nt::NetworkTableInstance::GetDefault().GetTable(NetTabs::DriveTeamTable);

if (mode == TrackingMode::CameraTracking) {
double speed = 0;

m_TargetCount = (int) m_VisionTable->GetNumber("tv", -1);

if (m_TargetCount > 0) {
std::cout << "Count: " << m_TargetCount << std::endl;
frc::SmartDashboard::PutBoolean("Limelight Has Target", true);
drivetable->PutBoolean("Limelight Has Target", true);

m_TargetErrorX = -m_VisionTable->GetNumber("tx", 0);
m_TargetErrorY = -m_VisionTable->GetNumber("ty", 0);
Expand All @@ -189,15 +191,15 @@ void Shooter::TrackingPeriodic (TrackingMode mode) {
speed = m_TurretPID->Calculate(m_TargetErrorX);
} else if (m_TargetCount == 0) {
std::cout << "No objects detected" << std::endl;
frc::SmartDashboard::PutBoolean("Limelight Has Target", false);
drivetable->PutBoolean("Limelight Has Target", false);
} else {
std::cout << "Variable tv does not exist in table limelight-gears" << std::endl;
frc::SmartDashboard::PutBoolean("Limelight Has Target", false);
drivetable->PutBoolean("Limelight Has Target", false);
}

SetTurretSpeed(speed);
} else {
frc::SmartDashboard::PutBoolean("Limelight Has Target", false);
drivetable->PutBoolean("Limelight Has Target", false);
SetLimelightLight(false);
return;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/include/Constants.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once

namespace NetTabs {
const std::string DriveTeamTable = "Driving";
}

namespace ConfigFiles {
const std::string ConfigFile = "config.toml";
const std::string AutoConfigFile = "auto.toml";
Expand Down