Réseautique NetworkTables
L’avantage que le programme du robot soit le serveur est qu’il s’agit d’un nom de réseau connu (et typiquement à une adresse connue) qui est basé sur le numéro de l’équipe. Cela est pourquoi il est possible dans le client NetworkTables, l’API client et plusieurs tableaux de bord de simplement fournir le numéro de l’équipe au lieu d’une adresse de serveur. Puisque le programme du robot est le serveur, notez que cela signifie que NetworkTables s’exécute sur l’ordinateur local lorsqu’en mode simulation.
Démarrer un serveur NetworkTables
NetworkTableInstance inst = NetworkTableInstance.getDefault(); inst.startServer();
nt::NetworkTableInstance inst = nt::NetworkTableInstance::GetDefault(); inst.StartServer();
NT_Inst inst = nt::GetDefaultInstance(); nt::StartServer(inst, "networktables.json", "", NT_DEFAULT_PORT3, NT_DEFAULT_PORT4);
NT_Inst inst = NT_GetDefaultInstance(); NT_StartServer(inst, "networktables.json", "", NT_DEFAULT_PORT3, NT_DEFAULT_PORT4);
import ntcore inst = ntcore.NetworkTableInstance.getDefault() inst.startServer()
Démarrer un client NetworkTables
NetworkTableInstance inst = NetworkTableInstance.getDefault(); // start a NT4 client inst.startClient4("example client"); // connect to a roboRIO with team number TEAM inst.setServerTeam(TEAM); // starting a DS client will try to get the roboRIO address from the DS application inst.startDSClient(); // connect to a specific host/port inst.setServer("host", NetworkTableInstance.kDefaultPort4)
nt::NetworkTableInstance inst = nt::NetworkTableInstance::GetDefault(); // start a NT4 client inst.StartClient4("example client"); // connect to a roboRIO with team number TEAM inst.SetServerTeam(TEAM); // starting a DS client will try to get the roboRIO address from the DS application inst.StartDSClient(); // connect to a specific host/port inst.SetServer("host", NT_DEFAULT_PORT4)
NT_Inst inst = nt::GetDefaultInstance(); // start a NT4 client nt::StartClient4(inst, "example client"); // connect to a roboRIO with team number TEAM nt::SetServerTeam(inst, TEAM); // starting a DS client will try to get the roboRIO address from the DS application nt::StartDSClient(inst); // connect to a specific host/port nt::SetServer(inst, "host", NT_DEFAULT_PORT4)
NT_Inst inst = NT_GetDefaultInstance(); // start a NT4 client NT_StartClient4(inst, "example client"); // connect to a roboRIO with team number TEAM NT_SetServerTeam(inst, TEAM); // starting a DS client will try to get the roboRIO address from the DS application NT_StartDSClient(inst); // connect to a specific host/port NT_SetServer(inst, "host", NT_DEFAULT_PORT4)
import ntcore inst = ntcore.NetworkTableInstance.getDefault() # start a NT4 client inst.startClient4("example client") # connect to a roboRIO with team number TEAM inst.setServerTeam(TEAM) # starting a DS client will try to get the roboRIO address from the DS application inst.startDSClient() # connect to a specific host/port inst.setServer("host", ntcore.NetworkTableInstance.kDefaultPort4)