Go to Post The most important things for a team to take to any competition are a sense of humor, a big bottle of Advil, and a camera! - Rick TYler [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 02-12-2016, 06:20 PM
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
Problem with NavX to turn around.

Hi,

This year, our shooter direction is opposite of our front of our robot. I decided that we should use the NavX we just got to semi-accurately turn ourselves around. We don't have any encoders on our motors so I just made a simple function that would have the motors turn until it hit a 10 degree range in which case it would stop.

The problem is that it doesn't always work. It works 9/10 times but that one time it just spins endlessly in a circle and never stops. This, of course, is not something you want to happen. I am asking if there is a better way to go about programming this so it ALWAYS works? Here is the current function:

Code:
        #if button pressed, start
        if self.turn_button.get():
            self.turn_state=0
            yaw=self.navx.getYaw()
            #Our NavX is not completely centered on the robot so 
            #that is why it isn't 180 degrees for turning around
            if yaw > 0:
               
                self.desired=self.navx.getYaw()-227
            else:
                self.desired=self.navx.getYaw()+133
 
 
        current=self.navx.getYaw()
        if self.turn_state==0:
            self.turn_state=1
        elif self.turn_state==1:
            if current < (self.desired+10) and current > self.desired:
                self.turn_state=2
            else:
                self.drive2.set(.7)
                self.drive1.set(.5)
Any help would be greatly appreciated!
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 04:43 AM.

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