Go to Post Leave it to Cheif Delphi to make a thread go from discussing the imminent game hint to discussing what is the superior pizza topping. - BriteBacon [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

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-03-2016, 18:51
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 222
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Help with Vision Algorithm

Hi,

I am attempting to make an auto line up algorithm with our vision stats. Right now, I am just using the X and Y coordinates to do line up the forward/ back and the side to side of the robot. The problem is that the robot overcompensates most of the time, even when I have a generous range of about 30 pixels(in a 320 x 240 image). I read a lot about how to set up the vision processing, but I really haven't seen much on actually using those values(probably because everyone's robot is different). The summary of the code looks like this:
Code:
visionXvalues = NetworkTables.getArray('centerX', self.centerX)
visionYvalues = NetworkTables.getArray('centerY', self.centerY)

if visionXvalues > 180:
     TURN
elif visionXvalues < 120:
     TURN
else:
     DO NOTHING

if visionYvalues > 110:
     GO FORWARD
elif visionYvalues < 80:
     GO BACK
else:
     DO NOTHING
For the turning and such it is merely just me doing "self.motor.set(.25)". My question is, is there a good way of quickly being able to line yourself up? I feel like the string of "if" statements are very clunky. Our robot shoots from the same relative area each time so I don't need to mess with Trig stuff.

One of the possible solutions I thought we might try is using PID control, but I haven't ever used it. Can you use PID only sometimes like when the align function is called? Or do you have to then implement it in all areas where you call that motor?

Also, I use GRIP if that changes anything.

Thanks!
  #2   Spotlight this post!  
Unread 08-03-2016, 18:57
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,058
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: Help with Vision Algorithm

There's a bunch of ways to go about this, but the basic idea is to define some set of controls that allow you to 'tell the robot to point at a particular direction'. Once you have that, you can:
  • Determine the robot's current angle (using a Gyro/NavX)
  • Determine the offset angle from your target (via GRIP/whatever)
  • Tell the robot to go to (current angle + offset)

For an example of using PIDController + NavX in pyfrc simulation to 'go to a particular angle', see this example: https://github.com/robotpy/robotpy-w...otate_to_angle
__________________
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
Closed Thread


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 00:40.

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