|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Team 254 2011 FRC Code
Hey all,
I'm Eric Bakan and I'm Team 254's Head of Programming/Controls aka Chief Executive Brogrammer. With the conclusion of our last offseason event, the MadTown Throwdown, Team 254 is releasing our 2011 FRC codebase. The code can be viewed and downloaded from our team GitHub at https://github.com/Team254/FRC-2011 We had used SVN for the duration of the season but unfortunately our server died and we lost all our SVN backlogs. Based on our programming team's previous experience we've decided to move to Git for our version control, primarily because it allows us to make offline commits when we have intermittent internet access on our developer laptop. At the moment this is merely the snapshot of our code as of the end of Championships. We hope that releasing this code will prove useful to other teams. The included README should provide useful details about the architecture of the system and the individual files should have further notes. Our only request is that you leave a reply if you found any of this code helpful. Everything is released under a 2-Clause BSD License so feel free to use any part of it. Last edited by ebakan : 14-11-2011 at 15:56. |
|
#2
|
|||||
|
|||||
|
Re: Team 254 2011 FRC Code
Thanks for posting! The attention to detail is astounding. 4 different sets of PID gains for the elevator, depending on direction and number of stages engaged?
![]() EDIT: And that's before I even saw the state space controller for the drive ![]() Last edited by Jared Russell : 14-11-2011 at 15:42. |
|
#3
|
|||||
|
|||||
|
Re: Team 254 2011 FRC Code
Incredibly exciting to see such sophisticated robot code being open sourced. I would love to see other teams follow suite
![]() |
|
#4
|
|||
|
|||
|
Re: Team 254 2011 FRC Code
Quote:
Quote:
If you or anyone else has any questions, we'd be glad to try and answer them. |
|
#5
|
||||
|
||||
|
Re: Team 254 2011 FRC Code
Quote:
|
|
#6
|
|||
|
|||
|
Re: Team 254 2011 FRC Code
We used a simple PD loop on the wrist and elevator with some gain scheduling, since it worked well enough after hand tuning. The elevator changes mass when it starts to lift the second stage, so there is a second set of constants for that case. For both the arm and elevator, they would undershoot when approaching the goal from below, and overshoot when approaching the goal from above. To solve this, we have 2 sets of constants, one per direction. This solved our overshoot problems. I also avoid integral whenever possible. We just accepted the small steady state error on the elevator and wrist, and moved on, rather than spending the extra time to tune the integral constant across 6 sets of constants. We pass a goal into the two sub systems when we hit the setpoint buttons. The manual joysticks for those two systems also tweak the goals, rather than doing anything with power.
One thing we realized when driving the robot was that it was very useful for the arm to be angled ~50 degrees above horizontal when lining up to place a tube. To facilitate this, whenever a setpoint button is hit, the elevator raises up, and then when it is all the way up, the arm tilts forwards. When the driver hits another button, the robot then goes through an "auto-score" motion which opens the claw, spits out, lowers the elevator, then raises the arm back up, and backs the robot up. This offloads a lot of stuff from the drivers. Most of the fancy controls is in the drivetrain, which we spent easily over a month working on to tune the robot so that it was accurate and precise enough to score two tubes. |
|
#7
|
|||||
|
|||||
|
Re: Team 254 2011 FRC Code
Ah, if only I knew enough C to appreciate it. (LabVIEW team here) I'm sure it would make me wanna tear up a bit..
|
|
#8
|
||||
|
||||
|
Re: Team 254 2011 FRC Code
Quote:
|
|
#9
|
|||||
|
|||||
|
Re: Team 254 2011 FRC Code
Quote:
Is there any reason that you didn't run the elevator and arm as a single integrated system, to simplify things like this? We ran our elevator/arm as a single state machine, and part of the state transition handled actions like this (with the data input being a requested state, and the data output being a pair of setpoints), and fed the positions output into a pair of setpoint controllers and anti-death logic. |
|
#10
|
|||
|
|||
|
Re: Team 254 2011 FRC Code
Quote:
Looking back, I really like how easy it was to write auto modes with the multi-threading that we did, and would like to make it that easy to write auto-score functions as well. |
|
#11
|
|||||
|
|||||
|
Re: Team 254 2011 FRC Code
Yes, multithreading can lead to prettier/less verbose auto modes, in my experience. We have been prototyping a trapezoidal motion profile as well, and I really like how smoothly it achieves distance setpoints with sub-inch accuracy. Are you using a trapezoidal profile for turning in place, as well? (I didn't notice it, but haven't gone through line by line - yet)
EDIT: Yes, I see that you did ![]() Last edited by Jared Russell : 15-11-2011 at 09:03. |
|
#12
|
||||
|
||||
|
Re: Team 254 2011 FRC Code
I perused the code over lunch and noticed something that confused me. In your ports file you've assigned both the "B" port of an encoder and a limit switch to digital I/O 10. In order to facilitate this, was there a specific order the wires had to go into the DIN for I/O 10?
We rely heavily on limit switches to act as redundant safeties during programming as well as sensor failures, so being able to pair limit switches with encoders in this manner could save us from having to make I/O port tradeoffs. |
|
#13
|
|||||
|
|||||
|
Re: Team 254 2011 FRC Code
The port definitions for the top and bottom roller encoders are probably obsolete. It doesn't look like either of those encoders is actually used in the code, so there's no real conflict.
|
|
#14
|
|||
|
|||
|
Re: Team 254 2011 FRC Code
Correct. There are no encoders on the rollers. That sounds like a very old piece of code that didn't get removed as the code evolved...
|
|
#15
|
|||
|
|||
|
Re: Team 254 2011 FRC Code
Hi,
Thanks for posting your code. The architecture is very pleasing to a controls engineer. I like control loops and filters as classes. Can you expand a little on your use of negitive inertia. I assume this is equivalent to adding derivatives of the control input to improve performance, but I would like to hear more about your use. Any papers to refererence? Also, I think you can use much simpler functions to fit your Victors. One linearizer that involves a single parameter to adjust is: vic_cmd = min_cmd/(1 - (1-min_cmd)*input_cmd) where min_cmd = the minimum command to keep the motor moving, i.e. equivalent to the torque required to overcome dynamic friction. All commands are normalized [-1,1]. One can play with min_cmd to get a very good fit. The equation is valid for input_cmd>0. You have to change a few signs for input_cmd<0 and the min_cmd can be different for each sign. This equation follows directly from the steady state current model of the h_bridge with a low frequency pwm. The current model is summarized in this older post. I will write a blog post on this later. Attached is a curve fit of some old data I had on a victor. Maybe Joe Ross sent it to me and it could be an 883 or 884. The inverse is obtained by taking the victor speed and running it through the inverse function above. Last edited by vamfun : 17-02-2012 at 17:06. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|