Go to Post This is still about fun. Remember that. - Koko Ed [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
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 01-02-2012, 12:22
juchong's Avatar
juchong juchong is offline
Electrical Engineer
AKA: Juan Chong
FRC #2655 (Flying Platypi)
Team Role: Engineer
 
Join Date: Aug 2008
Rookie Year: 2008
Location: Greensboro, NC
Posts: 107
juchong is a jewel in the roughjuchong is a jewel in the roughjuchong is a jewel in the rough
Extrapolating Direction From Images

Has anyone gotten direction extrapolation working using the included VIs? We're trying to find a way to determine how far off center the camera is and have the base correct for it. I know that the processing software will vary the distance measured with respect to the angle of the camera, and with that measurement it's definitely possible to have the robot center itself using the ultrasonic sensor as a verification method, but I'm not sure how to determine which direction the robot has to turn in order to correct itself.

Any ideas?
__________________
Teams I've worked with:My Website: http://www.juanjchong.com/
What I do: Analog Devices iSensor Product Engineer
Reply With Quote
  #2   Spotlight this post!  
Unread 01-02-2012, 12:37
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Extrapolating Direction From Images

In addition to the distance, the vision code you're working with tells you the location on the image of the target. Use the x coordinate of the target to decide which direction you need to turn the robot, and how far.
Reply With Quote
  #3   Spotlight this post!  
Unread 07-02-2012, 16:56
juchong's Avatar
juchong juchong is offline
Electrical Engineer
AKA: Juan Chong
FRC #2655 (Flying Platypi)
Team Role: Engineer
 
Join Date: Aug 2008
Rookie Year: 2008
Location: Greensboro, NC
Posts: 107
juchong is a jewel in the roughjuchong is a jewel in the roughjuchong is a jewel in the rough
Re: Extrapolating Direction From Images

Excellent! We got basic auto-aim working, it may need a bit of tuning, but we'll need carpet and more weight on the robot to fully tweak everything.

http://youtu.be/HreYf3EIXPY
__________________
Teams I've worked with:My Website: http://www.juanjchong.com/
What I do: Analog Devices iSensor Product Engineer
Reply With Quote
  #4   Spotlight this post!  
Unread 07-02-2012, 17:29
Pirate programe's Avatar
Pirate programe Pirate programe is offline
Registered User
FRC #0354
 
Join Date: Jan 2012
Location: Queens,NY
Posts: 53
Pirate programe is an unknown quantity at this point
Re: Extrapolating Direction From Images

When you figure out the way to tune your auto-aim, do you think you could post it here? I think a lot of teams would appreciate it.
Reply With Quote
  #5   Spotlight this post!  
Unread 07-02-2012, 18:10
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Extrapolating Direction From Images

Quote:
Originally Posted by Pirate programe View Post
When you figure out the way to tune your auto-aim, do you think you could post it here? I think a lot of teams would appreciate it.
It really depends on how exactly you code the auto-aiming. If you use PID to get the target in the center of the camera's field of view, then it's really just a matter of tuning the PID parameters to get the best results from your system. There are many ways to tune a PID controller, but one of the most common (and easiest to implement in our timeframes) is a guess/check and Ziegler–Nichols combination. I'm not sure there's really much information to post.

But if you have specific questions about the logic/methodology behind auto-aiming, ask away, I'd be happy to answer.
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #6   Spotlight this post!  
Unread 09-02-2012, 21:19
VelocityofGear's Avatar
VelocityofGear VelocityofGear is offline
Registered User
FRC #4347 (Mechanical End)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Paterson
Posts: 5
VelocityofGear is an unknown quantity at this point
Re: Extrapolating Direction From Images

Quote:
Originally Posted by plnyyanks View Post
It really depends on how exactly you code the auto-aiming. If you use PID to get the target in the center of the camera's field of view, then it's really just a matter of tuning the PID parameters to get the best results from your system. There are many ways to tune a PID controller, but one of the most common (and easiest to implement in our timeframes) is a guess/check and Ziegler–Nichols combination. I'm not sure there's really much information to post.

But if you have specific questions about the logic/methodology behind auto-aiming, ask away, I'd be happy to answer.
Hello.

Attached is the portion of the code I am using to control a motor to align to a target. I am encountering problems in determining the logic to have the motor focus on the target chosen.

From the picture, I have taken the position of the x-value and specified when the value is less than 0.09 and greater than -0.09 to assign an output of 0, allowing the motor to stay fixed on the target. Yet when the values are out of this range, I'm looking for the motor to move clockwise or counter-clockwise to set its value within that range. I am having trouble using the x-position to center itself on the target.

We have read through the Vision Target processing and checked FRCMastery's section on vision processing; however, we are still having trouble.

Any pointers would be greatly appreciated. Thank you in advance for your responses and time.
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	75
Size:	20.9 KB
ID:	11826  
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2012, 22:24
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Extrapolating Direction From Images

Quote:
Originally Posted by VelocityofGear View Post
Any pointers would be greatly appreciated.
Here are some pointers.

But all jokes aside, you're going to want to use a PID Controller in order to get your turret to aim. A PID controller is a feedback control mechanism, which, simply put, means that it will calculate the error between your desired value (the "setpoint") and the current value (the "process variable"). So, since you have real-life feedback (your camera) as well as a desired value, you can use a PID controller to "lock onto" the target.

In LV, there's a PID palate, and you place PID.vi onto your block diagram. You will want to wire the offset between the center (x) of the target and the center of the image (
Code:
offset = xCenter - (xResolution/2)
) as the process variable to the PID controller, and put the setpoint at 0 (you want the center of target to be exactly in the center of your image). You will have to make sure that the output ranges are scaled properly, and also that the input ranges are both scaled to the same units (you shouldn't have to do any scaling in this case - both are a pixel offset).

Then comes the hard part. You'll have to tune the parameters of the controller. There are three parameters: P (proportional), I (integral), and D (derivative). See the links in my last post for some common approaches and read through this section of the wikipedia page for how the gains work.

And if you can't get this to work, there is a simpler (but much less robust method). You could figure out the sign of the offset between target center and image center. This will tell you if your turret needs to move left or right to get centered. Then, you can either send a positive or negative value to your motor, depending on the direction and keep a constant value sending until the offset is within a threshold for the center, when you stop the motor. This is similar to the approach you started with.

I would recommend going with a PID solution because it's much more powerful and robust than the other way, but it does take some time and effort to get right. There are a lot of resources out on the internet and around ChiefDelphi for you to use. And as always, feel free to ask questions.
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android

Last edited by plnyyanks : 09-02-2012 at 22:28.
Reply With Quote
  #8   Spotlight this post!  
Unread 15-02-2012, 00:24
VelocityofGear's Avatar
VelocityofGear VelocityofGear is offline
Registered User
FRC #4347 (Mechanical End)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Paterson
Posts: 5
VelocityofGear is an unknown quantity at this point
Re: Extrapolating Direction From Images

Quote:
Originally Posted by plnyyanks View Post
Here are some pointers.
Very funny lol With all the reading and work getting done, it was nice to have a little humor.

I read through the documents, thanks for the links. However, I still do not understand how the process is accomplished inside of LabView. I set up a case select for the automation to run when a button is pressed down.

I think I set up the input and outputs for the PID block correctly as you stated. I enclosed a screen capture of what was done.

You mention to use this code:

Code:
offset = xCenter - (xResolution/2)
I think that is what I have done, I still am unsure however.

As you can see from the picture, I manually set the pixel value for the camera in the x direction. Is there a better way of doing this? Maybe as a variable that will update if the settings are changed?
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	41
Size:	17.5 KB
ID:	11904  

Last edited by VelocityofGear : 15-02-2012 at 00:26. Reason: Needed to attach picture
Reply With Quote
  #9   Spotlight this post!  
Unread 15-02-2012, 07:53
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,752
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: Extrapolating Direction From Images

I think that if you look at the Rectangle processing, it has already defined the X and Y position to be in the range of -1 to 1 to be more like a joystick. Unless that code has been removed, subtracting 320/2 doesn't make sense.

Greg McKaskle
Reply With Quote
  #10   Spotlight this post!  
Unread 15-02-2012, 10:16
VelocityofGear's Avatar
VelocityofGear VelocityofGear is offline
Registered User
FRC #4347 (Mechanical End)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Paterson
Posts: 5
VelocityofGear is an unknown quantity at this point
Re: Extrapolating Direction From Images

Quote:
Originally Posted by Greg McKaskle View Post
I think that if you look at the Rectangle processing, it has already defined the X and Y position to be in the range of -1 to 1 to be more like a joystick. Unless that code has been removed, subtracting 320/2 doesn't make sense.

Greg McKaskle
Then what about comensating for the pixel offset as mentioned?

Quote:
Originally Posted by plnyyanks
In LV, there's a PID palate, and you place PID.vi onto your block diagram. You will want to wire the offset between the center (x) of the target and the center of the image (
Code:

Code:
offset = xCenter - (xResolution/2)
) as the process variable to the PID controller, and put the setpoint at 0 (you want the center of target to be exactly in the center of your image).
This post clearly states there must be an offset created and it makes sence. If there is no offset then how would the PID controller know the error and hence how to correct for it?
Reply With Quote
  #11   Spotlight this post!  
