Go to Post They can either incorporate the suggestions in this thread, go totally against them, or even make us all write code on banana peels with our fingernails. - Andy Baker [more]
Home
Go Back   Chief Delphi > Technical > Programming
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 11-04-2016, 12:38
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,041
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Problems with three cameras

1418 has two lifecam cameras so the operator can view the front and back of the robot, and at CHCMP we added a third lifecam camera so that they could reliably score in autonomous mode. We also added a USB hub and a memory stick so that we could log images and tune on them if necessary.

The first problem of course that we ran into was USB bandwidth and opening the third device failed. We were able to overcome this by switching the two viewing cameras to 160x120, and kept the vision camera at 320x240. So far so good, and after various bugs and tuning, in our last match it finally scored in autonomous (woo!).

However, in the first quarterfinal match, the USB devices decided to randomly swap, such that the vision camera was /dev/video0, and the other two were 1 and 2. This hadn't happened at all prior to that point, and some quick testing in the pits showed it happening again. After another autonomous failure in the next match it was decided to let the Robobees score from the low bar, the vision camera and usb stick were removed, and the remaining two cameras had no issues for the rest of the day.

We'd like to have the vision camera back by the time CMP rolls around. I'm curious if anyone else has tried using this many devices on the roborio, or have had similar issues, and how have you resolved them?

I know that you can use udev rules to make sure that devices are assigned to static symlinks, but I haven't looked into it too deeply yet. It appears that the lifecam devices do not have serial numbers associated with them, so it might be a bit harder to statically assign them. I've attached the output of lsusb with all devices attached.
Attached Files
File Type: txt lsusb.txt (117.8 KB, 13 views)
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #2   Spotlight this post!  
Unread 11-04-2016, 12:44
euhlmann's Avatar
euhlmann euhlmann is online now
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 312
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Problems with three cameras

How did you get a hub to even work?

We tried using a hub, and even before opening any cameras for capture we'd only see two: one from the hub and the one directly connected (order didn't matter; current draw wasn't the issue; we tried two different hubs). We just gave up on the idea of three USB cameras.
What hub did you use, and how exactly did you do it?
Reply With Quote
  #3   Spotlight this post!  
Unread 11-04-2016, 13:03
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,041
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Problems with three cameras

Well, if you look at lsusb.txt you'll see exactly what we used in more detail than anyone would want. It's some random usb hub that we've been using on our DS for a few years now. According to lsusb.txt, its a "Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB".

The two USB ports are a camera and the hub. The other two cameras are plugged into the hub, and the usb stick is also plugged in.

We use mjpg-streamer to interact with the cameras. There are potential USB bandwidth issues to be mindful of -- we were not able to open the camera devices until setting the resolution to 160x120, 160x120, and 320x240. I believe mjpg-streamer opens the devices in mjpg mode, as opposed to YUV (which an image processing framework such as NIVision or OpenCV would be more likely to open it in).

What did you use to determine that only two devices were detected? We used two different random hubs and had no issues detecting all cameras on either of them.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #4   Spotlight this post!  
Unread 11-04-2016, 16:10
vScourge's Avatar
vScourge vScourge is offline
Videogame Developer
AKA: Adam Pletcher
FRC #4096 (Ctrl-Z)
Team Role: Coach
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Champaign, IL
Posts: 33
vScourge is on a distinguished road
Re: Problems with three cameras

We also had three cameras, connect to an RPi2, and hit the same device-swapping issue at some point. One of our programming students came up with a workaround that involved hard-coding the serial numbers of each attached camera. I'll see if he can post here or summarize the process for me to pass on.
Reply With Quote
  #5   Spotlight this post!  
Unread 11-04-2016, 16:26
techhelpbb's Avatar
techhelpbb techhelpbb is offline
Registered User
FRC #0011 (MORT - Team 11)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 1997
Location: New Jersey
Posts: 1,620
techhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond repute
Re: Problems with three cameras

Just to be clear:

Your team is streaming 3 cameras at the same time?
Instead of switching between the cameras?

This would be good to read:
http://unix.stackexchange.com/questi...n-after-reboot
Reply With Quote
  #6   Spotlight this post!  
Unread 11-04-2016, 16:30
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,041
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Problems with three cameras

Quote:
Originally Posted by techhelpbb View Post
Just to be clear:

Your team is streaming 3 cameras at the same time?
Instead of switching between the cameras?
Technically, streaming 2 cameras, and consuming from the other (but not streaming the results).

Quote:
This would be good to read:
http://unix.stackexchange.com/questi...n-after-reboot
That looks exactly what I'm looking for, I'll play around with it on a RoboRIO tonight.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #7   Spotlight this post!  
Unread 11-04-2016, 16:48
vScourge's Avatar
vScourge vScourge is offline
Videogame Developer
AKA: Adam Pletcher
FRC #4096 (Ctrl-Z)
Team Role: Coach
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Champaign, IL
Posts: 33
vScourge is on a distinguished road
Re: Problems with three cameras

Cool, I believe that's the method we used.
Reply With Quote
  #8   Spotlight this post!  
Unread 11-04-2016, 17:00
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Problems with three cameras

Heads up from 836, we had some issues with the ms cameras too. Not sure why, but colors were changing on us in some cases. I plan to go back to the axis for Champs and investigate the usb cameras more over the summer.

As to the question of running multiple cameras, we wrote some beta code from scratch. I'll send you some system calls that let you track cameras by usb port.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #9   Spotlight this post!  
Unread 11-04-2016, 21:41
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,041
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Problems with three cameras

