Go to Post Backstabbing your opponents at the last second will not help you win friends and word will get around pretty quick. Your team will be shunned and distrusted for years. People have long memories, and some of us mentors have been playing this game since you kids were playing with blocks. - ChrisH [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 Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
  #16   Spotlight this post!  
Unread 16-06-2014, 12:44
Bpk9p4's Avatar
Bpk9p4 Bpk9p4 is offline
Registered User
FRC #1756
Team Role: Mentor
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Illinios
Posts: 271
Bpk9p4 is on a distinguished road
Re: Driving Straight

Quote:
Originally Posted by Chris Hibner View Post
You can use the encoders to emulate a gyro for driving straight. Here is some psuedo-code for how to do it:

Code:
heading = 57.3*(leftEncDist - rightEncDist) / trackWidth;

if (abs(driverTurnCmd) < turnDeadZone)
{
  if (headingCaptured == FALSE)
  {
     desiredHeading = heading;
     headingCaptured = TRUE;
  }
  turnCmdPID = PID(heading, desiredHeading);
  arcadeDrive(driverThrottleCmd, turnCmdPID);
}
else
{
  headingCaptured = FALSE;
  arcadeDrive(driverThrottleCmd, driverTurnCmd);
}
When we've done this in the past, it makes it a little smoother if you lead your desired heading with your turn rate. So instead of "desiredHeading = heading" in the above code, we've done "desiredHeading = Heading + robotTurnSpeed * leadFactor", where "leadFactor" is a calibration that you tune to make the stopping of the turn smooth.
I really like this gyro idea i will have to give it a try.

I am only going to be using this outside of auto. During auto we use a gyro.

The method i am trying now is to use a velocity control PID for each side. however it would be nice to have a slave/master configuration but i am not sure hot to deal with turning
Reply With Quote
  #17   Spotlight this post!  
Unread 16-06-2014, 12:55
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,717
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Driving Straight

Quote:
Originally Posted by Bpk9p4 View Post
I really like this gyro idea i will have to give it a try.

I am only going to be using this outside of auto. During auto we use a gyro.

The method i am trying now is to use a velocity control PID for each side. however it would be nice to have a slave/master configuration but i am not sure hot to deal with turning
For long uses of a gyro make sure to take into account the gyro's drift.
Reply With Quote
  #18   Spotlight this post!  
Unread 18-06-2014, 13:42
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Driving Straight

We've found LabView compensates fairly well for the drift. We usually see a few degrees per minute, which has been more than accurate enough for our matches. If you need more than that, you can extend the duration it uses to measure the drift.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #19   Spotlight this post!  
Unread 08-08-2014, 04:45
lakecat's Avatar
lakecat lakecat is offline
Cat Expert
AKA: Tristan Thompson
FRC #2635 (Lake Monsters)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Lake Oswego, OR
Posts: 15
lakecat is an unknown quantity at this point
Re: Driving Straight

I believe that the CAN bus library has built in PID. All we had to do last year was set it to speed control mode and to read off the encoder.
Reply With Quote
  #20   Spotlight this post!  
Unread 13-11-2015, 11:26
mschwab013's Avatar
mschwab013 mschwab013 is offline
Registered User
AKA: Matt Schwabenbauer
FRC #0291
Team Role: College Student
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Erie, PA
Posts: 87
mschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to all
Re: Driving Straight

Quote:
Originally Posted by Chris Hibner View Post
You can use the encoders to emulate a gyro for driving straight. Here is some psuedo-code for how to do it:

Code:
heading = 57.3*(leftEncDist - rightEncDist) / trackWidth;

if (abs(driverTurnCmd) < turnDeadZone)
{
  if (headingCaptured == FALSE)
  {
     desiredHeading = heading;
     headingCaptured = TRUE;
  }
  turnCmdPID = PID(heading, desiredHeading);
  arcadeDrive(driverThrottleCmd, turnCmdPID);
}
else
{
  headingCaptured = FALSE;
  arcadeDrive(driverThrottleCmd, driverTurnCmd);
}
When we've done this in the past, it makes it a little smoother if you lead your desired heading with your turn rate. So instead of "desiredHeading = heading" in the above code, we've done "desiredHeading = Heading + robotTurnSpeed * leadFactor", where "leadFactor" is a calibration that you tune to make the stopping of the turn smooth.
I'm currently trying to implement a very similar system and was wondering if you had any recommendations for tuning the PID constants and the "leadFactor" at the same time
__________________


2013 Pittsburgh- Gracious Professionalism award, 7th seed, 6th alliance captian, quarter-finalist(291,3492,4601)
2013 Queen CIty- Chairman's Award, 39th seed
2012 Pittsburgh- 23rd seed
2012 Buckeye- 34th seed, 2nd alliance, quarter-finalist(291,1241,4085)
2011 Pittsburgh- 13th seed, 5th alliance, quarter-finalist(291,337,3504)
2011 Buckeye- 18th seed, 8th alliance, quarter-finalist(279,291,3496)
2010 Finger Lakes- 15th seed, 5th alliance, quarter-finalist(291,1507,1559)
2010 Buckeye- Chairman's Award, Imagery Award, Quality Award, 4th seed, 1st pick, 1st alliance, semi-finalist(291,1014,1629)
Reply With Quote
  #21   Spotlight this post!  
Unread 13-11-2015, 11:40
aeastet aeastet is offline
Programming Mentor
AKA: Tim Easterling
FRC #6043 (Allegan Tigers Robotics)
Team Role: Coach
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Holland, MI
Posts: 117
aeastet is an unknown quantity at this point
Re: Driving Straight

We used the gyro for driving straight for Auto and during the matches this year. The gyro is the easiest way to make sure you are going in a certain direction. We used the drive straight to drive to the step and drive straight to back up from the step. This way we did not knock over a stack of totes. We had a lance sticking out that we used for auto to move the recycle bins out of the way. If the driver turned while backing up it would move the stack. This function to drive straight back was a huge hit with the drivers.

The NavMXP had very little drift. We left it running for 20 minutes one time and had no drift. Way better than the old kit gyro. If you are trying to drive straight and you have a gyro why would you do it any other way?

Tim
Reply With Quote
  #22   Spotlight this post!  
Unread 13-11-2015, 17:48
dubiousSwain's Avatar
dubiousSwain dubiousSwain is offline
The ride never ends
AKA: Christian Steward
FRC #5420 (Velocity)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2011
Location: USA
Posts: 304
dubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond repute
Re: Driving Straight

Quote:
Originally Posted by adciv View Post
We've found LabView compensates fairly well for the drift. We usually see a few degrees per minute, which has been more than accurate enough for our matches. If you need more than that, you can extend the duration it uses to measure the drift.
Its important to tune your gyro properly or you'll get noise and drift. 316 ran into this problem last year.
__________________
2015 MAR District Champions




Reply With Quote
  #23   Spotlight this post!  
Unread 13-11-2015, 20:42
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,590
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Driving Straight

Quote:
Originally Posted by dubiousSwain View Post
Its important to tune your gyro properly or you'll get noise and drift. 316 ran into this problem last year.
As with so many things, it's important to understand how much noise and drift you can accept. If you're only using the gyro for autonomous (15 seconds long) or to do short-term maneuvers (like backing up in a straight line without your probe knocking down a stack), you can allow significantly more drift than if you're expecting your "arena coordinates" mecanum drive to be stable through a full 2-1/2 minute match. If you're looking for full-match alignment and can't get it from your gyro or encoders, consider if your strategy puts you up against a wall or other well-defined feature of the field on a regular basis, and see if you can use that as an opportunity for a heading correction.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #24   Spotlight this post!  
Unread 14-11-2015, 00:21
Ari423's Avatar
Ari423 Ari423 is offline
LabVIEW aficionado and robot addict
AKA: The guy with the yellow hat
FRC #5987 (Galaxia)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2012
Location: Haifa, Israel
Posts: 576
Ari423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant future
Re: Driving Straight

Quote:
Originally Posted by GeeTwo View Post
As with so many things, it's important to understand how much noise and drift you can accept. If you're only using the gyro for autonomous (15 seconds long) or to do short-term maneuvers (like backing up in a straight line without your probe knocking down a stack), you can allow significantly more drift than if you're expecting your "arena coordinates" mecanum drive to be stable through a full 2-1/2 minute match. If you're looking for full-match alignment and can't get it from your gyro or encoders, consider if your strategy puts you up against a wall or other well-defined feature of the field on a regular basis, and see if you can use that as an opportunity for a heading correction.
We never got it fully implemented in a competition robot, but we made code last year that would use the output from two ultrasonic sensors to detect the angle the robot was at compared to a flat wall. When we would click a button on the dashboard corresponding to which wall the robot was facing, it would automatically reset the gyro to the measured angle away from the angle of the wall (+/- 90 for side walls, 180 for back wall). This meant we wouldn't have to slam against a wall to reset the gyro, we just had to drive up to it at a not-too-shallow angle.
__________________
2017-present: Mentor FRC 5987
2017-present: CSA for FIRST in Israel
2012-2016: Member FRC 423
2013: Programmer
2014: Head Programmer, Wiring
2015: Head Programmer, Wiring
2016: Captain, Head Programmer, Wiring, Manipulator, Chassis, CAD, Business, Outreach (basically everything)


Reply With Quote
  #25   Spotlight this post!  
Unread 19-11-2015, 08:59
aeastet aeastet is offline
Programming Mentor
AKA: Tim Easterling
FRC #6043 (Allegan Tigers Robotics)
Team Role: Coach
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Holland, MI
Posts: 117
aeastet is an unknown quantity at this point
Re: Driving Straight

Quote:
Originally Posted by GeeTwo View Post
As with so many things, it's important to understand how much noise and drift you can accept. If you're only using the gyro for autonomous (15 seconds long) or to do short-term maneuvers (like backing up in a straight line without your probe knocking down a stack), you can allow significantly more drift than if you're expecting your "arena coordinates" mecanum drive to be stable through a full 2-1/2 minute match. If you're looking for full-match alignment and can't get it from your gyro or encoders, consider if your strategy puts you up against a wall or other well-defined feature of the field on a regular basis, and see if you can use that as an opportunity for a heading correction.
We actually had our NavMXP gyro running for over 20 minutes with only 1 degree of error the whole time. The NavMXP Gyro has been one of the most awesome finds I have had for the years that I have been coaching. I did a little work to the code from NavMXP but I do not see drift specially in the two minutes of the game. Our auto went 12 for 12 at world championships and was about 95% the rest of the year. We turned and drove straight many times throughout the match. The old kit of parts gyro was a waist of time. I am tell everyone that I see that this one is for real.
Reply With Quote
  #26   Spotlight this post!  
Unread 27-11-2015, 23:33
Skyehawk's Avatar
Skyehawk Skyehawk is offline
Nuts N' Bolts
AKA: Skye Leake
FRC #0876 (Thunder Robotics)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2011
Location: Northwood, ND
Posts: 216
Skyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to all
Re: Driving Straight

Here is a comparison based "drive straight" code example that doesn't use PIDs. It is handy for demonstrations, programming practice, etc. where you need to be able to follow along without getting wrapped up in more advanced functions (such as PIDs) useful, like it was said before, if the user hasn't taken basic calculus. Works like a charm, it may be a little sparsely commented, but just PM me if you have any questions.

FYI: Top encoder is left side, bottom is right side. This code makes the robot REVERSE at 50% speed. (I just pulled it out of one of our autonomous routines).

The .06125 constant is "inches traveled/encoder tick" (you will need to update this to accommodate for your drive train reduction between the encoder shaft and the wheels).
The 85 constant is the desired distance in inches.

You can import this vi code snippet into Labview.

Cheers,
Skye
Attached Thumbnails
Click image for larger version

Name:	Auto_Straight_Line_reverse_encoder.png
Views:	31
Size:	31.7 KB
ID:	19507  
__________________
My time in FIRST has made me a better person, frankly I don't know where I'd be without it.



2011 Lake Superior Regional Champs
2015 Central Illinois Regional Engineering Inspiration Award recipients
2016 Central Illinois Regional Champs
Reply With Quote
  #27   Spotlight this post!  
Unread 28-11-2015, 11:45
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,749
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: Driving Straight

I've seen a number of FLL teams use an approach similar to what I attached. They will have three to five cases where they tune the coefficients or return hard-coded numbers. Sometimes the sensor is an ultrasonic sensor to follow a wall instead of two encoders. Sometimes they reset the sensors inside the loop instead of accumulating.

These approaches work pretty well if the loop runs fast enough. It gives them a piece to tune and once they gain a sense of how the control works, you can add storage and have both integrated and term-to-term error, and pretty soon you have a simple PID, or at least the portion of it that you need for that problem.

Since FRC robots take lots of space and infrastructure to run, you may find it useful to use a smaller robot to structure the code, then try it out on an FRC bot.

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	From Clipboard 3.png
Views:	33
Size:	48.6 KB
ID:	19508  
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 06:12.

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