Go to Post Off season? More like on season, our season is always on. - joeweber [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-2013, 18:57
rickyman20 rickyman20 is offline
Registered User
FRC #3933
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Mexico
Posts: 5
rickyman20 is an unknown quantity at this point
Robot drive and camera interaction not working

I a currently working on a program that will use the camera to guide the robot, but the problem is I can't get it to work. When I try the drive or the camera separately, it works without an issue, but when I use one to control the other, it does not work and it fills my console with
Code:
"Robot Drive... Output not updated often enough."
It I am not able to figure out what the problem is? Here is the code I used (without the teleop and class declaration, but it extends SimpleRobot)
Code:
    AxisCamera camera;          // the axis camera object (connected to the switch)
    CriteriaCollection cc;      // the criteria for doing the particle filter operation
    
    RobotDrive drive;
    
    public void robotInit() {
        camera = AxisCamera.getInstance();  // get an instance ofthe camera
        cc = new CriteriaCollection();      // create the criteria for the particle filter
        cc.addCriteria(MeasurementType.IMAQ_MT_BOUNDING_RECT_WIDTH, 30, 400, false);
        cc.addCriteria(MeasurementType.IMAQ_MT_BOUNDING_RECT_HEIGHT, 40, 400, false);
        
    	drive = new RobotDrive(1, 3);
    }

    public void autonomous() {
        while (isAutonomous() && isEnabled()) {
            try
            {
                ColorImage image = camera.getImage();
                BinaryImage thresholdImage = image.thresholdRGB(0, 45, 25, 255, 0, 47);
                BinaryImage bigObjectsImage = thresholdImage.removeSmallObjects(false, 2);
                BinaryImage convexHullImage = bigObjectsImage.convexHull(false);
                BinaryImage filteredImage = convexHullImage.particleFilter(cc);
                
                ParticleAnalysisReport[] reports = filteredImage.getOrderedParticleAnalysisReports();
                if(reports.length > 0)
                {
	                if(reports[0].center_mass_x > image.getWidth() / 2 + 10)
	                	drive.arcadeDrive(0, 1);
	                else if(reports[0].center_mass_x < image.getWidth() / 2 - 10)
	                	drive.arcadeDrive(0, -1);
	                else
	                	drive.arcadeDrive(0, 0);
                }
                
                filteredImage.free();
                convexHullImage.free();
                bigObjectsImage.free();
                thresholdImage.free();
                image.free();
            } catch (NIVisionException ex) {
                ex.printStackTrace();
            } catch (AxisCameraException e) {
		e.printStackTrace();
            }
        }
    }
Reply With Quote
  #2   Spotlight this post!  
Unread 24-01-2013, 21:03
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Robot drive and camera interaction not working

My guess is that processing the camera image is taking longer then the frequency of the driver station packets (20 ms). Have you tried timing each of the operations? You might have to break up the processing for each step (1st time through the loop get the image, 2nd time through the loop threshold the image, etc).
Reply With Quote
  #3   Spotlight this post!  
Unread 24-01-2013, 21:12
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Robot drive and camera interaction not working

Try putting this at the end of autonomous

Timer.delay(1);
Reply With Quote
  #4   Spotlight this post!  
Unread 24-01-2013, 21:46
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Robot drive and camera interaction not working

Another thing is that if reports.length is 0, you won't call the RobotDrive, which will cause that message.
Reply With Quote
  #5   Spotlight this post!  
Unread 24-01-2013, 21:54
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Robot drive and camera interaction not working

Quote:
Originally Posted by Joe Ross View Post
Another thing is that if reports.length is 0, you won't call the RobotDrive, which will cause that message.
True. Your criteria are quite strict for a 160x120 camera
Reply With Quote
  #6   Spotlight this post!  
Unread 24-01-2013, 22:28
rickyman20 rickyman20 is offline
Registered User
FRC #3933
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Mexico
Posts: 5
rickyman20 is an unknown quantity at this point
Re: Robot drive and camera interaction not working

I did put an if in case it was zero, and the resolution is higher. I had tested it and there was always at least one rectangle
Reply With Quote
  #7   Spotlight this post!  
Unread 24-01-2013, 22:44
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Robot drive and camera interaction not working

Quote:
Originally Posted by rickyman20 View Post
I did put an if in case it was zero, and the resolution is higher. I had tested it and there was always at least one rectangle
put this line on the top of auton

drive.setSafetyEnabled(false)
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:08.

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