Go to Post Sometimes students ask me if MIT wants students who are well-rounded. I usually say I don't care as much if you're well-rounded or pointy, what I care about is evaluating the space enclosed by the shape. - Petey [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 28-02-2012, 21:19
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 671
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Use Gyro to turn 90 Degrees

Yes, you can do the following, for eample:
Code:
float targetHeading = gyro->GetAngle() + 90.0;
while (gyro->GetAngle() < targetHeading)
{
    drive->ArcadeDrive(0.0, 0.5);
}
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 28-02-2012, 21:27
DavisC DavisC is offline
Registered User
FRC #0539 (Titans)
Team Role: College Student
 
Join Date: Jul 2011
Rookie Year: 2010
Location: Virginia
Posts: 200
DavisC is just really niceDavisC is just really niceDavisC is just really niceDavisC is just really nice
Re: Use Gyro to turn 90 Degrees

Alright I will be testing that tomorrow. I was curious about the value range because we had the bot set up with the following code:
Code:
float angle = gyro.GetAngle() + 90;
myRobot.Drive(-0.2, -angle / 30);
The robot went straight before the "+ 90"; the -0.2 is because a negative value is actually forward on the bot.

The result when running this was that the robot would turn right at a medium rate and continue turning after passing 90 degrees.

The other result that seemed odd was that changing "/ 30" to "/ 1" caused a slower turn rate while changing it to "/ 60" caused a faster turn rate.
__________________
FRC Team 539
Student Member: 2010 Breakaway - 2014 Aerial Assist
Mentor: 2015 Recycle Rush - present
Reply With Quote
  #3   Spotlight this post!  
Unread 28-02-2012, 21:42
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 671
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Use Gyro to turn 90 Degrees

If you just want a simple turn, don't use myRobot.Drive, just use ArcadeDrive, like this:
Code:
#define TURN_TOLERANCE 0.5
void Turn(float angle)
{
    float targetHeading = gyro.GetAngle() + angle;
    while (fabs(targetHeading - gyro.GetAngle()) > TURN_TOLERANCE)
    {
        myRobot.ArcadeDrive(0.0, (angle < 0.0)? -0.5: 0.5);
    }
}
However, if you want to adjust the turn power according to how far you are from your target, then you need to use PID.
BTW, you should really fix your signs by calling myRobot->SetInvertedMotor(), you will benefit from it in the long run.
__________________

Last edited by mikets : 28-02-2012 at 21:46.
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 03:04.

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