Go to Post If you cannot complete relatively simple tasks, why would anyone assign you something more challenging?? - Chris Fultz [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 22-07-2016, 19:19
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: 216
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
How to more accurately calculate angle to goal with offsets?

Hi!

We were excited to finally have an angle to goal PID loop somewhat working the other day until we realized how inconsistent it was. Sometimes it would be dead on, other times it would be just enough off that our shot missed. I set the tolerance to a minimal .5 degrees so it should be going right where it is told to be going. The prime suspect is how our camera and gyro is mounted.(C is for camera and G is for gyro, arrow points to where we line up)

We have never done vision before this season so we weren't exactly trained on where the ideal places are for the camera and gyro to make programming easier. Thankfully for programming, we do shoot only a couple feet from the end of the batter, so there is more wiggle room. Our current vision code looks like this:
Code:
###X is inputted into gyroMagic which then is used for when I call the visionTurn function for the PID loop###

    def gyroMagic(self, x):
        angle = ((x-170)*(60/320)) #170 is about center of target when lined up
        yaw=self.navx.getYaw()
        print (yaw)
        if yaw > 0:
            self.desiredAngle=self.navx.getYaw()+(angle) 
            if self.desiredAngle>179:
                self.desiredAngle -= 360
        else:
            self.desiredAngle=self.navx.getYaw()+(angle)
            if self.desiredAngle<-179:
                self.desiredAngle += 360

        return self.desiredAngle

    def visionTurn(self):

        if self.vision_state == 1:
            self.turnController.setSetpoint(self.desiredAngle)
            self.rotateReady = True
            self.vision_state=2
        elif self.vision_state == 2:

            if self.turnController.onTarget() or self.cancel.get():
                self.vision_state=3
                self.rotateReady=False
                self.auto_aline_autoNow=False
So my ultimate question is, as someone who hasn't taken a trig class yet, how do I offset the camera and gyro placement to get a more accurate angle to the target? I am also of thinking of changing my angle algorithm to copy what Jared Russell recommends, but I believe that an offset algorithm would make our robot shoot much better. Any help would be greatly appreciated! Thanks!
__________________
#Python4Life
Reply With Quote
 


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:36.

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