Quote:
Originally Posted by techhelpbb View Post
Hm, so it definitely looks like the lifecam devices don't have serial numbers or unique identifiers of any kind on them. There are symlinks setup at /dev/v4l/by-id and /dev/v4l/by-path. As you might imagine, the by-id symlinks are useless (only one appears even with multiple devices plugged in), but the by-path symlinks appear to be related to the position on the USB hub, and the information I've found appears to indicate that it should be a stable path.

Initial experiments on a roborio with a hub indicate that the by-path positions are indeed stable across device insert/removals and reboots. I'm not 100% sure of the best way to test this, but I'll add the information to mjpg-streamer's documentation anyways.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #10   Spotlight this post!  
Unread 11-04-2016, 22:02
bdaroz's Avatar
bdaroz bdaroz is offline
Programming Mentor
AKA: Brian Rozmierski
FRC #5881 (TVHS Dragons)
Team Role: Mentor
 
Join Date: Jan 2016
Rookie Year: 2016
Location: Albany, NY
Posts: 388
bdaroz has much to be proud ofbdaroz has much to be proud ofbdaroz has much to be proud ofbdaroz has much to be proud ofbdaroz has much to be proud ofbdaroz has much to be proud ofbdaroz has much to be proud ofbdaroz has much to be proud ofbdaroz has much to be proud of
Re: Problems with three cameras

We were using three cameras on our robot this year (Forward drive, intake alignment, and reverse). They were spare HP cams the school had lying around, all identical. They also didn't have any identifying characteristics from the USB side of things and the RoboRIO would somewhat randomly assign them cam0 cam1 and cam2.

What we did was to use the SmartDashboard to set the camera names and the code that toggled the camera feeds used those values. Took an extra 15-30s once FMS came up on the field to switch through the cameras and make the settings changes, but it worked fine from there on.
Reply With Quote
  #11   Spotlight this post!  
Unread 11-04-2016, 23:34
techhelpbb's Avatar
techhelpbb techhelpbb is offline
Registered User
FRC #0011 (MORT - Team 11)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 1997
Location: New Jersey
Posts: 1,620
techhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond repute
Re: Problems with three cameras

Quote:
Originally Posted by virtuald View Post
Hm, so it definitely looks like the lifecam devices don't have serial numbers or unique identifiers of any kind on them. There are symlinks setup at /dev/v4l/by-id and /dev/v4l/by-path. As you might imagine, the by-id symlinks are useless (only one appears even with multiple devices plugged in), but the by-path symlinks appear to be related to the position on the USB hub, and the information I've found appears to indicate that it should be a stable path.

Initial experiments on a roborio with a hub indicate that the by-path positions are indeed stable across device insert/removals and reboots. I'm not 100% sure of the best way to test this, but I'll add the information to mjpg-streamer's documentation anyways.
Could put a queue in the image (dots on lens or card in field of vision with image or color you could detect with code) or put a relay on the USB wires and connect the cameras one at a time then check the relay output against the device names that appear.

Does this help?
http://superuser.com/questions/74803...ng-usb-devices

Last edited by techhelpbb : 11-04-2016 at 23:40.
Reply With Quote
  #12   Spotlight this post!  
Unread 12-04-2016, 01:09
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,041
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Problems with three cameras

Quote:
Originally Posted by techhelpbb View Post
Could put a queue in the image (dots on lens or card in field of vision with image or color you could detect with code) or put a relay on the USB wires and connect the cameras one at a time then check the relay output against the device names that appear.

Does this help?
http://superuser.com/questions/74803...ng-usb-devices
That user seems to have a similar problem, namely that there is no serial number. The answers seem to confirm that the by-path identifier will be stable across reboots, so I think I'll go with that until it can be shown that it won't work.

Unfortunately, it looks like at the moment OpenCV won't allow using devices other than /dev/videoX. I've patched OpenCV and pushed a pull request to the OpenCV repo, hopefully they'll take it and it'll work in 3.2.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #13   Spotlight this post!  
Unread 12-04-2016, 07:45
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Problems with three cameras

By the way, NIVision does allow you to open the UVC camera in any mode that it enumerates. The WPILib VIs parse and compare the size and framerate. The DB in HW mode uses the JPEG mode while the SW uses YUV and compresses with the roboRIO. I don't have a ton of experience with multiple cameras, but NIVision enumerates and attempts to keep the cameras in order and returns lots of device info to validate.

This, by the way is the acquisition lib, called IMAQdx, and not the processing lib.

Greg McKaskle
Reply With Quote
  #14   Spotlight this post!  
Unread 13-04-2016, 02:06
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,041
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Problems with three cameras

I've posted the information I'm aware of and various information on the mjpg-streamer notes on the roborio-packages page:

https://github.com/robotpy/roborio-p...t-device-paths
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #15   Spotlight this post!  
Unread 13-04-2016, 08:55
Ben Wolsieffer Ben Wolsieffer is online now
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Problems with three cameras

Quote:
Originally Posted by virtuald View Post
Unfortunately, it looks like at the moment OpenCV won't allow using devices other than /dev/videoX. I've patched OpenCV and pushed a pull request to the OpenCV repo, hopefully they'll take it and it'll work in 3.2.
To work around this problem, we manually resolve the symlink and parse the index from the resolved filename (/dev/videoX), which is then passed to OpenCV.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
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 10:52.

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