Robot code not showing up #465

Open
nimrod46 opened this Issue Jan 16, 2017 · 22 comments

Projects

None yet

5 participants

@nimrod46

The robot code not showing up randomly after deploying it since updating to 2017 lib.

Error: NT: ERROR: bind() to port 1735 failed: Address already in use (TCPAcceptor.cpp:108)
That error is showing up when this happends.
The only way to fix it is by restarting the roborio.

Right now this problem has been reported to happened in java and c++.
See thread: https://www.chiefdelphi.com/forums/showthread.php?t=153362

@mikearnold514

Team 514 is having the same problem.

The offending line of code is the one getting the CameraServer instance and starting auto capture - VideoSource usbCamera = CameraServer.getInstance().startAutomaticCapture();

I was wondering if this issue is being assigned and planned for a release. Please let me know the status when you have a chance.

Kind Regards,
Mike

@mikearnold514

Just following up to see if anyone had a resolution to this problem. My team is still experiencing the issue. Will be in the tech room tomorrow night. Was hoping to discuss this with someone to get some ideas on how best to troubleshoot.
Thanks!
Mike

@AustinShalit
Member
AustinShalit commented Jan 31, 2017 edited

@mikearnold514 Can you please send me your code?

The issue you are seeing is that your robot code is unable to exit and is still listening on that port.

@mikearnold514
@AustinShalit
Member

Sounds good

@nightpool

Should this be an open issue or can we close this?

@nimrod46

@nightpool keep it open until it will be fixed so no one else will open a new issue

@mikearnold514
@nightpool

@nimrod46 I'm not sure I understand what the issue is here from WPILib's perspective, sorry. The issue that you're seeing is just a symptom of your robot code isn't exiting—which isn't something WPILib can control.

@mikearnold514
@nimrod46

@AustinShalit @nightpool
I think this problem should be solved, even if a tcp server is listening on this port you should shut it down.
I mean you can't leave it as it is because this is will be a problem during matches.
This is my opinion

@mikearnold514
@mikearnold514

Seems the source code did not upload when I attached it to the email. Here it is for your review. Thank you!
FRC2017Test.zip

@mikearnold514

I will leave it up to the person who opened this issue but from what I can tell, this issue can be closed.

Austin, if you have had a chance to look at the code I sent you, I would welcome your feedback.

Kind Regards,
Mike Arnold, Team 514

@AustinShalit
Member
AustinShalit commented Feb 2, 2017 edited

I just took a look. You will not notice any SmartDashboard updates while the DriverStation is not connected. disabledPeriodic only runs when the robot has a connection to the DriverStation.

Vision is not something that works well right now in the command based format. I would recommend removing the ProcessImages command. The VisionThread (line 57 of VisionUtil) will automatically call copyPipelineOutputs every time it has finished running the pipeline. You can take a look at how that works here.

It looks like you are not using the visionLock right now. I would read this article by Oracle. It explains what the synchronized block does and how to use it. Let me know if you have trouble.

@mikearnold514
@mikearnold514
@SamCarlberg
Member

copyPipelineOutputs method in the VisionUtil() class synchronized on an
object called visionLock. However, based on what I read, I think the
subsequent getter methods in the VisionUtil() class would each also have to
be synchronized on the same visionLock object.

It's a bit more involved than that. All reads should be in a single synchronized block, and all writes should be in another. If not, one thread can read a variable, then the vision thread would update all of them, and the first thread would then have data from multiple runs of the pipeline, making the data useless.

@mikearnold514
@SamCarlberg
Member

You could store all the extracted data in a single value object and expose that synchronously.

public final class VisionData {
  private final double angleToGearPeg;
  ...
}

and then in VisionUtil, you'd have something like

@Override
public void copyPipelineOutputs(VisionProcessingPipeline pipeline) {
  synchronized (visionLock) {
    this.visionData = new VisionData(pipeline.calcAngleToGearPeg(), ...);
  }
}

public VisionData getVisionData() {
  synchronized (visionLock) {
    return visionData;
  }
}
@AustinShalit
Member

I would continue to use CommandBasedRobot for everything except vision.

@mikearnold514

Hey Sam/Austin -
So you have given some great guidance and now I have a number of things to try out! Good thing our Saturday meeting is all day long! hehe...

I will update you on our testing. I am feeling confident that we can get something going from among the options you guys have mapped out for us! Can't thank you enough!
Kind Regards,
Mike

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment