Go to Post Seats are seats, we're all watching the same thing. - katiyeh07 [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 06-03-2016, 10:19
isiple04 isiple04 is offline
Registered User
FRC #1025
 
Join Date: Mar 2016
Location: Ferndale MI
Posts: 1
isiple04 is an unknown quantity at this point
Usb camera

How can i use GRIP to make the robot auto allign with a usb or axis camera?

Sample code?
Reply With Quote
  #2   Spotlight this post!  
Unread 06-03-2016, 23:18
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 296
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: Usb camera

The quick and easy way to align is to just turn until the target is in the center of the frame.
I'm not familiar with GRIP, but there should be a function that gives you the center of the object you are looking at.
Initially we tried using PID for alignment but the inherent issues with our robot's large drive dead zone and the lag in vision processing drove us to ditch pid and do our own two-phase constant rate turn.
First, we turn quickly until the target is within 20% around the center. Then, we turn slowly until we just pass the target and immediately stop there. This results in pretty decent alignment.

Here's some psuedocode for you
Code:
slow_zone = 0.2
slow_speed = 0.5
fast_speed = 1
repeat until (error = abs(target_center - image_width / 2)) < acceptable_error
  sign = target_center > image_width / 2 ? -1 : 1 // which direction to turn
  if error < slow_zone
    arcadedrive(0, slow_speed * sign)
  else
    arcadedrive(0, fast_speed * sign)
end
Good luck implementing this!
Reply With Quote
  #3   Spotlight this post!  
Unread 09-03-2016, 02:12
josephno1's Avatar
josephno1 josephno1 is offline
Registered User
FRC #3647
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: murica
Posts: 20
josephno1 is an unknown quantity at this point
Re: Usb camera

Here is a grip file to help you get started.
It does a half decent job of detecting targets. You might want to play around with contour areas and rgb stuff.

I also uploaded some sample picture that you might want to play around with it.
Use network tables to use it in the java code
Attached Files
File Type: zip Robotics.zip (4.67 MB, 17 views)
Reply With Quote
  #4   Spotlight this post!  
Unread 28-03-2016, 15:44
ARaine ARaine is offline
Registered User
FRC #2834
 
Join Date: Feb 2016
Location: Michigan
Posts: 5
ARaine is an unknown quantity at this point
Re: Usb camera

I found that using the vision to directly control a motor was too slow. By using a gyro, I calculated (roughly) the angle needed to rotate so that the center of the target was on the center of the camera's vision.

The calculation was:

arctan([Distance of center target to center vision] / [Constant])

The constant is just a value that I found through experimentation (around 300, may be different for you). This method only works if you have a gyroscope because I then took that calculated angle and plugged it into a PID loop to rotate the robot based on a gyro reading.

I had some success with this in autonomous by performing this operation twice.
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 09:31.

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