joelg236
22-03-2013, 19:50
I've been looking into automatic drivetrain shifting code. I've found this thread (http://www.chiefdelphi.com/forums/showthread.php?threadid=110235) pretty helpful so far, specifically
apalrd's post (http://www.chiefdelphi.com/forums/showpost.php?p=1205934&postcount=6). I've basically been looking all over this (https://www.google.ca/search?q=automatic+gear+shifting+site%3Achiefdelph i.com&aq=f&oq=automatic+gear+shifting+site%3Achiefdelphi.com&aqs=chrome.0.57.10720&sourceid=chrome&ie=UTF-8#hl=en&sclient=psy-ab&q=automatic+gear+shifting+jvn+site:chiefdelphi.com&oq=automatic+gear+shifting+jvn+site:chiefdelphi.co m&gs_l=serp.3...1067.2297.0.2780.4.4.0.0.0.0.83.308. 4.4.0...0.0...1c.1.7.psy-ab.z1rRkTEjGo4&pbx=1&fp=1&biw=1600&bih=783&bav=on.2,or.r_cp.r_qf.&cad=b&sei=U-tMUeDHC8eRiALGw4CIDQ) search. I've also found 254's driving code here (https://github.com/Team254/FRC-2012/blob/master/src/subsystems/Drive.cpp) and here (https://github.com/Team254/FRC-2011/blob/master/Source/ControlLoops/DriveControl.cpp), but I just don't know enough C++ to understand exactly how it works (or if it even auto-shifts! - I was told that they do but I can't find where it happens). Anyways, I'm just looking for some kind of rundown on how exactly you'd determine whether to shift up or down. So far I've come up with this:
if (input > shiftersInputThreshhold && m.encoder.getRate() > shiftersSpeedThreshhold
// Make sure not to shift too much
&& (System.currentTimeMillis() - lastShift) > shiftersShiftTimeLimit * 1000) {
m.gearShifterController.setSecondGear();
lastShift = System.currentTimeMillis();
} else {
m.gearShifterController.setFirstGear();
}
Although I can't think of them right now, I have a pretty strong feeling that there are a lot of things that this doesn't account for. Just as much, I have no idea what to set "shiftersSpeedThreashhold" or "shiftersInputThreashhold". It seems arbitrary to me. I've been told (and others in old threads have alluded to) that JVN has some kind of way to determine those kinds of threashholds. We're using 2 CIMs and the super shifter gear box (from what I'm told). Is there anywhere you could point to for some ways for algorithms to shift gears?
My goal here is for it to shift when the robot is going fast enough that it needs to, and have enough torque to push others around.
Oh and one last thing, should shifting take turning into account? Right now that's a little bit difficult to do with my code (for implementation reasons). What benefit would something like this
if(abs(turn) > 0) doNotShiftGears()
give me? Is it really necessary if we aren't using tank drive?
apalrd's post (http://www.chiefdelphi.com/forums/showpost.php?p=1205934&postcount=6). I've basically been looking all over this (https://www.google.ca/search?q=automatic+gear+shifting+site%3Achiefdelph i.com&aq=f&oq=automatic+gear+shifting+site%3Achiefdelphi.com&aqs=chrome.0.57.10720&sourceid=chrome&ie=UTF-8#hl=en&sclient=psy-ab&q=automatic+gear+shifting+jvn+site:chiefdelphi.com&oq=automatic+gear+shifting+jvn+site:chiefdelphi.co m&gs_l=serp.3...1067.2297.0.2780.4.4.0.0.0.0.83.308. 4.4.0...0.0...1c.1.7.psy-ab.z1rRkTEjGo4&pbx=1&fp=1&biw=1600&bih=783&bav=on.2,or.r_cp.r_qf.&cad=b&sei=U-tMUeDHC8eRiALGw4CIDQ) search. I've also found 254's driving code here (https://github.com/Team254/FRC-2012/blob/master/src/subsystems/Drive.cpp) and here (https://github.com/Team254/FRC-2011/blob/master/Source/ControlLoops/DriveControl.cpp), but I just don't know enough C++ to understand exactly how it works (or if it even auto-shifts! - I was told that they do but I can't find where it happens). Anyways, I'm just looking for some kind of rundown on how exactly you'd determine whether to shift up or down. So far I've come up with this:
if (input > shiftersInputThreshhold && m.encoder.getRate() > shiftersSpeedThreshhold
// Make sure not to shift too much
&& (System.currentTimeMillis() - lastShift) > shiftersShiftTimeLimit * 1000) {
m.gearShifterController.setSecondGear();
lastShift = System.currentTimeMillis();
} else {
m.gearShifterController.setFirstGear();
}
Although I can't think of them right now, I have a pretty strong feeling that there are a lot of things that this doesn't account for. Just as much, I have no idea what to set "shiftersSpeedThreashhold" or "shiftersInputThreashhold". It seems arbitrary to me. I've been told (and others in old threads have alluded to) that JVN has some kind of way to determine those kinds of threashholds. We're using 2 CIMs and the super shifter gear box (from what I'm told). Is there anywhere you could point to for some ways for algorithms to shift gears?
My goal here is for it to shift when the robot is going fast enough that it needs to, and have enough torque to push others around.
Oh and one last thing, should shifting take turning into account? Right now that's a little bit difficult to do with my code (for implementation reasons). What benefit would something like this
if(abs(turn) > 0) doNotShiftGears()
give me? Is it really necessary if we aren't using tank drive?