Go to Post ... simple things can amaze me. - Andy Baker [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-01-2017, 18:49
RileyC3826 RileyC3826 is offline
Registered User
FRC #3826 (Sequim Robotics Federation)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2013
Location: Sequim, Washington
Posts: 9
RileyC3826 is an unknown quantity at this point
Vision Stops Returning Numbers

So we are using a USB camera with GRIP generated code in Java in order to find retro-reflective tape targets. We are able to see these targets, and return their X positions, but sometimes when we run our robot, the numbers that are returned simply stop changing. This prevents us from getting new values from the camera until we redeploy code, and this only fixes the issue until the bug randomly occurs again. The issue can be replicated by using visionThread.stop(), it has the exact same effect. If we try to use visionThread.start() in TeleopPeriodic to restart the vision program, it crashes: we lose code and comms for a second or two before it returns.

The code is a slightly modified version of the code found in the WPILIB documentation for vision processing, in addition to some NavX stuff. The class that it is calling, VisionPipelinew(), is just the code generated from GRIP.
Code here: https://github.com/NeutralIntel/3826...aster/2017COAD
Reply With Quote
  #2   Spotlight this post!  
Unread 24-01-2017, 19:08
SamCarlberg's Avatar
SamCarlberg SamCarlberg is online now
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 136
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Vision Stops Returning Numbers

You're getting an IndexOutOfBoundsException on this line.

When working with lists and arrays, you need to check that it contains an item at a given index before trying to access it. This is very important to remember for FRC, because an exception will crash your code and cause your robot to not move for the entirety of the match.

I cannot stress this enough: check the list size before trying to access anything

You also need to set centerRX and centerQX in the same synchronized block, otherwise the main thread can read one new value and one old value when it updates and you'll have junk data.
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #3   Spotlight this post!  
Unread 24-01-2017, 19:44
RileyC3826 RileyC3826 is offline
Registered User
FRC #3826 (Sequim Robotics Federation)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2013
Location: Sequim, Washington
Posts: 9
RileyC3826 is an unknown quantity at this point
Re: Vision Stops Returning Numbers

Thanks, I think I understand what you mean, but I cannot deploy new code and test it right now due to windows updates on our driverstation laptop, I will reply back if/when I get a chance to test some changes.
Reply With Quote
  #4   Spotlight this post!  
Unread 24-01-2017, 22:06
RileyC3826 RileyC3826 is offline
Registered User
FRC #3826 (Sequim Robotics Federation)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2013
Location: Sequim, Washington
Posts: 9
RileyC3826 is an unknown quantity at this point
Re: Vision Stops Returning Numbers

Quote:
Originally Posted by RileyC3826 View Post
Thanks, I think I understand what you mean, but I cannot deploy new code and test it right now due to windows updates on our driverstation laptop, I will reply back if/when I get a chance to test some changes.
The issue has been resolved! By switching '!pipeline.filterContoursOutput().isEmpty()' to 'pipeline.filterContoursOutput().size >= 2', the program does stop when only one target is visible, but the numbers resume updating when both targets are back in view. The updated code has been committed directly to the code on GitHub which I linked earlier. This code could be further modified to allow values to update when one target is visible.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:16.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi