NTWorker

class NTWorker : public Worker

The threaded NetworkTables worker periodically retrieves the latest robot pose from the LocalizationWorker and publishes the global frame pose data to NetworkTables. By default, the worker will attempt to connect to the NetworkTables server at 10.TE.AM.2, where TEAM is the FRC team number. You may also specify a hostname to connect to instead, i.e. 127.0.0.1, 192.168.1.213, etc..

Other clients connected to the same NetworkTables server will see data being published at:

  • MAPLE/location: double[pos_x, pos_y, pos_z] in meters

  • MAPLE/orientation: double[roll, pitch, yaw] in degrees

  • MAPLE/robot_relative_tagid: int[tagid1, tagid2, …]

  • MAPLE/robot_relative_x: double[tag1_dist_x, tag2_dist_x, …]

  • MAPLE/robot_relative_y: double[tag1_dist_y, tag2_dist_y, …]

  • MAPLE/robot_relative_yaw: double[tag1_angle_yaw, tag2_angle_yaw, …]

Compatible with NetworkTables 4.

Public Functions

NTWorker()

Create the worker, default NetworkTables client connection to 127.0.0.1. Setup the publishers to position and orientation.

NTWorker(int team_num)

Create the worker, connect to NetworkTables via FRC team number.

Parameters:

team_num – The FRC team number.

NTWorker(std::string hostname)

Create the worker, connect to NetworkTables via hostname string.

Parameters:

hostname – The hostname with the NetworkTables server running.

NTWorker(const std::string &hostname, int ntport4)

Create the worker, connect to NetworkTables via hostname string.

Parameters:
  • hostname – The hostname with the NetworkTables server running.

  • ntport4 – The port which the NetworkTables 4 server is running on.

void RegisterPoseCallback(const std::function<RobotPose()> &pose_callback)

Register the pose callback function that is periodically called to retrieve the latest pose data to publish to NetworkTables.

Parameters:

pose_callback – The callback function which returns a RobotPose object to be parsed and published to NetworkTables.

bool IsConnected()

Check if the worker is connected to the NetworkTables server.

Returns:

true if connected to a NetworkTables server, false otherwise.