Unread 15-02-2012, 10:56
juchong's Avatar
juchong juchong is offline
Electrical Engineer
AKA: Juan Chong
FRC #2655 (Flying Platypi)
Team Role: Engineer
 
Join Date: Aug 2008
Rookie Year: 2008
Location: Greensboro, NC
Posts: 107
juchong is a jewel in the roughjuchong is a jewel in the roughjuchong is a jewel in the rough
Re: Extrapolating Direction From Images

From our testing, with the stock kitbot setup and using PWM, it's nearly impossible to have the robot precisely move to a certain position. The slop in the chain, transmission, and the varied power needed to overcome the moment of inertia are all contributing to the robot overshooting in order to attempt to aim.

Our solution: use CAN and encoders on the transmission, tune motor PID on the carpet, and tweak autoaim code. CAN enables us to closely monitor the number of rotations or set a speed at which to track, no matter what resistance the wheels meet (to an extent).

The overshoot that everyone is noticing with the example above is due to the camera being slightly off and the robot trying to precisely correct. This can be improved by using more case structures which vary the motors' power, instead of having a single power at which the robot will track, but it won't solve the problem.
__________________
Teams I've worked with:My Website: http://www.juanjchong.com/
What I do: Analog Devices iSensor Product Engineer
Reply With Quote
  #12   Spotlight this post!  
