2023-Robot
Robot code for 2023 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
nt_subscriber.h
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <networktables/DoubleTopic.h>
8#include <networktables/NetworkTableInstance.h>
9
10#include <string>
11#include <vector>
12
13namespace argos_lib {
18 public:
24 explicit NTSubscriber(const std::string& tableName);
25
27
36 void AddMonitor(const std::string& keyName,
37 std::function<void(double)> onUpdateCallback,
38 const double defaultValue = 0.0,
39 const bool forceUpdate = true);
40
41 private:
42 const std::string m_tableName;
43 std::vector<NT_Entry> m_ntEntries;
44 std::vector<NT_Listener> m_ntListeners;
45 };
46
47} // namespace argos_lib
Subscribes to Network Tables entry updates and calls a specified callback to use the new value.
Definition nt_subscriber.h:17
void AddMonitor(const std::string &keyName, std::function< void(double)> onUpdateCallback, const double defaultValue=0.0, const bool forceUpdate=true)
Register a new listener for the specified key and send values to callback on update.
Definition nt_subscriber.cpp:27
~NTSubscriber()
Definition nt_subscriber.cpp:17
std::vector< NT_Entry > m_ntEntries
Publish/subscribe entries.
Definition nt_subscriber.h:43
std::vector< NT_Listener > m_ntListeners
Entry listeners.
Definition nt_subscriber.h:44
const std::string m_tableName
Table containing keys to monitor.
Definition nt_subscriber.h:42
Definition swap_controllers_command.h:12