-
Notifications
You must be signed in to change notification settings - Fork 7
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
Issues connecting to simulator #111
Comments
Thanks for the report Josh, @fisherjacobc, can you provide a minimal robot code repository similar to your environment so I can reproduce this? Also, @CrispyBacon1999, let me know if you are interested in owning this package... or if you have the bandwidth to help me with the NT 4.1 migration and adding global listeners. My priorities have shifted, and my primary focus is my job and college right now |
I haven't looked that deep into NT 4.1 yet, but it's possible that's what's causing the issues. My local testing was done using my team's 2023 robot, which wouldn't have the new 4.1 things, so I could see small conflicts causing issues. Looking at the way they have the negotiations handled, it theoretically shouldn't cause issues, but you never know. I'd definitely be down to help out with adding 4.1 support as well! |
Glad to hear! TL;DR I don't think this is 4.1 related From the spec: https://github.com/wpilibsuite/allwpilib/blob/main/ntcore/doc/networktables4.adoc#motivation4.1
|
I don't think this is my client. My client connects to the robot in the form of This message says |
Interesting, so it's likely another app connecting and having issues, but the errors are being sent through and displayed? |
That's what it seems like at first glance. This is one of those things that's hard to debug without the same environment. Looking at your linked issue, it sounds like it just disconnects and reconnects? Maybe in NT4.0, there's a bug that reloads all clients when it gets an error like that |
In case you didn't see (in the other issue), example code for the issue is at https://github.com/FIRST-TEAM-339/kilroy-dashboard. |
Could be robot code issue |
Since I was just testing out NT Tables, I didn't really have anything sophisticated code wise, but I had stuff in a subsystem (using commaned-based). Below is the minimal code relating to the values I want to change through the subsystem. package frc.robot.subsystems;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.RobotController;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants.*;
import frc.robot.enums.DriveGears;
public class DashboardSubsystem extends SubsystemBase
{
private NetworkTableInstance inst = NetworkTableInstance.getDefault();
private NetworkTable table = inst.getTable("kilroy");
private NetworkTableEntry autonomousMode = table
.getEntry("autonomous/mode");
private NetworkTableEntry leftRightNone = table
.getEntry("autonomous/left-right-none");
public DashboardSubsystem()
{
// this.autonomousMode.setPersistent();
this.autonomousMode.setInteger(2);
// this.leftRightNone.setPersistent();
this.leftRightNone.setInteger(1);
}
} I should have also mentioned this before, but in my console I get a warning of "Topic /kilroy/autonomous/mode is not announced, so it cannot be updated" which I traced back to coming from |
@CrispyBacon1999 @fisherjacobc I think I may have found something https://github.com/CrispyBacon1999/ntcore-react/blob/main/src/lib/useNTState.ts#L62-L63 We publish then immediately set the value. publish is technically an asynchronous action, because the server response (an "announce" message), needs to come back before we can set values From the spec: https://github.com/wpilibsuite/allwpilib/blob/main/ntcore/doc/networktables4.adoc#topic-announcement-message-announce
2 options:
The way I worked around this (and never noticed this issue) was by using a useEffect to setup my topics as publishers. I don't think I published values immediately either.
|
I'm just curious since I haven't done too much with network tables. Is setting a value not count as publishing on the robot side? |
You're right, the topic is published/announced already I forgot that NT won't send the announce message unless the client is subscribing or publishing, so this is a client side issue. |
So I guess either you would have to make a PR to ntcore-react or the developer would have to update it |
I think refactoring the async calls to promises is the best option. Resolve when server ack, reject on timeout? I can try to get to that when I have time (which is not very often), so feel free to look into it or PR. Then we will have to update ntcore-react. It's more of an issue with my package |
This print statement says I will queue the value if it isn't announced But really I'm only queueing if we aren't connected to the robot. TODO: either refactor queue, or make publish a promise. I need to think about this more. Open to opinions |
I think using promises for it is definitely the ideal way of doing it. Will probably be awkward for handling backward compatibility/deprecation, but it's probably not the end of the world. |
Hey there! I saw there have been some commits on here that seem related to this issue if I am not mistaken? I am wondering if that is a fix for the issues I have been encountered, and if the react library should update to the latest version of |
Hey @fisherjacobc you can try https://www.npmjs.com/package/ntcore-ts-client/v/1.0.0-beta.4 but I think I had problems with it. I'm in the middle of finals right now and I'll try to work on this in the next few weeks |
Closing this as issues should be fixed with https://www.npmjs.com/package/ntcore-ts-client/v/2.0.0-beta.3 Please comment if this should be reopened |
Can you confirm you are using the latest WPILib distribution? |
Yep, I recently updated the robot sim to be 2024.1.1 |
I also made sure to have the items published/set when the robot is initialized /**
* This function is run when the robot is first started up and should be used
* for any
* initialization code.
*/
@Override
public void robotInit() {
NetworkTableInstance inst = NetworkTableInstance.getDefault();
NetworkTable table = inst.getTable("kilroy");
IntegerPublisher entry = table.getIntegerTopic("autonomous/mode").publish();
entry.set(2);
IntegerPublisher entry2 = table.getIntegerTopic("autonomous/left-right-none").publish();
entry2.set(1);
} |
Hi @fisherjacobc please try 2.0.0-beta.5 |
Hi there! I waited until tonight when I could try seeing if it works with a real robot, since that's what really matters. Unfortunately, it didn't. Just kept looping and connecting/disconnecting... Recording.2024-01-10.181449.mp4I will try skipping the whole react thing and just see if I can update the states directly through |
Logically, there should be no way that the issue stems from it being in the react library, but it's definitely worth testing whether it happens with base as well. |
@fisherjacobc One thing I did notice after looking at your code is that you're explicity declaring the uri you connect to as |
Ok so, while just trying to test setting the value, it has some errors of it's own
import { NetworkTables, NetworkTablesTypeInfos } from "ntcore-ts-client";
const main = async () => {
const kilroy = NetworkTables.getInstanceByTeam(339);
const autonomousMode = kilroy.createTopic<number>(
"/autonomous/mode",
NetworkTablesTypeInfos.kInteger
);
await autonomousMode.publish();
autonomousMode.setValue(1);
setTimeout(() => {
autonomousMode.setValue(2);
}, 3000);
};
main(); |
I will try to take a look this weekend |
@SpiffyJif The error you are getting says that it can't connect to a NetworkTables server running on your local computer (localhost) The port for NT4.0/4.1 is 5810, so if you're running the simulator locally, you need to change the port. If you are trying to connect to the robot, you need to change "localhost" |
@fisherjacobc I tried to reproduce but I couldn't in the simulator. I'm using the template arcade drive robot file and your typescript code Screen.Recording.2024-01-15.at.10.47.32.AM.movAs you can see, the autonomous value changes from |
@fisherjacobc Do you still have any issues? I think everything should be solved at this point |
Apologies, I forgot to get back to you. I am still getting the same error, the robot is currently using 2023.4.2 for the rio/wpilib stuff, would that be an issue? |
Maybe, I'm not sure. I think this might be a robot code issue though. Could you provide me a minimal reproducible example on the robot? |
you can look at https://github.com/FIRST-TEAM-339/2024Base |
Hey there, still encountering the issue. Currently still running on 2023.4.2, also even with the minimal arcade java example completely unmodified (created a new project) I still get the error of |
hey there, for whatever weird reason, it works perfectly fine if i remove the subprotocols when first trying to connect with the websocket... will just use that as a patch and see how it goes from there |
Thanks for the update. I'll take a look when I get some time |
Hi @fisherjacobc is this still an issue with 2024 wpilib? |
I have a user of my wrapping package reporting issues with connecting to a simulated robot. I can't seem to reproduce it on my end, but it definitely seems like an issue that's stemming from this package as well. It seems to only appear when modifying networktables values from the client side, rather than robot side.
The error they're reporting is
NT: DISCONNECTED NT4 client '1700087460502@1' (from 127.0.0.1:61606): binary decode error: mpack_error_type
. More details can be found at this issue: CrispyBacon1999/ntcore-react#149The text was updated successfully, but these errors were encountered: