[ntcore] NetworkTables 4 (#3217)

This commit is contained in:
Peter Johnson
2022-10-08 10:01:31 -07:00
committed by GitHub
parent 90cfa00115
commit 77301b126c
380 changed files with 34573 additions and 22095 deletions

View File

@@ -11,7 +11,7 @@
#include <frc/shuffleboard/Shuffleboard.h>
#include <frc/shuffleboard/ShuffleboardLayout.h>
#include <frc/shuffleboard/ShuffleboardTab.h>
#include <networktables/NetworkTableEntry.h>
#include <networktables/GenericEntry.h>
#include <networktables/NetworkTableInstance.h>
/**
@@ -31,10 +31,10 @@ class Robot : public frc::TimedRobot {
public:
void RobotInit() override {
// Add a widget titled 'Max Speed' with a number slider.
m_maxSpeed = frc::Shuffleboard::GetTab("Configuration")
.Add("Max Speed", 1)
.WithWidget("Number Slider")
.GetEntry();
m_maxSpeed = &frc::Shuffleboard::GetTab("Configuration")
.Add("Max Speed", 1)
.WithWidget("Number Slider")
.GetEntry();
// Create a 'DriveBase' tab and add the drivetrain object to it.
frc::ShuffleboardTab& driveBaseTab = frc::Shuffleboard::GetTab("DriveBase");
@@ -57,7 +57,7 @@ class Robot : public frc::TimedRobot {
void AutonomousInit() override {
// Update the Max Output for the drivetrain.
m_robotDrive.SetMaxOutput(m_maxSpeed.GetDouble(1.0));
m_robotDrive.SetMaxOutput(m_maxSpeed->GetDouble(1.0));
}
private:
@@ -73,7 +73,7 @@ class Robot : public frc::TimedRobot {
frc::Encoder m_rightEncoder{2, 3};
frc::AnalogPotentiometer m_ElevatorPot{0};
nt::NetworkTableEntry m_maxSpeed;
nt::GenericEntry* m_maxSpeed;
};
#ifndef RUNNING_FRC_TESTS

View File

@@ -14,10 +14,6 @@
class Robot : public frc::TimedRobot {
public:
void RobotInit() override {
// Flush NetworkTables every loop. This ensures that robot pose and other
// values are sent during every iteration.
SetNetworkTablesFlushEnabled(true);
m_trajectory = frc::TrajectoryGenerator::GenerateTrajectory(
frc::Pose2d{2_m, 2_m, 0_rad}, {}, frc::Pose2d{6_m, 4_m, 0_rad},
frc::TrajectoryConfig(2_mps, 2_mps_sq));

View File

@@ -9,11 +9,7 @@
#include <frc/smartdashboard/SmartDashboard.h>
#include <frc2/command/CommandScheduler.h>
void Robot::RobotInit() {
// Flush NetworkTables every loop. This ensures that robot pose and other
// values are sent during every iteration.
SetNetworkTablesFlushEnabled(true);
}
void Robot::RobotInit() {}
/**
* This function is called every 20 ms, no matter the mode. Use