Unread 15-02-2012, 12:56
VelocityofGear's Avatar
VelocityofGear VelocityofGear is offline
Registered User
FRC #4347 (Mechanical End)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Paterson
Posts: 5
VelocityofGear is an unknown quantity at this point
Re: Extrapolating Direction From Images

Quote:
Originally Posted by juchong View Post
Our solution: use CAN and encoders on the transmission, tune motor PID on the carpet, and tweak autoaim code.
And what auto-aim code are you referring to? There is a rectangular processing sample code? I do not see a auto-aim code... There is one however for tracking using a servo.

The camera is mounted about a axle moved by a drive motor. It is a turret that just rotates in the x direction. By limiting the speed I can not see the motor over-shooting the target.

I am hoping the approach documented by plnyyanks will work as mentioned. It seems like a simpler approach. But I would love to take a look at a screen cap of your code so I can see what you are referring to more precisely.
Reply With Quote
  #13   Spotlight this post!  
Unread 15-02-2012, 14:53
juchong's Avatar
juchong juchong is offline
Electrical Engineer
AKA: Juan Chong
FRC #2655 (Flying Platypi)
Team Role: Engineer
 
Join Date: Aug 2008
Rookie Year: 2008
Location: Greensboro, NC
Posts: 107
juchong is a jewel in the roughjuchong is a jewel in the roughjuchong is a jewel in the rough
Re: Extrapolating Direction From Images

There is enough slop in a kitbot system that you're very likely to overshoot. We created some autoaim code similar to what has been posted above, which is what I'm referring to.
On the topic of the servo, a servo works by providing position feedback. This same idea holds true for a larger system(such as a kitbot) which also requires feedback. You may be able to get the system to function by adding a bit more dampening (carpet) but it won't perform well enough to accurately aim.
__________________
Teams I've worked with:My Website: http://www.juanjchong.com/
What I do: Analog Devices iSensor Product Engineer
Reply With Quote
  #14   Spotlight this post!  
Unread 15-02-2012, 16:40
Pirate programe's Avatar
Pirate programe Pirate programe is offline
Registered User
FRC #0354
 
Join Date: Jan 2012
Location: Queens,NY
Posts: 53
Pirate programe is an unknown quantity at this point
Re: Extrapolating Direction From Images

Quote:
Originally Posted by juchong View Post
The overshoot that everyone is noticing with the example above is due to the camera being slightly off and the robot trying to precisely correct. This can be improved by using more case structures which vary the motors' power, instead of having a single power at which the robot will track, but it won't solve the problem.
See, I though this too, but then I noticed that after a while, with the teleop code (in thumbnail)we have can aim rather precisely with the right range, and that the offset was actually coming from, and that the overshoot/wobbling we noticed was actually coming from the targets swapping places in the Target info array.

Granted, it could turn out that we might need to center the camera better to ensure that the center of the camera corresponds to the center of the target, but that seems easy enough to do...
Attached Thumbnails
Click image for larger version

Name:	scrncap.png
Views:	29
Size:	8.3 KB
ID:	11916  
Reply With Quote
  #15   Spotlight this post!  
Unread 15-02-2012, 21:16
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,752
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: Extrapolating Direction From Images

If the coordinate system has zero at its center, and the center is the goal value, then measured position minus center is the same as center-0.

Ideally, I'd then compute the desired rotation and close the loop using a gyro or encoders -- use the faster sensors to feedback, and tune a PID loop --probably just a PI.

Greg Mckaskle
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 22:22.

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