diff --git a/.gitignore b/.gitignore index 5528d4f..2c29e44 100644 --- a/.gitignore +++ b/.gitignore @@ -176,3 +176,7 @@ logs/ # Folder that has CTRE Phoenix Sim device config storage ctre_sim/ + +.SysId/ +SysId +.SysId \ No newline at end of file diff --git a/.pathplanner/settings.json b/.pathplanner/settings.json index 8b73a9d..101b75c 100644 --- a/.pathplanner/settings.json +++ b/.pathplanner/settings.json @@ -1,15 +1,17 @@ { - "robotWidth": 0.6604, - "robotLength": 0.6604, + "robotWidth": 0.85, + "robotLength": 0.85, "holonomicMode": true, "pathFolders": [ - "3 Note Test" + "McNugget paths", + "Midfield Paths", + "Close" ], "autoFolders": [ "Testing" ], "defaultMaxVel": 4.0, - "defaultMaxAccel": 8.0, + "defaultMaxAccel": 3.5, "defaultMaxAngVel": 540.0, "defaultMaxAngAccel": 720.0, "maxModuleSpeed": 4.5 diff --git a/.vscode/launch.json b/.vscode/launch.json index c9c9713..1f39ec5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,18 +4,24 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ - + { + "type": "java", + "name": "Main", + "request": "launch", + "mainClass": "frc.robot.Main", + "projectName": "2024-Robot" + }, { "type": "wpilib", "name": "WPILib Desktop Debug", "request": "launch", - "desktop": true, + "desktop": true }, { "type": "wpilib", "name": "WPILib roboRIO Debug", "request": "launch", - "desktop": false, + "desktop": false } ] } diff --git a/CHOREO_TEST.chor b/CHOREO_TEST.chor index 9e7a53e..f171404 100644 --- a/CHOREO_TEST.chor +++ b/CHOREO_TEST.chor @@ -13,1383 +13,6 @@ "wheelRadius": 0.0508 }, "paths": { - "Choreo Test Path": { - "waypoints": [ - { - "x": 2.098140239715576, - "y": 1.6614248752593994, - "heading": 0, - "isInitialGuess": false, - "translationConstrained": true, - "headingConstrained": true, - "controlIntervalCount": 16 - }, - { - "x": 3.049372911453247, - "y": 1.7892024517059326, - "heading": 1.5451611748024034, - "isInitialGuess": false, - "translationConstrained": true, - "headingConstrained": false, - "controlIntervalCount": 16 - }, - { - "x": 3.929617404937744, - "y": 1.4626601934432983, - "heading": 0, - "isInitialGuess": false, - "translationConstrained": true, - "headingConstrained": true, - "controlIntervalCount": 40 - } - ], - "trajectory": [ - { - "x": 2.098140239715576, - "y": 1.6614248752593994, - "heading": 0, - "angularVelocity": -1.1782841342854263e-17, - "velocityX": 0, - "velocityY": 0, - "timestamp": 0 - }, - { - "x": 2.1051233600297774, - "y": 1.6635944045152462, - "heading": -3.951223132837311e-19, - "angularVelocity": -1.1782800630375306e-17, - "velocityX": 0.20824119889647139, - "velocityY": 0.06469677636224515, - "timestamp": 0.033533807676900264 - }, - { - "x": 2.119117786580325, - "y": 1.6678405678016424, - "heading": -7.9021234698948305e-19, - "angularVelocity": -1.1781838033475747e-17, - "velocityX": 0.4173229203609856, - "velocityY": 0.12662335656327253, - "timestamp": 0.06706761535380053 - }, - { - "x": 2.1401546040286137, - "y": 1.6740553731630874, - "heading": -1.1852369347134683e-18, - "angularVelocity": -1.177988639288366e-17, - "velocityX": 0.6273316066871726, - "velocityY": 0.1853295462694014, - "timestamp": 0.1006014230307008 - }, - { - "x": 2.1682680830995276, - "y": 1.6821118294466222, - "heading": -1.5801501749567216e-18, - "angularVelocity": -1.1776565942199235e-17, - "velocityX": 0.8383622683647712, - "velocityY": 0.24024877703001501, - "timestamp": 0.13413523070760106 - }, - { - "x": 2.203495885097548, - "y": 1.6918586180026898, - "heading": -1.97490623007624e-18, - "angularVelocity": -1.1771878578827117e-17, - "velocityX": 1.05051601468707, - "velocityY": 0.29065558704154515, - "timestamp": 0.1676690383845013 - }, - { - "x": 2.2458790364152166, - "y": 1.703112650834629, - "heading": -2.36944701232745e-18, - "angularVelocity": -1.1765459002163076e-17, - "velocityX": 1.263893194773236, - "velocityY": 0.33560259366823547, - "timestamp": 0.20120284606140157 - }, - { - "x": 2.2954613527044936, - "y": 1.7156484118689923, - "heading": -2.7636989943414952e-18, - "angularVelocity": -1.1756846791909453e-17, - "velocityX": 1.4785769861569105, - "velocityY": 0.3738245640085363, - "timestamp": 0.23473665373830183 - }, - { - "x": 2.352287604871465, - "y": 1.729182265786357, - "heading": -3.157524610938865e-18, - "angularVelocity": -1.1744132302464973e-17, - "velocityX": 1.6945958751387369, - "velocityY": 0.4035883442692906, - "timestamp": 0.2682704614152021 - }, - { - "x": 2.4163988172653466, - "y": 1.7433486874743551, - "heading": -3.5508014214230656e-18, - "angularVelocity": -1.1727766554501323e-17, - "velocityX": 1.9118381369511075, - "velocityY": 0.42245192745460064, - "timestamp": 0.3018042690921024 - }, - { - "x": 2.4878208995175837, - "y": 1.7576632912771164, - "heading": -3.94344512657471e-18, - "angularVelocity": -1.1708886946398038e-17, - "velocityX": 2.129853040859288, - "velocityY": 0.42687081469194577, - "timestamp": 0.3353380767690027 - }, - { - "x": 2.5665373086257057, - "y": 1.7714645173374621, - "heading": -4.335271205020906e-18, - "angularVelocity": -1.1684504789304052e-17, - "velocityX": 2.347374621652199, - "velocityY": 0.41156155582810217, - "timestamp": 0.36887188444590296 - }, - { - "x": 2.6524225977886715, - "y": 1.7838242511583042, - "heading": -4.726013111112515e-18, - "angularVelocity": -1.1652174076634648e-17, - "velocityX": 2.561155297080271, - "velocityY": 0.36857531777864144, - "timestamp": 0.40240569212280325 - }, - { - "x": 2.7450834234519204, - "y": 1.7934339266460941, - "heading": -5.115299885471634e-18, - "angularVelocity": -1.1608781113863041e-17, - "velocityX": 2.7632062113565348, - "velocityY": 0.2865667859843989, - "timestamp": 0.43593949979970353 - }, - { - "x": 2.843530303188657, - "y": 1.7985723309277442, - "heading": -5.502770619918827e-18, - "angularVelocity": -1.1554625647246029e-17, - "velocityX": 2.935750114787817, - "velocityY": 0.15323056454418926, - "timestamp": 0.4694733074766038 - }, - { - "x": 2.9458179129472843, - "y": 1.797488238615398, - "heading": -5.8894880430727135e-18, - "angularVelocity": -1.1532161415565022e-17, - "velocityX": 3.0502831871693488, - "velocityY": -0.032328339292479705, - "timestamp": 0.503007115153504 - }, - { - "x": 3.049372911453247, - "y": 1.7892024517059326, - "heading": -6.275464863063295e-18, - "angularVelocity": -1.1510076130028052e-17, - "velocityX": 3.0880775456133938, - "velocityY": -0.24708756575746865, - "timestamp": 0.5365409228304043 - }, - { - "x": 3.1571269598575213, - "y": 1.772490251509115, - "heading": -6.681562648101382e-18, - "angularVelocity": -1.1523095181534151e-17, - "velocityX": 3.0575407451325263, - "velocityY": -0.47421172382188026, - "timestamp": 0.5717829874131273 - }, - { - "x": 3.261123146904745, - "y": 1.7486292178338445, - "heading": -8.55841431876238e-18, - "angularVelocity": -5.3255999561210285e-17, - "velocityX": 2.9509107448319467, - "velocityY": -0.6770611755522685, - "timestamp": 0.6070250519958502 - }, - { - "x": 3.3588334048054063, - "y": 1.719697243767781, - "heading": -9.701173892106415e-18, - "angularVelocity": -3.2426007562861585e-17, - "velocityX": 2.7725463606510936, - "velocityY": -0.8209500325427858, - "timestamp": 0.6422671165785732 - }, - { - "x": 3.44889324038053, - "y": 1.6881771415609788, - "heading": -1.0845266271605606e-17, - "angularVelocity": -3.2463826162489857e-17, - "velocityX": 2.5554642340470015, - "velocityY": -0.8943886398259916, - "timestamp": 0.6775091811612961 - }, - { - "x": 3.5309014136529964, - "y": 1.6560260590968738, - "heading": -1.1990405056824877e-17, - "angularVelocity": -3.2493518099484904e-17, - "velocityX": 2.3269968500275913, - "velocityY": -0.912292819526431, - "timestamp": 0.712751245744019 - }, - { - "x": 3.6048635838845873, - "y": 1.6245744507374444, - "heading": -1.313656485800498e-17, - "angularVelocity": -3.252248961405374e-17, - "velocityX": 2.098690048591799, - "velocityY": -0.8924451144343082, - "timestamp": 0.747993310326742 - }, - { - "x": 3.6709082609882207, - "y": 1.5947168159655363, - "heading": -1.428352643667232e-17, - "angularVelocity": -3.2545240196853133e-17, - "velocityX": 1.874029739336285, - "velocityY": -0.8472158236309923, - "timestamp": 0.7832353749094649 - }, - { - "x": 3.729186240680233, - "y": 1.567074102332766, - "heading": -1.543112572514496e-17, - "angularVelocity": -3.2563335321547424e-17, - "velocityX": 1.653648285991231, - "velocityY": -0.7843670329780381, - "timestamp": 0.8184774394921879 - }, - { - "x": 3.7798396108943755, - "y": 1.5420946209676558, - "heading": -1.3557190662479192e-17, - "angularVelocity": 5.317323937946322e-17, - "velocityX": 1.4372986036401205, - "velocityY": -0.7087973324172524, - "timestamp": 0.8537195040749108 - }, - { - "x": 3.8229940170612227, - "y": 1.5201139765313663, - "heading": -1.1683646818756056e-17, - "angularVelocity": 5.316213847463545e-17, - "velocityX": 1.2245141332611627, - "velocityY": -0.6237047884835205, - "timestamp": 0.8889615686576338 - }, - { - "x": 3.8587583624336923, - "y": 1.5013913212357997, - "heading": -9.810398849655971e-18, - "angularVelocity": 5.315374298099486e-17, - "velocityX": 1.0148198125146835, - "velocityY": -0.531258753346293, - "timestamp": 0.9242036332403567 - }, - { - "x": 3.8872266540166653, - "y": 1.4861320597418657, - "heading": -7.937370756395587e-18, - "angularVelocity": 5.3147503963822577e-17, - "velocityX": 0.8077929576500821, - "velocityY": -0.43298432355222594, - "timestamp": 0.9594456978230796 - }, - { - "x": 3.9084802353875676, - "y": 1.4745025997323902, - "heading": -6.0645124516602805e-18, - "angularVelocity": 5.3142686179864185e-17, - "velocityX": 0.6030742416073348, - "velocityY": -0.3299880454556786, - "timestamp": 0.9946877624058026 - }, - { - "x": 3.9225898514135444, - "y": 1.4666402693172664, - "heading": -4.191768760702976e-18, - "angularVelocity": 5.313943399764024e-17, - "velocityX": 0.40036292405222634, - "velocityY": -0.22309505723391648, - "timestamp": 1.0299298269885255 - }, - { - "x": 3.929617404937744, - "y": 1.4626601934432983, - "heading": -2.0958673938534256e-18, - "angularVelocity": 5.947156826205235e-17, - "velocityX": 0.19940811094378472, - "velocityY": -0.1129353776827106, - "timestamp": 1.0651718915712485 - }, - { - "x": 3.929617404937744, - "y": 1.4626601934432983, - "heading": 0, - "angularVelocity": 5.947060427768327e-17, - "velocityX": 0, - "velocityY": 0, - "timestamp": 1.1004139561539714 - } - ], - "constraints": [ - { - "scope": [ - "first" - ], - "type": "WptZeroVelocity" - }, - { - "scope": [ - "last" - ], - "type": "WptZeroVelocity" - } - ], - "usesControlIntervalGuessing": true, - "defaultControlIntervalCount": 40, - "usesDefaultFieldObstacles": true, - "circleObstacles": [] - }, - "Test 2": { - "waypoints": [ - { - "x": 1.2462917566299438, - "y": 7.013879299163818, - "heading": 0, - "isInitialGuess": false, - "translationConstrained": true, - "headingConstrained": true, - "controlIntervalCount": 9 - }, - { - "x": 2.4246835708618164, - "y": 6.99968147277832, - "heading": 0, - "isInitialGuess": false, - "translationConstrained": true, - "headingConstrained": false, - "controlIntervalCount": 11 - }, - { - "x": 3.9012229442596436, - "y": 6.304004669189453, - "heading": 0, - "isInitialGuess": false, - "translationConstrained": true, - "headingConstrained": false, - "controlIntervalCount": 17 - }, - { - "x": 7.649360656738281, - "y": 7.4256062507629395, - "heading": 0, - "isInitialGuess": false, - "translationConstrained": true, - "headingConstrained": true, - "controlIntervalCount": 16 - }, - { - "x": 3.9012229442596436, - "y": 6.942891597747803, - "heading": 0, - "isInitialGuess": false, - "translationConstrained": true, - "headingConstrained": true, - "controlIntervalCount": 40 - } - ], - "trajectory": [ - { - "x": 1.2462917566299438, - "y": 7.013879299163818, - "heading": 0, - "angularVelocity": 1.8576957689615527e-38, - "velocityX": 5.650902657479953e-31, - "velocityY": -5.509730104969581e-32, - "timestamp": 0 - }, - { - "x": 1.2728393380635374, - "y": 7.020025993967499, - "heading": -2.1422561939962651e-19, - "angularVelocity": -3.2119799002278703e-18, - "velocityX": 0.3980396549749024, - "velocityY": 0.09216011955865565, - "timestamp": 0.0666958206344134 - }, - { - "x": 1.3262202394266138, - "y": 7.030919145292598, - "heading": -6.179926514323356e-19, - "angularVelocity": -6.0538581091913635e-18, - "velocityX": 0.800363513865061, - "velocityY": 0.1633258459311531, - "timestamp": 0.1333916412688268 - }, - { - "x": 1.4066903645270812, - "y": 7.044766925115804, - "heading": -1.1793044915636138e-18, - "angularVelocity": -8.416002349787475e-18, - "velocityX": 1.2065242519701218, - "velocityY": 0.20762590056762728, - "timestamp": 0.2000874619032402 - }, - { - "x": 1.5144033649690225, - "y": 7.05923241946752, - "heading": -2.051076797499284e-18, - "angularVelocity": -1.3070873776347306e-17, - "velocityX": 1.6149887566774053, - "velocityY": 0.2168875682798883, - "timestamp": 0.2667832825376536 - }, - { - "x": 1.6492537465114516, - "y": 7.071224389847329, - "heading": -2.0856321133302972e-18, - "angularVelocity": -5.180989819451271e-19, - "velocityX": 2.021871539471901, - "velocityY": 0.1798009270420352, - "timestamp": 0.33347910317206697 - }, - { - "x": 1.8105532743625672, - "y": 7.076659046067202, - "heading": -2.1002211194393107e-18, - "angularVelocity": -2.1873166890130693e-19, - "velocityX": 2.4184353129901455, - "velocityY": 0.08148420947829117, - "timestamp": 0.40017492380648034 - }, - { - "x": 1.996442068118288, - "y": 7.070349612577893, - "heading": -1.946519159461839e-18, - "angularVelocity": 2.304534766433042e-18, - "velocityX": 2.7871130752648194, - "velocityY": -0.09460013280231008, - "timestamp": 0.4668707444408937 - }, - { - "x": 2.2031295038232215, - "y": 7.046434155152575, - "heading": -1.5479848716999483e-18, - "angularVelocity": 5.975420933476796e-18, - "velocityX": 3.098956332477912, - "velocityY": -0.3585750530992917, - "timestamp": 0.5335665650753071 - }, - { - "x": 2.4246835708618164, - "y": 6.99968147277832, - "heading": -7.857898560248294e-19, - "angularVelocity": 1.1427955190954808e-17, - "velocityX": 3.3218583253186806, - "velocityY": -0.7009836887796346, - "timestamp": 0.6002623857097205 - }, - { - "x": 2.5541388102121663, - "y": 6.964365766560133, - "heading": -2.0196357456600574e-19, - "angularVelocity": 1.5288290601618025e-17, - "velocityX": 3.389953097093239, - "velocityY": -0.9247875039436507, - "timestamp": 0.6384503003039254 - }, - { - "x": 2.685955086778719, - "y": 6.920434264641045, - "heading": 5.837695378946101e-19, - "angularVelocity": 2.0575490709452673e-17, - "velocityX": 3.4517799143272825, - "velocityY": -1.1504032725046753, - "timestamp": 0.6766382148981303 - }, - { - "x": 2.8197656895488885, - "y": 6.867794774338436, - "heading": 1.246996690820799e-18, - "angularVelocity": 1.7367422203128303e-17, - "velocityX": 3.504003928777101, - "velocityY": -1.3784332258569356, - "timestamp": 0.7148261294923351 - }, - { - "x": 2.9549433705621735, - "y": 6.806327065659224, - "heading": 3.3584531801563643e-18, - "angularVelocity": 5.529118585459454e-17, - "velocityX": 3.539802643045796, - "velocityY": -1.609611557285164, - "timestamp": 0.75301404408654 - }, - { - "x": 3.0902070954482963, - "y": 6.735926337900825, - "heading": 6.144806500333234e-18, - "angularVelocity": 7.296425796261651e-17, - "velocityX": 3.5420558132891666, - "velocityY": -1.8435342308355922, - "timestamp": 0.7912019586807449 - }, - { - "x": 3.222134587082462, - "y": 6.657238540440367, - "heading": 9.630920095804186e-18, - "angularVelocity": 9.128839928842624e-17, - "velocityX": 3.454692224906208, - "velocityY": -2.060541883392227, - "timestamp": 0.8293898732749498 - }, - { - "x": 3.349264802716153, - "y": 6.571014734758072, - "heading": 1.2954476277599915e-17, - "angularVelocity": 8.703162288677359e-17, - "velocityX": 3.329069339983813, - "velocityY": -2.257882018403783, - "timestamp": 0.8675777878691547 - }, - { - "x": 3.481191794816829, - "y": 6.492326078688536, - "heading": 1.7597431411802467e-17, - "angularVelocity": 1.2158179318074916e-16, - "velocityX": 3.4546791439872995, - "velocityY": -2.060564367162037, - "timestamp": 0.9057657024633596 - }, - { - "x": 3.6174699398570356, - "y": 6.421439537112809, - "heading": 2.0225513163692036e-17, - "angularVelocity": 6.881972424538472e-17, - "velocityX": 3.56861971879322, - "velocityY": -1.856255894789645, - "timestamp": 0.9439536170575645 - }, - { - "x": 3.7576383461149243, - "y": 6.358594880649259, - "heading": 2.243630761030922e-17, - "angularVelocity": 5.789251573743686e-17, - "velocityX": 3.6704912469715123, - "velocityY": -1.6456687182535479, - "timestamp": 0.9821415316517694 - }, - { - "x": 3.901222944259643, - "y": 6.304004669189453, - "heading": 2.47929413031983e-17, - "angularVelocity": 6.171150527421755e-17, - "velocityX": 3.759948655764368, - "velocityY": -1.4295153856750347, - "timestamp": 1.0203294462459744 - }, - { - "x": 4.199944605669076, - "y": 6.228799995672069, - "heading": 3.100148897614544e-17, - "angularVelocity": 8.107334480443901e-17, - "velocityX": 3.900809904617719, - "velocityY": -0.9820484190864626, - "timestamp": 1.096908840964896 - }, - { - "x": 4.505390450863175, - "y": 6.18888491371662, - "heading": 3.068102356864592e-17, - "angularVelocity": -4.184747198454113e-18, - "velocityX": 3.9886166026134253, - "velocityY": -0.5212248295105096, - "timestamp": 1.1734882356838174 - }, - { - "x": 4.813406217718833, - "y": 6.184802263219741, - "heading": 2.9566016685455517e-17, - "angularVelocity": -1.4560142284808256e-17, - "velocityX": 4.022175521054888, - "velocityY": -0.05331265039115567, - "timestamp": 1.250067630402739 - }, - { - "x": 5.119802709590309, - "y": 6.216607481698429, - "heading": 3.52377994780859e-17, - "angularVelocity": 7.406408490756321e-17, - "velocityX": 4.001030472964381, - "velocityY": 0.415323450838281, - "timestamp": 1.3266470251216604 - }, - { - "x": 5.420412868385874, - "y": 6.283867538771131, - "heading": 3.848949003766367e-17, - "angularVelocity": 4.246169053061748e-17, - "velocityX": 3.925470551172821, - "velocityY": 0.8783048928329202, - "timestamp": 1.403226419840582 - }, - { - "x": 5.71634502412257, - "y": 6.369392635548687, - "heading": 4.1170423309352994e-17, - "angularVelocity": 3.500854622761714e-17, - "velocityX": 3.8643835828530744, - "velocityY": 1.1168160455134108, - "timestamp": 1.4798058145595034 - }, - { - "x": 6.012277066075067, - "y": 6.454918126038977, - "heading": 5.506942631831843e-17, - "angularVelocity": 1.8149794810968406e-16, - "velocityX": 3.864382097019984, - "velocityY": 1.1168211867493296, - "timestamp": 1.556385209278425 - }, - { - "x": 6.3082087417235275, - "y": 6.540444883990324, - "heading": 4.481737476003156e-17, - "angularVelocity": -1.3387480531183782e-16, - "velocityX": 3.8643773136962514, - "velocityY": 1.116837737690506, - "timestamp": 1.6329646039973464 - }, - { - "x": 6.594966037333605, - "y": 6.6529643659063735, - "heading": 4.841360100358121e-17, - "angularVelocity": 4.6960755653354393e-17, - "velocityX": 3.7445751126979148, - "velocityY": 1.4693179846795974, - "timestamp": 1.709543998716268 - }, - { - "x": 6.848772987308951, - "y": 6.779795600711972, - "heading": 4.204680155814927e-17, - "angularVelocity": -8.313982722738282e-17, - "velocityX": 3.314298198710489, - "velocityY": 1.6562057622889883, - "timestamp": 1.7861233934351894 - }, - { - "x": 7.067412419546155, - "y": 6.899290890343004, - "heading": 3.6458514740789416e-17, - "angularVelocity": -7.297373685909452e-17, - "velocityX": 2.8550686909919953, - "velocityY": 1.5604104742547948, - "timestamp": 1.862702788154111 - }, - { - "x": 7.251170888102313, - "y": 7.010190252281107, - "heading": 2.889241168076903e-17, - "angularVelocity": -9.88007038620393e-17, - "velocityX": 2.3995811044279933, - "velocityY": 1.4481619023706132, - "timestamp": 1.9392821828730324 - }, - { - "x": 7.4001612724406005, - "y": 7.112047913646065, - "heading": 2.1944177837341752e-17, - "angularVelocity": -9.073242257004582e-17, - "velocityX": 1.9455675366074576, - "velocityY": 1.33009227533376, - "timestamp": 2.015861577591954 - }, - { - "x": 7.51444364347692, - "y": 7.204635943834979, - "heading": 1.5592060084324575e-17, - "angularVelocity": -8.294813863311352e-17, - "velocityX": 1.4923383954087404, - "velocityY": 1.209046252312866, - "timestamp": 2.0924409723108757 - }, - { - "x": 7.594055258058767, - "y": 7.2878159439317, - "heading": 9.822855730351304e-18, - "angularVelocity": -7.533626000185252e-17, - "velocityX": 1.0395957669023037, - "velocityY": 1.0861929687794476, - "timestamp": 2.1690203670297974 - }, - { - "x": 7.639021472581016, - "y": 7.361494958394011, - "heading": 4.627623553541244e-18, - "angularVelocity": -6.784113894031215e-17, - "velocityX": 0.5871842508963836, - "velocityY": 0.9621258398956097, - "timestamp": 2.245599761748719 - }, - { - "x": 7.649360656738281, - "y": 7.4256062507629395, - "heading": 0, - "angularVelocity": -6.042911536454736e-17, - "velocityX": 0.13501261266285436, - "velocityY": 0.8371872434424734, - "timestamp": 2.322179156467641 - }, - { - "x": 7.600824522324889, - "y": 7.494356470481976, - "heading": -5.199536290305884e-18, - "angularVelocity": -5.0560214645722654e-17, - "velocityX": -0.47196469577117206, - "velocityY": 0.6685261800522405, - "timestamp": 2.4250176417362526 - }, - { - "x": 7.48991208583228, - "y": 7.545603113049983, - "heading": -9.403502434751289e-18, - "angularVelocity": -4.087930941746883e-17, - "velocityX": -1.0785109893722118, - "velocityY": 0.49832163935617596, - "timestamp": 2.5278561270048643 - }, - { - "x": 7.316689652080842, - "y": 7.579111596852661, - "heading": -1.2640474818606514e-17, - "angularVelocity": -3.147627586763133e-17, - "velocityX": -1.6844125358222435, - "velocityY": 0.32583603030631414, - "timestamp": 2.630694612273476 - }, - { - "x": 7.081267195564433, - "y": 7.594500069269045, - "heading": -1.4957060676591272e-17, - "angularVelocity": -2.2526454180008613e-17, - "velocityX": -2.289244691824056, - "velocityY": 0.14963729168276652, - "timestamp": 2.7335330975420877 - }, - { - "x": 6.7838623866104655, - "y": 7.591037417525899, - "heading": -1.6442803884596208e-17, - "angularVelocity": -1.4447351341853733e-17, - "velocityX": -2.8919602245904463, - "velocityY": -0.03367077737603705, - "timestamp": 2.8363715828106995 - }, - { - "x": 6.4251059318965735, - "y": 7.566762499257423, - "heading": -2.986425944771221e-17, - "angularVelocity": -1.3051006229833453e-16, - "velocityX": -3.488542774398327, - "velocityY": -0.23604896751525264, - "timestamp": 2.939210068079311 - }, - { - "x": 6.016720927626869, - "y": 7.5008443435353165, - "heading": -3.467478724998584e-17, - "angularVelocity": -4.677750542229833e-17, - "velocityX": -3.971130099816352, - "velocityY": -0.640987229148065, - "timestamp": 3.042048553347923 - }, - { - "x": 5.616728238183579, - "y": 7.395348514025283, - "heading": -3.390128241552755e-17, - "angularVelocity": 7.521550173191142e-18, - "velocityX": -3.889523347203425, - "velocityY": -1.02583997843259, - "timestamp": 3.1448870386165346 - }, - { - "x": 5.216735664422249, - "y": 7.289852245902379, - "heading": -2.3452803355527372e-17, - "angularVelocity": 1.0160086501380395e-16, - "velocityX": -3.88952222231366, - "velocityY": -1.025844243498041, - "timestamp": 3.2477255238851463 - }, - { - "x": 4.840874915610426, - "y": 7.190720639628367, - "heading": -1.6752117047626585e-17, - "angularVelocity": 6.515738739653489e-17, - "velocityX": -3.6548646922414014, - "velocityY": -0.9639543602285213, - "timestamp": 3.350564009153758 - }, - { - "x": 4.527657602112525, - "y": 7.108110961714319, - "heading": -1.1168131864503311e-17, - "angularVelocity": 5.429860003544753e-17, - "velocityX": -3.0457207987826376, - "velocityY": -0.8032953587194801, - "timestamp": 3.45340249442237 - }, - { - "x": 4.277083743214221, - "y": 7.0420232172467445, - "heading": -6.700891701543933e-18, - "angularVelocity": 4.343938583567588e-17, - "velocityX": -2.436576717790238, - "velocityY": -0.6426363077492735, - "timestamp": 3.5562409796909815 - }, - { - "x": 4.089153345344071, - "y": 6.99245740792115, - "heading": -3.3504585356800222e-18, - "angularVelocity": 3.257956897302995e-17, - "velocityX": -1.8274325742866233, - "velocityY": -0.48197724029201133, - "timestamp": 3.6590794649595932 - }, - { - "x": 3.9638664117163565, - "y": 6.959413534585286, - "heading": -1.116819200639241e-18, - "angularVelocity": 2.1719880139959676e-17, - "velocityX": -1.2182883995274036, - "velocityY": -0.3213181645912218, - "timestamp": 3.761917950228205 - }, - { - "x": 3.901222944259643, - "y": 6.942891597747803, - "heading": 0, - "angularVelocity": 1.0859935530094074e-17, - "velocityX": -0.6091442060148221, - "velocityY": -0.1606590839443162, - "timestamp": 3.8647564354968167 - }, - { - "x": 3.901222944259643, - "y": 6.942891597747803, - "heading": 0, - "angularVelocity": 0, - "velocityX": -8.630031752099511e-32, - "velocityY": 0, - "timestamp": 3.9675949207654284 - } - ], - "constraints": [ - { - "scope": [ - "first" - ], - "type": "StopPoint" - }, - { - "scope": [ - "last" - ], - "type": "StopPoint" - } - ], - "usesControlIntervalGuessing": true, - "defaultControlIntervalCount": 40, - "usesDefaultFieldObstacles": true, - "circleObstacles": [] - }, - "Test 3": { - "waypoints": [ - { - "x": 1.3740688562393188, - "y": 2.1015472412109375, - "heading": 0, - "isInitialGuess": false, - "translationConstrained": true, - "headingConstrained": true, - "controlIntervalCount": 19 - }, - { - "x": 3.077767848968506, - "y": 2.45648455619812, - "heading": 1.5707963267948966, - "isInitialGuess": false, - "translationConstrained": true, - "headingConstrained": true, - "controlIntervalCount": 27 - }, - { - "x": 4.483319282531738, - "y": 1.4768576622009277, - "heading": -1.5707963267948966, - "isInitialGuess": false, - "translationConstrained": true, - "headingConstrained": true, - "controlIntervalCount": 40 - } - ], - "trajectory": [ - { - "x": 1.3740688562393188, - "y": 2.1015472412109375, - "heading": 0, - "angularVelocity": 0, - "velocityX": 0, - "velocityY": 0, - "timestamp": 0 - }, - { - "x": 1.3827319927716195, - "y": 2.1056840940342982, - "heading": 0.024187462948881532, - "angularVelocity": 0.5814493745934073, - "velocityX": 0.20825562934773315, - "velocityY": 0.09944699417395882, - "timestamp": 0.04159857075378794 - }, - { - "x": 1.4001445473800622, - "y": 2.1139530067021113, - "heading": 0.07183187897208339, - "angularVelocity": 1.1453378123250968, - "velocityX": 0.41858540552980794, - "velocityY": 0.19877876855005897, - "timestamp": 0.08319714150757589 - }, - { - "x": 1.4264050912023196, - "y": 2.1263405769046955, - "heading": 0.14207148158241312, - "angularVelocity": 1.6885099977538955, - "velocityX": 0.6312847616250105, - "velocityY": 0.2977883609511227, - "timestamp": 0.12479571226136382 - }, - { - "x": 1.461644669528872, - "y": 2.1428235310818113, - "heading": 0.23354680029910396, - "angularVelocity": 2.1990014815116687, - "velocityX": 0.8471343531274942, - "velocityY": 0.3962384735473897, - "timestamp": 0.16639428301515177 - }, - { - "x": 1.5060492101550866, - "y": 2.1633450352713384, - "heading": 0.3440303057594644, - "angularVelocity": 2.655944746609454, - "velocityX": 1.067453516348391, - "velocityY": 0.49332233819105575, - "timestamp": 0.20799285376893972 - }, - { - "x": 1.5598689877360068, - "y": 2.1877699582208265, - "heading": 0.47025292230788457, - "angularVelocity": 3.0343017623157595, - "velocityX": 1.2937891039441975, - "velocityY": 0.587157743813019, - "timestamp": 0.24959142452272767 - }, - { - "x": 1.6233962833017608, - "y": 2.2158406981890693, - "heading": 0.6081456509926965, - "angularVelocity": 3.314842942575804, - "velocityX": 1.5271509192404589, - "velocityY": 0.6748005871294988, - "timestamp": 0.2911899952765156 - }, - { - "x": 1.6969228086864487, - "y": 2.2471577725494125, - "heading": 0.7531530032346565, - "angularVelocity": 3.485873423389107, - "velocityX": 1.767525279170269, - "velocityY": 0.7528401527510284, - "timestamp": 0.33278856603030355 - }, - { - "x": 1.7807044327096728, - "y": 2.2811428510793297, - "heading": 0.8996751634093815, - "angularVelocity": 3.522288326722431, - "velocityX": 2.014050543204923, - "velocityY": 0.8169770719100108, - "timestamp": 0.37438713678409147 - }, - { - "x": 1.874863599501791, - "y": 2.3169249011545388, - "heading": 1.039921254531021, - "angularVelocity": 3.371416098679782, - "velocityX": 2.2635192768863255, - "velocityY": 0.860174987432263, - "timestamp": 0.4159857075378794 - }, - { - "x": 1.9790611887944067, - "y": 2.3530646807512396, - "heading": 1.1622275414761678, - "angularVelocity": 2.9401559892271805, - "velocityX": 2.504835800954579, - "velocityY": 0.8687745502290541, - "timestamp": 0.4575842782916673 - }, - { - "x": 2.0932451980418487, - "y": 2.3882113850013775, - "heading": 1.2660024391339892, - "angularVelocity": 2.494674595239208, - "velocityX": 2.7449022208787723, - "velocityY": 0.8449017265086323, - "timestamp": 0.49918284904545523 - }, - { - "x": 2.217212476082111, - "y": 2.420658735334921, - "heading": 1.3531768415072132, - "angularVelocity": 2.095610517226054, - "velocityX": 2.980085031622671, - "velocityY": 0.7800111817671773, - "timestamp": 0.5407814197992432 - }, - { - "x": 2.3501935564528202, - "y": 2.4482015090574127, - "heading": 1.4262550842141035, - "angularVelocity": 1.756748883021386, - "velocityX": 3.196770416891297, - "velocityY": 0.662108654774838, - "timestamp": 0.5823799905530311 - }, - { - "x": 2.4906536483278, - "y": 2.46851554155244, - "heading": 1.4886926420034476, - "angularVelocity": 1.500954399590967, - "velocityX": 3.3765605243084034, - "velocityY": 0.48833486648020946, - "timestamp": 0.6239785613068191 - }, - { - "x": 2.636556239981357, - "y": 2.4798247504507454, - "heading": 1.5443965976357683, - "angularVelocity": 1.3390834017437327, - "velocityX": 3.507394340949799, - "velocityY": 0.27186532357102605, - "timestamp": 0.665577132060607 - }, - { - "x": 2.784486963341596, - "y": 2.4812509905043107, - "heading": 1.5824822995529222, - "angularVelocity": 0.915553136260199, - "velocityX": 3.55614918204015, - "velocityY": 0.03428579461936428, - "timestamp": 0.7071757028143949 - }, - { - "x": 2.9319879700538403, - "y": 2.4732781401372903, - "heading": 1.5928024946439976, - "angularVelocity": 0.2480901363854538, - "velocityX": 3.5458191000164043, - "velocityY": -0.19166164180201423, - "timestamp": 0.7487742735681828 - }, - { - "x": 3.077767848968506, - "y": 2.45648455619812, - "heading": 1.5707963267948966, - "angularVelocity": -0.5290125946501647, - "velocityX": 3.5044444141473514, - "velocityY": -0.4037057916934574, - "timestamp": 0.7903728443219707 - }, - { - "x": 3.1950861088883977, - "y": 2.4371849871011824, - "heading": 1.5299506752490524, - "angularVelocity": -1.202969278370701, - "velocityX": 3.455208991207777, - "velocityY": -0.5684029469487673, - "timestamp": 0.8243268714787733 - }, - { - "x": 3.309155534819785, - "y": 2.4119403886613155, - "heading": 1.478537222717671, - "angularVelocity": -1.5142077932128373, - "velocityX": 3.359525672891005, - "velocityY": -0.7434934985188447, - "timestamp": 0.8582808986355758 - }, - { - "x": 3.4193096830151886, - "y": 2.380930163774979, - "heading": 1.4211355944324973, - "angularVelocity": -1.6905690750790594, - "velocityX": 3.244214528268367, - "velocityY": -0.9133003499957304, - "timestamp": 0.8922349257923783 - }, - { - "x": 3.5252925044888306, - "y": 2.3443333770341446, - "heading": 1.3578303696691585, - "angularVelocity": -1.8644393630120046, - "velocityX": 3.1213623345506205, - "velocityY": -1.0778334649837304, - "timestamp": 0.9261889529491808 - }, - { - "x": 3.6267984253619163, - "y": 2.3023968893924756, - "heading": 1.2884922471851454, - "angularVelocity": -2.042117777794756, - "velocityX": 2.989510505020297, - "velocityY": -1.2350961330078705, - "timestamp": 0.9601429801059833 - }, - { - "x": 3.7234699768082784, - "y": 2.2554603435851734, - "heading": 1.2127113952283004, - "angularVelocity": -2.2318663882639043, - "velocityX": 2.847130651096655, - "velocityY": -1.3823557833156956, - "timestamp": 0.9940970072627858 - }, - { - "x": 3.814908272910244, - "y": 2.2039836020719794, - "heading": 1.129729146369758, - "angularVelocity": -2.443958958856986, - "velocityX": 2.693002973687319, - "velocityY": -1.5160717541770827, - "timestamp": 1.0280510344195883 - }, - { - "x": 3.9007054057350934, - "y": 2.148565496917068, - "heading": 1.038390775419664, - "angularVelocity": -2.6900600193564195, - "velocityX": 2.5268617601269985, - "velocityY": -1.6321511701343638, - "timestamp": 1.062005061576391 - }, - { - "x": 3.9805012090104195, - "y": 2.0899327454341323, - "heading": 0.9371495335396042, - "angularVelocity": -2.981715288529822, - "velocityX": 2.3501130780991346, - "velocityY": -1.726827607577971, - "timestamp": 1.0959590887331936 - }, - { - "x": 4.053655012390132, - "y": 2.0292588496633805, - "heading": 0.8293051851574991, - "angularVelocity": -3.1761872570754117, - "velocityX": 2.1544956373477353, - "velocityY": -1.786942547066038, - "timestamp": 1.1299131158899962 - }, - { - "x": 4.119927818624713, - "y": 1.9679960836064079, - "heading": 0.7137645375013505, - "angularVelocity": -3.402855488164233, - "velocityX": 1.9518393482026792, - "velocityY": -1.8042857117986315, - "timestamp": 1.1638671430467988 - }, - { - "x": 4.179384944413853, - "y": 1.9075792317237577, - "heading": 0.5896796080209632, - "angularVelocity": -3.654498151485701, - "velocityX": 1.7511067395499393, - "velocityY": -1.779372196522297, - "timestamp": 1.1978211702036015 - }, - { - "x": 4.232333921459595, - "y": 1.8492512775948615, - "heading": 0.45638614526052235, - "angularVelocity": -3.925704074646035, - "velocityX": 1.5594314277127905, - "velocityY": -1.717850841659724, - "timestamp": 1.231775197360404 - }, - { - "x": 4.279204985937824, - "y": 1.7939724784813917, - "heading": 0.3132208792361718, - "angularVelocity": -4.2164443517373975, - "velocityX": 1.3804272542329112, - "velocityY": -1.6280483860824002, - "timestamp": 1.2657292245172067 - }, - { - "x": 4.320441595908879, - "y": 1.7424131364284248, - "heading": 0.15934425300509544, - "angularVelocity": -4.531910913547163, - "velocityX": 1.2144836245965511, - "velocityY": -1.5185044712080482, - "timestamp": 1.2996832516740093 - }, - { - "x": 4.356420236259085, - "y": 1.6949789978909888, - "heading": -0.006355243449938616, - "angularVelocity": -4.8801132098280045, - "velocityX": 1.05962807251248, - "velocityY": -1.3970106791318475, - "timestamp": 1.333637278830812 - }, - { - "x": 4.387409086244814, - "y": 1.651863988262444, - "heading": -0.18526060257567917, - "angularVelocity": -5.269046829093284, - "velocityX": 0.9126708252490286, - "velocityY": -1.269805476374806, - "timestamp": 1.3675913059876146 - }, - { - "x": 4.41359473495854, - "y": 1.6131465719605549, - "heading": -0.37893299146064197, - "angularVelocity": -5.703959297385947, - "velocityX": 0.7712089229593995, - "velocityY": -1.14028937195647, - "timestamp": 1.4015453331444172 - }, - { - "x": 4.4350042238715455, - "y": 1.5791111641775315, - "heading": -0.584927468780437, - "angularVelocity": -6.066864362454111, - "velocityX": 0.6305434349257187, - "velocityY": -1.0023967886331036, - "timestamp": 1.4354993603012198 - }, - { - "x": 4.45163244894447, - "y": 1.5502696896357162, - "heading": -0.7898839519998764, - "angularVelocity": -6.036293788434603, - "velocityX": 0.4897276248306672, - "velocityY": -0.8494272095834752, - "timestamp": 1.4694533874580225 - }, - { - "x": 4.463826845716735, - "y": 1.5265783798021662, - "heading": -0.9844765994557877, - "angularVelocity": -5.731062373152404, - "velocityX": 0.3591443429072621, - "velocityY": -0.6977466833093577, - "timestamp": 1.503407414614825 - }, - { - "x": 4.472183367519406, - "y": 1.5078619625249268, - "heading": -1.1610616366629594, - "angularVelocity": -5.200709665192236, - "velocityX": 0.2461128326282439, - "velocityY": -0.5512282001456157, - "timestamp": 1.5373614417716277 - }, - { - "x": 4.477461351357098, - "y": 1.4939941108118897, - "heading": -1.3141687721041224, - "angularVelocity": -4.509248188250044, - "velocityX": 0.1554450025424584, - "velocityY": -0.40843024743689504, - "timestamp": 1.5713154689284303 - }, - { - "x": 4.480557191442016, - "y": 1.4847418449881848, - "heading": -1.4384150849106647, - "angularVelocity": -3.6592511466260937, - "velocityX": 0.09117740498451485, - "velocityY": -0.2724939159958763, - "timestamp": 1.605269496085233 - }, - { - "x": 4.482401705838399, - "y": 1.4793489828824327, - "heading": -1.5259837396767848, - "angularVelocity": -2.5790358934892232, - "velocityX": 0.05432387704300033, - "velocityY": -0.15882834990084585, - "timestamp": 1.6392235232420356 - }, - { - "x": 4.483319282531738, - "y": 1.4768576622009275, - "heading": -1.5707963267948966, - "angularVelocity": -1.3198018282509576, - "velocityX": 0.02702409022356453, - "velocityY": -0.07337334891149445, - "timestamp": 1.6731775503988382 - }, - { - "x": 4.483319282531738, - "y": 1.4768576622009275, - "heading": -1.5707963267948966, - "angularVelocity": 2.6449030967255686e-30, - "velocityX": 1.3058140867459075e-31, - "velocityY": 0, - "timestamp": 1.7071315775556408 - } - ], - "constraints": [ - { - "scope": [ - "first" - ], - "type": "StopPoint" - }, - { - "scope": [ - "last" - ], - "type": "StopPoint" - } - ], - "usesControlIntervalGuessing": true, - "defaultControlIntervalCount": 40, - "usesDefaultFieldObstacles": true, - "circleObstacles": [] - }, "Troll": { "waypoints": [ { diff --git a/README.md b/README.md index e656d59..a8d7486 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ [![Build](https://github.com/FRC-Team-1710/2024-Robot/actions/workflows/main.yml/badge.svg)](https://github.com/FRC-Team-1710/2024-Robot/actions/workflows/main.yml) [![Spotless](https://github.com/FRC-Team-1710/2024-Robot/actions/workflows/TruthMin.yml/badge.svg)](https://github.com/FRC-Team-1710/2024-Robot/actions/workflows/TruthMin.yml) # Team 1710 2024 Robot Code
-Thanks to dirtbikerxz for the [template](https://github.com/dirtbikerxz/BaseTalonFXSwerve).

-Using PhotonVision with a Raspberry Pi 4, SDS Mk4i swerve modules, and PathPlanner autos with trajectory generation through Choreo. +Thanks to dirtbikerxz for the [template](https://github.com/dirtbikerxz/BaseTalonFXSwerve). + +Using PhotonVision with a Raspberry Pi 4, SDS Mk4i swerve modules, and PathPlanner for autos and trajectory generation. + +[![Team 1710 2024 Robot Adonis](https://img.youtube.com/vi/qDYD3rMLS-k/0.jpg)](https://www.youtube.com/watch?v=qDYD3rMLS-k) diff --git a/build.gradle b/build.gradle index b1ba844..2eef37a 100644 --- a/build.gradle +++ b/build.gradle @@ -28,13 +28,20 @@ deploy { // getTargetTypeClass is a shortcut to get the class type using a string frcJava(getArtifactTypeClass('FRCJavaArtifact')) { + // Switch GC to 2023's G1 + //gcType = 'G1' + //jvmArgs.add("-XX:+UseG1GC") + //jvmArgs.add("-XX:MaxGCPauseMillis=1") + //jvmArgs.add("-XX:GCTimeRatio=1") + //jvmArgs.remove('-XX:+AlwaysPreTouch') + // Use VisualVM for code profiling //jvmArgs.add("-Dcom.sun.management.jmxremote=true") //jvmArgs.add("-Dcom.sun.management.jmxremote.port=1099") //jvmArgs.add("-Dcom.sun.management.jmxremote.local.only=false") //jvmArgs.add("-Dcom.sun.management.jmxremote.ssl=false") //jvmArgs.add("-Dcom.sun.management.jmxremote.authenticate=false") - //jvmArgs.add("-Djava.rmi.server.hostname=172.22.11.2") + //jvmArgs.add("-Djava.rmi.server.hostname=10.17.10.2") } // Static files artifact @@ -120,10 +127,10 @@ spotless { include '**/*.java' exclude '**/build/**', '**/build-*/**' } - toggleOffOn() palantirJavaFormat().style("AOSP") removeUnusedImports() trimTrailingWhitespace() + toggleOffOn() } groovyGradle { diff --git a/src/main/deploy/choreo/Troll.1.traj b/src/main/deploy/choreo/Troll.1.traj new file mode 100644 index 0000000..4eefac9 --- /dev/null +++ b/src/main/deploy/choreo/Troll.1.traj @@ -0,0 +1,1030 @@ +{ + "samples": [ + { + "x": 1.472737193107605, + "y": 5.55, + "heading": 0, + "angularVelocity": 0, + "velocityX": -8.875549299448591e-33, + "velocityY": 1.6865999682592782e-32, + "timestamp": 0 + }, + { + "x": 1.4954238510421338, + "y": 5.562202684480301, + "heading": 0.04016028608194298, + "angularVelocity": 0.6064807443024526, + "velocityX": 0.34260266876073076, + "velocityY": 0.18427889559851518, + "timestamp": 0.06621856746356154 + }, + { + "x": 1.5408911314828666, + "y": 5.5867292912686075, + "heading": 0.11807101658857888, + "angularVelocity": 1.1765692537747552, + "velocityX": 0.6866243439312181, + "velocityY": 0.37038866480770294, + "timestamp": 0.13243713492712308 + }, + { + "x": 1.6092554887422894, + "y": 5.623729916528466, + "heading": 0.23034305047627052, + "angularVelocity": 1.695476634245707, + "velocityX": 1.0324046544353558, + "velocityY": 0.5587651119184867, + "timestamp": 0.19865570239068464 + }, + { + "x": 1.7006794384120958, + "y": 5.673376134035544, + "heading": 0.3716946261904345, + "angularVelocity": 2.134621468396251, + "velocityX": 1.3806391948922, + "velocityY": 0.7497325811887481, + "timestamp": 0.26487426985424617 + }, + { + "x": 1.8153711212066734, + "y": 5.73583043809041, + "heading": 0.5342344602957644, + "angularVelocity": 2.4545960495864176, + "velocityX": 1.732016973301174, + "velocityY": 0.9431539588837228, + "timestamp": 0.3310928373178077 + }, + { + "x": 1.9535237520205713, + "y": 5.811224596512345, + "heading": 0.7068082719295097, + "angularVelocity": 2.6061242072128543, + "velocityX": 2.0863125873256005, + "velocityY": 1.1385652289053465, + "timestamp": 0.3973114047813692 + }, + { + "x": 2.115146815140512, + "y": 5.899607450474536, + "heading": 0.8720605081292071, + "angularVelocity": 2.4955574022441915, + "velocityX": 2.440751428349426, + "velocityY": 1.334714074127719, + "timestamp": 0.46352997224493075 + }, + { + "x": 2.2991611528231366, + "y": 6.000703985717269, + "heading": 0.9970511976008042, + "angularVelocity": 1.8875474698297623, + "velocityX": 2.778893363766644, + "velocityY": 1.52670979024674, + "timestamp": 0.5297485397084923 + }, + { + "x": 2.5044278422735613, + "y": 6.114387084295501, + "heading": 1.0665576726522747, + "angularVelocity": 1.0496523515057667, + "velocityX": 3.099835851377757, + "velocityY": 1.716785834136148, + "timestamp": 0.5959671071720539 + }, + { + "x": 2.7311192639784148, + "y": 6.24051707801207, + "heading": 1.0817751050892828, + "angularVelocity": 0.22980612568192132, + "velocityX": 3.423381543697635, + "velocityY": 1.904752678106116, + "timestamp": 0.6621856746356155 + }, + { + "x": 2.964942433247541, + "y": 6.368100850146288, + "heading": 1.0817751413957877, + "angularVelocity": 5.482828485290889e-7, + "velocityX": 3.531081662220997, + "velocityY": 1.9267069195422228, + "timestamp": 0.7284042420991771 + }, + { + "x": 3.1987656298041083, + "y": 6.495684572270795, + "heading": 1.081775177702228, + "angularVelocity": 5.482818756667397e-7, + "velocityX": 3.5310820743024163, + "velocityY": 1.926706164320354, + "timestamp": 0.7946228095627387 + }, + { + "x": 3.4325888263613256, + "y": 6.623268294394111, + "heading": 1.0817752140086683, + "angularVelocity": 5.482818741182615e-7, + "velocityX": 3.531082074312233, + "velocityY": 1.9267061643023646, + "timestamp": 0.8608413770263003 + }, + { + "x": 3.6664120229185433, + "y": 6.7508520165174275, + "heading": 1.0817752503151086, + "angularVelocity": 5.482818737417958e-7, + "velocityX": 3.531082074312234, + "velocityY": 1.926706164302361, + "timestamp": 0.9270599444898618 + }, + { + "x": 3.9002352194806806, + "y": 6.878435738631726, + "heading": 1.0817752866215484, + "angularVelocity": 5.482818710733048e-7, + "velocityX": 3.5310820743865343, + "velocityY": 1.9267061641661918, + "timestamp": 0.9932785119534234 + }, + { + "x": 4.13405862259109, + "y": 7.006019082203452, + "heading": 1.0817753229279854, + "angularVelocity": 5.482818239333129e-7, + "velocityX": 3.531085193576202, + "velocityY": 1.926700447603791, + "timestamp": 1.059497079416985 + }, + { + "x": 4.373840182030626, + "y": 7.122017776417369, + "heading": 1.0817753593434176, + "angularVelocity": 5.49927814371679e-7, + "velocityX": 3.6210623186839843, + "velocityY": 1.7517548122397577, + "timestamp": 1.1257156468805465 + }, + { + "x": 4.624085072947641, + "y": 7.213277774894042, + "heading": 1.0817753970756958, + "angularVelocity": 5.698141760636061e-7, + "velocityX": 3.7790743669397395, + "velocityY": 1.3781632851977732, + "timestamp": 1.191934214344108 + }, + { + "x": 4.882248762866474, + "y": 7.278870463039004, + "heading": 1.0817754381512044, + "angularVelocity": 6.203019793980544e-7, + "velocityX": 3.8986601463538673, + "velocityY": 0.990548280602039, + "timestamp": 1.2581527818076697 + }, + { + "x": 5.14570593286406, + "y": 7.318128697944957, + "heading": 1.081775485432278, + "angularVelocity": 7.14015351698796e-7, + "velocityX": 3.9785996600207425, + "velocityY": 0.5928584143345571, + "timestamp": 1.3243713492712312 + }, + { + "x": 5.411777394358682, + "y": 7.330653209159577, + "heading": 1.0817755436800227, + "angularVelocity": 8.796285819324463e-7, + "velocityX": 4.018079395043312, + "velocityY": 0.18913896350161738, + "timestamp": 1.3905899167347928 + }, + { + "x": 5.677757348071688, + "y": 7.316316612470789, + "heading": 1.0817756485534318, + "angularVelocity": 0.000001583746269380313, + "velocityX": 4.016697489859879, + "velocityY": -0.21650418059371343, + "timestamp": 1.4568084841983544 + }, + { + "x": 5.939941346681472, + "y": 7.275392278730094, + "heading": 1.08417598446994, + "angularVelocity": 0.0362486838427761, + "velocityX": 3.959372856473502, + "velocityY": -0.6180190135223776, + "timestamp": 1.523027051661916 + }, + { + "x": 6.1926233871200065, + "y": 7.209386056553619, + "heading": 1.094230473023442, + "angularVelocity": 0.1518379049657743, + "velocityX": 3.8158789916072857, + "velocityY": -0.9967932666739766, + "timestamp": 1.5892456191254776 + }, + { + "x": 6.431036236235606, + "y": 7.120827418505734, + "heading": 1.0882465943881172, + "angularVelocity": -0.09036557063270015, + "velocityX": 3.6003927334549006, + "velocityY": -1.337368678303358, + "timestamp": 1.6554641865890392 + }, + { + "x": 6.652946472167969, + "y": 7.011868953704834, + "heading": 1.0516507294432773, + "angularVelocity": -0.5526526221664004, + "velocityX": 3.351178444844405, + "velocityY": -1.6454367554969764, + "timestamp": 1.7216827540526007 + }, + { + "x": 6.817330150088381, + "y": 6.91398458094159, + "heading": 0.9974973350877399, + "angularVelocity": -1.0346873253086366, + "velocityX": 3.1408134255664746, + "velocityY": -1.8702377025339256, + "timestamp": 1.7740206855522294 + }, + { + "x": 6.96932848776031, + "y": 6.8050318321958345, + "heading": 0.9307984833276803, + "angularVelocity": -1.274388380452764, + "velocityX": 2.9041716651145895, + "velocityY": -2.0817167515787003, + "timestamp": 1.826358617051858 + }, + { + "x": 7.108447801764001, + "y": 6.685502841506335, + "heading": 0.853783246677348, + "angularVelocity": -1.4714994353737287, + "velocityX": 2.6580972922989385, + "velocityY": -2.2837927916648284, + "timestamp": 1.8786965485514866 + }, + { + "x": 7.2341948641942375, + "y": 6.5559531119456285, + "heading": 0.7687330983314559, + "angularVelocity": -1.6250192911520678, + "velocityX": 2.4025990104543773, + "velocityY": -2.475255055917257, + "timestamp": 1.9310344800511152 + }, + { + "x": 7.346097509127973, + "y": 6.41698515308241, + "heading": 0.6779280050822188, + "angularVelocity": -1.7349767300200096, + "velocityX": 2.13807924248075, + "velocityY": -2.6552054099464035, + "timestamp": 1.9833724115507438 + }, + { + "x": 7.44376495093577, + "y": 6.2691546896150365, + "heading": 0.5838410686967184, + "angularVelocity": -1.797681598978898, + "velocityX": 1.8660928892172433, + "velocityY": -2.8245377536256293, + "timestamp": 2.0357103430503725 + }, + { + "x": 7.5267974986172455, + "y": 6.113117237651097, + "heading": 0.48865781043808765, + "angularVelocity": -1.8186285841141039, + "velocityX": 1.586469799290113, + "velocityY": -2.981345412266578, + "timestamp": 2.088048274550001 + }, + { + "x": 7.594641436841627, + "y": 5.9499464596390546, + "heading": 0.3933862357072056, + "angularVelocity": -1.8203160117544566, + "velocityX": 1.29626709119871, + "velocityY": -3.1176390303693813, + "timestamp": 2.1403862060496297 + }, + { + "x": 7.64676744326269, + "y": 5.780900656781067, + "heading": 0.2985965379951544, + "angularVelocity": -1.8111089795882303, + "velocityX": 0.9959508319780062, + "velocityY": -3.2298907888476207, + "timestamp": 2.1927241375492583 + }, + { + "x": 7.682689941029465, + "y": 5.607494331086699, + "heading": 0.204267077341809, + "angularVelocity": -1.8023154135163826, + "velocityX": 0.6863568493727955, + "velocityY": -3.313205560972491, + "timestamp": 2.245062069048887 + }, + { + "x": 7.702012772608416, + "y": 5.431650226927326, + "heading": 0.10944883558979078, + "angularVelocity": -1.8116543591848093, + "velocityX": 0.3691936426468861, + "velocityY": -3.359783222625445, + "timestamp": 2.2974000005485156 + }, + { + "x": 7.709831956706759, + "y": 5.244786482851424, + "heading": 0.04182048420765616, + "angularVelocity": -1.2921479593173169, + "velocityX": 0.14939803454781883, + "velocityY": -3.5703310910792863, + "timestamp": 2.349737932048144 + }, + { + "x": 7.710148320506211, + "y": 5.047944741081597, + "heading": 0.001607732041278722, + "angularVelocity": -0.7683290304788382, + "velocityX": 0.006044637042151999, + "velocityY": -3.760976716690136, + "timestamp": 2.402075863547773 + }, + { + "x": 7.703890826207887, + "y": 4.848684527302479, + "heading": -0.031393890437942266, + "angularVelocity": -0.6305488492500959, + "velocityX": -0.11955944988709234, + "velocityY": -3.807185497587574, + "timestamp": 2.4544137950474014 + }, + { + "x": 7.689965111892734, + "y": 4.6520156160480495, + "heading": -0.07069569449240305, + "angularVelocity": -0.7509239079259387, + "velocityX": -0.2660730738900635, + "velocityY": -3.757674512907042, + "timestamp": 2.50675172654703 + }, + { + "x": 7.6736890071007915, + "y": 4.457429220119764, + "heading": -0.11423745831205336, + "angularVelocity": -0.8319351294951269, + "velocityX": -0.3109810480771227, + "velocityY": -3.7178847224725837, + "timestamp": 2.5590896580466587 + }, + { + "x": 7.657799890486921, + "y": 4.2638591081182335, + "heading": -0.1590132492502008, + "angularVelocity": -0.8555131938767111, + "velocityX": -0.30358701917716197, + "velocityY": -3.6984669904828595, + "timestamp": 2.6114275895462873 + }, + { + "x": 7.642337704419043, + "y": 4.071398640697783, + "heading": -0.20522832712376496, + "angularVelocity": -0.8830130757821877, + "velocityX": -0.29542982737076623, + "velocityY": -3.6772654536760823, + "timestamp": 2.663765521045916 + }, + { + "x": 7.627349314262189, + "y": 3.8801695282505793, + "heading": -0.2531486196328151, + "angularVelocity": -0.9155939322781721, + "velocityX": -0.28637719771100456, + "velocityY": -3.653738444908945, + "timestamp": 2.7161034525455445 + }, + { + "x": 7.612892055649704, + "y": 3.690334816903791, + "heading": -0.30312829452838497, + "angularVelocity": -0.9549417308539411, + "velocityX": -0.27622907895371474, + "velocityY": -3.627096178765391, + "timestamp": 2.768441384045173 + }, + { + "x": 7.599038616037834, + "y": 3.50212217111646, + "heading": -0.35565961313676014, + "angularVelocity": -1.003694970420229, + "velocityX": -0.264692149936568, + "velocityY": -3.596104018529388, + "timestamp": 2.8207793155448018 + }, + { + "x": 7.58588568265439, + "y": 3.3158679152826034, + "heading": -0.4114672226763763, + "angularVelocity": -1.066293755610362, + "velocityX": -0.25130785658842936, + "velocityY": -3.5586858421253695, + "timestamp": 2.8731172470444304 + }, + { + "x": 7.573571145277833, + "y": 3.1321108409056713, + "heading": -0.4717089783444659, + "angularVelocity": -1.1510152186377078, + "velocityX": -0.23528895819364495, + "velocityY": -3.5109731911784747, + "timestamp": 2.925455178544059 + }, + { + "x": 7.562314657485301, + "y": 2.9518321478713343, + "heading": -0.5384896128552801, + "angularVelocity": -1.275950970880255, + "velocityX": -0.21507322643450313, + "velocityY": -3.44451314503355, + "timestamp": 2.9777931100436876 + }, + { + "x": 7.552475081584032, + "y": 2.778276274707623, + "heading": -0.6187626830239448, + "angularVelocity": -1.5337455621300466, + "velocityX": -0.18800085558091725, + "velocityY": -3.3160629048735397, + "timestamp": 3.0301310415433163 + }, + { + "x": 7.5459751353703055, + "y": 2.6199152915908197, + "heading": -0.7306496828630857, + "angularVelocity": -2.1377803178928008, + "velocityX": -0.12419188201534234, + "velocityY": -3.025740196055188, + "timestamp": 3.082468973042945 + }, + { + "x": 7.542089138041763, + "y": 2.4767558634954696, + "heading": -0.8750887967914319, + "angularVelocity": -2.7597405894688265, + "velocityX": -0.07424820234959534, + "velocityY": -2.735290142224239, + "timestamp": 3.1348069045425735 + }, + { + "x": 7.5216270585803455, + "y": 2.331419967454435, + "heading": -1.0120731965665102, + "angularVelocity": -2.6173063369166254, + "velocityX": -0.390960797936048, + "velocityY": -2.776875047919336, + "timestamp": 3.187144836042202 + }, + { + "x": 7.484441535370467, + "y": 2.1871473310520577, + "heading": -1.1444783193039663, + "angularVelocity": -2.5298119154441765, + "velocityX": -0.710488973186514, + "velocityY": -2.756559769722614, + "timestamp": 3.2394827675418307 + }, + { + "x": 7.430689261020509, + "y": 2.045319270385381, + "heading": -1.2712939627154947, + "angularVelocity": -2.4230159614243214, + "velocityX": -1.0270232852121666, + "velocityY": -2.7098522353272774, + "timestamp": 3.2918206990414594 + }, + { + "x": 7.360584286485429, + "y": 1.9069970614078058, + "heading": -1.3909439169907853, + "angularVelocity": -2.286103994693467, + "velocityX": -1.3394678109427585, + "velocityY": -2.642867324218853, + "timestamp": 3.344158630541088 + }, + { + "x": 7.274381021511414, + "y": 1.7730949945870125, + "heading": -1.50169441917269, + "angularVelocity": -2.1160657100614175, + "velocityX": -1.6470514310376692, + "velocityY": -2.558413429497911, + "timestamp": 3.3964965620407166 + }, + { + "x": 7.172363334905187, + "y": 1.6444234151770394, + "heading": -1.6017844735100242, + "angularVelocity": -1.9123807813850309, + "velocityX": -1.9492112829669335, + "velocityY": -2.4584765909383464, + "timestamp": 3.448834493540345 + }, + { + "x": 7.054833854515175, + "y": 1.5217039601454048, + "heading": -1.689495586048226, + "angularVelocity": -1.6758612735550291, + "velocityX": -2.2455889451963866, + "velocityY": -2.344751722419604, + "timestamp": 3.501172425039974 + }, + { + "x": 6.922601222991943, + "y": 1.4058892726898191, + "heading": -1.754739642827425, + "angularVelocity": -1.2465921925031216, + "velocityX": -2.526516194553274, + "velocityY": -2.2128250799595794, + "timestamp": 3.5535103565396025 + }, + { + "x": 6.776206366537654, + "y": 1.2881464891497267, + "heading": -1.7163442600815282, + "angularVelocity": 0.701977704776456, + "velocityX": -2.6765177991575464, + "velocityY": -2.1526757394363294, + "timestamp": 3.6082063710777343 + }, + { + "x": 6.619200799462664, + "y": 1.184169918255188, + "heading": -1.6479685771095909, + "angularVelocity": 1.2501035687758868, + "velocityX": -2.870512018120276, + "velocityY": -1.9009898942829024, + "timestamp": 3.6629023856158662 + }, + { + "x": 6.453145942349176, + "y": 1.096120131949485, + "heading": -1.5766994559842828, + "angularVelocity": 1.303003915863407, + "velocityX": -3.035958991083723, + "velocityY": -1.609802598036071, + "timestamp": 3.717598400153998 + }, + { + "x": 6.278278647893632, + "y": 1.024136466565589, + "heading": -1.5039595806005146, + "angularVelocity": 1.3298935214567948, + "velocityX": -3.197075617522952, + "velocityY": -1.3160678340414054, + "timestamp": 3.77229441469213 + }, + { + "x": 6.0946622707930835, + "y": 0.9682554227258839, + "heading": -1.4319058401965126, + "angularVelocity": 1.3173490063662636, + "velocityX": -3.357033938414989, + "velocityY": -1.0216657339950712, + "timestamp": 3.826990429230262 + }, + { + "x": 5.901723318023782, + "y": 0.9281131404158702, + "heading": -1.3656720034044707, + "angularVelocity": 1.2109444783379562, + "velocityX": -3.527477356413067, + "velocityY": -0.7339160384716592, + "timestamp": 3.881686443768394 + }, + { + "x": 5.697449612094902, + "y": 0.9013098773658532, + "heading": -1.3280729441876722, + "angularVelocity": 0.6874186270114382, + "velocityX": -3.7347091493561853, + "velocityY": -0.4900405134880769, + "timestamp": 3.9363824583065257 + }, + { + "x": 5.481732185562019, + "y": 0.8878298601999052, + "heading": -1.318078319190418, + "angularVelocity": 0.1827304069894859, + "velocityX": -3.9439331796742034, + "velocityY": -0.2464533710504764, + "timestamp": 3.9910784728446576 + }, + { + "x": 5.261756953565252, + "y": 0.8920718938341556, + "heading": -1.3180778684404388, + "angularVelocity": 0.000008241002253313922, + "velocityX": -4.021778073855989, + "velocityY": 0.0775565399064386, + "timestamp": 4.04577448738279 + }, + { + "x": 5.042078221460965, + "y": 0.904252420018932, + "heading": -1.318077498096455, + "angularVelocity": 0.000006770950078101512, + "velocityX": -4.0163572055352335, + "velocityY": 0.22269494930539713, + "timestamp": 4.100470501920922 + }, + { + "x": 4.822399513022668, + "y": 0.9164333730320937, + "heading": -1.3180771277548, + "angularVelocity": 0.0000067709074968390835, + "velocityX": -4.01635677285307, + "velocityY": 0.22270275295231748, + "timestamp": 4.1551665164590545 + }, + { + "x": 4.602720804585333, + "y": 0.9286143260630619, + "heading": -1.318076757413277, + "angularVelocity": 0.000006770905088161991, + "velocityX": -4.016356772835495, + "velocityY": 0.22270275327787067, + "timestamp": 4.209862530997187 + }, + { + "x": 4.383042096147975, + "y": 0.9407952790940776, + "heading": -1.3180763870718855, + "angularVelocity": 0.000006770902679722202, + "velocityX": -4.016356772835924, + "velocityY": 0.2227027532787389, + "timestamp": 4.264558545535319 + }, + { + "x": 4.163363387710593, + "y": 0.95297623212514, + "heading": -1.3180760167306258, + "angularVelocity": 0.00000677090027094694, + "velocityX": -4.016356772836354, + "velocityY": 0.22270275327959346, + "timestamp": 4.3192545600734515 + }, + { + "x": 3.9436846792731868, + "y": 0.9651571851562493, + "heading": -1.3180756463894978, + "angularVelocity": 0.000006770897862681277, + "velocityX": -4.016356772836784, + "velocityY": 0.22270275328044806, + "timestamp": 4.373950574611584 + }, + { + "x": 3.7240059708357576, + "y": 0.9773381381874052, + "heading": -1.3180752760485015, + "angularVelocity": 0.000006770895455737502, + "velocityX": -4.016356772837213, + "velocityY": 0.22270275328130246, + "timestamp": 4.428646589149716 + }, + { + "x": 3.5043272623983053, + "y": 0.9895190912186087, + "heading": -1.318074905707637, + "angularVelocity": 0.000006770893046361098, + "velocityX": -4.016356772837642, + "velocityY": 0.2227027532821716, + "timestamp": 4.4833426036878485 + }, + { + "x": 3.2846485539619055, + "y": 1.001700044269276, + "heading": -1.3180745353669043, + "angularVelocity": 0.000006770890636851538, + "velocityX": -4.016356772818388, + "velocityY": 0.222702753638031, + "timestamp": 4.538038618225981 + }, + { + "x": 3.064969871401373, + "y": 1.0138814639860811, + "heading": -1.3180741650285315, + "angularVelocity": 0.000006770847492232218, + "velocityX": -4.01635629973334, + "velocityY": 0.22271128563330012, + "timestamp": 4.592734632764113 + }, + { + "x": 2.845916361742838, + "y": 1.0344400044578748, + "heading": -1.3180737108157792, + "angularVelocity": 0.000008304311678697556, + "velocityX": -4.0049263462481175, + "velocityY": 0.3758690764838311, + "timestamp": 4.6474306473022455 + }, + { + "x": 2.640815838094564, + "y": 1.0655973128674503, + "heading": -1.289493164429316, + "angularVelocity": 0.5225343496743684, + "velocityX": -3.749825748369397, + "velocityY": 0.5696449489542624, + "timestamp": 4.702126661840378 + }, + { + "x": 2.45163944240355, + "y": 1.1038380268542072, + "heading": -1.2300528516755753, + "angularVelocity": 1.0867393768205997, + "velocityX": -3.4586870229663123, + "velocityY": 0.6991499163087526, + "timestamp": 4.75682267637851 + }, + { + "x": 2.278319287222078, + "y": 1.1496508795842428, + "heading": -1.142402837116851, + "angularVelocity": 1.6024936240577001, + "velocityX": -3.168789474791445, + "velocityY": 0.8375903275017751, + "timestamp": 4.8115186909166425 + }, + { + "x": 2.1205992924858448, + "y": 1.2036932398128166, + "heading": -1.0278733070437767, + "angularVelocity": 2.093928251266424, + "velocityX": -2.8835738045644375, + "velocityY": 0.9880493247071551, + "timestamp": 4.866214705454775 + }, + { + "x": 1.9780450716131908, + "y": 1.2666236472330685, + "heading": -0.8853675420058136, + "angularVelocity": 2.6054140551431404, + "velocityX": -2.606299966760295, + "velocityY": 1.1505483160272978, + "timestamp": 4.920910719992907 + }, + { + "x": 1.8498924673957173, + "y": 1.3391158080858083, + "heading": -0.7099571475748747, + "angularVelocity": 3.2070050425456333, + "velocityX": -2.3429971141339836, + "velocityY": 1.325364589447393, + "timestamp": 4.9756067345310395 + }, + { + "x": 1.7366792266224975, + "y": 1.4213022199550633, + "heading": -0.511849503089355, + "angularVelocity": 3.621975863477321, + "velocityX": -2.0698627080825407, + "velocityY": 1.5026032986728497, + "timestamp": 5.030302749069172 + }, + { + "x": 1.6392937564566123, + "y": 1.512661705013378, + "heading": -0.31945189307685995, + "angularVelocity": 3.517580058385459, + "velocityX": -1.780485671364439, + "velocityY": 1.670313382607105, + "timestamp": 5.084998763607304 + }, + { + "x": 1.5571204513790267, + "y": 1.614239806992095, + "heading": -0.1279423976429246, + "angularVelocity": 3.5013427770029124, + "velocityX": -1.5023636689341893, + "velocityY": 1.857139004303521, + "timestamp": 5.1396947781454365 + }, + { + "x": 1.4895694278857712, + "y": 1.7268360109242187, + "heading": 0.06777744416413656, + "angularVelocity": 3.5783199829050085, + "velocityX": -1.235026428592189, + "velocityY": 2.0585815051227545, + "timestamp": 5.194390792683569 + }, + { + "x": 1.4359342742944703, + "y": 1.8511693868204304, + "heading": 0.274536590508249, + "angularVelocity": 3.7801501277568823, + "velocityX": -0.9806044196128505, + "velocityY": 2.2731706678469514, + "timestamp": 5.249086807221701 + }, + { + "x": 1.3972040384965922, + "y": 1.985797456283131, + "heading": 0.46662822108389085, + "angularVelocity": 3.5119858768086685, + "velocityX": -0.7080997788399548, + "velocityY": 2.461387188802272, + "timestamp": 5.3037828217598335 + }, + { + "x": 1.373390793800354, + "y": 2.129699468612671, + "heading": 0.6304013934483359, + "angularVelocity": 2.9942432505803147, + "velocityX": -0.43537440336967165, + "velocityY": 2.630941459714892, + "timestamp": 5.358478836297966 + }, + { + "x": 1.363097994232707, + "y": 2.277885546279951, + "heading": 0.7388351387639758, + "angularVelocity": 2.0277089931298335, + "velocityX": -0.19247515786758002, + "velocityY": 2.7710768586653205, + "timestamp": 5.411954826039604 + }, + { + "x": 1.3664026020560647, + "y": 2.4333190233418533, + "heading": 0.8009908612218983, + "angularVelocity": 1.1623108381578078, + "velocityX": 0.061796103995895656, + "velocityY": 2.9066030907114606, + "timestamp": 5.465430815781243 + }, + { + "x": 1.3840403171376008, + "y": 2.5953692238583987, + "heading": 0.8219734655425052, + "angularVelocity": 0.39237430521587746, + "velocityX": 0.32982493950555586, + "velocityY": 3.030335694569958, + "timestamp": 5.518906805522882 + }, + { + "x": 1.4168581437621641, + "y": 2.7629163129609116, + "heading": 0.8067832999547334, + "angularVelocity": -0.2840558101151666, + "velocityX": 0.6136927391735564, + "velocityY": 3.133127407496165, + "timestamp": 5.57238279526452 + }, + { + "x": 1.4658290464052255, + "y": 2.9340177695630913, + "heading": 0.7613652665039514, + "angularVelocity": -0.8493163692754846, + "velocityX": 0.915754956189807, + "velocityY": 3.199594012730387, + "timestamp": 5.625858785006159 + }, + { + "x": 1.5318217076610499, + "y": 3.1050959732003816, + "heading": 0.6944449920709036, + "angularVelocity": -1.2514078702678118, + "velocityX": 1.2340615213417758, + "velocityY": 3.199159182725336, + "timestamp": 5.679334774747797 + }, + { + "x": 1.613943962289886, + "y": 3.2693665308083615, + "heading": 0.6243357428898241, + "angularVelocity": -1.3110416379351097, + "velocityX": 1.5356846133301518, + "velocityY": 3.07185633031998, + "timestamp": 5.732810764489436 + }, + { + "x": 1.707205824850905, + "y": 3.420371354182967, + "heading": 0.540461395859667, + "angularVelocity": -1.5684487082031198, + "velocityX": 1.7439950716498998, + "velocityY": 2.823787350251241, + "timestamp": 5.7862867542310745 + }, + { + "x": 1.803332479492569, + "y": 3.554784837261743, + "heading": 0.43066614318580515, + "angularVelocity": -2.0531691550604427, + "velocityX": 1.7975666295487922, + "velocityY": 2.513529599511379, + "timestamp": 5.839762743972713 + }, + { + "x": 1.8963203040621885, + "y": 3.6729531605178494, + "heading": 0.29050245020603344, + "angularVelocity": -2.621058416252808, + "velocityX": 1.738870566377101, + "velocityY": 2.2097454170931385, + "timestamp": 5.893238733714352 + }, + { + "x": 1.9828336996382947, + "y": 3.775961775527485, + "heading": 0.11920450803898805, + "angularVelocity": -3.203268289089085, + "velocityX": 1.6177988662590852, + "velocityY": 1.926259158686087, + "timestamp": 5.94671472345599 + }, + { + "x": 2.060121274343493, + "y": 3.864144859360976, + "heading": -0.05942729762417511, + "angularVelocity": -3.340411398203106, + "velocityX": 1.445276189905063, + "velocityY": 1.6490220051940039, + "timestamp": 6.000190713197629 + }, + { + "x": 2.127082581576336, + "y": 3.938231595081354, + "heading": -0.231565089097053, + "angularVelocity": -3.218973455274698, + "velocityX": 1.2521751828504142, + "velocityY": 1.385420561233492, + "timestamp": 6.0536667029392675 + }, + { + "x": 2.183199632616322, + "y": 3.998876793011361, + "heading": -0.38824009125711667, + "angularVelocity": -2.9298195866409387, + "velocityX": 1.0493877964878584, + "velocityY": 1.1340640579633077, + "timestamp": 6.107142692680906 + }, + { + "x": 2.228229768002549, + "y": 4.046617261125075, + "heading": -0.5226070066615436, + "angularVelocity": -2.512658784878971, + "velocityX": 0.8420626827812412, + "velocityY": 0.892745853688067, + "timestamp": 6.160618682422545 + }, + { + "x": 2.262056803725308, + "y": 4.081907934162313, + "heading": -0.629130589840352, + "angularVelocity": -1.9919889971828624, + "velocityX": 0.632564930283457, + "velocityY": 0.6599349204706556, + "timestamp": 6.214094672164183 + }, + { + "x": 2.2846197824922263, + "y": 4.105137889298369, + "heading": -0.7034068078221513, + "angularVelocity": -1.388963875949814, + "velocityX": 0.4219272775675214, + "velocityY": 0.4343997230960695, + "timestamp": 6.267570661905822 + }, + { + "x": 2.295893669128418, + "y": 4.116629123687744, + "heading": -0.7419473060415813, + "angularVelocity": -0.7207065901095526, + "velocityX": 0.2108214675531846, + "velocityY": 0.21488586644012128, + "timestamp": 6.32104665164746 + }, + { + "x": 2.295893669128418, + "y": 4.116629123687744, + "heading": -0.7419473060415813, + "angularVelocity": 7.691238387715462e-32, + "velocityX": 4.371614381676517e-33, + "velocityY": 2.1909450998623725e-33, + "timestamp": 6.374522641389099 + } + ] +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/3N-0M.auto b/src/main/deploy/pathplanner/autos/3N-0M.auto new file mode 100644 index 0000000..439cfa8 --- /dev/null +++ b/src/main/deploy/pathplanner/autos/3N-0M.auto @@ -0,0 +1,73 @@ +{ + "version": 1.0, + "startingPose": { + "position": { + "x": 0.89943932856987, + "y": 3.782906188140168 + }, + "rotation": 1.0416266760099369 + }, + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toRightCloseFromRight" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseRight" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseMiddle" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer2" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseMiddle" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + } + ] + } + }, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/3N-1M-Left.auto b/src/main/deploy/pathplanner/autos/3N-1M-Left.auto new file mode 100644 index 0000000..bd33ff5 --- /dev/null +++ b/src/main/deploy/pathplanner/autos/3N-1M-Left.auto @@ -0,0 +1,73 @@ +{ + "version": 1.0, + "startingPose": { + "position": { + "x": 1.4174820372432768, + "y": 6.537032333323926 + }, + "rotation": 0 + }, + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toMidAmpLeft" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "backMidAmpLeft" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseLeft" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer2" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseLeft" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + } + ] + } + }, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/4 piece mcnugget.auto b/src/main/deploy/pathplanner/autos/4 piece mcnugget.auto new file mode 100644 index 0000000..607c514 --- /dev/null +++ b/src/main/deploy/pathplanner/autos/4 piece mcnugget.auto @@ -0,0 +1,97 @@ +{ + "version": 1.0, + "startingPose": { + "position": { + "x": 1.55, + "y": 7.0 + }, + "rotation": 0 + }, + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "3N Top 1" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "3N Top Shoot 1" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer2" + } + }, + { + "type": "path", + "data": { + "pathName": "3N Top Shoot 2" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "3N Grab Note 3" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "3N Top Shoot 3" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "named", + "data": { + "name": "Idle Speed" + } + } + ] + } + }, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/4N-1M-left.auto b/src/main/deploy/pathplanner/autos/4N-1M-left.auto new file mode 100644 index 0000000..f79442e --- /dev/null +++ b/src/main/deploy/pathplanner/autos/4N-1M-left.auto @@ -0,0 +1,97 @@ +{ + "version": 1.0, + "startingPose": { + "position": { + "x": 1.3771774811958186, + "y": 6.50308873064302 + }, + "rotation": 0 + }, + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toMidAmpLeft" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "backMidAmpLeft" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseLeft" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer2" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseLeft" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseMiddle" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseMiddle" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + } + ] + } + }, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/5N-1M-left.auto b/src/main/deploy/pathplanner/autos/5N-1M-left.auto new file mode 100644 index 0000000..3c7d412 --- /dev/null +++ b/src/main/deploy/pathplanner/autos/5N-1M-left.auto @@ -0,0 +1,121 @@ +{ + "version": 1.0, + "startingPose": { + "position": { + "x": 1.3479282065452507, + "y": 6.620085829245293 + }, + "rotation": 0 + }, + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toMidAmpLeft" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "backMidAmpLeft" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseLeft" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer2" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseLeft" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseMiddle" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseMiddle" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseRight" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer2" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseRight" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + } + ] + } + }, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/Copy of 5N-1M-left.auto b/src/main/deploy/pathplanner/autos/Copy of 5N-1M-left.auto new file mode 100644 index 0000000..a95fdbd --- /dev/null +++ b/src/main/deploy/pathplanner/autos/Copy of 5N-1M-left.auto @@ -0,0 +1,115 @@ +{ + "version": 1.0, + "startingPose": { + "position": { + "x": 1.3771774811958186, + "y": 6.50308873064302 + }, + "rotation": 0 + }, + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toMidAmpLeft" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "backMidAmpLeft" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseLeft" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer2" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseLeft" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseMiddle" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseRight" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer2" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseRight" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + } + ] + } + }, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/ROMAN CHARGE.auto b/src/main/deploy/pathplanner/autos/ROMAN CHARGE.auto new file mode 100644 index 0000000..76c7f52 --- /dev/null +++ b/src/main/deploy/pathplanner/autos/ROMAN CHARGE.auto @@ -0,0 +1,97 @@ +{ + "version": 1.0, + "startingPose": { + "position": { + "x": 0.744692763774372, + "y": 4.446330676429759 + }, + "rotation": -61.949224233821454 + }, + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toMidSourceRight" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "backMidSourceRight" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toMidSourceLeft" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer2" + } + }, + { + "type": "named", + "data": { + "name": "Fire Under Stage" + } + }, + { + "type": "path", + "data": { + "pathName": "backMidSourceLeft" + } + }, + { + "type": "named", + "data": { + "name": "Force Shoot" + } + }, + { + "type": "named", + "data": { + "name": "Idle Speed" + } + }, + { + "type": "path", + "data": { + "pathName": "idk what the naming scheme is" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + } + ] + } + }, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/kachow.auto b/src/main/deploy/pathplanner/autos/kachow.auto new file mode 100644 index 0000000..aefbd8d --- /dev/null +++ b/src/main/deploy/pathplanner/autos/kachow.auto @@ -0,0 +1,97 @@ +{ + "version": 1.0, + "startingPose": { + "position": { + "x": 1.45, + "y": 6.45 + }, + "rotation": 0 + }, + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toMidAmpLeft" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "backMidAmpLeft" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseLeft" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer2" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseLeft" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toCloseMiddle" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "backCloseMiddle" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + } + ] + } + }, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/toothy grin.auto b/src/main/deploy/pathplanner/autos/toothy grin.auto new file mode 100644 index 0000000..b431f47 --- /dev/null +++ b/src/main/deploy/pathplanner/autos/toothy grin.auto @@ -0,0 +1,67 @@ +{ + "version": 1.0, + "startingPose": { + "position": { + "x": 0.744692763774372, + "y": 4.446330676429759 + }, + "rotation": -61.949224233821454 + }, + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toMidSourceRightAlt" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer" + } + }, + { + "type": "path", + "data": { + "pathName": "backMidSourceRightAlt" + } + }, + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "toMidSourceLeftAlt" + } + }, + { + "type": "named", + "data": { + "name": "Idle Speed" + } + }, + { + "type": "named", + "data": { + "name": "Note Sniffer2" + } + } + ] + } + }, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/navgrid.json b/src/main/deploy/pathplanner/navgrid.json index bab0da9..20b7761 100644 --- a/src/main/deploy/pathplanner/navgrid.json +++ b/src/main/deploy/pathplanner/navgrid.json @@ -1 +1 @@ -{"field_size":{"x":16.54,"y":8.21},"nodeSizeMeters":0.3,"grid":[[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true],[true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true],[true,true,true,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,true,true,true,true],[true,true,true,true,false,false,false,false,false,false,true,true,true,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,true,true,true,false,false,false,false,false,false,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true],[true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true],[true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true]]} \ No newline at end of file +{"field_size":{"x":16.54,"y":8.21},"nodeSizeMeters":0.3,"grid":[[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true],[true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,true,true],[true,true,false,false,false,false,false,false,false,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,true,true,true],[true,true,true,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,true,true,true,true],[true,true,true,true,false,false,false,false,false,false,true,true,true,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,true,true,true,false,false,false,false,false,false,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true],[true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true],[true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true],[true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true],[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true],[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true]]} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/2nd Note TOP.path b/src/main/deploy/pathplanner/paths/2nd Note TOP.path new file mode 100644 index 0000000..44e74cc --- /dev/null +++ b/src/main/deploy/pathplanner/paths/2nd Note TOP.path @@ -0,0 +1,86 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 3.8, + "y": 7.0 + }, + "prevControl": null, + "nextControl": { + "x": 3.4685115218933618, + "y": 7.0 + }, + "isLocked": false, + "linkedName": "3 Note Top END" + }, + { + "anchor": { + "x": 1.494174579798092, + "y": 5.5768617000416905 + }, + "prevControl": { + "x": 0.975143016688687, + "y": 5.5768617000416905 + }, + "nextControl": { + "x": 1.8646653920386236, + "y": 5.5768617000416905 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 3.8, + "y": 5.5768617000416905 + }, + "prevControl": { + "x": 2.5129949850025284, + "y": 5.5768617000416905 + }, + "nextControl": null, + "isLocked": false, + "linkedName": "3 Note Top 2nd END" + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [ + { + "name": "Intake", + "waypointRelativePos": 1.6, + "command": { + "type": "parallel", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Intake" + } + } + ] + } + } + } + ], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "McNugget paths", + "previewStartingState": { + "rotation": 0, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/3N Grab Note 3.path b/src/main/deploy/pathplanner/paths/3N Grab Note 3.path new file mode 100644 index 0000000..de757a4 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/3N Grab Note 3.path @@ -0,0 +1,52 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 1.9251138929831317, + "y": 4.585369909386533 + }, + "prevControl": null, + "nextControl": { + "x": 1.9173088951256527, + "y": 4.251704312807356 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.9251138929831317, + "y": 4.131723545348486 + }, + "prevControl": { + "x": 1.9290137962698273, + "y": 4.525613777309474 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": true + }, + "reversed": false, + "folder": "McNugget paths", + "previewStartingState": { + "rotation": -20.0, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/3N Top 1.path b/src/main/deploy/pathplanner/paths/3N Top 1.path new file mode 100644 index 0000000..498a5b2 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/3N Top 1.path @@ -0,0 +1,58 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 1.55, + "y": 7.0 + }, + "prevControl": null, + "nextControl": { + "x": 1.6500000000000001, + "y": 7.0 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 2.3034045117971482, + "y": 7.0 + }, + "prevControl": { + "x": 2.203404511797148, + "y": 7.0 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [ + { + "waypointRelativePos": 0.15, + "rotationDegrees": 0, + "rotateFast": true + } + ], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "McNugget paths", + "previewStartingState": { + "rotation": 0, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/3N Top Shoot 1.path b/src/main/deploy/pathplanner/paths/3N Top Shoot 1.path new file mode 100644 index 0000000..1993c8e --- /dev/null +++ b/src/main/deploy/pathplanner/paths/3N Top Shoot 1.path @@ -0,0 +1,52 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 2.8981397630253705, + "y": 6.980826883268969 + }, + "prevControl": null, + "nextControl": { + "x": 2.4009020939657093, + "y": 6.4075411001178315 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 2.055760653089004, + "y": 5.565161990181464 + }, + "prevControl": { + "x": 2.2683053822164663, + "y": 6.2437451620746485 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "McNugget paths", + "previewStartingState": { + "rotation": 0, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/3N Top Shoot 2.path b/src/main/deploy/pathplanner/paths/3N Top Shoot 2.path new file mode 100644 index 0000000..f78350f --- /dev/null +++ b/src/main/deploy/pathplanner/paths/3N Top Shoot 2.path @@ -0,0 +1,52 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 2.755077047615666, + "y": 5.505607227681089 + }, + "prevControl": null, + "nextControl": { + "x": 2.299589943374272, + "y": 5.098637580035078 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.8966611698070783, + "y": 4.6478800976884465 + }, + "prevControl": { + "x": 2.203112957932501, + "y": 4.995742093990707 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": -20.0, + "rotateFast": false + }, + "reversed": false, + "folder": "McNugget paths", + "previewStartingState": { + "rotation": 0, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/3N Top Shoot 3.path b/src/main/deploy/pathplanner/paths/3N Top Shoot 3.path new file mode 100644 index 0000000..045e830 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/3N Top Shoot 3.path @@ -0,0 +1,52 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 2.6022294159701613, + "y": 4.1159435424278135 + }, + "prevControl": null, + "nextControl": { + "x": 2.3610924813659686, + "y": 4.356024795515781 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 2.0196231716467223, + "y": 4.912666546975921 + }, + "prevControl": { + "x": 2.1833413338408816, + "y": 4.674105796350148 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": -12.0, + "rotateFast": false + }, + "reversed": false, + "folder": "McNugget paths", + "previewStartingState": { + "rotation": 0, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/3rd Note TOP.path b/src/main/deploy/pathplanner/paths/3rd Note TOP.path new file mode 100644 index 0000000..c105bb5 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/3rd Note TOP.path @@ -0,0 +1,147 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 3.8, + "y": 5.5768617000416905 + }, + "prevControl": null, + "nextControl": { + "x": 2.8632110836634554, + "y": 5.5768617000416905 + }, + "isLocked": false, + "linkedName": "3 Note Top 2nd END" + }, + { + "anchor": { + "x": 1.8451658756049114, + "y": 5.5768617000416905 + }, + "prevControl": { + "x": 1.7551658756049113, + "y": 5.5768617000416905 + }, + "nextControl": { + "x": 1.9451658756049115, + "y": 5.5768617000416905 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.8451658756049114, + "y": 4.094898451079563 + }, + "prevControl": { + "x": 1.8451658756049114, + "y": 4.777660033953261 + }, + "nextControl": { + "x": 1.8451658756049114, + "y": 3.9948984510795627 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 2.75, + "y": 4.094898451079563 + }, + "prevControl": { + "x": 2.6500000000000004, + "y": 4.094898451079563 + }, + "nextControl": { + "x": 2.8499999999999996, + "y": 4.094898451079563 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.328428690111538, + "y": 4.3386424065009646 + }, + "prevControl": { + "x": 2.0609117652914652, + "y": 4.333767527392537 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [ + { + "waypointRelativePos": 3.55, + "rotationDegrees": 0, + "rotateFast": false + } + ], + "constraintZones": [], + "eventMarkers": [ + { + "name": "Shoot", + "waypointRelativePos": 0.35, + "command": { + "type": "parallel", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Shoot" + } + }, + { + "type": "named", + "data": { + "name": "Target" + } + } + ] + } + } + }, + { + "name": "Intake", + "waypointRelativePos": 2.6, + "command": { + "type": "parallel", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "Intake" + } + } + ] + } + } + } + ], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": -45.0, + "rotateFast": true + }, + "reversed": false, + "folder": "McNugget paths", + "previewStartingState": { + "rotation": 0, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/Copy of Midfield-2Scored.path b/src/main/deploy/pathplanner/paths/Copy of Midfield-2Scored.path new file mode 100644 index 0000000..e69de29 diff --git a/src/main/deploy/pathplanner/paths/Spin.path b/src/main/deploy/pathplanner/paths/Spin.path new file mode 100644 index 0000000..d9c9acd --- /dev/null +++ b/src/main/deploy/pathplanner/paths/Spin.path @@ -0,0 +1,65 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 0.9579378778710067, + "y": 7.088074223654385 + }, + "prevControl": null, + "nextControl": { + "x": 1.9579378778710068, + "y": 6.588074223654385 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 5.647571580178791, + "y": 6.395841390257602 + }, + "prevControl": { + "x": 6.82178789696324, + "y": 5.607668794059819 + }, + "nextControl": { + "x": 4.935839230348296, + "y": 6.873579542883553 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.43, + "y": 5.54 + }, + "prevControl": { + "x": 0.6207700680009443, + "y": 6.485726547035042 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 3.0, + "maxAcceleration": 3.0, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": null, + "previewStartingState": null, + "useDefaultConstraints": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/Straight Line Top.path b/src/main/deploy/pathplanner/paths/Straight Line Top.path new file mode 100644 index 0000000..c18b918 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/Straight Line Top.path @@ -0,0 +1,58 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 1.55, + "y": 7.0 + }, + "prevControl": null, + "nextControl": { + "x": 2.320230899131632, + "y": 7.0 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 3.8, + "y": 7.0 + }, + "prevControl": { + "x": 2.7755328178240863, + "y": 7.0 + }, + "nextControl": null, + "isLocked": false, + "linkedName": "3 Note Top END" + } + ], + "rotationTargets": [ + { + "waypointRelativePos": 0.3, + "rotationDegrees": 0, + "rotateFast": true + } + ], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0.0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "McNugget paths", + "previewStartingState": { + "rotation": 35.0, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/backCloseLeft.path b/src/main/deploy/pathplanner/paths/backCloseLeft.path new file mode 100644 index 0000000..e59303b --- /dev/null +++ b/src/main/deploy/pathplanner/paths/backCloseLeft.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 1.9231639413397603, + "y": 6.854080026449839 + }, + "prevControl": null, + "nextControl": { + "x": 1.776917568086919, + "y": 6.42509066490817 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.41, + "y": 5.57 + }, + "prevControl": { + "x": 1.6014219201835092, + "y": 6.113098401968776 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Close", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/backCloseMiddle.path b/src/main/deploy/pathplanner/paths/backCloseMiddle.path new file mode 100644 index 0000000..0f0d7d2 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/backCloseMiddle.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 1.8159166009543433, + "y": 5.547612425391122 + }, + "prevControl": null, + "nextControl": { + "x": 1.6014219201835092, + "y": 5.5768617000416905 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.41, + "y": 5.57 + }, + "prevControl": { + "x": 1.69891950235207, + "y": 5.606110974692258 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Close", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/backCloseRight.path b/src/main/deploy/pathplanner/paths/backCloseRight.path new file mode 100644 index 0000000..eace181 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/backCloseRight.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 1.59, + "y": 4.17 + }, + "prevControl": null, + "nextControl": { + "x": 1.5136740962318043, + "y": 4.7383824933920655 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.41, + "y": 5.57 + }, + "prevControl": { + "x": 1.4844248215812361, + "y": 5.079624030982029 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Close", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/backMidAmpLeft.path b/src/main/deploy/pathplanner/paths/backMidAmpLeft.path new file mode 100644 index 0000000..3f182c2 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/backMidAmpLeft.path @@ -0,0 +1,65 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 6.554299094346408, + "y": 7.361067453726357 + }, + "prevControl": null, + "nextControl": { + "x": 5.9108150520339064, + "y": 7.088074223654385 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 2.7908924226399536, + "y": 6.308093566305898 + }, + "prevControl": { + "x": 3.3824207875442123, + "y": 6.475840416054866 + }, + "nextControl": { + "x": 2.137658622110595, + "y": 6.122848160185632 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.41, + "y": 5.57 + }, + "prevControl": { + "x": 1.8159166009543433, + "y": 5.723108073294532 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/backMidAmpRight.path b/src/main/deploy/pathplanner/paths/backMidAmpRight.path new file mode 100644 index 0000000..c803c05 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/backMidAmpRight.path @@ -0,0 +1,65 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 6.4763010286115605, + "y": 6.10334864375192 + }, + "prevControl": null, + "nextControl": { + "x": 5.984594320162516, + "y": 6.390200672467855 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 5.0430865707337125, + "y": 6.639585345679005 + }, + "prevControl": { + "x": 6.436490622294017, + "y": 6.397872397959361 + }, + "nextControl": { + "x": 4.087610265481815, + "y": 6.805331235365558 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.41, + "y": 5.57 + }, + "prevControl": { + "x": 2.1181591056768823, + "y": 6.044850094450783 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/backMidSourceLeft.path b/src/main/deploy/pathplanner/paths/backMidSourceLeft.path new file mode 100644 index 0000000..a142a21 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/backMidSourceLeft.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 7.344029509911752, + "y": 2.8859284321894068 + }, + "prevControl": null, + "nextControl": { + "x": 6.661546434731825, + "y": 3.344167068381643 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 6.027812150636178, + "y": 3.782906188140168 + }, + "prevControl": { + "x": 6.495800545045272, + "y": 3.412415375899636 + }, + "nextControl": null, + "isLocked": false, + "linkedName": "i hope this works" + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": -29.430000000000007, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/backMidSourceRight.path b/src/main/deploy/pathplanner/paths/backMidSourceRight.path new file mode 100644 index 0000000..30ac516 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/backMidSourceRight.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 6.651796676514969, + "y": 0.70198259161364 + }, + "prevControl": null, + "nextControl": { + "x": 5.6670710966125295, + "y": 1.2284695353208006 + }, + "isLocked": false, + "linkedName": "bottom wing line" + }, + { + "anchor": { + "x": 1.3479282065452507, + "y": 3.9584018360435778 + }, + "prevControl": { + "x": 1.5429233708823726, + "y": 2.993175772574823 + }, + "nextControl": null, + "isLocked": false, + "linkedName": "SHoot from bottomn" + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": -48.64118525790135, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/backMidSourceRightAlt.path b/src/main/deploy/pathplanner/paths/backMidSourceRightAlt.path new file mode 100644 index 0000000..6048004 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/backMidSourceRightAlt.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 6.798043049767811, + "y": 2.378941004912889 + }, + "prevControl": null, + "nextControl": { + "x": 5.364828591889964, + "y": 0.6922328333967845 + }, + "isLocked": false, + "linkedName": "3 Note Top Alt" + }, + { + "anchor": { + "x": 1.3479282065452507, + "y": 3.9584018360435778 + }, + "prevControl": { + "x": 1.5429233708823726, + "y": 2.993175772574823 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": -48.64118525790135, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/idk what the naming scheme is.path b/src/main/deploy/pathplanner/paths/idk what the naming scheme is.path new file mode 100644 index 0000000..9cc1024 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/idk what the naming scheme is.path @@ -0,0 +1,52 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 6.027812150636178, + "y": 3.782906188140168 + }, + "prevControl": null, + "nextControl": { + "x": 6.4763010286115605, + "y": 3.9681515942604335 + }, + "isLocked": false, + "linkedName": "i hope this works" + }, + { + "anchor": { + "x": 6.983288455888077, + "y": 4.1338974839469875 + }, + "prevControl": { + "x": 6.612789523297573, + "y": 4.0266781996568355 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": { + "rotation": 0, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/toCloseLeft.path b/src/main/deploy/pathplanner/paths/toCloseLeft.path new file mode 100644 index 0000000..ce9ff1e --- /dev/null +++ b/src/main/deploy/pathplanner/paths/toCloseLeft.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 1.41, + "y": 5.57 + }, + "prevControl": null, + "nextControl": { + "x": 1.6209214366172213, + "y": 6.064349610884495 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.92, + "y": 6.85 + }, + "prevControl": { + "x": 1.7476682934363506, + "y": 6.327593082739611 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Close", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/toCloseMiddle.path b/src/main/deploy/pathplanner/paths/toCloseMiddle.path new file mode 100644 index 0000000..79f39e7 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/toCloseMiddle.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 1.41, + "y": 5.55 + }, + "prevControl": null, + "nextControl": { + "x": 1.4161765140632432, + "y": 5.55686170004169 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.82, + "y": 5.557362183607978 + }, + "prevControl": { + "x": 1.8102502417831439, + "y": 5.567111941824834 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Close", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/toCloseRight.path b/src/main/deploy/pathplanner/paths/toCloseRight.path new file mode 100644 index 0000000..e609aae --- /dev/null +++ b/src/main/deploy/pathplanner/paths/toCloseRight.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 1.41, + "y": 5.57 + }, + "prevControl": null, + "nextControl": { + "x": 1.4551755469306675, + "y": 5.17712161315059 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.59, + "y": 4.17 + }, + "prevControl": { + "x": 1.5136740962318043, + "y": 4.933377657729188 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Close", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/toMidAmpLeft.path b/src/main/deploy/pathplanner/paths/toMidAmpLeft.path new file mode 100644 index 0000000..77d8522 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/toMidAmpLeft.path @@ -0,0 +1,97 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 0.9774373943047189, + "y": 7.068574707220673 + }, + "prevControl": null, + "nextControl": { + "x": 1.4525645005705963, + "y": 6.373314171129768 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 2.62197994481459, + "y": 6.303149244475128 + }, + "prevControl": { + "x": 2.2009903848867527, + "y": 6.338231707802447 + }, + "nextControl": { + "x": 3.102052624207869, + "y": 6.263143187859021 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 3.873254470155664, + "y": 6.537032333323926 + }, + "prevControl": { + "x": 3.4392388686731197, + "y": 6.418028055498066 + }, + "nextControl": { + "x": 4.598292045586939, + "y": 6.735832958845405 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 5.323329621018216, + "y": 6.958021893251764 + }, + "prevControl": { + "x": 4.880368383741278, + "y": 6.831969463656056 + }, + "nextControl": { + "x": 5.929464796776777, + "y": 7.130508343843873 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 6.544549336129553, + "y": 7.380566970160069 + }, + "prevControl": { + "x": 6.118532123104131, + "y": 7.203599136543003 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 3.0, + "maxAcceleration": 3.0, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": null, + "useDefaultConstraints": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/toMidAmpRight.path b/src/main/deploy/pathplanner/paths/toMidAmpRight.path new file mode 100644 index 0000000..a7bce57 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/toMidAmpRight.path @@ -0,0 +1,65 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 0.9676876360878626, + "y": 7.010076157919538 + }, + "prevControl": null, + "nextControl": { + "x": 1.9676876360878635, + "y": 6.510076157919538 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 4.965088504998865, + "y": 6.171596951269913 + }, + "prevControl": { + "x": 3.5845515250736004, + "y": 6.478382946808862 + }, + "nextControl": { + "x": 5.491575448709092, + "y": 6.054599852667639 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 6.525049819695841, + "y": 5.742607589728245 + }, + "prevControl": { + "x": 5.345329075456252, + "y": 6.093598885535064 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/toMidSourceLeft.path b/src/main/deploy/pathplanner/paths/toMidSourceLeft.path new file mode 100644 index 0000000..d09d636 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/toMidSourceLeft.path @@ -0,0 +1,52 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 2.1571581385443066, + "y": 3.4709139252007724 + }, + "prevControl": null, + "nextControl": { + "x": 3.8926151011446923, + "y": 2.300942939178039 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 6.768338999394455, + "y": 2.355489245691538 + }, + "prevControl": { + "x": 5.1405841529022736, + "y": 1.3259671174924308 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": { + "rotation": -50.0, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/toMidSourceLeftAlt.path b/src/main/deploy/pathplanner/paths/toMidSourceLeftAlt.path new file mode 100644 index 0000000..03faadb --- /dev/null +++ b/src/main/deploy/pathplanner/paths/toMidSourceLeftAlt.path @@ -0,0 +1,52 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 1.9329136995566167, + "y": 3.3539168265984998 + }, + "prevControl": null, + "nextControl": { + "x": 3.288130091699615, + "y": 2.6031854439005797 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 6.5835483689969765, + "y": 0.8189796902159131 + }, + "prevControl": { + "x": 5.218582218637122, + "y": 1.540461798263264 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": { + "rotation": -50.0, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/toMidSourceRight.path b/src/main/deploy/pathplanner/paths/toMidSourceRight.path new file mode 100644 index 0000000..92a4b04 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/toMidSourceRight.path @@ -0,0 +1,64 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 0.744692763774372, + "y": 4.446330676429759 + }, + "prevControl": null, + "nextControl": { + "x": 2.4789001597005584, + "y": 2.8469293993219815 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 6.651796676514969, + "y": 0.70198259161364 + }, + "prevControl": { + "x": 6.037561908853036, + "y": 1.0627236456373161 + }, + "nextControl": null, + "isLocked": false, + "linkedName": "bottom wing line" + } + ], + "rotationTargets": [], + "constraintZones": [ + { + "name": "New Constraints Zone", + "minWaypointRelativePos": 0.0, + "maxWaypointRelativePos": 1.0, + "constraints": { + "maxVelocity": 4.25, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + } + } + ], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": { + "rotation": -59.63572899983965, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/toMidSourceRightAlt.path b/src/main/deploy/pathplanner/paths/toMidSourceRightAlt.path new file mode 100644 index 0000000..f6c0ccd --- /dev/null +++ b/src/main/deploy/pathplanner/paths/toMidSourceRightAlt.path @@ -0,0 +1,64 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 0.744692763774372, + "y": 4.446330676429759 + }, + "prevControl": null, + "nextControl": { + "x": 2.44965088504999, + "y": 2.47643858708145 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 6.798043049767811, + "y": 2.378941004912889 + }, + "prevControl": { + "x": 5.452576415841669, + "y": 0.9067275141676178 + }, + "nextControl": null, + "isLocked": false, + "linkedName": "3 Note Top Alt" + } + ], + "rotationTargets": [], + "constraintZones": [ + { + "name": "New Constraints Zone", + "minWaypointRelativePos": 0.0, + "maxWaypointRelativePos": 1.0, + "constraints": { + "maxVelocity": 4.25, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + } + } + ], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Midfield Paths", + "previewStartingState": { + "rotation": -59.63572899983965, + "velocity": 0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/toRightCloseFromRight.path b/src/main/deploy/pathplanner/paths/toRightCloseFromRight.path new file mode 100644 index 0000000..f554d3a --- /dev/null +++ b/src/main/deploy/pathplanner/paths/toRightCloseFromRight.path @@ -0,0 +1,49 @@ +{ + "version": 1.0, + "waypoints": [ + { + "anchor": { + "x": 0.93, + "y": 3.782906188140168 + }, + "prevControl": null, + "nextControl": { + "x": 1.211431591509265, + "y": 3.8706540120918724 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 1.59, + "y": 4.17 + }, + "prevControl": { + "x": 1.6014219201835092, + "y": 4.163146758597556 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 4.0, + "maxAcceleration": 3.5, + "maxAngularVelocity": 540.0, + "maxAngularAcceleration": 720.0 + }, + "goalEndState": { + "velocity": 0, + "rotation": 0, + "rotateFast": false + }, + "reversed": false, + "folder": "Close", + "previewStartingState": null, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/java/frc/lib/math/Conversions.java b/src/main/java/frc/lib/math/Conversions.java index ac68dcd..84781f3 100644 --- a/src/main/java/frc/lib/math/Conversions.java +++ b/src/main/java/frc/lib/math/Conversions.java @@ -1,13 +1,13 @@ package frc.lib.math; public class Conversions { - + /** * @param wheelRPS Wheel Velocity: (in Rotations per Second) * @param circumference Wheel Circumference: (in Meters) * @return Wheel Velocity: (in Meters per Second) */ - public static double RPSToMPS(double wheelRPS, double circumference){ + public static double RPSToMPS(double wheelRPS, double circumference) { double wheelMPS = wheelRPS * circumference; return wheelMPS; } @@ -17,7 +17,7 @@ public static double RPSToMPS(double wheelRPS, double circumference){ * @param circumference Wheel Circumference: (in Meters) * @return Wheel Velocity: (in Rotations per Second) */ - public static double MPSToRPS(double wheelMPS, double circumference){ + public static double MPSToRPS(double wheelMPS, double circumference) { double wheelRPS = wheelMPS / circumference; return wheelRPS; } @@ -27,7 +27,7 @@ public static double MPSToRPS(double wheelMPS, double circumference){ * @param circumference Wheel Circumference: (in Meters) * @return Wheel Distance: (in Meters) */ - public static double rotationsToMeters(double wheelRotations, double circumference){ + public static double rotationsToMeters(double wheelRotations, double circumference) { double wheelMeters = wheelRotations * circumference; return wheelMeters; } @@ -37,8 +37,8 @@ public static double rotationsToMeters(double wheelRotations, double circumferen * @param circumference Wheel Circumference: (in Meters) * @return Wheel Position: (in Rotations) */ - public static double metersToRotations(double wheelMeters, double circumference){ + public static double metersToRotations(double wheelMeters, double circumference) { double wheelRotations = wheelMeters / circumference; return wheelRotations; } -} \ No newline at end of file +} diff --git a/src/main/java/frc/lib/math/FiringSolutions.java b/src/main/java/frc/lib/math/FiringSolutions.java index 3c0c68b..7971a85 100644 --- a/src/main/java/frc/lib/math/FiringSolutions.java +++ b/src/main/java/frc/lib/math/FiringSolutions.java @@ -1,5 +1,5 @@ package frc.lib.math; -// format:off +// spotless:off public final class FiringSolutions { private static final double shooterHeight = 0.355; private static final double noteFallAccel = 9.8; @@ -86,5 +86,5 @@ public static double getShooterAngle(double shooterVelocityX, double shooterVelo public static double getRobotOffsetAngle(double robotVelocityPerpendicularToSpeaker, double shooterVelocityX){ return Math.atan(robotVelocityPerpendicularToSpeaker / shooterVelocityX); } - +// spotless:on } diff --git a/src/main/java/frc/lib/math/FiringSolutionsV2.java b/src/main/java/frc/lib/math/FiringSolutionsV2.java index 930ce26..96c9efe 100644 --- a/src/main/java/frc/lib/math/FiringSolutionsV2.java +++ b/src/main/java/frc/lib/math/FiringSolutionsV2.java @@ -1,5 +1,5 @@ package frc.lib.math; -// format:off +// spotless:off public class FiringSolutionsV2 { private static final double shooterHeight = 0.355; @@ -141,5 +141,5 @@ public static double getR() { public static double getShooterAngle() { return Math.acos(R); } - +// spotless:on } diff --git a/src/main/java/frc/lib/math/FiringSolutionsV3.java b/src/main/java/frc/lib/math/FiringSolutionsV3.java index d5388bc..3b38fa1 100644 --- a/src/main/java/frc/lib/math/FiringSolutionsV3.java +++ b/src/main/java/frc/lib/math/FiringSolutionsV3.java @@ -1,34 +1,44 @@ package frc.lib.math; -// format:off +// spotless:off import java.util.Optional; import edu.wpi.first.math.geometry.Translation2d; public class FiringSolutionsV3 { + // Robot Values private static final double defaultShooterHeight = 0.42672; - private static final double laserCANOffset = 0; private static double shooterHeight = 0.42672; - + private static final double laserCANOffset = 0; + public static final double maxShooterAngle = Math.toRadians(70); + public static double slipPercent = 0.5324; + private static double shooterVelocity = 10.0; private static final double noteFallAccel = 9.8; - private static final double maxShooterAngle = Math.toRadians(70); - private static final double ampTargetXBlue = 1.84; - private static final double ampTargetXRed = 14.7; - - public static final double speakerTargetY = 5.55; - public static final double ampTargetY = 8.0; + + // Amp Values (used for targeting from afar) + private static final double ampTargetXRed = 15.91; + private static final double ampTargetXBlue = 16.54 - ampTargetXRed; + public static double ampTargetX; + public static final double ampTargetY = 7; public static final double ampTargetZ = .125; - public static double speakerTargetXOffset = .24; - public static double speakerTargetZ = 1.92; - public static double slipPercent = 0.5324; + // True Amp Values + private static final double trueAmpXBlue = 1.8415; + private static final double trueAmpXRed = 16.54 - trueAmpXBlue; + public static double trueAmpX; + public static final double trueAmpY = 8.2; + // Speaker Values + public static double speakerTargetXOffset = .24; private static double speakerTargetXBlue = 0.0 + speakerTargetXOffset; private static double speakerTargetXRed = 16.54 - speakerTargetXOffset; public static double speakerTargetX; - public static double ampTargetX; - private static double shooterVelocity = 10.0; + public static final double speakerTargetY = 5.55; + public static double speakerTargetZ = 1.92; + + //R Values private static double speakerR, ampR, customR = 1.0; + public static double maxRangeWithR = 11.25; private FiringSolutionsV3() { } @@ -37,13 +47,15 @@ public static void setAlliance(boolean redAlliance) { if (redAlliance) { speakerTargetX = speakerTargetXRed; ampTargetX = ampTargetXRed; + trueAmpX = trueAmpXRed; } else { speakerTargetX = speakerTargetXBlue; ampTargetX = ampTargetXBlue; + trueAmpX = trueAmpXBlue; } } - public static void updateHeight(double laserCANValue){ + public static void updateHeight(double laserCANValue) { shooterHeight = defaultShooterHeight + (laserCANValue - laserCANOffset); } @@ -55,7 +67,8 @@ public static double getDistanceToTarget(double robotX, double robotY, double ta return Math.abs(Math.sqrt(Math.pow(targetX - robotX, 2) + Math.pow(targetY - robotY, 2))); } - public static double getRobotVelocityTowardsTarget(double robotX, double targetX, double robotVelocityX, double robotVelocityY, + public static double getRobotVelocityTowardsTarget(double robotX, double targetX, double robotVelocityX, + double robotVelocityY, double angleToTarget, double robotHeading) { if (robotX <= targetX) { if (robotVelocityX == 0) { @@ -76,7 +89,8 @@ public static double getRobotVelocityTowardsTarget(double robotX, double targetX } } - public static double getRobotVelocityPerpendicularToTarget(double robotX, double targetX, double robotVelocityX, double robotVelocityY, + public static double getRobotVelocityPerpendicularToTarget(double robotX, double targetX, double robotVelocityX, + double robotVelocityY, double angleToSpeaker, double robotHeading) { if (robotX <= targetX) { if (robotVelocityX == 0) { @@ -184,7 +198,7 @@ public static double getShooterAngleFromCustomR() { return Math.acos(customR); } - public static void resetAllR(){ + public static void resetAllR() { resetSpeakerR(); resetAmpR(); resetCustomR(); @@ -259,40 +273,78 @@ public static Optional movingTarget( // is based on the same as the input translate2ds) } - public static double getAngleToMovingTarget(double robotX, double robotY, double targetX, double targetY, double robotVelocityX, + public static double getAngleToMovingTarget(double robotX, double robotY, double targetX, double targetY, + double robotVelocityX, double robotVelocityY, double robotHeading) { - return Math.atan((movingTarget(robotX, robotY, targetX, targetY, - getRobotVelocityTowardsTarget(robotX, targetX, robotVelocityX, robotVelocityY, - getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading), - getRobotVelocityPerpendicularToTarget(robotX, targetX, robotVelocityX, robotVelocityY, - getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)).get().getY() - robotY) - / (movingTarget(robotX, robotY, targetX, targetY, + //if (robotX >= targetX) { + return Math.atan((movingTarget(robotX, robotY, targetX, targetY, + getRobotVelocityTowardsTarget(robotX, targetX, robotVelocityX, robotVelocityY, + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading), + getRobotVelocityPerpendicularToTarget(robotX, targetX, robotVelocityX, robotVelocityY, + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)) + .get().getY() - robotY) + / (movingTarget(robotX, robotY, targetX, targetY, + getRobotVelocityTowardsTarget(robotX, targetX, robotVelocityX, robotVelocityY, + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading), + getRobotVelocityPerpendicularToTarget(robotX, targetX, robotVelocityX, robotVelocityY, + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)) + .get().getX() - robotX)); + /*} else { + if (robotY >= targetY) { + return Math.atan((movingTarget(robotX, robotY, targetX, targetY, + getRobotVelocityTowardsTarget(robotX, targetX, robotVelocityX, robotVelocityY, + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading), + getRobotVelocityPerpendicularToTarget(robotX, targetX, robotVelocityX, robotVelocityY, + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)) + .get().getY() - robotY) + / (movingTarget(robotX, robotY, targetX, targetY, + getRobotVelocityTowardsTarget(robotX, targetX, robotVelocityX, robotVelocityY, + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading), + getRobotVelocityPerpendicularToTarget(robotX, targetX, robotVelocityX, robotVelocityY, + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)) + .get().getX() - robotX)) + Math.toRadians(180); + } else { + return Math.atan((movingTarget(robotX, robotY, targetX, targetY, getRobotVelocityTowardsTarget(robotX, targetX, robotVelocityX, robotVelocityY, getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading), getRobotVelocityPerpendicularToTarget(robotX, targetX, robotVelocityX, robotVelocityY, - getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)).get().getX() - robotX)); + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)) + .get().getY() - robotY) + / (movingTarget(robotX, robotY, targetX, targetY, + getRobotVelocityTowardsTarget(robotX, targetX, robotVelocityX, robotVelocityY, + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading), + getRobotVelocityPerpendicularToTarget(robotX, targetX, robotVelocityX, robotVelocityY, + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)) + .get().getX() - robotX)) - Math.toRadians(180); + } + }*/ + } - public static double getDistanceToMovingTarget(double robotX, double robotY, double targetX, double targetY, double robotVelocityX, + public static double getDistanceToMovingTarget(double robotX, double robotY, double targetX, double targetY, + double robotVelocityX, double robotVelocityY, double robotHeading) { return Math.abs(Math.sqrt( - Math.pow(movingTarget(robotX, robotY, targetX, targetY, + Math.pow(movingTarget(robotX, robotY, targetX, targetY, getRobotVelocityTowardsTarget(robotX, targetX, robotVelocityX, robotVelocityY, getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading), getRobotVelocityPerpendicularToTarget(robotX, targetX, robotVelocityX, robotVelocityY, - getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)).get().getX() - robotX, 2) + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)) + .get().getX() - robotX, 2) + Math.pow( movingTarget(robotX, robotY, targetX, targetY, getRobotVelocityTowardsTarget(robotX, targetX, robotVelocityX, robotVelocityY, getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading), - getRobotVelocityPerpendicularToTarget(robotX, targetX, robotVelocityX, robotVelocityY, - getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)).get().getY() - robotY, + getRobotVelocityPerpendicularToTarget(robotX, targetX, robotVelocityX, + robotVelocityY, + getAngleToTarget(robotX, robotY, targetX, targetY), robotHeading)) + .get().getY() - robotY, 2))); } - + /** Convert meters per second to rotations per minute */ public static double convertToRPM(double velocity) { return (60 * velocity) / (slipPercent * Math.PI * .1016); } - +// spotless:on } diff --git a/src/main/java/frc/lib/math/Interpolations.java b/src/main/java/frc/lib/math/Interpolations.java index ae8047c..98c665a 100644 --- a/src/main/java/frc/lib/math/Interpolations.java +++ b/src/main/java/frc/lib/math/Interpolations.java @@ -8,24 +8,58 @@ public class Interpolations { - public InterpolatingDoubleTreeMap shooterSpeeds = new InterpolatingDoubleTreeMap(); - - public Interpolations() { - shooterSpeeds.put(1.25, 53.0); - shooterSpeeds.put(1.5, 48.0); - shooterSpeeds.put(1.75, 44.0); - shooterSpeeds.put(2.0, 41.0); - shooterSpeeds.put(2.25, 39.0); - shooterSpeeds.put(2.5, 37.5); - shooterSpeeds.put(2.75, 35.5); - shooterSpeeds.put(3.0, 34.0); - shooterSpeeds.put(3.25, 33.0); - shooterSpeeds.put(3.5, 32.0); - shooterSpeeds.put(4.0, 30.75); - shooterSpeeds.put(4.5, 29.75); - } - - public double getShooterAngleFromInterpolation(double distanceToTarget){ - return shooterSpeeds.get(distanceToTarget); - } -} \ No newline at end of file + public InterpolatingDoubleTreeMap shooterSpeeds = new InterpolatingDoubleTreeMap(); + public InterpolatingDoubleTreeMap bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds = + new InterpolatingDoubleTreeMap(); + + private double offset = 1; + + public Interpolations() { + /* + shooterSpeeds.put(1.25, 53.0); + shooterSpeeds.put(1.5, 48.0); + shooterSpeeds.put(1.75, 44.0); + shooterSpeeds.put(2.0, 41.0); + shooterSpeeds.put(2.25, 39.0); + shooterSpeeds.put(2.5, 37.5); + shooterSpeeds.put(2.75, 35.5); + shooterSpeeds.put(3.0, 34.0); + shooterSpeeds.put(3.25, 33.0); + shooterSpeeds.put(3.5, 32.0); + shooterSpeeds.put(4.0, 30.75); + shooterSpeeds.put(4.5, 29.75); + */ + bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(1.25, 44.0); + bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(1.5, 39.5); + bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(1.75, 36.0); + bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(2.0, 32.25); + bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(2.25, 30.0); + bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(2.5, 28.0); + bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(2.75, 26.5); + bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(3.0, 24.5); + bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(3.25, 22.5); + bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(3.5, 21.25); + bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(3.75, 20.0); + + shooterSpeeds.put(1.25, 56.0 + offset); + shooterSpeeds.put(1.35, 53.0 + offset); + shooterSpeeds.put(1.5, 50.0 + offset); + shooterSpeeds.put(1.75, 46.0 + offset); + shooterSpeeds.put(2.0, 42.0 + offset); + shooterSpeeds.put(2.25, 38.5 + offset); + shooterSpeeds.put(2.5, 35.5 + offset); + shooterSpeeds.put(2.75, 33.75 + offset); + shooterSpeeds.put(3.0, 32.25 + offset); + shooterSpeeds.put(3.25, 31.0 + offset); + shooterSpeeds.put(3.5, 30.0 + offset); + shooterSpeeds.put(4.0, 28.25 + offset); + } + + public double getShooterAngleFromInterpolation(double distanceToTarget) { + return shooterSpeeds.get(distanceToTarget); + } + + public double getShooterAngleFromInterpolationElevatorUp(double distanceToTarget) { + return bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.get(distanceToTarget); + } +} diff --git a/src/main/java/frc/lib/util/COTSTalonFXSwerveConstants.java b/src/main/java/frc/lib/util/COTSTalonFXSwerveConstants.java index 0f4d7f9..e0930a2 100644 --- a/src/main/java/frc/lib/util/COTSTalonFXSwerveConstants.java +++ b/src/main/java/frc/lib/util/COTSTalonFXSwerveConstants.java @@ -4,7 +4,7 @@ import com.ctre.phoenix6.signals.SensorDirectionValue; import edu.wpi.first.math.util.Units; - +// spotless:off /* Contains values and required settings for common COTS swerve modules. */ public class COTSTalonFXSwerveConstants { public final double wheelDiameter; @@ -307,5 +307,4 @@ public static final class driveRatios{ } } } - - \ No newline at end of file +// spotless:on diff --git a/src/main/java/frc/lib/util/SwerveModuleConstants.java b/src/main/java/frc/lib/util/SwerveModuleConstants.java index da90a20..05bb3a2 100644 --- a/src/main/java/frc/lib/util/SwerveModuleConstants.java +++ b/src/main/java/frc/lib/util/SwerveModuleConstants.java @@ -1,7 +1,7 @@ package frc.lib.util; import edu.wpi.first.math.geometry.Rotation2d; - +// spotless:off public class SwerveModuleConstants { public final int driveMotorID; public final int angleMotorID; @@ -22,3 +22,4 @@ public SwerveModuleConstants(int driveMotorID, int angleMotorID, int canCoderID, this.angleOffset = angleOffset; } } +// spotless:on diff --git a/src/main/java/frc/robot/CTREConfigs.java b/src/main/java/frc/robot/CTREConfigs.java index 24b6695..8bbb55d 100644 --- a/src/main/java/frc/robot/CTREConfigs.java +++ b/src/main/java/frc/robot/CTREConfigs.java @@ -8,7 +8,7 @@ public final class CTREConfigs { public TalonFXConfiguration swerveDriveFXConfig = new TalonFXConfiguration(); public CANcoderConfiguration swerveCANcoderConfig = new CANcoderConfiguration(); - public CTREConfigs(){ + public CTREConfigs() { /** Swerve CANCoder Configuration */ swerveCANcoderConfig.MagnetSensor.SensorDirection = Constants.Swerve.cancoderInvert; @@ -20,12 +20,15 @@ public CTREConfigs(){ /* Gear Ratio and Wrapping Config */ swerveAngleFXConfig.Feedback.SensorToMechanismRatio = Constants.Swerve.angleGearRatio; swerveAngleFXConfig.ClosedLoopGeneral.ContinuousWrap = true; - + /* Current Limiting */ - swerveAngleFXConfig.CurrentLimits.SupplyCurrentLimitEnable = Constants.Swerve.angleEnableCurrentLimit; + swerveAngleFXConfig.CurrentLimits.SupplyCurrentLimitEnable = + Constants.Swerve.angleEnableCurrentLimit; swerveAngleFXConfig.CurrentLimits.SupplyCurrentLimit = Constants.Swerve.angleCurrentLimit; - swerveAngleFXConfig.CurrentLimits.SupplyCurrentThreshold = Constants.Swerve.angleCurrentThreshold; - swerveAngleFXConfig.CurrentLimits.SupplyTimeThreshold = Constants.Swerve.angleCurrentThresholdTime; + swerveAngleFXConfig.CurrentLimits.SupplyCurrentThreshold = + Constants.Swerve.angleCurrentThreshold; + swerveAngleFXConfig.CurrentLimits.SupplyTimeThreshold = + Constants.Swerve.angleCurrentThresholdTime; /* PID Config */ swerveAngleFXConfig.Slot0.kP = Constants.Swerve.angleKP; @@ -41,10 +44,13 @@ public CTREConfigs(){ swerveDriveFXConfig.Feedback.SensorToMechanismRatio = Constants.Swerve.driveGearRatio; /* Current Limiting */ - swerveDriveFXConfig.CurrentLimits.SupplyCurrentLimitEnable = Constants.Swerve.driveEnableCurrentLimit; + swerveDriveFXConfig.CurrentLimits.SupplyCurrentLimitEnable = + Constants.Swerve.driveEnableCurrentLimit; swerveDriveFXConfig.CurrentLimits.SupplyCurrentLimit = Constants.Swerve.driveCurrentLimit; - swerveDriveFXConfig.CurrentLimits.SupplyCurrentThreshold = Constants.Swerve.driveCurrentThreshold; - swerveDriveFXConfig.CurrentLimits.SupplyTimeThreshold = Constants.Swerve.driveCurrentThresholdTime; + swerveDriveFXConfig.CurrentLimits.SupplyCurrentThreshold = + Constants.Swerve.driveCurrentThreshold; + swerveDriveFXConfig.CurrentLimits.SupplyTimeThreshold = + Constants.Swerve.driveCurrentThresholdTime; /* PID Config */ swerveDriveFXConfig.Slot0.kP = Constants.Swerve.driveKP; @@ -52,10 +58,13 @@ public CTREConfigs(){ swerveDriveFXConfig.Slot0.kD = Constants.Swerve.driveKD; /* Open and Closed Loop Ramping */ - swerveDriveFXConfig.OpenLoopRamps.DutyCycleOpenLoopRampPeriod = Constants.Swerve.openLoopRamp; + swerveDriveFXConfig.OpenLoopRamps.DutyCycleOpenLoopRampPeriod = + Constants.Swerve.openLoopRamp; swerveDriveFXConfig.OpenLoopRamps.VoltageOpenLoopRampPeriod = Constants.Swerve.openLoopRamp; - swerveDriveFXConfig.ClosedLoopRamps.DutyCycleClosedLoopRampPeriod = Constants.Swerve.closedLoopRamp; - swerveDriveFXConfig.ClosedLoopRamps.VoltageClosedLoopRampPeriod = Constants.Swerve.closedLoopRamp; + swerveDriveFXConfig.ClosedLoopRamps.DutyCycleClosedLoopRampPeriod = + Constants.Swerve.closedLoopRamp; + swerveDriveFXConfig.ClosedLoopRamps.VoltageClosedLoopRampPeriod = + Constants.Swerve.closedLoopRamp; } -} \ No newline at end of file +} diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 66117b7..ea136a7 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -1,16 +1,16 @@ package frc.robot; -import java.io.UncheckedIOException; - import com.ctre.phoenix6.signals.InvertedValue; import com.ctre.phoenix6.signals.NeutralModeValue; import com.ctre.phoenix6.signals.SensorDirectionValue; +import com.pathplanner.lib.path.PathConstraints; import edu.wpi.first.apriltag.AprilTagFieldLayout; import edu.wpi.first.apriltag.AprilTagFields; import edu.wpi.first.math.Matrix; import edu.wpi.first.math.VecBuilder; import edu.wpi.first.math.Vector; +import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.geometry.Rotation2d; import edu.wpi.first.math.geometry.Rotation3d; import edu.wpi.first.math.geometry.Transform3d; @@ -22,34 +22,52 @@ import edu.wpi.first.math.trajectory.TrapezoidProfile; import edu.wpi.first.math.util.Units; import edu.wpi.first.wpilibj.DataLogManager; + import frc.lib.util.COTSTalonFXSwerveConstants; import frc.lib.util.SwerveModuleConstants; +import java.io.UncheckedIOException; + public final class Constants { public static final double stickDeadband = 0.07; public static class Vision { - public static final String kAprilTagCameraFront = "ChristiansThirdEye"; - public static final String kAprilTagCameraBack = "ChristiansFourthEye"; + public static final String kAprilTagCameraFront = "ChristiansFourthEye"; + public static final String kAprilTagCameraBack = "ChristiansThirdEye"; public static final String kNoteCamera = "OnionRing"; - public static final Transform3d kRobotToCamFront = - new Transform3d(new Translation3d(Units.inchesToMeters(12), Units.inchesToMeters(1.25), Units.inchesToMeters(13.5)), new Rotation3d(0, 0, 0)); - public static final Transform3d kRobotToCamBack = - new Transform3d(new Translation3d(Units.inchesToMeters(-8), 0, Units.inchesToMeters(12)), new Rotation3d(0, 0, Math.PI)); + public static final Transform3d kRobotToCamFront = new Transform3d( + new Translation3d( + Units.inchesToMeters(11.5), + Units.inchesToMeters(-1.25), + Units.inchesToMeters(14.75)), + new Rotation3d(0, Units.degreesToRadians(15), 0)); + + public static final Transform3d kRobotToCamBack = new Transform3d( + new Translation3d( + Units.inchesToMeters(-7), + Units.inchesToMeters(11), + Units.inchesToMeters(14.5)), + new Rotation3d(0, Units.degreesToRadians(15), Math.PI)); // The layout of the AprilTags on the field - public static final AprilTagFieldLayout kTagLayout = errorWrapper(); + public static final AprilTagFieldLayout kTagLayout = getFieldLayout(); // The standard deviations of our vision estimated poses, which affect correction rate - public static final Matrix kSingleTagStdDevs = VecBuilder.fill(4, 4, 20); - public static final Matrix kMultiTagStdDevs = VecBuilder.fill(2, 2, 15); - public static final Vector stateStdDevs = VecBuilder.fill(1, 1, 1); // Encoder Odometry + public static final Matrix kSingleTagStdDevs = VecBuilder.fill(8, 8, 40); + public static final Matrix kMultiTagStdDevs = VecBuilder.fill(4, 4, 20); + public static final Vector stateStdDevs = + VecBuilder.fill(.5, .5, .5); // Encoder Odometry + + public static final Pose2d startingPoseBlue = new Pose2d(1.35, 5.55, new Rotation2d(0)); + public static final Pose2d startingPoseRed = + new Pose2d(15.19, 5.55, new Rotation2d(Math.PI)); } - private static AprilTagFieldLayout errorWrapper() { + private static AprilTagFieldLayout getFieldLayout() { try { - AprilTagFieldLayout attemptedKTagLayout = AprilTagFields.k2024Crescendo.loadAprilTagLayoutField(); + AprilTagFieldLayout attemptedKTagLayout = + AprilTagFields.k2024Crescendo.loadAprilTagLayoutField(); return attemptedKTagLayout; } catch (UncheckedIOException e) { DataLogManager.log(e.getMessage()); @@ -58,24 +76,25 @@ private static AprilTagFieldLayout errorWrapper() { } public static final class Swerve { - public static final String canivore = "uno"; + public static final String canivore = "rex"; public static final int pigeonID = 13; - public static final COTSTalonFXSwerveConstants chosenModule = - COTSTalonFXSwerveConstants.SDS.MK4i.Falcon500(COTSTalonFXSwerveConstants.SDS.MK4i.driveRatios.L2); + public static final COTSTalonFXSwerveConstants chosenModule = + COTSTalonFXSwerveConstants.SDS.MK4i.Falcon500( + COTSTalonFXSwerveConstants.SDS.MK4i.driveRatios.L2); /* Drivetrain Constants */ public static final double trackWidth = Units.inchesToMeters(20.75); public static final double wheelBase = Units.inchesToMeters(20.75); public static final double wheelCircumference = chosenModule.wheelCircumference; - /* Swerve Kinematics + /* Swerve Kinematics * No need to ever change this unless you are not doing a traditional rectangular/square 4 module swerve */ - public static final SwerveDriveKinematics swerveKinematics = new SwerveDriveKinematics( - new Translation2d(wheelBase / 2.0, trackWidth / 2.0), - new Translation2d(wheelBase / 2.0, -trackWidth / 2.0), - new Translation2d(-wheelBase / 2.0, trackWidth / 2.0), - new Translation2d(-wheelBase / 2.0, -trackWidth / 2.0)); + public static final SwerveDriveKinematics swerveKinematics = new SwerveDriveKinematics( + new Translation2d(wheelBase / 2.0, trackWidth / 2.0), + new Translation2d(wheelBase / 2.0, -trackWidth / 2.0), + new Translation2d(-wheelBase / 2.0, trackWidth / 2.0), + new Translation2d(-wheelBase / 2.0, -trackWidth / 2.0)); /* Module Gear Ratios */ public static final double driveGearRatio = chosenModule.driveGearRatio; @@ -110,93 +129,111 @@ public static final class Swerve { public static final double angleKD = chosenModule.angleKD; /* Drive Motor PID Values */ - public static final double driveKP = 0.12; + public static final double driveKP = 0.36; public static final double driveKI = 0.0; public static final double driveKD = 0.0; public static final double driveKF = 0.0; /* Drive Motor Characterization Values From SYSID */ - public static final double driveKS = 0.080723; - public static final double driveKV = 0.73696; - public static final double driveKA = 0.073127; + public static final double driveKS = 0.072013; + public static final double driveKV = 2.3106; + public static final double driveKA = 0.27696; /* Swerve Profiling Values */ /** Meters per Second */ public static final double maxSpeed = 4.5; /** Radians per Second */ - public static final double maxAngularVelocity = 10.0; //TODO: This must be tuned to specific robot + public static final double maxAngularVelocity = + 10.0; // TODO: This must be tuned to specific robot /* Neutral Modes */ public static final NeutralModeValue angleNeutralMode = NeutralModeValue.Brake; public static final NeutralModeValue driveNeutralMode = NeutralModeValue.Brake; /* Module Specific Constants */ - /* Front Left Module - Module 0 */ + /** Front Left Module - Module 0 */ public static final class Mod0 { public static final int driveMotorID = 1; public static final int angleMotorID = 3; public static final int canCoderID = 2; - public static final Rotation2d angleOffset = Rotation2d.fromDegrees(112.5); - public static final SwerveModuleConstants constants = - new SwerveModuleConstants(driveMotorID, angleMotorID, canCoderID, angleOffset); + public static final Rotation2d angleOffset = Rotation2d.fromDegrees(111.7); + public static final SwerveModuleConstants constants = + new SwerveModuleConstants(driveMotorID, angleMotorID, canCoderID, angleOffset); } - /* Front Right Module - Module 1 */ + /** Front Right Module - Module 1 */ public static final class Mod1 { public static final int driveMotorID = 4; public static final int angleMotorID = 6; public static final int canCoderID = 5; - public static final Rotation2d angleOffset = Rotation2d.fromDegrees(-79.4); - public static final SwerveModuleConstants constants = - new SwerveModuleConstants(driveMotorID, angleMotorID, canCoderID, angleOffset); + public static final Rotation2d angleOffset = Rotation2d.fromDegrees(-79.1); + public static final SwerveModuleConstants constants = + new SwerveModuleConstants(driveMotorID, angleMotorID, canCoderID, angleOffset); } - - /* Back Left Module - Module 2 */ + + /** Back Left Module - Module 2 */ public static final class Mod2 { public static final int driveMotorID = 7; public static final int angleMotorID = 9; public static final int canCoderID = 8; - public static final Rotation2d angleOffset = Rotation2d.fromDegrees(-80.5); - public static final SwerveModuleConstants constants = - new SwerveModuleConstants(driveMotorID, angleMotorID, canCoderID, angleOffset); + public static final Rotation2d angleOffset = Rotation2d.fromDegrees(-80.1); + public static final SwerveModuleConstants constants = + new SwerveModuleConstants(driveMotorID, angleMotorID, canCoderID, angleOffset); } - /* Back Right Module - Module 3 */ + /** Back Right Module - Module 3 */ public static final class Mod3 { public static final int driveMotorID = 10; public static final int angleMotorID = 12; public static final int canCoderID = 11; - public static final Rotation2d angleOffset = Rotation2d.fromDegrees(114); - public static final SwerveModuleConstants constants = - new SwerveModuleConstants(driveMotorID, angleMotorID, canCoderID, angleOffset); + public static final Rotation2d angleOffset = Rotation2d.fromDegrees(111.44); + public static final SwerveModuleConstants constants = + new SwerveModuleConstants(driveMotorID, angleMotorID, canCoderID, angleOffset); } } + public static final class Intake { + public static final double noteOutsideSpeed = 0.5; + public static final double noteInsideSpeed = 0.25; + public static final double outakeSpeed = -0.5; + } + public static final class Shooter { public static final double intakeAngleRadians = 0.56; public static final double idleSpeedRPM = 1300; - public static final double angleOffsetManual = Units.degreesToRadians(68.2); + public static final double angleOffsetBottom = Units.degreesToRadians(-1); + public static final double wristAngleMax = Units.degreesToRadians(62.7); + public static final double wristAngleMin = Units.degreesToRadians(-28.8); + public static final double angleOffsetManual = Units.degreesToRadians(62.7); public static final double angleOffsetAuto = Units.degreesToRadians(75.5); } - public static final class Elevator { //TODO tune - public static final double maxHeightMeters = 0.81; - public static final double minHeightMeters = 0.015; + public static final class Elevator { + public static final double maxHeightMeters = 0.61; + public static final double minHeightMeters = -0.01; + public static final double ampHeight = 0.513; + public static final double antiBozoSmileToasterAhhGoonBotShooterHeight = .5; } public static final class Auto { - public static final double kMaxSpeedMetersPerSecond = 4.25; - public static final double kMaxAccelerationMetersPerSecondSquared = 8; - public static final double kMaxAngularSpeedRadiansPerSecond = (Math.PI*3)/2; - public static final double kMaxAngularSpeedRadiansPerSecondSquared = Math.PI*2; - + public static final double kMaxSpeedMetersPerSecond = 2.5; + public static final double kMaxAccelerationMetersPerSecondSquared = 3; + public static final double kMaxAngularSpeedRadiansPerSecond = 9.424778; + public static final double kMaxAngularSpeedRadiansPerSecondSquared = 12.56637; + public static final double kPXController = 1; public static final double kPYController = 1; public static final double kPThetaController = 1; - - /* Constraint for the motion profilied robot angle controller */ + + public static final PathConstraints PathfindingConstraints = new PathConstraints( + kMaxSpeedMetersPerSecond, + kMaxAccelerationMetersPerSecondSquared, + kMaxAngularSpeedRadiansPerSecond, + kMaxAngularSpeedRadiansPerSecondSquared); + + /** Constraint for the motion profilied robot angle controller */ public static final TrapezoidProfile.Constraints kThetaControllerConstraints = - new TrapezoidProfile.Constraints( - kMaxAngularSpeedRadiansPerSecond, kMaxAngularSpeedRadiansPerSecondSquared); + new TrapezoidProfile.Constraints( + kMaxAngularSpeedRadiansPerSecond, kMaxAngularSpeedRadiansPerSecondSquared); } } diff --git a/src/main/java/frc/robot/Main.java b/src/main/java/frc/robot/Main.java index 8776e5d..61037e8 100644 --- a/src/main/java/frc/robot/Main.java +++ b/src/main/java/frc/robot/Main.java @@ -12,14 +12,14 @@ * call. */ public final class Main { - private Main() {} + private Main() {} - /** - * Main initialization function. Do not perform any initialization here. - * - *

If you change your main robot class, change the parameter type. - */ - public static void main(String... args) { - RobotBase.startRobot(Robot::new); - } + /** + * Main initialization function. Do not perform any initialization here. + * + *

If you change your main robot class, change the parameter type. + */ + public static void main(String... args) { + RobotBase.startRobot(Robot::new); + } } diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 79ff5fd..78484b6 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -4,35 +4,30 @@ package frc.robot; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Optional; -import org.littletonrobotics.urcl.URCL; - -import com.ctre.phoenix6.SignalLogger; - import edu.wpi.first.net.PortForwarder; import edu.wpi.first.wpilibj.DataLogManager; import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.DriverStation.Alliance; import edu.wpi.first.wpilibj.PowerDistribution; import edu.wpi.first.wpilibj.PowerDistribution.ModuleType; +import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.CommandScheduler; -import frc.lib.math.FiringSolutions; + import frc.lib.math.FiringSolutionsV3; +import org.littletonrobotics.urcl.URCL; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Optional; + /** - * The VM is configured to automatically run this class, and to call the - * functions corresponding to - * each mode, as described in the TimedRobot documentation. If you change the - * name of this class or - * the package after creating this project, you must also update the - * build.gradle file in the - * project. + * The VM is configured to automatically run this class, and to call the functions corresponding to + * each mode, as described in the TimedRobot documentation. If you change the name of this class or + * the package after creating this project, you must also update the build.gradle file in the project. */ public class Robot extends TimedRobot { public static final CTREConfigs ctreConfigs = new CTREConfigs(); @@ -43,7 +38,7 @@ public class Robot extends TimedRobot { private static boolean redAlliance; - //PowerDistribution PDH = new PowerDistribution(1, ModuleType.kRev); + PowerDistribution PDH; /** * This function is run when the robot is first started up and should be used for any @@ -55,6 +50,8 @@ public void robotInit() { // autonomous chooser on the dashboard. m_robotContainer = new RobotContainer(); + PDH = new PowerDistribution(1, ModuleType.kRev); + // Disable LiveWindow since we don't use it LiveWindow.disableAllTelemetry(); LiveWindow.setEnabled(false); @@ -62,7 +59,10 @@ public void robotInit() { DriverStation.silenceJoystickConnectionWarning(true); // Starts recording to data log - DataLogManager.start("/media/sda1/logs/", DateTimeFormatter.ofPattern("yyyy-MM-dd__HH-mm-ss").format(LocalDateTime.now())+".wpilog"); + DataLogManager.start( + "/media/sda1/logs/", + DateTimeFormatter.ofPattern("yyyy-MM-dd__HH-mm-ss").format(LocalDateTime.now()) + + ".wpilog"); // Record both DS control and joystick data DriverStation.startDataLog(DataLogManager.getLog()); @@ -73,17 +73,21 @@ public void robotInit() { URCL.start(); // Log data from all CTRE devices - SignalLogger.setPath("/media/sda1/logs/"); - SignalLogger.start(); + // SignalLogger.setPath("/media/sda1/logs/"); + // SignalLogger.start(); // Output command scheduler to dashboard SmartDashboard.putData(CommandScheduler.getInstance()); // Access PhotonVision dashboard when connected via usb TODO make work - // PortForwarder.add(5800, "10.17.10.11", 5800); + PortForwarder.add(5800, "10.17.10.11", 5800); - // idk if this is useful - System.gc(); + SmartDashboard.putData(PDH); + + redAlliance = checkRedAlliance(); + + // idk if this is useful + // System.gc(); } /** @@ -100,7 +104,7 @@ public void robotPeriodic() { // and running subsystem periodic() methods. This must be called from the robot's periodic // block in order for anything in the Command-based framework to work. CommandScheduler.getInstance().run(); - //SmartDashboard.putData(PDH); + SmartDashboard.putNumber("Match Time", DriverStation.getMatchTime()); } /** Gets the current alliance, true is red */ @@ -108,22 +112,28 @@ public static boolean getAlliance() { return redAlliance; } - public boolean checkRedAlliance() { + public static boolean checkRedAlliance() { Optional alliance = DriverStation.getAlliance(); if (alliance.isPresent()) { return alliance.get() == DriverStation.Alliance.Red; + } else { + DataLogManager.log("ERROR: Alliance not found. Defaulting to Blue"); + return false; } - return false; } /** This function is called once each time the robot enters Disabled mode. */ @Override public void disabledInit() { + m_robotContainer.stopAll(); + + if (m_autonomousCommand != null) { + m_autonomousCommand.cancel(); + } } @Override - public void disabledPeriodic() { - } + public void disabledPeriodic() {} /** * This autonomous runs the autonomous command selected by your @@ -132,10 +142,10 @@ public void disabledPeriodic() { @Override public void autonomousInit() { redAlliance = checkRedAlliance(); - + m_autonomousCommand = m_robotContainer.getAutonomousCommand(); - FiringSolutions.setAlliance(redAlliance); + FiringSolutionsV3.setAlliance(redAlliance); // schedule the autonomous command (example) if (m_autonomousCommand != null) { @@ -143,18 +153,18 @@ public void autonomousInit() { } FiringSolutionsV3.resetAllR(); + m_robotContainer.zeroWristEncoders(); } /** This function is called periodically during autonomous. */ @Override - public void autonomousPeriodic() { - } + public void autonomousPeriodic() {} @Override public void teleopInit() { redAlliance = checkRedAlliance(); - FiringSolutions.setAlliance(redAlliance); + FiringSolutionsV3.setAlliance(redAlliance); // This makes sure that the autonomous stops running when // teleop starts running. If you want the autonomous to // continue until interrupted by another command, remove @@ -168,8 +178,7 @@ public void teleopInit() { /** This function is called periodically during operator control. */ @Override - public void teleopPeriodic() { - } + public void teleopPeriodic() {} @Override public void testInit() { @@ -179,6 +188,5 @@ public void testInit() { /** This function is called periodically during test mode. */ @Override - public void testPeriodic() { - } + public void testPeriodic() {} } diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index cfe477b..7c27b75 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -3,8 +3,6 @@ import com.pathplanner.lib.auto.AutoBuilder; import com.pathplanner.lib.auto.NamedCommands; -import edu.wpi.first.math.geometry.Pose2d; -import edu.wpi.first.math.geometry.Rotation2d; import edu.wpi.first.wpilibj.GenericHID; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.XboxController; @@ -14,25 +12,23 @@ import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.button.JoystickButton; import edu.wpi.first.wpilibj2.command.button.Trigger; -import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction; + import frc.lib.math.FiringSolutionsV3; import frc.robot.commands.*; import frc.robot.subsystems.*; /** - * This class is where the bulk of the robot should be declared. Since - * Command-based is a - * "declarative" paradigm, very little robot logic should actually be handled in - * the {@link Robot} + * This class is where the bulk of the robot should be declared. Since Command-based is a + * "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot} * periodic methods (other than the scheduler calls). Instead, the structure of - * the robot (including - * subsystems, commands, and button mappings) should be declared here. + * the robot (including subsystems, commands, and button mappings) should be declared here. */ public class RobotContainer { /* Controllers */ private final Joystick driver = new Joystick(0); private final Joystick mech = new Joystick(1); + private final Joystick FF = new Joystick(2); /* Analog */ private final int leftVerticalAxis = XboxController.Axis.kLeftY.value; @@ -42,46 +38,82 @@ public class RobotContainer { private final int leftTrigger = XboxController.Axis.kLeftTrigger.value; private final int rightTrigger = XboxController.Axis.kRightTrigger.value; - /* Driver Buttons */ - private final JoystickButton resetOdom = new JoystickButton(driver, XboxController.Button.kStart.value); - private final JoystickButton robotCentric = new JoystickButton(driver, XboxController.Button.kB.value); + /* DRIVER BUTTONS spotless:off */ + /** Driver X */ + private final JoystickButton intakeNoMove = new JoystickButton(driver, XboxController.Button.kX.value); + /** Driver A */ private final JoystickButton Shoot = new JoystickButton(driver, XboxController.Button.kA.value); + /** Driver B */ + private final JoystickButton forceShoot = new JoystickButton(driver, XboxController.Button.kB.value); + /** Driver Y */ + private final JoystickButton intakeFromSource = new JoystickButton(driver, XboxController.Button.kY.value); + /** Driver RB */ private final JoystickButton intex = new JoystickButton(driver, XboxController.Button.kRightBumper.value); + /** Driver LB */ private final JoystickButton outex = new JoystickButton(driver, XboxController.Button.kLeftBumper.value); - private final JoystickButton xButtonDriver = new JoystickButton(driver, XboxController.Button.kX.value); - private final JoystickButton forceShoot = new JoystickButton(driver, XboxController.Button.kY.value); + /** Driver LT */ private final Trigger targetAmp = new Trigger(() -> driver.getRawAxis(leftTrigger) > .5); + /** Driver RT */ private final Trigger targetSpeaker = new Trigger(() -> driver.getRawAxis(rightTrigger) > .5); + /** Driver Up */ + private final Trigger driverUp = new Trigger(() -> driver.getPOV() == 0); + /** Driver Down */ + private final Trigger driverDown = new Trigger(() -> driver.getPOV() == 180); + /** Driver Right */ + private final Trigger driverLeft = new Trigger(() -> driver.getPOV() == 90); + /** Driver Left */ + private final Trigger driverRight = new Trigger(() -> driver.getPOV() == 270); + /** Driver Start */ + private final JoystickButton resetOdom = new JoystickButton(driver, XboxController.Button.kStart.value); - /* Mech Buttons */ - private final JoystickButton zeroShooter = new JoystickButton(mech, XboxController.Button.kBack.value); - private final JoystickButton primeShooterSpeedSpeaker = new JoystickButton(mech, XboxController.Button.kRightBumper.value); - private final JoystickButton primeShooterSpeedAmp = new JoystickButton(mech, XboxController.Button.kLeftBumper.value); - private final JoystickButton shooterTo45 = new JoystickButton(mech, XboxController.Button.kB.value); + /* MECH BUTTONS */ + /** Mech X */ + private final JoystickButton shooterToAntiDefense = new JoystickButton(mech, XboxController.Button.kX.value); + /** Mech A */ private final JoystickButton shooterToIntake = new JoystickButton(mech, XboxController.Button.kA.value); - private final Trigger resetR = new Trigger(() -> mech.getPOV() == 90); - private final Trigger elevatorDown = new Trigger(() -> mech.getPOV() == 180); + /** Mech Y */ + private final JoystickButton shooterToAmp = new JoystickButton(mech, XboxController.Button.kY.value); + /** Mech B */ + private final JoystickButton shooterToSubwoofer = new JoystickButton(mech, XboxController.Button.kB.value); + /** Mech RB */ + private final JoystickButton primeShooterSpeedSpeaker = new JoystickButton(mech, XboxController.Button.kRightBumper.value); + /** Mech LB */ + private final JoystickButton resetNoteInShooter = new JoystickButton(mech, XboxController.Button.kLeftBumper.value); + /** Mech RT */ + private final Trigger mechRT = new Trigger(() -> mech.getRawAxis(rightTrigger) > .5); + /** Mech LT */ + private final Trigger mechLT = new Trigger(() -> mech.getRawAxis(leftTrigger) > .5); + /** Mech Up */ private final Trigger elevatorUp = new Trigger(() -> mech.getPOV() == 0); - private final Trigger intakeThroughShooter = new Trigger(() -> mech.getPOV() == 270); + /** Mech Down */ + private final Trigger elevatorDown = new Trigger(() -> mech.getPOV() == 180); + /** Mech Right */ + private final Trigger resetR = new Trigger(() -> mech.getPOV() == 90); + /** Mech Left */ + private final Trigger mechLeft = new Trigger(() -> mech.getPOV() == 270); + /** Mech Start */ private final JoystickButton autoZeroShooter = new JoystickButton(mech, XboxController.Button.kStart.value); - private final JoystickButton shooterToAmp = new JoystickButton(mech, XboxController.Button.kY.value); - private final JoystickButton xButtonMech = new JoystickButton(mech, XboxController.Button.kX.value); - private final JoystickButton rightStick = new JoystickButton(mech, XboxController.Button.kRightStick.value); - - /* - private final Trigger dynamicForward = new Trigger(() -> mech.getPOV() == 90); - private final Trigger dynamicBackward = new Trigger(() -> mech.getPOV() == 270); - private final Trigger quasistaticForward = new Trigger(() -> mech.getPOV() == 0); - private final Trigger quasistaticBackwards = new Trigger(() -> mech.getPOV() == 180); - */ + /** Mech Back */ + private final JoystickButton zeroShooter = new JoystickButton(mech, XboxController.Button.kBack.value); + /** Mech RS */ + private final JoystickButton mechRightStick = new JoystickButton(mech, XboxController.Button.kRightStick.value); + /** Mech LS */ + private final JoystickButton mechLeftStick = new JoystickButton(mech, XboxController.Button.kLeftStick.value); +// spotless:on + private final Trigger dynamicForward = new Trigger(() -> FF.getPOV() == 90); + private final Trigger dynamicBackward = new Trigger(() -> FF.getPOV() == 270); + private final Trigger quasistaticForward = new Trigger(() -> FF.getPOV() == 0); + private final Trigger quasistaticBackwards = new Trigger(() -> FF.getPOV() == 180); /* Subsystems */ private final VisionSubsystem m_VisionSubsystem = new VisionSubsystem(); private final SwerveSubsystem m_SwerveSubsystem = new SwerveSubsystem(m_VisionSubsystem); - public final ShooterSubsystem m_Shoota = new ShooterSubsystem(m_SwerveSubsystem); - //private final LEDSubsystem m_LEDSubsystem = new LEDSubsystem(m_VisionSubsystem); private final ElevatorSubsystem m_ElevatorSubsystem = new ElevatorSubsystem(); private final IntexerSubsystem m_IntexerSubsystem = new IntexerSubsystem(); + private final ShooterSubsystem m_ShooterSubsystem = + new ShooterSubsystem(m_SwerveSubsystem, m_ElevatorSubsystem); + private final LEDSubsystem m_LEDSubsystem = new LEDSubsystem( + m_VisionSubsystem, m_ShooterSubsystem, m_IntexerSubsystem, m_SwerveSubsystem); private final SendableChooser autoChooser; @@ -89,38 +121,44 @@ public class RobotContainer { * The container for the robot. Contains subsystems, OI devices, and commands. */ public RobotContainer() { + // spotless:off // Named commands for PathPlanner autos - NamedCommands.registerCommand("Intake", new IntexForAutosByAutos(m_IntexerSubsystem)); - NamedCommands.registerCommand("Idle Speed", new InstantCommand(() -> m_Shoota.setShooterVelocity(Constants.Shooter.idleSpeedRPM))); - NamedCommands.registerCommand("Target Speed", new InstantCommand(() -> m_Shoota.setShooterVelocity(FiringSolutionsV3.convertToRPM(m_Shoota.getCalculatedVelocity())))); + NamedCommands.registerCommand("Intake", new IntexForAutosByAutos(m_IntexerSubsystem, m_ShooterSubsystem)); + NamedCommands.registerCommand("Shoot", new AimBot(m_ShooterSubsystem, m_SwerveSubsystem, m_IntexerSubsystem, FiringSolutionsV3.convertToRPM(m_ShooterSubsystem.getCalculatedVelocity()))); + NamedCommands.registerCommand("Idle Speed", new InstantCommand(() -> m_ShooterSubsystem.setShooterVelocity(Constants.Shooter.idleSpeedRPM))); + NamedCommands.registerCommand("Target Speed", new InstantCommand(() -> m_ShooterSubsystem.setShooterVelocity(FiringSolutionsV3.convertToRPM(m_ShooterSubsystem.getCalculatedVelocity())))); NamedCommands.registerCommand("Set Shooter Intake", new InstantCommand(() -> m_IntexerSubsystem.setShooterIntake(.9))); NamedCommands.registerCommand("Stop Shooter Intake", new InstantCommand(() -> m_IntexerSubsystem.setShooterIntake(0))); - NamedCommands.registerCommand("Shoot", new FIREEE(m_Shoota, m_IntexerSubsystem)); - // TODO auto lock on command - - m_SwerveSubsystem.setDefaultCommand( - new TeleopSwerve( - m_SwerveSubsystem, m_VisionSubsystem, m_Shoota, - () -> -driver.getRawAxis(leftVerticalAxis), - () -> -driver.getRawAxis(leftHorizontalAxis), - () -> -driver.getRawAxis(rightHorizontalAxis), - () -> robotCentric.getAsBoolean(), - () -> targetAmp.getAsBoolean(), - () -> targetSpeaker.getAsBoolean(), - () -> intex.getAsBoolean(), driver)); + NamedCommands.registerCommand("Note Sniffer", new NoteSniffer(m_SwerveSubsystem, m_VisionSubsystem, m_IntexerSubsystem, m_ShooterSubsystem)); + NamedCommands.registerCommand("Note Sniffer2", new NoteSniffer(m_SwerveSubsystem, m_VisionSubsystem, m_IntexerSubsystem, m_ShooterSubsystem)); + NamedCommands.registerCommand("Fire Under Stage", new InstantCommand(() -> m_ShooterSubsystem.setWristByAngle(Math.toRadians(10)))); + NamedCommands.registerCommand("Force Shoot", new FIREEFORACERTAINAMOUNTOFTIME(m_ShooterSubsystem, m_IntexerSubsystem, .2)); + // spotless:on - m_ElevatorSubsystem.setDefaultCommand( - new ElevationManual( - m_ElevatorSubsystem, - () -> -mech.getRawAxis(leftVerticalAxis))); + m_SwerveSubsystem.setDefaultCommand(new TeleopSwerve( + m_SwerveSubsystem, + m_VisionSubsystem, + m_ShooterSubsystem, + m_IntexerSubsystem, + () -> -driver.getRawAxis(leftVerticalAxis), + () -> -driver.getRawAxis(leftHorizontalAxis), + () -> -driver.getRawAxis(rightHorizontalAxis), + () -> false, + () -> targetAmp.getAsBoolean(), + () -> targetSpeaker.getAsBoolean(), + () -> intex.getAsBoolean(), + () -> intakeNoMove.getAsBoolean(), + driver)); - m_Shoota.setDefaultCommand(new ManRizzt(m_Shoota, () -> -mech.getRawAxis(rightVerticalAxis), () -> shooterTo45.getAsBoolean())); + m_ElevatorSubsystem.setDefaultCommand( + new ElevationManual(m_ElevatorSubsystem, () -> -mech.getRawAxis(leftVerticalAxis))); - // m_LEDSubsystem.setAllianceColor(); + m_ShooterSubsystem.setDefaultCommand(new ManRizzt( + m_ShooterSubsystem, + () -> -mech.getRawAxis(rightVerticalAxis), + () -> shooterToSubwoofer.getAsBoolean())); - // Another option that allows you to specify the default auto by its name - // autoChooser = AutoBuilder.buildAutoChooser("My Default Auto"); - autoChooser = AutoBuilder.buildAutoChooser(); + autoChooser = AutoBuilder.buildAutoChooser("4 piece mcnugget"); SmartDashboard.putData("Auto Chooser", autoChooser); @@ -130,77 +168,152 @@ public RobotContainer() { /** * Use this method to define your button->command mappings. Buttons can be - * created by - * instantiating a {@link GenericHID} or one of its subclasses ({@link + * created by instantiating a {@link GenericHID} or one of its subclasses ({@link * edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then passing - * it to a {@link - * edu.wpi.first.wpilibj2.command.button.JoystickButton}. + * it to a {@link edu.wpi.first.wpilibj2.command.button.JoystickButton}. */ private void configureButtonBindings() { /* DRIVER BUTTONS */ // Lock on to speaker - targetSpeaker.whileTrue(new MissileLock(m_Shoota, "speaker")); - targetAmp.whileTrue(new MissileLock(m_Shoota, "amp")); - + targetSpeaker + .whileTrue(new MissileLock(m_ShooterSubsystem, "speaker")) + .onFalse(new InstantCommand(() -> + m_ShooterSubsystem.setShooterVelocity(Constants.Shooter.idleSpeedRPM))); + targetAmp + .whileTrue(new MissileLock(m_ShooterSubsystem, "amp")) + .onFalse(new InstantCommand(() -> + m_ShooterSubsystem.setShooterVelocity(Constants.Shooter.idleSpeedRPM))); + // Shooter - targetSpeaker.or(targetAmp).and(Shoot).whileTrue(new FIREEE(m_Shoota, m_IntexerSubsystem)); // Main fire + targetSpeaker + .or(targetAmp) + .and(Shoot) + .whileTrue(new FIREEE(m_ShooterSubsystem, m_IntexerSubsystem)); // Main fire // Reset Odometry - resetOdom.onTrue(new InstantCommand(() -> m_SwerveSubsystem.zeroHeading()).alongWith( - new InstantCommand(() -> m_SwerveSubsystem.setPose(new Pose2d(1.35, 5.55, new Rotation2d(0)))))); + resetOdom.onTrue(new InstantCommand(() -> m_SwerveSubsystem.zeroHeading()) + .alongWith(new InstantCommand(() -> m_SwerveSubsystem.setPose( + Robot.getAlliance() + ? Constants.Vision.startingPoseRed + : Constants.Vision.startingPoseBlue)))); // Intexer - intex.whileTrue(new IntexBestHex(m_IntexerSubsystem, true, driver)); + intex.or(intakeNoMove) + .whileTrue(new IntexBestHex(m_IntexerSubsystem, true, driver)) + .onFalse(new ResetNoteInShooterPart2( + m_ShooterSubsystem, m_IntexerSubsystem, driver)); outex.whileTrue(new IntexBestHex(m_IntexerSubsystem, false, driver)); // Shooter intake - forceShoot.whileTrue(new InstantCommand(() -> m_IntexerSubsystem.setShooterIntake(.9))) - .onFalse(new InstantCommand(() -> m_IntexerSubsystem.setShooterIntake(0))); - + forceShoot + .whileTrue(new InstantCommand(() -> m_IntexerSubsystem.setShooterIntake(.9))) + .onFalse(new InstantCommand(() -> m_IntexerSubsystem.setShooterIntake(0))); + + // Move to Amp + // driverUp.whileTrue(m_SwerveSubsystem.pathToAmpChain()); + + // Move to Source + // driverDown.whileTrue(m_SwerveSubsystem.pathToSourceChain()); + + // Intake from Source + intakeFromSource + .whileTrue(new IntakeThroughShooter(m_ShooterSubsystem, m_IntexerSubsystem, driver)) + .onFalse(new IntakeThroughShooterPart2( + m_ShooterSubsystem, m_IntexerSubsystem, driver)); + /* MECH BUTTONS */ - - // Prime for Speaker + + // Prime Shooter primeShooterSpeedSpeaker - .whileTrue(new InstantCommand(() -> m_Shoota.setShooterVelocity(FiringSolutionsV3.convertToRPM(m_Shoota.getCalculatedVelocity())))) - .onFalse(new InstantCommand(() -> m_Shoota.setShooterVelocity(Constants.Shooter.idleSpeedRPM))); - - // Prime for Amp - primeShooterSpeedAmp.whileTrue(new InstantCommand(() -> m_Shoota.setShooterVelocity(3417.8))) - .onFalse(new InstantCommand(() -> m_Shoota.setShooterVelocity(Constants.Shooter.idleSpeedRPM))); - + .whileTrue(new InstantCommand( + () -> m_ShooterSubsystem.setShooterVelocity(FiringSolutionsV3.convertToRPM( + m_ShooterSubsystem.getCalculatedVelocity())))) + .onFalse(new InstantCommand(() -> + m_ShooterSubsystem.setShooterVelocity(Constants.Shooter.idleSpeedRPM))); + // Elevator - elevatorDown.onTrue(new ElevatorSet(m_ElevatorSubsystem, Constants.Elevator.minHeightMeters)); - elevatorUp.onTrue(new ElevatorSet(m_ElevatorSubsystem, Constants.Elevator.maxHeightMeters)); - + elevatorDown.onTrue(new ElevatorSet(m_ElevatorSubsystem, Constants.Elevator.minHeightMeters) + .alongWith( + new RizzLevel(m_ShooterSubsystem, Constants.Shooter.intakeAngleRadians))); + elevatorUp.onTrue(new ElevatorSet(m_ElevatorSubsystem, Constants.Elevator.maxHeightMeters) + .alongWith(new RizzLevel(m_ShooterSubsystem, 0.0))); + // Zero wrist - zeroShooter.onTrue(new InstantCommand(() -> m_Shoota.resetWristEncoders(Constants.Shooter.angleOffsetManual))); // Set encoder to zero - autoZeroShooter.onTrue(new ZeroWrist(m_Shoota).andThen(new RizzLevel(m_Shoota, Constants.Shooter.intakeAngleRadians))); + mechLT.negate() + .and(zeroShooter) + .onTrue(new InstantCommand(() -> m_ShooterSubsystem.resetWristEncoders( + Constants.Shooter.angleOffsetManual))); // Set encoder to zero + // autoZeroShooter.onTrue(new ZeroRizz(m_ShooterSubsystem) + // .andThen(new RizzLevel(m_ShooterSubsystem, + // Constants.Shooter.intakeAngleRadians))); + + // Intake Preset + shooterToIntake + .onTrue(new RizzLevel(m_ShooterSubsystem, Constants.Shooter.intakeAngleRadians)) + .onTrue(new ElevatorSet(m_ElevatorSubsystem, Constants.Elevator.minHeightMeters)); - // Wrist - shooterToIntake.onTrue(new RizzLevel(m_Shoota, Constants.Shooter.intakeAngleRadians)); // Move wrist to intake position - // Amp Preset - shooterToAmp.onTrue(new RizzLevel(m_Shoota, -0.48)).onTrue(new ElevatorSet(m_ElevatorSubsystem, Constants.Elevator.maxHeightMeters)); - - //xButton.whileTrue(new InstantCommand(() -> m_Shoota.SetOffsetVelocity(2000))) - //.onFalse(new InstantCommand(() -> m_Shoota.SetShooterVelocity(Constants.Shooter.idleSpeedRPM))); - - // Reset R - resetR.onTrue(new InstantCommand(() -> FiringSolutionsV3.resetAllR())); // Reset the R calculation incase it gets off - - // Kill Shooter - rightStick.onTrue(new InstantCommand(()-> m_Shoota.setShooterVelocity(0))); - - //Intake Through Shooter - intakeThroughShooter.whileTrue(new IntakeThroughShooter(m_Shoota, m_IntexerSubsystem, mech)) - .onFalse(new IntakeThroughShooterPart2(m_Shoota, m_IntexerSubsystem, mech)); - - // Characterization tests - /*dynamicForward.whileTrue(m_SwerveSubsystem.sysIdDynamic(Direction.kForward)); + shooterToAmp + .onTrue(new RizzLevel(m_ShooterSubsystem, -0.48)) + .onTrue(new ElevatorSet(m_ElevatorSubsystem, Constants.Elevator.ampHeight)); + + // Subwoofer Preset + shooterToSubwoofer + .onTrue(new RizzLevel(m_ShooterSubsystem, Math.toRadians(57))) + .onTrue(new ElevatorSet(m_ElevatorSubsystem, Constants.Elevator.minHeightMeters)); + + // Anti-Defense Preset + shooterToAntiDefense.onTrue(new ElevatorSet( + m_ElevatorSubsystem, + Constants.Elevator.antiBozoSmileToasterAhhGoonBotShooterHeight)); + + // Reset the R calculation in case it gets off + resetR.onTrue(new InstantCommand(() -> FiringSolutionsV3.resetAllR())); + + // Reset Note in Shooter + resetNoteInShooter + .whileTrue(new ResetNoteInShooter(m_ShooterSubsystem, m_IntexerSubsystem, mech)) + .onFalse(new ResetNoteInShooterPart2(m_ShooterSubsystem, m_IntexerSubsystem, mech)); + + // Kill Flywheels + mechLT.negate() + .and(mechRightStick) + .onTrue(new InstantCommand(() -> m_ShooterSubsystem.setShooterVelocity(0))); + + // Kill Wrist + mechLT.and(mechRightStick) + .onTrue(new InstantCommand(() -> m_ShooterSubsystem.setWristSpeedManual(0)) + .alongWith(new InstantCommand(() -> m_ShooterSubsystem.setWristToCoast()))) + .onFalse(new InstantCommand(() -> m_ShooterSubsystem.setWristToBrake())); + + // Kill Elevator + mechLT.and(mechLeftStick) + .onTrue(new InstantCommand(() -> m_ElevatorSubsystem.setElevatorSpeedManual(0))); + + mechLT.and(zeroShooter) + .onTrue(new InstantCommand(() -> m_ShooterSubsystem.resetWristEncoders( + Constants.Shooter.angleOffsetBottom))); + + /* THIRD CONTROLLER */ + // Characterization tests + /* + dynamicForward.whileTrue(m_SwerveSubsystem.sysIdDynamic(Direction.kForward)); dynamicBackward.whileTrue(m_SwerveSubsystem.sysIdDynamic(Direction.kReverse)); quasistaticForward.whileTrue(m_SwerveSubsystem.sysIdQuasistatic(Direction.kForward)); - quasistaticBackwards.whileTrue(m_SwerveSubsystem.sysIdQuasistatic(Direction.kReverse));*/ + quasistaticBackwards.whileTrue(m_SwerveSubsystem.sysIdQuasistatic(Direction.kReverse)); + */ + } + + public void stopAll() { + m_ShooterSubsystem.setShooterVelocity(0); + m_ShooterSubsystem.setWristSpeedManual(0); + m_IntexerSubsystem.setALL(0); + m_ElevatorSubsystem.setPositionWithEncoder(m_ElevatorSubsystem.getPosition()); + } + + public void zeroWristEncoders() { + m_ShooterSubsystem.resetWristEncoders(Constants.Shooter.angleOffsetBottom); } /** @@ -211,5 +324,4 @@ private void configureButtonBindings() { public Command getAutonomousCommand() { return autoChooser.getSelected(); } - } diff --git a/src/main/java/frc/robot/SwerveModule.java b/src/main/java/frc/robot/SwerveModule.java index ca272d7..173f44c 100644 --- a/src/main/java/frc/robot/SwerveModule.java +++ b/src/main/java/frc/robot/SwerveModule.java @@ -11,6 +11,7 @@ import edu.wpi.first.math.geometry.Rotation2d; import edu.wpi.first.math.kinematics.SwerveModulePosition; import edu.wpi.first.math.kinematics.SwerveModuleState; + import frc.lib.math.Conversions; import frc.lib.util.SwerveModuleConstants; @@ -22,7 +23,8 @@ public class SwerveModule { private TalonFX mDriveMotor; private CANcoder angleEncoder; - private final SimpleMotorFeedforward driveFeedForward = new SimpleMotorFeedforward(Constants.Swerve.driveKS, Constants.Swerve.driveKV, Constants.Swerve.driveKA); + private final SimpleMotorFeedforward driveFeedForward = new SimpleMotorFeedforward( + Constants.Swerve.driveKS, Constants.Swerve.driveKV, Constants.Swerve.driveKA); /* drive motor control requests */ private final DutyCycleOut driveDutyCycle = new DutyCycleOut(0); @@ -32,10 +34,10 @@ public class SwerveModule { /* angle motor control requests */ private final PositionVoltage anglePosition = new PositionVoltage(0); - public SwerveModule(int moduleNumber, SwerveModuleConstants moduleConstants){ + public SwerveModule(int moduleNumber, SwerveModuleConstants moduleConstants) { this.moduleNumber = moduleNumber; this.angleOffset = moduleConstants.angleOffset; - + /* Angle Encoder Config */ angleEncoder = new CANcoder(moduleConstants.cancoderID, Constants.Swerve.canivore); angleEncoder.getConfigurator().apply(Robot.ctreConfigs.swerveCANcoderConfig); @@ -51,56 +53,66 @@ public SwerveModule(int moduleNumber, SwerveModuleConstants moduleConstants){ mDriveMotor.getConfigurator().setPosition(0.0); } - public void setDesiredState(SwerveModuleState desiredState, boolean isOpenLoop){ - desiredState = SwerveModuleState.optimize(desiredState, getState().angle); + public void setDesiredState(SwerveModuleState desiredState, boolean isOpenLoop) { + desiredState = SwerveModuleState.optimize(desiredState, getState().angle); mAngleMotor.setControl(anglePosition.withPosition(desiredState.angle.getRotations())); setSpeed(desiredState, isOpenLoop); } - private void setSpeed(SwerveModuleState desiredState, boolean isOpenLoop){ - if(isOpenLoop){ + private void setSpeed(SwerveModuleState desiredState, boolean isOpenLoop) { + if (isOpenLoop) { driveDutyCycle.Output = desiredState.speedMetersPerSecond / Constants.Swerve.maxSpeed; mDriveMotor.setControl(driveDutyCycle); - } - else { - driveVelocity.Velocity = Conversions.MPSToRPS(desiredState.speedMetersPerSecond, Constants.Swerve.wheelCircumference); - driveVelocity.FeedForward = driveFeedForward.calculate(desiredState.speedMetersPerSecond); + } else { + driveVelocity.Velocity = Conversions.MPSToRPS( + desiredState.speedMetersPerSecond, Constants.Swerve.wheelCircumference); + driveVelocity.FeedForward = + driveFeedForward.calculate(desiredState.speedMetersPerSecond); mDriveMotor.setControl(driveVelocity); } } - public Rotation2d getCANcoder(){ + public Rotation2d getCANcoder() { return Rotation2d.fromRotations(angleEncoder.getAbsolutePosition().getValue()); } - public void resetToAbsolute(){ + /** Set module angles to absolute position */ + public void resetToAbsolute() { double absolutePosition = getCANcoder().getRotations() - angleOffset.getRotations(); mAngleMotor.setPosition(absolutePosition); } - public SwerveModuleState getState(){ + public SwerveModuleState getState() { return new SwerveModuleState( - Conversions.RPSToMPS(mDriveMotor.getVelocity().getValue(), Constants.Swerve.wheelCircumference), - Rotation2d.fromRotations(mAngleMotor.getPosition().getValue()) - ); + Conversions.RPSToMPS( + mDriveMotor.getVelocity().getValue(), Constants.Swerve.wheelCircumference), + Rotation2d.fromRotations(mAngleMotor.getPosition().getValue())); } - public SwerveModulePosition getPosition(){ + public SwerveModulePosition getPosition() { return new SwerveModulePosition( - Conversions.rotationsToMeters(mDriveMotor.getPosition().getValue(), Constants.Swerve.wheelCircumference), - Rotation2d.fromRotations(mAngleMotor.getPosition().getValue()) - ); + Conversions.rotationsToMeters( + mDriveMotor.getPosition().getValue(), Constants.Swerve.wheelCircumference), + Rotation2d.fromRotations(mAngleMotor.getPosition().getValue())); } - public void voltageDrive(double Volts){ + /** + * Drive robot based on provided voltage value + *

+ * Does NOT have optimization, meaning wheels have to be facing same direction + */ + public void voltageDrive(double Volts) { mDriveMotor.setControl(driveCharacteriztionControl.withOutput(Volts)); } - public double getMotorVoltage(){ + /** Get drive motor voltage */ + public double getMotorVoltage() { return mDriveMotor.getMotorVoltage().getValue(); } - public double getMotorVelocity(){ - return mDriveMotor.getVelocity().getValue(); + /** IN METERS PER SECOND */ + public double getMotorVelocity() { + return Conversions.RPSToMPS( + mDriveMotor.getVelocity().getValue(), Constants.Swerve.wheelCircumference); } -} \ No newline at end of file +} diff --git a/src/main/java/frc/robot/commands/AimBot.java b/src/main/java/frc/robot/commands/AimBot.java new file mode 100644 index 0000000..8a2917a --- /dev/null +++ b/src/main/java/frc/robot/commands/AimBot.java @@ -0,0 +1,105 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.commands; + +import edu.wpi.first.math.controller.PIDController; +import edu.wpi.first.math.geometry.Pose2d; +import edu.wpi.first.math.geometry.Translation2d; +import edu.wpi.first.math.kinematics.ChassisSpeeds; +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj2.command.Command; + +import frc.lib.math.FiringSolutionsV3; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.subsystems.IntexerSubsystem; +import frc.robot.subsystems.ShooterSubsystem; +import frc.robot.subsystems.SwerveSubsystem; + +public class AimBot extends Command { + + private ShooterSubsystem shooter; + private SwerveSubsystem swerveSubsystem; + private IntexerSubsystem intexer; + private PIDController rotationPID = new PIDController(0.65, 0.00001, 0.04); + private double speed; + private Timer timer = new Timer(); + + /** Creates a new AimBot. */ + public AimBot( + ShooterSubsystem shooterSubsystem, + SwerveSubsystem swerve, + IntexerSubsystem intexer, + double speed) { + this.shooter = shooterSubsystem; + this.speed = speed; + this.intexer = intexer; + this.swerveSubsystem = swerve; + addRequirements(shooterSubsystem, swerve); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + shooter.setShooterVelocity(speed); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + Pose2d pose = swerveSubsystem.getPose(); + ChassisSpeeds currentSpeed = swerveSubsystem.getChassisSpeeds(); + + double offset; + if (Robot.getAlliance()) { + if (pose.getRotation().getRadians() > 0) { + offset = -Math.toRadians(180); + } else { + offset = Math.toRadians(180); + } + } else { + offset = 0; + } + + double rotationVal = rotationPID.calculate( + pose.getRotation().getRadians() + offset, + FiringSolutionsV3.getAngleToMovingTarget( + pose.getX(), + pose.getY(), + FiringSolutionsV3.speakerTargetX, + FiringSolutionsV3.speakerTargetY, + currentSpeed.vxMetersPerSecond, + currentSpeed.vyMetersPerSecond, + pose.getRotation().getRadians())); + + swerveSubsystem.drive( + new Translation2d(0, 0).times(Constants.Swerve.maxSpeed), + rotationVal * Constants.Swerve.maxAngularVelocity, + true, + false); + + if (shooter.isShooterAtSpeed() && rotationPID.getPositionError() <= .035) { + timer.reset(); + timer.start(); + intexer.setShooterIntake(.9); + } + + shooter.setWristByAngle(shooter.getCalculatedAngleToSpeaker()); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + swerveSubsystem.setChassisSpeeds(new ChassisSpeeds(0, 0, 0)); + intexer.setShooterIntake(0); + shooter.setWristSpeedManual(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return !intexer.shooterBreak() && timer.get() > .2; + } +} diff --git a/src/main/java/frc/robot/commands/ElevationManual.java b/src/main/java/frc/robot/commands/ElevationManual.java index 4ae7d4c..57bda1e 100644 --- a/src/main/java/frc/robot/commands/ElevationManual.java +++ b/src/main/java/frc/robot/commands/ElevationManual.java @@ -4,18 +4,22 @@ package frc.robot.commands; -import java.util.function.DoubleSupplier; - +import edu.wpi.first.math.MathUtil; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.Command; + +import frc.robot.Constants; import frc.robot.subsystems.ElevatorSubsystem; +import java.util.function.DoubleSupplier; + public class ElevationManual extends Command { private ElevatorSubsystem m_elevatorSubsystem; double m_speed; DoubleSupplier axis; Boolean locked = false; double lockedValue = 0.0; + double lastElevatorSetpoint = 0.0; public ElevationManual(ElevatorSubsystem elevate, DoubleSupplier control) { m_elevatorSubsystem = elevate; @@ -25,23 +29,25 @@ public ElevationManual(ElevatorSubsystem elevate, DoubleSupplier control) { // Called when the command is initially scheduled. @Override - public void initialize() { - } + public void initialize() {} // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - double value = axis.getAsDouble(); + lastElevatorSetpoint = m_elevatorSubsystem.getSetpoint(); + double value = axis.getAsDouble(); + value = MathUtil.applyDeadband(value, Constants.stickDeadband); value = Math.pow(value, 3); - if (Math.abs(value) > .05) { // Crime zone - m_elevatorSubsystem.setManualOverride(true); - m_elevatorSubsystem.ManSpin(value); - } else { - m_elevatorSubsystem.setManualOverride(false); - lockedValue = m_elevatorSubsystem.getEncoderValue(); - } + // if (Math.abs(value) > .1) { // Crime zone + m_elevatorSubsystem.ManSpin(value); + /* } else { + if (!m_elevatorSubsystem.locked){ + lastElevatorSetpoint = m_elevatorSubsystem.getPosition(); + m_elevatorSubsystem.setPositionWithEncoder(lastElevatorSetpoint); + } + }*/ SmartDashboard.putBoolean("locked", locked); SmartDashboard.putNumber("locked value", lockedValue); @@ -49,8 +55,7 @@ public void execute() { // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) { - } + public void end(boolean interrupted) {} // Returns true when the command should end. @Override diff --git a/src/main/java/frc/robot/commands/ElevatorSet.java b/src/main/java/frc/robot/commands/ElevatorSet.java index bae921b..5a8f0a0 100644 --- a/src/main/java/frc/robot/commands/ElevatorSet.java +++ b/src/main/java/frc/robot/commands/ElevatorSet.java @@ -5,6 +5,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; + import frc.robot.subsystems.ElevatorSubsystem; public class ElevatorSet extends Command { @@ -21,7 +22,7 @@ public ElevatorSet(ElevatorSubsystem elevator, double position) { // Called when the command is initially scheduled. @Override public void initialize() { - //m_elevator.setManualOverride(true); + // m_elevator.setManualOverride(true); } // Called every time the scheduler runs while the command is scheduled. @@ -32,9 +33,7 @@ public void execute() { // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) { - m_elevator.stopHere(); - } + public void end(boolean interrupted) {} // Returns true when the command should end. @Override diff --git a/src/main/java/frc/robot/commands/FIREEE.java b/src/main/java/frc/robot/commands/FIREEE.java index 24fe217..641d227 100644 --- a/src/main/java/frc/robot/commands/FIREEE.java +++ b/src/main/java/frc/robot/commands/FIREEE.java @@ -5,6 +5,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; + import frc.robot.subsystems.IntexerSubsystem; import frc.robot.subsystems.ShooterSubsystem; @@ -21,13 +22,12 @@ public FIREEE(ShooterSubsystem shooterSub, IntexerSubsystem intex) { // Called when the command is initially scheduled. @Override - public void initialize() { - } + public void initialize() {} // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if (shooter.shooterAtSpeed()){ + if (shooter.isShooterAtSpeed()) { intexer.setShooterIntake(.9); } } diff --git a/src/main/java/frc/robot/commands/FIREEFORACERTAINAMOUNTOFTIME.java b/src/main/java/frc/robot/commands/FIREEFORACERTAINAMOUNTOFTIME.java new file mode 100644 index 0000000..8f50a4b --- /dev/null +++ b/src/main/java/frc/robot/commands/FIREEFORACERTAINAMOUNTOFTIME.java @@ -0,0 +1,52 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj2.command.Command; + +import frc.robot.subsystems.IntexerSubsystem; +import frc.robot.subsystems.ShooterSubsystem; + +public class FIREEFORACERTAINAMOUNTOFTIME extends Command { + private ShooterSubsystem shooter; + private IntexerSubsystem intexer; + private double time; + private Timer timer = new Timer(); + + public FIREEFORACERTAINAMOUNTOFTIME( + ShooterSubsystem shooterSub, IntexerSubsystem intex, double time) { + shooter = shooterSub; + intexer = intex; + this.time = time; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(intex); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + timer.reset(); + timer.start(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + intexer.setShooterIntake(.9); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + intexer.setShooterIntake(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return timer.get() > time; + } +} diff --git a/src/main/java/frc/robot/commands/IntakeThroughShooter.java b/src/main/java/frc/robot/commands/IntakeThroughShooter.java index 5dab49c..bcefdb8 100644 --- a/src/main/java/frc/robot/commands/IntakeThroughShooter.java +++ b/src/main/java/frc/robot/commands/IntakeThroughShooter.java @@ -7,6 +7,7 @@ import edu.wpi.first.wpilibj.GenericHID.RumbleType; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj2.command.Command; + import frc.robot.Constants; import frc.robot.subsystems.IntexerSubsystem; import frc.robot.subsystems.ShooterSubsystem; @@ -18,7 +19,8 @@ public class IntakeThroughShooter extends Command { Joystick controller; /** Creates a new IntakeFromShooter. */ - public IntakeThroughShooter(ShooterSubsystem shooterSub, IntexerSubsystem intex, Joystick controller) { + public IntakeThroughShooter( + ShooterSubsystem shooterSub, IntexerSubsystem intex, Joystick controller) { shooter = shooterSub; intexer = intex; this.controller = controller; @@ -29,30 +31,29 @@ public IntakeThroughShooter(ShooterSubsystem shooterSub, IntexerSubsystem intex, // Called when the command is initially scheduled. @Override public void initialize() { + shooter.setWristByAngle(.66); } // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { shooter.setShooterVelocity(-1000); - intexer.setALL(-.5); - shooter.setWristPosition(.66); + intexer.setALL(Constants.Intake.outakeSpeed); } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { shooter.setShooterVelocity(Constants.Shooter.idleSpeedRPM); - shooter.setWristPosition(Constants.Shooter.intakeAngleRadians); + shooter.setWristByAngle(Constants.Shooter.intakeAngleRadians); intexer.setALL(0); } - + // Returns true when the command should end. @Override public boolean isFinished() { if (intexer.intakeBreak()) { controller.setRumble(RumbleType.kBothRumble, 0.75); - intexer.setIntakeThroughShooterPart2Status(true); return true; } else { return false; diff --git a/src/main/java/frc/robot/commands/IntakeThroughShooterPart2.java b/src/main/java/frc/robot/commands/IntakeThroughShooterPart2.java index 0d7f116..42d258a 100644 --- a/src/main/java/frc/robot/commands/IntakeThroughShooterPart2.java +++ b/src/main/java/frc/robot/commands/IntakeThroughShooterPart2.java @@ -6,7 +6,9 @@ import edu.wpi.first.wpilibj.GenericHID.RumbleType; import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj2.command.Command; + import frc.robot.Constants; import frc.robot.subsystems.IntexerSubsystem; import frc.robot.subsystems.ShooterSubsystem; @@ -17,9 +19,11 @@ public class IntakeThroughShooterPart2 extends Command { private boolean finishPlease = false; Joystick controller; + public final Timer timer = new Timer(); /** Creates a new IntakeFromShooterPart2. */ - public IntakeThroughShooterPart2(ShooterSubsystem shooterSub, IntexerSubsystem intex, Joystick controller) { + public IntakeThroughShooterPart2( + ShooterSubsystem shooterSub, IntexerSubsystem intex, Joystick controller) { shooter = shooterSub; intexer = intex; this.controller = controller; @@ -30,15 +34,17 @@ public IntakeThroughShooterPart2(ShooterSubsystem shooterSub, IntexerSubsystem i // Called when the command is initially scheduled. @Override public void initialize() { + timer.reset(); + timer.start(); controller.setRumble(RumbleType.kBothRumble, 0); + shooter.setWristByAngle(Constants.Shooter.intakeAngleRadians); } // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { shooter.setShooterVelocity(0); - intexer.setALL(.35); - shooter.setWristPosition(Constants.Shooter.intakeAngleRadians); + intexer.setALL(Constants.Intake.noteInsideSpeed); } // Called once the command ends or is interrupted. @@ -52,7 +58,7 @@ public void end(boolean interrupted) { // Returns true when the command should end. @Override public boolean isFinished() { - if (!intexer.intakeThroughShooterPart2isReady || intexer.shooterBreak()) { + if (intexer.shooterBreak() || timer.get() > 1.5) { return true; } else { return false; diff --git a/src/main/java/frc/robot/commands/IntexBestHex.java b/src/main/java/frc/robot/commands/IntexBestHex.java index 945a74c..8a6e674 100644 --- a/src/main/java/frc/robot/commands/IntexBestHex.java +++ b/src/main/java/frc/robot/commands/IntexBestHex.java @@ -4,10 +4,12 @@ package frc.robot.commands; -import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.GenericHID.RumbleType; +import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj2.command.Command; + import frc.lib.math.FiringSolutionsV3; +import frc.robot.Constants; import frc.robot.subsystems.IntexerSubsystem; public class IntexBestHex extends Command { @@ -35,17 +37,17 @@ public void initialize() { public void execute() { if (in) { // Hood logic to run forwards or backwards if (intexer.intakeBreak() && !intexer.shooterBreak()) { // If note is not at shooter yet - intexer.setALL(.4); - } else if (!intexer.intakeBreak() && intexer.shooterBreak()) { // Stop note if at shooter + intexer.setALL(Constants.Intake.noteInsideSpeed); + } else if (!intexer.intakeBreak() + && intexer.shooterBreak()) { // Stop note if at shooter controller.setRumble(RumbleType.kBothRumble, 0.75); intexer.setALL(0); } else { // Note is not in robot - intexer.setFrontIntake(.75); + intexer.setFrontIntake(Constants.Intake.noteOutsideSpeed); } } else { // Outtake - intexer.setALL(-0.5); + intexer.setALL(Constants.Intake.outakeSpeed); } - } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/IntexForAutosByAutos.java b/src/main/java/frc/robot/commands/IntexForAutosByAutos.java index 43bf8c1..67889da 100644 --- a/src/main/java/frc/robot/commands/IntexForAutosByAutos.java +++ b/src/main/java/frc/robot/commands/IntexForAutosByAutos.java @@ -5,44 +5,52 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; + +import frc.robot.Constants; import frc.robot.subsystems.IntexerSubsystem; +import frc.robot.subsystems.ShooterSubsystem; public class IntexForAutosByAutos extends Command { private IntexerSubsystem intexer; + private ShooterSubsystem shooter; /** Creates a new IntexForAutosByAutos. */ - public IntexForAutosByAutos(IntexerSubsystem intexerSub) { + public IntexForAutosByAutos(IntexerSubsystem intexerSub, ShooterSubsystem shooterSubsystem) { this.intexer = intexerSub; - addRequirements(intexerSub); + this.shooter = shooterSubsystem; + addRequirements(intexerSub, shooterSubsystem); } // Called when the command is initially scheduled. @Override - public void initialize() { - } + public void initialize() {} // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { + shooter.setWristByAngle(Constants.Shooter.intakeAngleRadians); + if (intexer.intakeBreak() && !intexer.shooterBreak()) { // If note is not at shooter yet - intexer.setALL(.4); - } else if (!intexer.intakeBreak() && intexer.shooterBreak()) { // Stop note if at shooter + intexer.setALL(Constants.Intake.noteInsideSpeed); + } else if (intexer.shooterBreak()) { // Stop note if at shooter intexer.setALL(0); } else { // Note is not in robot - intexer.setFrontIntake(.75); + intexer.setFrontIntake(Constants.Intake.noteOutsideSpeed); + intexer.setShooterIntake(Constants.Intake.noteInsideSpeed); } } // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { + intexer.setALL(0); } // Returns true when the command should end. @Override public boolean isFinished() { - if (!intexer.intakeBreak() && intexer.shooterBreak()) { + if (intexer.shooterBreak()) { return true; } else { return false; diff --git a/src/main/java/frc/robot/commands/ManRizzt.java b/src/main/java/frc/robot/commands/ManRizzt.java index 2e6d3ea..1e44b33 100644 --- a/src/main/java/frc/robot/commands/ManRizzt.java +++ b/src/main/java/frc/robot/commands/ManRizzt.java @@ -4,42 +4,59 @@ package frc.robot.commands; -import java.util.function.BooleanSupplier; -import java.util.function.DoubleSupplier; - +import edu.wpi.first.math.MathUtil; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.Command; + +import frc.robot.Constants; import frc.robot.subsystems.ShooterSubsystem; +import java.util.function.BooleanSupplier; +import java.util.function.DoubleSupplier; + public class ManRizzt extends Command { - ShooterSubsystem shooterSubsystem; + ShooterSubsystem m_shooterSubsystem; private DoubleSupplier speed; BooleanSupplier setAngle; + double lastWristSetpoint = 0.0; + boolean wristIsLocked = false; public ManRizzt(ShooterSubsystem subsystem, DoubleSupplier speed, BooleanSupplier setAngle) { // Use addRequirements() here to declare subsystem dependencies. - shooterSubsystem = subsystem; + m_shooterSubsystem = subsystem; this.setAngle = setAngle; this.speed = speed; SmartDashboard.putNumber("Set Wrist Angle", 0); - addRequirements(shooterSubsystem); + addRequirements(m_shooterSubsystem); } // Called when the command is initially scheduled. @Override - public void initialize() { - } + public void initialize() {} @Override public void execute() { - double speedValue = speed.getAsDouble() * 0.5; - - speedValue = Math.pow(speed.getAsDouble(), 3); - if (setAngle.getAsBoolean()){ - shooterSubsystem.setWristPosition(SmartDashboard.getNumber("Set Wrist Angle", 0)); + double speedValue = MathUtil.applyDeadband(speed.getAsDouble(), Constants.stickDeadband); + speedValue = Math.pow(speedValue, 3); + + if (setAngle.getAsBoolean()) { + // m_shooterSubsystem.setWristByAngle(SmartDashboard.getNumber("Set Wrist Angle", 0)); } else { - shooterSubsystem.manualWristSpeed(speedValue); + if (Math.abs(speedValue) > .0) { + wristIsLocked = false; + m_shooterSubsystem.setWristSpeedManual(speedValue); + } else { + if (m_shooterSubsystem.isZeroed) { + if (!wristIsLocked) { + m_shooterSubsystem.setWristByAngle( + m_shooterSubsystem.getCurrentShooterAngle()); + wristIsLocked = true; + } + } else { + m_shooterSubsystem.setWristSpeedManual(0); + } + } } } @@ -50,6 +67,6 @@ public boolean isFinished() { @Override public void end(boolean interrupted) { - shooterSubsystem.manualWristSpeed(0); + // m_shooterSubsystem.setWristSpeedManual(0); } } diff --git a/src/main/java/frc/robot/commands/MissileLock.java b/src/main/java/frc/robot/commands/MissileLock.java index 9839f15..6063198 100644 --- a/src/main/java/frc/robot/commands/MissileLock.java +++ b/src/main/java/frc/robot/commands/MissileLock.java @@ -5,6 +5,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; + import frc.lib.math.FiringSolutionsV3; import frc.robot.Constants; import frc.robot.subsystems.ShooterSubsystem; @@ -24,17 +25,23 @@ public MissileLock(ShooterSubsystem shooterSub, String target) { // Called when the command is initially scheduled. @Override - public void initialize() { - } + public void initialize() {} // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { if (target == "amp") { - shooter.PointShoot(shooter.getCalculatedAngleToAmp(), - FiringSolutionsV3.convertToRPM(shooter.getCalculatedVelocity())); + if (shooter.outsideAllianceWing) { + shooter.PointShoot( + Math.toRadians(55), + FiringSolutionsV3.convertToRPM(shooter.getCalculatedVelocity())); + } else { + shooter.setShooterVelocity( + FiringSolutionsV3.convertToRPM(shooter.getCalculatedVelocity())); + } } else { - shooter.PointShoot(shooter.getCalculatedAngleToSpeaker(), + shooter.PointShoot( + shooter.getCalculatedAngleToSpeaker(), FiringSolutionsV3.convertToRPM(shooter.getCalculatedVelocity())); } } @@ -42,8 +49,10 @@ public void execute() { // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { - shooter.setShooterVelocity(Constants.Shooter.idleSpeedRPM); - shooter.setWristPosition(Constants.Shooter.intakeAngleRadians); + // shooter.setShooterVelocity(Constants.Shooter.idleSpeedRPM); + if (target != "amp" || shooter.outsideAllianceWing) { + shooter.setWristByAngle(Constants.Shooter.intakeAngleRadians); + } } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/commands/NoteSniffer.java b/src/main/java/frc/robot/commands/NoteSniffer.java new file mode 100644 index 0000000..ba2b011 --- /dev/null +++ b/src/main/java/frc/robot/commands/NoteSniffer.java @@ -0,0 +1,116 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.commands; + +import edu.wpi.first.math.controller.PIDController; +import edu.wpi.first.math.geometry.Translation2d; +import edu.wpi.first.math.kinematics.ChassisSpeeds; +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj2.command.Command; + +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.subsystems.IntexerSubsystem; +import frc.robot.subsystems.ShooterSubsystem; +import frc.robot.subsystems.SwerveSubsystem; +import frc.robot.subsystems.VisionSubsystem; + +import org.photonvision.targeting.PhotonPipelineResult; + +public class NoteSniffer extends Command { + + private SwerveSubsystem swerveSubsystem; + private VisionSubsystem vision; + private IntexerSubsystem intexer; + private ShooterSubsystem shooter; + private PIDController rotationPID = new PIDController(0.65, 0.00001, 0.04); + private Timer timer = new Timer(); + private boolean noteInside = false; + private double translationVal = .35; + + /** Creates a new IntakeWithVision. */ + public NoteSniffer( + SwerveSubsystem swerve, + VisionSubsystem vision, + IntexerSubsystem intexer, + ShooterSubsystem shooter) { + this.swerveSubsystem = swerve; + this.vision = vision; + this.intexer = intexer; + this.shooter = shooter; + addRequirements(swerve, intexer); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + timer.reset(); + timer.start(); + translationVal = .35; + noteInside = false; + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + shooter.setWristByAngle(Constants.Shooter.intakeAngleRadians); + + PhotonPipelineResult result = vision.getLatestResultN(); + double rotationVal; + boolean overMidfield = Robot.getAlliance() + ? (16.54 - swerveSubsystem.getPose().getX()) > 8.3 + : swerveSubsystem.getPose().getX() > 8.3; + + if (intexer.intakeBreak() || overMidfield) { + noteInside = true; + translationVal = 0; + rotationVal = 0; + } + + if (result.hasTargets() && !noteInside) { // Lock robot towards detected note + double yawToNote = Math.toRadians(result.getBestTarget().getYaw()) + + swerveSubsystem.getGyroYaw().getRadians(); + + SmartDashboard.putNumber("Note Yaw", yawToNote); + + rotationVal = rotationPID.calculate( + yawToNote, swerveSubsystem.getGyroYaw().getRadians()); + + intexer.setFrontIntake(Constants.Intake.noteOutsideSpeed); + intexer.setShooterIntake(Constants.Intake.noteInsideSpeed); + } else { + rotationVal = 0; + } + + // if (shooter.getDistanceToSpeaker() < 2.5){ + swerveSubsystem.drive( + new Translation2d(translationVal, 0).times(Constants.Swerve.maxSpeed), + rotationVal * Constants.Swerve.maxAngularVelocity, + false, + false); + /* } else { + intexer.setALL(-.5); + swerveSubsystem.drive( + new Translation2d(-0.2, 0).times(Constants.Swerve.maxSpeed), + 0 * Constants.Swerve.maxAngularVelocity, + false, + false); + }*/ + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + intexer.setALL(0); + swerveSubsystem.setChassisSpeeds(new ChassisSpeeds(0, 0, 0)); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return intexer.shooterBreak() || timer.get() > 2; + } +} diff --git a/src/main/java/frc/robot/commands/ResetNoteInShooter.java b/src/main/java/frc/robot/commands/ResetNoteInShooter.java new file mode 100644 index 0000000..4fb5633 --- /dev/null +++ b/src/main/java/frc/robot/commands/ResetNoteInShooter.java @@ -0,0 +1,60 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.GenericHID.RumbleType; +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj2.command.Command; + +import frc.robot.Constants; +import frc.robot.subsystems.IntexerSubsystem; +import frc.robot.subsystems.ShooterSubsystem; + +public class ResetNoteInShooter extends Command { + private ShooterSubsystem shooter; + private IntexerSubsystem intexer; + + Joystick controller; + + /** Creates a new IntakeFromShooter. */ + public ResetNoteInShooter( + ShooterSubsystem shooterSub, IntexerSubsystem intex, Joystick controller) { + shooter = shooterSub; + intexer = intex; + this.controller = controller; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(shooterSub, intex); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + shooter.setWristByAngle(.66); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + intexer.setALL(Constants.Intake.outakeSpeed); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + shooter.setWristByAngle(Constants.Shooter.intakeAngleRadians); + intexer.setALL(0); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + if (intexer.intakeBreak()) { + controller.setRumble(RumbleType.kBothRumble, 0.75); + return true; + } else { + return false; + } + } +} diff --git a/src/main/java/frc/robot/commands/ResetNoteInShooterPart2.java b/src/main/java/frc/robot/commands/ResetNoteInShooterPart2.java new file mode 100644 index 0000000..67a6cd5 --- /dev/null +++ b/src/main/java/frc/robot/commands/ResetNoteInShooterPart2.java @@ -0,0 +1,64 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.GenericHID.RumbleType; +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj2.command.Command; + +import frc.robot.Constants; +import frc.robot.subsystems.IntexerSubsystem; +import frc.robot.subsystems.ShooterSubsystem; + +public class ResetNoteInShooterPart2 extends Command { + private ShooterSubsystem shooter; + private IntexerSubsystem intexer; + + Joystick controller; + public final Timer timer = new Timer(); + + /** Creates a new IntakeFromShooterPart2. */ + public ResetNoteInShooterPart2( + ShooterSubsystem shooterSub, IntexerSubsystem intex, Joystick controller) { + shooter = shooterSub; + intexer = intex; + this.controller = controller; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(shooterSub, intex); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + timer.reset(); + timer.start(); + controller.setRumble(RumbleType.kBothRumble, 0); + shooter.setWristByAngle(Constants.Shooter.intakeAngleRadians); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + intexer.setALL(Constants.Intake.noteInsideSpeed); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + intexer.setALL(0); + intexer.setIntakeThroughShooterPart2Status(false); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + if (intexer.shooterBreak() || timer.get() > 1.5) { + return true; + } else { + return false; + } + } +} diff --git a/src/main/java/frc/robot/commands/RizzLevel.java b/src/main/java/frc/robot/commands/RizzLevel.java index 02eead3..392b7d0 100644 --- a/src/main/java/frc/robot/commands/RizzLevel.java +++ b/src/main/java/frc/robot/commands/RizzLevel.java @@ -5,6 +5,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; + import frc.robot.subsystems.ShooterSubsystem; public class RizzLevel extends Command { @@ -23,30 +24,22 @@ public RizzLevel(ShooterSubsystem noteAccelerator, double angleInRADIANS) { // Called when the command is initially scheduled. @Override public void initialize() { - + shooter.setWristByAngle(angle); } // Called every time the scheduler runs while the command is scheduled. @Override - public void execute() { - if (shooter.isZeroed){ - shooter.setWristPosition(angle); - } - } + public void execute() {} // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { - //shooter.manualWristSpeed(0); + // shooter.manualWristSpeed(0); } // Returns true when the command should end. @Override public boolean isFinished() { - if (shooter.isZeroed){ - return shooter.getAngle() >= (angle - Math.toRadians(.5)) && shooter.getAngle() < (angle + Math.toRadians(.5)); - } else { - return true; - } + return true; } } diff --git a/src/main/java/frc/robot/commands/TeleopSwerve.java b/src/main/java/frc/robot/commands/TeleopSwerve.java index d78ab6b..38885e4 100644 --- a/src/main/java/frc/robot/commands/TeleopSwerve.java +++ b/src/main/java/frc/robot/commands/TeleopSwerve.java @@ -1,32 +1,33 @@ package frc.robot.commands; -import frc.lib.math.FiringSolutions; +import edu.wpi.first.math.MathUtil; +import edu.wpi.first.math.controller.PIDController; +import edu.wpi.first.math.geometry.Pose2d; +import edu.wpi.first.math.geometry.Translation2d; +import edu.wpi.first.math.kinematics.ChassisSpeeds; +import edu.wpi.first.wpilibj.GenericHID.RumbleType; +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj2.command.Command; + import frc.lib.math.FiringSolutionsV3; import frc.robot.Constants; import frc.robot.Robot; +import frc.robot.subsystems.IntexerSubsystem; import frc.robot.subsystems.ShooterSubsystem; import frc.robot.subsystems.SwerveSubsystem; import frc.robot.subsystems.VisionSubsystem; -import java.util.function.BooleanSupplier; -import java.util.function.DoubleSupplier; - import org.photonvision.targeting.PhotonPipelineResult; -import edu.wpi.first.math.MathUtil; -import edu.wpi.first.math.controller.PIDController; -import edu.wpi.first.math.geometry.Pose2d; -import edu.wpi.first.math.geometry.Translation2d; -import edu.wpi.first.math.kinematics.ChassisSpeeds; -import edu.wpi.first.wpilibj.Joystick; -import edu.wpi.first.wpilibj.GenericHID.RumbleType; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import edu.wpi.first.wpilibj2.command.Command; +import java.util.function.BooleanSupplier; +import java.util.function.DoubleSupplier; public class TeleopSwerve extends Command { private SwerveSubsystem swerveSubsystem; private VisionSubsystem vision; private ShooterSubsystem shooterSubsystem; + private IntexerSubsystem intexerSubsystem; private DoubleSupplier translationSup; private DoubleSupplier strafeSup; @@ -36,16 +37,33 @@ public class TeleopSwerve extends Command { private BooleanSupplier shooterOverrideAmp; private BooleanSupplier shooterOverrideSpeaker; private BooleanSupplier intakeOverride; + private BooleanSupplier intakeOverrideNoMove; private PIDController rotationPID = new PIDController(0.65, 0.00001, 0.04); private Joystick controller; - public TeleopSwerve(SwerveSubsystem swerve, VisionSubsystem vision, ShooterSubsystem shooter, DoubleSupplier translationSup, DoubleSupplier strafeSup, - DoubleSupplier rotationSup, BooleanSupplier robotCentricSup, BooleanSupplier shooterOverrideAmp, BooleanSupplier shooterOverrideSpeaker, BooleanSupplier intake, Joystick controller) { + private boolean noteInside = false; + + public TeleopSwerve( + SwerveSubsystem swerve, + VisionSubsystem vision, + ShooterSubsystem shooter, + IntexerSubsystem intexer, + DoubleSupplier translationSup, + DoubleSupplier strafeSup, + DoubleSupplier rotationSup, + BooleanSupplier robotCentricSup, + BooleanSupplier shooterOverrideAmp, + BooleanSupplier shooterOverrideSpeaker, + BooleanSupplier intake, + BooleanSupplier intakeNoMove, + Joystick controller) { + this.swerveSubsystem = swerve; this.vision = vision; this.shooterSubsystem = shooter; + this.intexerSubsystem = intexer; addRequirements(swerve); this.translationSup = translationSup; @@ -55,70 +73,136 @@ public TeleopSwerve(SwerveSubsystem swerve, VisionSubsystem vision, ShooterSubsy this.shooterOverrideAmp = shooterOverrideAmp; this.shooterOverrideSpeaker = shooterOverrideSpeaker; this.intakeOverride = intake; + this.intakeOverrideNoMove = intakeNoMove; this.controller = controller; - SmartDashboard.putData(rotationPID); + SmartDashboard.putData("Lock On Rotation PID", rotationPID); } @Override public void execute() { Pose2d pose = swerveSubsystem.getPose(); boolean robotCentric = robotCentricSup.getAsBoolean(); + boolean openLoop = true; PhotonPipelineResult result = vision.getLatestResultN(); /* Get Values, Deadband */ - double translationVal = MathUtil.applyDeadband(translationSup.getAsDouble(), Constants.stickDeadband); + double translationVal = + MathUtil.applyDeadband(translationSup.getAsDouble(), Constants.stickDeadband); double strafeVal = MathUtil.applyDeadband(strafeSup.getAsDouble(), Constants.stickDeadband); double rotationVal; + double offset; + double ampLockOffset; + + if (Robot.getAlliance()) { + ampLockOffset = 16.54 - 5; + if (pose.getRotation().getRadians() > 0) { + offset = -Math.toRadians(180); + } else { + offset = Math.toRadians(180); + } + } else { + ampLockOffset = 5; + offset = 0; + } + /* Exponential Drive */ translationVal = Math.copySign(Math.pow(translationVal, 2), translationVal); strafeVal = Math.copySign(Math.pow(strafeVal, 2), strafeVal); if (shooterOverrideSpeaker.getAsBoolean()) { // Lock robot angle to speaker - if (shooterSubsystem.getDistanceToSpeaker() >= 3.5){ + if (shooterSubsystem.getDistanceToSpeakerWhileMoving() >= 3.5) { controller.setRumble(RumbleType.kBothRumble, 0.5); } else { controller.setRumble(RumbleType.kBothRumble, 0); } + ChassisSpeeds currentSpeed = swerveSubsystem.getChassisSpeeds(); - rotationVal = rotationPID.calculate(swerveSubsystem.getHeading().getRadians(), - FiringSolutionsV3.getAngleToMovingTarget(pose.getX(), pose.getY(), FiringSolutionsV3.speakerTargetX, FiringSolutionsV3.speakerTargetY, + rotationVal = rotationPID.calculate( + pose.getRotation().getRadians() + offset, + FiringSolutionsV3.getAngleToMovingTarget( + pose.getX(), + pose.getY(), + FiringSolutionsV3.speakerTargetX, + FiringSolutionsV3.speakerTargetY, currentSpeed.vxMetersPerSecond, currentSpeed.vyMetersPerSecond, - FiringSolutions.getAngleToSpeaker(pose.getX(), pose.getY()))); - + pose.getRotation().getRadians())); + openLoop = false; + } else if (shooterOverrideAmp.getAsBoolean()) { // Lock robot angle to amp ChassisSpeeds currentSpeed = swerveSubsystem.getChassisSpeeds(); + openLoop = false; + + if ((Robot.getAlliance() && pose.getX() < 16.54 - 5) + ^ (!Robot.getAlliance() && pose.getX() > 5)) { + + rotationVal = rotationPID.calculate( + pose.getRotation().getRadians() + offset, + FiringSolutionsV3.getAngleToMovingTarget( + pose.getX(), + pose.getY(), + FiringSolutionsV3.ampTargetX, + FiringSolutionsV3.ampTargetY, + currentSpeed.vxMetersPerSecond, + currentSpeed.vyMetersPerSecond, + pose.getRotation().getRadians())); + } else { + rotationVal = + rotationPID.calculate(pose.getRotation().getRadians(), Math.toRadians(-90)); + } - rotationVal = rotationPID.calculate(swerveSubsystem.getHeading().getRadians(), - FiringSolutionsV3.getAngleToMovingTarget(pose.getX(), pose.getY(), FiringSolutionsV3.ampTargetX, FiringSolutionsV3.ampTargetY, - currentSpeed.vxMetersPerSecond, - currentSpeed.vyMetersPerSecond, - FiringSolutions.getAngleToSpeaker(pose.getX(), pose.getY()))); + } else if (intakeOverride.getAsBoolean() + && result.hasTargets() + && !noteInside) { // Lock robot towards detected note - } else if (intakeOverride.getAsBoolean() && result.hasTargets()) { // Lock robot towards detected note - double yawToNote = Math.toRadians(result.getBestTarget().getYaw()) + swerveSubsystem.getGyroYaw().getRadians(); + double yawToNote = Math.toRadians(result.getBestTarget().getYaw()) + + swerveSubsystem.getGyroYaw().getRadians(); SmartDashboard.putNumber("Note Yaw", yawToNote); - rotationVal = rotationPID.calculate(yawToNote, swerveSubsystem.getGyroYaw().getRadians()); + rotationVal = rotationPID.calculate( + yawToNote, swerveSubsystem.getGyroYaw().getRadians()); + + translationVal = 0.35; + robotCentric = true; + openLoop = false; + + } else if (intakeOverrideNoMove.getAsBoolean() && result.hasTargets() && !noteInside) { + double yawToNote = Math.toRadians(result.getBestTarget().getYaw()) + + swerveSubsystem.getGyroYaw().getRadians(); + + SmartDashboard.putNumber("Note Yaw", yawToNote); + + openLoop = false; + rotationVal = rotationPID.calculate( + yawToNote, swerveSubsystem.getGyroYaw().getRadians()); + } else { - rotationVal = MathUtil.applyDeadband(rotationSup.getAsDouble(), Constants.stickDeadband); + rotationVal = + MathUtil.applyDeadband(rotationSup.getAsDouble(), Constants.stickDeadband); rotationVal = Math.copySign(Math.pow(rotationVal, 2), rotationVal); controller.setRumble(RumbleType.kBothRumble, 0); + noteInside = false; } - if (Robot.getAlliance() && !robotCentric){ // Invert field oriented for always blue origin + if (Robot.getAlliance() && !robotCentric) { // Invert field oriented for always blue origin translationVal = -translationVal; strafeVal = -strafeVal; } + if (intexerSubsystem.intakeBreak()) { + translationVal = 0; + rotationVal = 0; + noteInside = true; + } + /* Drive */ swerveSubsystem.drive( new Translation2d(translationVal, strafeVal).times(Constants.Swerve.maxSpeed), rotationVal * Constants.Swerve.maxAngularVelocity, !robotCentric, - true); + openLoop); } -} \ No newline at end of file +} diff --git a/src/main/java/frc/robot/commands/ToBreakOrNotToBreak.java b/src/main/java/frc/robot/commands/ToBreakOrNotToBreak.java index 2e1c3bd..ec1f75d 100644 --- a/src/main/java/frc/robot/commands/ToBreakOrNotToBreak.java +++ b/src/main/java/frc/robot/commands/ToBreakOrNotToBreak.java @@ -5,10 +5,13 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; + import frc.robot.subsystems.IntexerSubsystem; +import frc.robot.subsystems.LEDSubsystem; public class ToBreakOrNotToBreak extends Command { IntexerSubsystem intexer; + LEDSubsystem ledSubsystem; /** Creates a new ToBreakOrNotToBreak. */ public ToBreakOrNotToBreak(IntexerSubsystem intexer) { @@ -19,13 +22,12 @@ public ToBreakOrNotToBreak(IntexerSubsystem intexer) { // Called when the command is initially scheduled. @Override - public void initialize() { - } + public void initialize() {} // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if (!intexer.shooterBreak()){ + if (!intexer.shooterBreak()) { intexer.setShooterIntake(.5); } else { intexer.setShooterIntake(0); diff --git a/src/main/java/frc/robot/commands/ZeroWrist.java b/src/main/java/frc/robot/commands/ZeroRizz.java similarity index 91% rename from src/main/java/frc/robot/commands/ZeroWrist.java rename to src/main/java/frc/robot/commands/ZeroRizz.java index 5e70ce4..6dcd871 100644 --- a/src/main/java/frc/robot/commands/ZeroWrist.java +++ b/src/main/java/frc/robot/commands/ZeroRizz.java @@ -6,15 +6,16 @@ import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj2.command.Command; + import frc.robot.Constants; import frc.robot.subsystems.ShooterSubsystem; -public class ZeroWrist extends Command { +public class ZeroRizz extends Command { ShooterSubsystem shooter; public final Timer timer = new Timer(); /** Creates a new ZeroWrist. */ - public ZeroWrist(ShooterSubsystem shooter) { + public ZeroRizz(ShooterSubsystem shooter) { this.shooter = shooter; addRequirements(shooter); // Use addRequirements() here to declare subsystem dependencies. @@ -30,7 +31,7 @@ public void initialize() { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - shooter.manualWristSpeed(.45); + shooter.setWristSpeedManual(.45); } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/subsystems/ElevatorSubsystem.java b/src/main/java/frc/robot/subsystems/ElevatorSubsystem.java index 62563fa..4703e22 100644 --- a/src/main/java/frc/robot/subsystems/ElevatorSubsystem.java +++ b/src/main/java/frc/robot/subsystems/ElevatorSubsystem.java @@ -4,19 +4,18 @@ package frc.robot.subsystems; -import com.ctre.phoenix6.configs.ClosedLoopRampsConfigs; -import com.ctre.phoenix6.configs.CurrentLimitsConfigs; -import com.ctre.phoenix6.configs.Slot0Configs; -import com.ctre.phoenix6.configs.Slot1Configs; +import au.grapplerobotics.ConfigurationFailedException; +import au.grapplerobotics.LaserCan; +import au.grapplerobotics.LaserCan.RangingMode; + +import com.ctre.phoenix6.configs.TalonFXConfiguration; import com.ctre.phoenix6.controls.Follower; import com.ctre.phoenix6.controls.PositionDutyCycle; import com.ctre.phoenix6.hardware.TalonFX; import com.ctre.phoenix6.signals.GravityTypeValue; +import com.ctre.phoenix6.signals.InvertedValue; import com.ctre.phoenix6.signals.NeutralModeValue; -import au.grapplerobotics.ConfigurationFailedException; -import au.grapplerobotics.LaserCan; -import au.grapplerobotics.LaserCan.RangingMode; import edu.wpi.first.math.controller.PIDController; import edu.wpi.first.wpilibj.DataLogManager; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; @@ -25,60 +24,50 @@ public class ElevatorSubsystem extends SubsystemBase { // Devices - public TalonFX m_elevatorLeft = new TalonFX(20); // left leader - public TalonFX m_elevatorRight = new TalonFX(21); - public LaserCan lasercan = new LaserCan(22); + public TalonFX m_elevatorLeft; // left leader + public TalonFX m_elevatorRight; + public LaserCan lasercan; // Falcon stuff - private final PositionDutyCycle m_requestPosition = new PositionDutyCycle(0); private final PositionDutyCycle lockPosition = new PositionDutyCycle(0); private final PIDController elevatorPID = new PIDController(0, 0, 0); - private final Slot1Configs encoderConfigSlot1 = new Slot1Configs(); // Constants IN METERS private final double spoolCircumference = 0.0508; private final double gearRatio = 17.33; - private final double maxHeight = .8; // Vars private double revolutionCount; private double currentHeight; private double setHeight; - private boolean laser; - LaserCan.Measurement measurement; + private LaserCan.Measurement measurement; public boolean manualOverride = false; public boolean locked = false; public ElevatorSubsystem() { + m_elevatorLeft = new TalonFX(20); // left leader + m_elevatorRight = new TalonFX(21); + lasercan = new LaserCan(22); + // Falcon setup - m_elevatorLeft.setNeutralMode(NeutralModeValue.Brake); + TalonFXConfiguration elevatorConfigs = new TalonFXConfiguration(); + elevatorConfigs.MotorOutput.Inverted = InvertedValue.Clockwise_Positive; + elevatorConfigs.Slot0.kP = 0.09; + elevatorConfigs.Slot1.kP = 1; + elevatorConfigs.Slot0.GravityType = GravityTypeValue.Elevator_Static; + elevatorConfigs.MotorOutput.NeutralMode = NeutralModeValue.Brake; + elevatorConfigs.ClosedLoopRamps.DutyCycleClosedLoopRampPeriod = 0.25; + elevatorConfigs.ClosedLoopRamps.TorqueClosedLoopRampPeriod = 0.25; + elevatorConfigs.ClosedLoopRamps.VoltageClosedLoopRampPeriod = 0.25; + + m_elevatorLeft.getConfigurator().apply(elevatorConfigs); + m_elevatorRight.getConfigurator().apply(elevatorConfigs); m_elevatorRight.setControl(new Follower(m_elevatorLeft.getDeviceID(), true)); - // PID - Slot0Configs encoderConfigSlot0 = new Slot0Configs(); - ClosedLoopRampsConfigs closedloop = new ClosedLoopRampsConfigs(); - - closedloop.withDutyCycleClosedLoopRampPeriod(.5).withTorqueClosedLoopRampPeriod(0.5); - encoderConfigSlot0.kP = .09; - encoderConfigSlot0.kI = .0; - encoderConfigSlot0.kD = .0; - encoderConfigSlot0.kV = .0; - encoderConfigSlot0.kG = .0; - encoderConfigSlot0.GravityType = GravityTypeValue.Elevator_Static; - - encoderConfigSlot1.kP = 1; - encoderConfigSlot1.kI = .0; - encoderConfigSlot1.kD = .0; - encoderConfigSlot1.kV = .01; - - - m_elevatorLeft.getConfigurator().apply(encoderConfigSlot0, 0.050); - m_elevatorLeft.getConfigurator().apply(closedloop); - // laser can pid shenanigans - elevatorPID.setP(2.5); - elevatorPID.setI(0); + elevatorPID.setP(3); + elevatorPID.setI(0.5); elevatorPID.setD(0); elevatorPID.setTolerance(0.02); @@ -92,8 +81,6 @@ public ElevatorSubsystem() { SmartDashboard.putData("Elevator PID", elevatorPID); m_elevatorLeft.setPosition(0); - - laser = false; } @Override @@ -105,60 +92,54 @@ public void periodic() { SmartDashboard.putNumber("Set Height", setHeight); SmartDashboard.putNumber("LaserCan Meters", getHeightLaserCan()); SmartDashboard.putBoolean("LaserCan failure", lasercanFailureCheck()); - SmartDashboard.putNumber("Elevator Left Supply Current", m_elevatorLeft.getSupplyCurrent().getValueAsDouble()); - SmartDashboard.putNumber("Elevator Right Supply Current", - m_elevatorRight.getSupplyCurrent().getValueAsDouble()); - SmartDashboard.putNumber("LaserCan Ambient", measurement.ambient); + SmartDashboard.putNumber( + "Elevator Left Supply Current", + m_elevatorLeft.getSupplyCurrent().getValueAsDouble()); + SmartDashboard.putNumber( + "Elevator Right Supply Current", + m_elevatorRight.getSupplyCurrent().getValueAsDouble()); + SmartDashboard.putNumber("LaserCan Ambient", measurement != null ? measurement.ambient : 0); revolutionCount = m_elevatorLeft.getPosition().getValueAsDouble(); - if (!manualOverride){ // Flagitious logic - if (!locked){ - stopHere(); - locked = true; - } - } else { - locked = false; - } - - //FiringSolutionsV3.updateHeight(getHeight()); //TODO: test this + // FiringSolutionsV3.updateHeight(getHeight()); //TODO: test this } - public void setManualOverride(boolean value){ + public void setElevatorSpeedManual(double value) { + m_elevatorLeft.set(value); + } + + public void setManualOverride(boolean value) { manualOverride = value; } - public double getEncoderValue(){ + public double getEncoderValue() { return revolutionCount; } - public void setToEncoder(double value){ + public void setPositionWithEncoder(double value) { + locked = true; m_elevatorLeft.setControl(lockPosition.withPosition(value)); } - public void stopHere(){ + public void stopHere() { + locked = true; m_elevatorLeft.setControl(lockPosition.withPosition(revolutionCount).withSlot(0)); } /** Get height from motor encoder */ public double getHeightEncoder() { - return (revolutionCount / gearRatio) * (spoolCircumference * Math.PI) + 0.2; + return (revolutionCount / gearRatio) * (spoolCircumference * Math.PI); } /** Set height IN METERS. Will run off LaserCan but will switch to encoder if it fails */ public void setHeight(double height) { + locked = true; setHeight = height; - if (!lasercanFailureCheck()) { // Run off LaserCan - m_elevatorLeft.set(elevatorPID.calculate(getHeightLaserCan(), height)); - } else { // Run off encoder - double rot = (height / (spoolCircumference * Math.PI)) * gearRatio; - if (getHeightEncoder() < maxHeight) { - m_elevatorLeft.setControl(m_requestPosition.withPosition(rot).withSlot(1)); - } - } + m_elevatorLeft.set(elevatorPID.calculate(getHeight(), height)); } /** Get height IN METERS. Will run off LaserCan but will switch to encoder if it fails */ - public double getHeight(){ + public double getHeight() { if (!lasercanFailureCheck()) { // Run off LaserCan return getHeightLaserCan(); } else { // Run off encoder @@ -171,6 +152,7 @@ public boolean atHeight() { } public void ManSpin(double percent) { + locked = false; m_elevatorLeft.set(percent); } @@ -178,11 +160,6 @@ public void resetElevatorEncoder() { m_elevatorLeft.setPosition(0); } - //lasercan methods - public void useLaserCan(boolean laserCanOn) { - laser = laserCanOn; - } - /** Get height from LaserCan IN METERS */ public double getHeightLaserCan() { return currentHeight; @@ -204,4 +181,11 @@ public boolean lasercanFailureCheck() { } } + public double getSetpoint() { + return m_elevatorLeft.getClosedLoopReference().getValue(); + } + + public double getPosition() { + return m_elevatorLeft.getPosition().getValueAsDouble(); + } } diff --git a/src/main/java/frc/robot/subsystems/IntexerSubsystem.java b/src/main/java/frc/robot/subsystems/IntexerSubsystem.java index 258296a..f85cad4 100644 --- a/src/main/java/frc/robot/subsystems/IntexerSubsystem.java +++ b/src/main/java/frc/robot/subsystems/IntexerSubsystem.java @@ -4,28 +4,37 @@ package frc.robot.subsystems; -import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import edu.wpi.first.wpilibj2.command.SubsystemBase; import com.revrobotics.CANSparkBase; -import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkBase.IdleMode; import com.revrobotics.CANSparkLowLevel.MotorType; +import com.revrobotics.CANSparkMax; + +import edu.wpi.first.wpilibj.DigitalInput; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj2.command.SubsystemBase; public class IntexerSubsystem extends SubsystemBase { // Devices - private CANSparkBase left = new CANSparkMax(30, MotorType.kBrushless); - private CANSparkBase right = new CANSparkMax(31, MotorType.kBrushless); - private CANSparkBase shooterIntake = new CANSparkMax(10, MotorType.kBrushless); + private CANSparkBase left; + private CANSparkBase right; + private CANSparkBase shooterIntake; public boolean intakeThroughShooterPart2isReady = false; + public boolean resetNoteInShooterPart2isReady = false; /** Front Intake */ - private DigitalInput breakingBeam = new DigitalInput(2); + private DigitalInput breakingBeam; /** Shooter Intake */ - private DigitalInput beamKamen = new DigitalInput(1); + private DigitalInput beamKamen; public IntexerSubsystem() { + left = new CANSparkMax(30, MotorType.kBrushless); + right = new CANSparkMax(31, MotorType.kBrushless); + shooterIntake = new CANSparkMax(10, MotorType.kBrushless); + + beamKamen = new DigitalInput(1); + breakingBeam = new DigitalInput(2); + left.setIdleMode(IdleMode.kCoast); right.setIdleMode(IdleMode.kCoast); shooterIntake.setIdleMode(IdleMode.kCoast); @@ -49,7 +58,7 @@ public void setALL(double speed) { shooterIntake.set(speed); } } - + public void setFrontIntake(double speed) { if (speed == 0) { left.stopMotor(); @@ -61,7 +70,7 @@ public void setFrontIntake(double speed) { } public void setShooterIntake(double speed) { - if (speed == 0){ + if (speed == 0) { shooterIntake.stopMotor(); } else { shooterIntake.set(speed); @@ -76,10 +85,14 @@ public boolean shooterBreak() { return !beamKamen.get(); } - public void setIntakeThroughShooterPart2Status(boolean value){ + public void setIntakeThroughShooterPart2Status(boolean value) { intakeThroughShooterPart2isReady = value; } + public void resetNoteInShooterPart2Status(boolean value) { + resetNoteInShooterPart2isReady = value; + } + @Override public void periodic() { SmartDashboard.putBoolean("Intake Beam Break", intakeBreak()); diff --git a/src/main/java/frc/robot/subsystems/LEDSubsystem.java b/src/main/java/frc/robot/subsystems/LEDSubsystem.java index 45beeb0..5331fac 100644 --- a/src/main/java/frc/robot/subsystems/LEDSubsystem.java +++ b/src/main/java/frc/robot/subsystems/LEDSubsystem.java @@ -5,51 +5,260 @@ package frc.robot.subsystems; import edu.wpi.first.wpilibj.DigitalOutput; +import edu.wpi.first.wpilibj.DriverStation; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.SubsystemBase; + +import frc.robot.Constants; import frc.robot.Robot; public class LEDSubsystem extends SubsystemBase { - public DigitalOutput AllianceColor = new DigitalOutput(2); // Alliance color - public DigitalOutput FoundNote = new DigitalOutput(3); // Sends if the camera 'OnionRing' sees a note - public DigitalOutput Aimed = new DigitalOutput(4); // Sends if the outtake is aimed - public DigitalOutput NoteInIntake = new DigitalOutput(5); // Sends if the Note is in the intake/outtake - public DigitalOutput NoteOuttaked = new DigitalOutput(6); // Sends if the Note has been outtaked + public DigitalOutput WalterLight = new DigitalOutput(3); // Bit 1 (1) + public DigitalOutput JesseBlinkman = new DigitalOutput(4); // Bit 2 (2) + public DigitalOutput GusBling = new DigitalOutput(5); // Bit 3 (4) + public DigitalOutput SkylerBright = new DigitalOutput(6); // Bit 4 (8) + + // Output bits to the LEDs + public DigitalOutput[] bits = {WalterLight, JesseBlinkman, GusBling, SkylerBright + }; // Actual Outputs + private boolean[] output = new boolean[4]; // Computed Outputs + + // Booleans used for Easy input + private Boolean hasNote = false; + private Boolean chargingOuttake = false; + private Boolean atSpeed = false; + + public Boolean[] inputBooleans = { + false, // Amp -0 Rainbow Pattern #1 + false, // Source -1 Rainbow Pattern #2 + false, // Climb -2 Rainbow Pattern #3 + false, // Blank/DC -3 None + false, // Note Detected -4 White Solid + false, // Charging -5 Green Pulse (HasNote) + false, // At Speed -6 Green BLink (HasNote) + false, // Charging -7 Magenta Pulse (NoNote) + false, // At Speed -8 Magenta BLink (NoNote) + false, // Note in Intake -9 Orange Blink + false, // Note in Shooter -10 Orange Solid + false, // Alliance Color -11 Red Pulse + false // Alliance Color -12 Blue Pulse + }; + + // Use subsystems + VisionSubsystem vision; + ShooterSubsystem shooter; + IntexerSubsystem intexer; + SwerveSubsystem swerve; + + /** Creates a new LEDSubsystem. */ + public LEDSubsystem( + VisionSubsystem m_VisionSubsystem, + ShooterSubsystem m_ShooterSubsystem, + IntexerSubsystem m_IntexerSubsystem, + SwerveSubsystem m_SwerveSubsystem) { + this.vision = m_VisionSubsystem; + this.shooter = m_ShooterSubsystem; + this.intexer = m_IntexerSubsystem; + this.swerve = m_SwerveSubsystem; + } + + @Override + public void periodic() { + set(); // Decimal Phase + encoder(); // Transition Phase + send(); // Send Phase + } + + private void set() { // Decimal phase + var results = vision.getLatestResultN(); + + // Note Detected + if (results.hasTargets()) { + NoteDetected(true); + } else { + NoteDetected(false); + } + + // Driver Station Connected + if (DriverStation.isDSAttached()) { + inputBooleans[1] = false; + } else { + inputBooleans[1] = true; + } + + if (Robot.checkRedAlliance()) { + inputBooleans[11] = true; + inputBooleans[12] = false; + } else { + inputBooleans[11] = false; + inputBooleans[12] = true; + } + + // HasNote for ChargingOuttake and AtSpeed + if (hasNote) { // Converts from simple inputs to boolean + if (chargingOuttake) { + inputBooleans[5] = true; + inputBooleans[6] = false; + } else if (atSpeed) { + inputBooleans[5] = false; + inputBooleans[6] = true; + } + inputBooleans[7] = false; + inputBooleans[8] = false; + } else { + if (chargingOuttake) { + inputBooleans[7] = true; + inputBooleans[8] = false; + } else if (atSpeed) { + inputBooleans[7] = false; + inputBooleans[8] = true; + } + inputBooleans[5] = false; + inputBooleans[6] = false; + } + + // Check if pathfinding + if (SwerveSubsystem.followingPath) { + inputBooleans[0] = true; + } else { + inputBooleans[0] = false; + } + + // Check beam breaks + if (intexer.intakeBreak()) { + inputBooleans[9] = true; // Intake + inputBooleans[10] = false; // Shooter + hasNote = true; + } else if (intexer.shooterBreak()) { + inputBooleans[9] = false; // Intake + inputBooleans[10] = true; // Shooter + hasNote = true; + } else { + inputBooleans[9] = false; // Intake + inputBooleans[10] = false; // Shooter + hasNote = false; + } + + // Charging or At Speed with Note or without Note + if (hasNote) { // Has Note + if (shooter.isShooterAtSpeed()) { // At speed + inputBooleans[5] = false; + inputBooleans[6] = true; + } else if (shooter.getVelocity() > Constants.Shooter.idleSpeedRPM + 500) { // Charging + inputBooleans[5] = true; + inputBooleans[6] = false; + } + inputBooleans[7] = false; + inputBooleans[8] = false; + } else { // No Note + if (shooter.isShooterAtSpeed()) { // At speed + inputBooleans[7] = false; + inputBooleans[8] = true; + } else if (shooter.getVelocity() > Constants.Shooter.idleSpeedRPM + 500) { // Charging + inputBooleans[7] = true; + inputBooleans[8] = false; + } + inputBooleans[5] = false; + inputBooleans[6] = false; + } + + SmartDashboard.putBooleanArray("Input Booleans", inputBooleans); + } + + private void encoder() { // Transition phase + // Decimal to Binary + int pin_amount = 4; // Amount of pins + + int trueIndex = 0; // Index of selected LED sequence + + for (int i = 0; + i < inputBooleans.length; + i++) { // Picks the first true sequence based on priority + if (inputBooleans[i]) { + trueIndex = i; + break; + } + } - VisionSubsystem vision; + String binaryString = Integer.toBinaryString(trueIndex); // Cast Number to Binary + int length = binaryString.length(); // Find length of Binary (How many bits) + String finalString; // Final binary string - /** Creates a new LEDSubsystem. */ - public LEDSubsystem(VisionSubsystem m_VisionSubsystem) { - this.vision = m_VisionSubsystem; - } + // Adds the amount of 0's needed for acurate transcription. Ex. 0x01 -> 0x0001 + if (length < pin_amount) { + int zerosToAdd = pin_amount - length; + StringBuilder paddedStringBuilder = new StringBuilder(); - @Override - public void periodic() { - var results = vision.getLatestResultN(); + for (int i = 0; i < zerosToAdd; i++) { + paddedStringBuilder.append("0"); + } - if (results.hasTargets()) { - FoundNote(true); - } else { - FoundNote(false); + paddedStringBuilder.append(binaryString); + String paddedBinaryString = paddedStringBuilder.toString(); + + finalString = paddedBinaryString; + } else { + finalString = binaryString; + } + + SmartDashboard.putString("Binary Output", finalString); + + for (int i = pin_amount - 1; i >= 0; i--) { + output[i] = finalString.charAt(i) == '1'; + } + } + + private void send() { // Send Phase - "Redundancy is bliss" + for (int i = 0; i < output.length; i++) { + bits[i].set(output[i]); + } + SmartDashboard.putBooleanArray("DigitalOutputs", output); + } + + // SET FUNCTIONS + public void ampTele(boolean amp) { + inputBooleans[0] = amp; + } + + public void sourceTele(boolean source) { + inputBooleans[1] = source; + } + + public void climbTele(boolean climb) { + inputBooleans[2] = climb; } - } - public void setAllianceColor() { - AllianceColor.set(Robot.getAlliance()); // True is Red, False is Blue - } + public void HasNote(boolean hasNote) { + this.hasNote = hasNote; + } + + public void ChargingOuttake(boolean chargingOuttake) { + this.chargingOuttake = chargingOuttake; + } - public void FoundNote(boolean foundNote) { - FoundNote.set(foundNote); - } + public void ReadyToFire(boolean fire) { + this.atSpeed = fire; + } - public void Aimed(boolean aimed) { - Aimed.set(aimed); - } + public void NoteInIntake(boolean noteInIntake) { + inputBooleans[9] = noteInIntake; + } - public void NoteInIntake(boolean noteInIntake) { - NoteInIntake.set(noteInIntake); - } + public void NoteInShooter(boolean noteInShooter) { + inputBooleans[10] = noteInShooter; + } - public void NoteOuttaked(boolean noteOuttaked) { - NoteOuttaked.set(noteOuttaked); - } + public void NoteDetected(boolean note) { + inputBooleans[4] = note; + } + + /* DISCLAIMER: DISCONTINUED */ + public void setAllianceColor() { + inputBooleans[11] = Robot.getAlliance(); // True is Red + inputBooleans[12] = !Robot.getAlliance(); // False is Blue + } + + public void Disconnected(boolean disconnected) { // NOT CONFIRMED TO BE IN FINAL + inputBooleans[3] = disconnected; + } } diff --git a/src/main/java/frc/robot/subsystems/ShooterSubsystem.java b/src/main/java/frc/robot/subsystems/ShooterSubsystem.java index 5a38ac1..8aa7656 100644 --- a/src/main/java/frc/robot/subsystems/ShooterSubsystem.java +++ b/src/main/java/frc/robot/subsystems/ShooterSubsystem.java @@ -4,30 +4,33 @@ package frc.robot.subsystems; -import edu.wpi.first.wpilibj2.command.SubsystemBase; -import frc.lib.math.FiringSolutionsV3; -import frc.lib.math.Interpolations; import com.revrobotics.CANSparkBase; -import com.revrobotics.RelativeEncoder; -import com.revrobotics.SparkPIDController; import com.revrobotics.CANSparkBase.IdleMode; import com.revrobotics.CANSparkLowLevel.MotorType; import com.revrobotics.CANSparkMax; +import com.revrobotics.RelativeEncoder; +import com.revrobotics.SparkPIDController; -import edu.wpi.first.wpilibj.DutyCycleEncoder; -import edu.wpi.first.wpilibj.Timer; -import edu.wpi.first.wpilibj.smartdashboard.*; import edu.wpi.first.math.controller.PIDController; import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.kinematics.ChassisSpeeds; import edu.wpi.first.math.util.Units; +import edu.wpi.first.wpilibj.DutyCycleEncoder; +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.smartdashboard.*; +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +import frc.lib.math.FiringSolutionsV3; +import frc.lib.math.Interpolations; +import frc.robot.Constants; +import frc.robot.Robot; public class ShooterSubsystem extends SubsystemBase { // Devices - private CANSparkBase m_Wrist = new CANSparkMax(13, MotorType.kBrushless); - private CANSparkBase shootaTop = new CANSparkMax(11, MotorType.kBrushless); // leader - private CANSparkBase shootaBot = new CANSparkMax(12, MotorType.kBrushless); + private CANSparkBase m_Wrist; + private CANSparkBase shootaTop; // leader + private CANSparkBase shootaBot; private RelativeEncoder m_VelocityEncoder; private RelativeEncoder m_VelocityEncoder2; @@ -40,29 +43,50 @@ public class ShooterSubsystem extends SubsystemBase { private SparkPIDController topPID; // PID Constants - private double velocityP = 0.00018; + private double velocityP = 0.0001; private double velocityI = 5.2e-7; - private double velocityD = 1.5; + private double velocityD = 0; - private double positionP = 2; + private double positionP = 1; private double positionI = 0; private double positionD = 0; // Vars + /** In m/s */ private double shooterVelocity = 12.1; + private double shooterAngleToSpeaker, shooterAngleToAmp; - private Boolean ENCFAIL = false; + private boolean ENCFAIL = false; public boolean isZeroed = false; - private double angleOffset = 68.2; // IN RADIANS + public boolean wristIsLocked = false; + /** IN RADIANS */ + private double angleOffset = Constants.Shooter.angleOffsetManual; + + private double distanceToMovingSpeakerTarget = .94; + public double lastWristAngleSetpoint = 0.0; + public boolean manualOverride = false; + public double wristAngleUpperBound; + public double wristAngleLowerBound; + + public boolean outsideAllianceWing = false; + + // Constants + private final double wristAngleMax = 0.0; + private final double wristAngleMin = 0.0; private final Timer speedTimer = new Timer(); - private final int m_WristCurrentMax = 84; private final Interpolations interpolation = new Interpolations(); - private double distanceToMovingSpeakerTarget = .94; + private final int m_WristCurrentMax = 84; private SwerveSubsystem swerveSubsystem; + private ElevatorSubsystem elevatorSubsystem; - public ShooterSubsystem(SwerveSubsystem swerve) { + public ShooterSubsystem(SwerveSubsystem swerve, ElevatorSubsystem elevator) { swerveSubsystem = swerve; + elevatorSubsystem = elevator; + + m_Wrist = new CANSparkMax(13, MotorType.kBrushless); + shootaTop = new CANSparkMax(11, MotorType.kBrushless); // leader + shootaBot = new CANSparkMax(12, MotorType.kBrushless); // Encoders m_VelocityEncoder = shootaTop.getEncoder(); @@ -76,7 +100,7 @@ public ShooterSubsystem(SwerveSubsystem swerve) { m_Wrist.restoreFactoryDefaults(); m_Wrist.setIdleMode(IdleMode.kBrake); - m_Wrist.setInverted(true); + m_Wrist.setInverted(false); shootaBot.setInverted(false); @@ -95,14 +119,14 @@ public ShooterSubsystem(SwerveSubsystem swerve) { m_Wrist.burnFlash(); shootaBot.burnFlash(); shootaTop.burnFlash(); - + m_pidWrist = new PIDController(positionP, positionI, positionD); m_VelocityEncoder.setMeasurementPeriod(20); SmartDashboard.putNumber("set velocity", shooterVelocity); - SmartDashboard.putData(m_pidWrist); + SmartDashboard.putData("Wrist PID", m_pidWrist); SmartDashboard.putData(this); SmartDashboard.putNumber("Set Slip Offset", FiringSolutionsV3.slipPercent); @@ -118,29 +142,40 @@ public ShooterSubsystem(SwerveSubsystem swerve) { @Override public void periodic() { // This method will be called once per scheduler run -/* - pidSpdP = SmartDashboard.getNumber("Velo P", pidSpdP); - pidSpdI = SmartDashboard.getNumber("Velo I", pidSpdI); - pidSpdD = SmartDashboard.getNumber("Velo D", pidSpdD); -Minor whoopsie if these guys were causing loop overruns - botPID.setP(pidSpdP, 0); - botPID.setI(pidSpdI, 0); - botPID.setD(pidSpdD, 0); - - topPID.setP(pidSpdP, 0); - topPID.setI(pidSpdI, 0); - topPID.setD(pidSpdD, 0); -*/ + /* + if (velocityP != SmartDashboard.getNumber("Velo P", velocityP)){ + velocityP = SmartDashboard.getNumber("Velo P", velocityP); + topPID.setP(velocityP, 0); + botPID.setP(velocityP, 0); + } + + if (velocityI != SmartDashboard.getNumber("Velo I", velocityI)){ + velocityI = SmartDashboard.getNumber("Velo I", velocityI); + topPID.setI(velocityI, 0); + botPID.setI(velocityI, 0); + } + + if (velocityD != SmartDashboard.getNumber("Velo D", velocityD)){ + velocityD = SmartDashboard.getNumber("Velo D", velocityD); + topPID.setD(velocityD, 0); + botPID.setD(velocityD, 0); + } + */ shooterVelocity = SmartDashboard.getNumber("set velocity", shooterVelocity); - FiringSolutionsV3.slipPercent = SmartDashboard.getNumber("Set Slip Offset", FiringSolutionsV3.slipPercent); - FiringSolutionsV3.speakerTargetZ = SmartDashboard.getNumber("Set Target Z", FiringSolutionsV3.speakerTargetZ); + FiringSolutionsV3.slipPercent = + SmartDashboard.getNumber("Set Slip Offset", FiringSolutionsV3.slipPercent); + FiringSolutionsV3.speakerTargetZ = + SmartDashboard.getNumber("Set Target Z", FiringSolutionsV3.speakerTargetZ); - SmartDashboard.putNumber("Top - Bottom error", m_VelocityEncoder.getVelocity() - m_VelocityEncoder2.getVelocity()); - SmartDashboard.putNumber("Current Angle Radians", getAngle()); + SmartDashboard.putNumber( + "Top - Bottom error", + m_VelocityEncoder.getVelocity() - m_VelocityEncoder2.getVelocity()); + SmartDashboard.putNumber("Current Angle Radians", getCurrentShooterAngle()); SmartDashboard.putNumber("Current Velocity", getVelocity()); - SmartDashboard.putBoolean("shooter at speed", shooterAtSpeed()); - SmartDashboard.putNumber("Current Angle Degrees", Units.radiansToDegrees(getAngle())); + SmartDashboard.putBoolean("shooter at speed", isShooterAtSpeed()); + SmartDashboard.putNumber( + "Current Angle Degrees", Units.radiansToDegrees(getCurrentShooterAngle())); // check for encoder failure if (m_WristEncoder.isConnected()) { @@ -156,27 +191,68 @@ public void periodic() { SmartDashboard.putNumber("Flywheel Right Current", shootaBot.getOutputCurrent()); SmartDashboard.putNumber("Wrist Current", m_Wrist.getOutputCurrent()); SmartDashboard.putBoolean("is Wrist Stalled", isWristMotorStalled()); + + if (isZeroed) { + if (!manualOverride) { + m_Wrist.set(m_pidWrist.calculate(getCurrentShooterAngle(), lastWristAngleSetpoint)); + } + + // Implement whenever build stops throwing + /* + * if (getCurrentShooterAngle() > wristAngleUpperBound){ + * m_Wrist.set(m_pidWrist.calculate(getCurrentShooterAngle(), + * wristAngleUpperBound)); + * } else if (getCurrentShooterAngle() < wristAngleLowerBound){ + * m_Wrist.set(m_pidWrist.calculate(getCurrentShooterAngle(), + * wristAngleLowerBound)); + * } + */ + } } - /** Check if wrist motor is exceeding stall current, used for zeroing */ - public boolean isWristMotorStalled() { - if (m_Wrist.getOutputCurrent() > m_WristCurrentMax) { - return true; + /** in RADIANs units MATTER */ + public double getCurrentShooterAngle() { + if (!ENCFAIL) { + return ((m_WristEncoder.get() * 2 * Math.PI) / 4) + angleOffset; } else { - return false; + return ((m_PositionEncoder.getPosition() * 2 * Math.PI) / 100); } } - /** Reset wrist encoder to given value */ - public void setWristEncoderPosition(double newPosition) { - m_WristEncoder.setPositionOffset(newPosition); + public double getCalculatedAngleToAmp() { + return shooterAngleToAmp; } - /** Get whether shooter is at target speed */ - public boolean shooterAtSpeed() { // Copied from Hudson but made it better + public double getCalculatedAngleToSpeaker() { + return shooterAngleToSpeaker; + } + + public double getCalculatedVelocity() { + return shooterVelocity; + } + + public double getDistanceTo(double x, double y) { + return FiringSolutionsV3.getDistanceToTarget( + swerveSubsystem.getPose().getX(), swerveSubsystem.getPose().getY(), x, y); + } + + public double getDistanceToSpeakerWhileMoving() { + return distanceToMovingSpeakerTarget; + } + + /** Shooter velocity in RPM */ + public double getVelocity() { + return m_VelocityEncoder.getVelocity(); + } + + public double getWristRotations() { + return m_PositionEncoder.getPosition(); + } + /** Get whether shooter is at target speed */ + public boolean isShooterAtSpeed() { // Copied from Hudson but made it better // if error less than certain amount start the timer - if (Math.abs(getVelocity() - FiringSolutionsV3.convertToRPM(shooterVelocity)) < 50) { + if (Math.abs(getVelocity() - FiringSolutionsV3.convertToRPM(shooterVelocity)) < 80) { speedTimer.start(); } else { speedTimer.reset(); @@ -190,20 +266,21 @@ public boolean shooterAtSpeed() { // Copied from Hudson but made it better } } - /** Shooter velocity in RPM */ - public double getVelocity() { - return m_VelocityEncoder.getVelocity(); - } - - /** in RADIANs units MATTER */ - public double getAngle() { - if (!ENCFAIL) { - return ((-m_WristEncoder.get() * 2 * Math.PI) / 4) + angleOffset; + /** Check if wrist motor is exceeding stall current, used for zeroing */ + public boolean isWristMotorStalled() { + if (m_Wrist.getOutputCurrent() > m_WristCurrentMax) { + return true; } else { - return ((m_PositionEncoder.getPosition() * 2 * Math.PI) / 100); + return false; } } + public void PointShoot(double PointAngle, double launchVelocity) { + setWristByAngle(PointAngle); + botPID.setReference(launchVelocity, CANSparkMax.ControlType.kVelocity); + topPID.setReference(launchVelocity, CANSparkMax.ControlType.kVelocity); + } + public void resetWristEncoders(double newOffset) { angleOffset = newOffset; m_WristEncoder.reset(); @@ -211,88 +288,171 @@ public void resetWristEncoders(double newOffset) { isZeroed = true; } - /** IN RADIANS */ - public void setWristPosition(double angle) { - if (isZeroed){ - m_Wrist.set(m_pidWrist.calculate(getAngle(), angle)); - } + /** Wrist Encoder Reset */ + public void restartWristEncoders() { + m_WristEncoder.reset(); + m_PositionEncoder.setPosition(0); + } + + public void setManualOverride(boolean value) { + manualOverride = value; } /** In rotations per minute */ - public void setShooterVelocity(double velocity) { + public void setOffsetVelocity(double velocity) { if (velocity == 0) { shootaBot.stopMotor(); shootaTop.stopMotor(); } else { - botPID.setReference(velocity, CANSparkMax.ControlType.kVelocity); - topPID.setReference(velocity, CANSparkMax.ControlType.kVelocity); + botPID.setReference( + velocity - SmartDashboard.getNumber("Top Bottom Offset", 400), + CANSparkMax.ControlType.kVelocity); + topPID.setReference( + velocity + SmartDashboard.getNumber("Top Bottom Offset", 400), + CANSparkMax.ControlType.kVelocity); } } /** In rotations per minute */ - public void SetOffsetVelocity(double velocity) { + public void setShooterVelocity(double velocity) { if (velocity == 0) { shootaBot.stopMotor(); shootaTop.stopMotor(); } else { - botPID.setReference(velocity - SmartDashboard.getNumber("Top Bottom Offset", 400), CANSparkMax.ControlType.kVelocity); - topPID.setReference(velocity + SmartDashboard.getNumber("Top Bottom Offset", 400), CANSparkMax.ControlType.kVelocity); + botPID.setReference(velocity, CANSparkMax.ControlType.kVelocity); + topPID.setReference(velocity, CANSparkMax.ControlType.kVelocity); } } - public void PointShoot(double PointAngle, double launchVelocity) { - setWristPosition(PointAngle); - botPID.setReference(launchVelocity, CANSparkMax.ControlType.kVelocity); - topPID.setReference(launchVelocity, CANSparkMax.ControlType.kVelocity); + /** Reset wrist encoder to given value */ + public void setWristEncoderOffset(double newPosition) { + m_WristEncoder.setPositionOffset(newPosition); } - public void manualWristSpeed(double speed) { - m_Wrist.set(speed); + public void setWristAngleLowerBound(double wristAngleLowerBound) { + if (wristAngleLowerBound < wristAngleMin) { + wristAngleLowerBound = wristAngleMin; + } else if (wristAngleLowerBound > wristAngleUpperBound) { + wristAngleLowerBound = wristAngleUpperBound; + } else { + this.wristAngleLowerBound = wristAngleLowerBound; + } } - public double getCalculatedVelocity() { - return shooterVelocity; + public void setWristAngleUpperBound(double wristAngleUpperBound) { + if (wristAngleUpperBound > wristAngleMax) { + wristAngleUpperBound = wristAngleMax; + } else if (wristAngleUpperBound < wristAngleLowerBound) { + wristAngleUpperBound = wristAngleLowerBound; + } else { + this.wristAngleUpperBound = wristAngleUpperBound; + } } - public double getCalculatedAngleToAmp() { - return shooterAngleToAmp; + /** IN RADIANS */ + public void setWristByAngle(double angle) { + manualOverride = false; + if (isZeroed) { + // manualOverride = false; + updateWristAngleSetpoint(angle); + } } - public double getCalculatedAngleToSpeaker() { - return shooterAngleToSpeaker; + /** IN ROTATIONS */ + public void setWristByRotations(double newPosition) { + if (isZeroed) { + m_Wrist.set(m_pidWrist.calculate(getWristRotations(), newPosition)); + } } - public double getDistanceToSpeaker () { - return distanceToMovingSpeakerTarget; + public void setWristSpeedManual(double speed) { + manualOverride = true; + m_Wrist.set(speed); + } + + public void setWristToBrake() { + m_Wrist.setIdleMode(IdleMode.kBrake); + } + + public void setWristToCoast() { + m_Wrist.setIdleMode(IdleMode.kCoast); + } + + public void updateWristAngleSetpoint(double angle) { + if (angle != lastWristAngleSetpoint) { + lastWristAngleSetpoint = angle; + } } public void updateShooterMath() { // Shooter Math + Pose2d pose = swerveSubsystem.getPose(); ChassisSpeeds chassisSpeeds = swerveSubsystem.getChassisSpeeds(); - distanceToMovingSpeakerTarget = FiringSolutionsV3.getDistanceToMovingTarget(pose.getX(), pose.getY(), FiringSolutionsV3.speakerTargetX, FiringSolutionsV3.speakerTargetY, - chassisSpeeds.vxMetersPerSecond, chassisSpeeds.vyMetersPerSecond, pose.getRotation().getRadians()); + distanceToMovingSpeakerTarget = FiringSolutionsV3.getDistanceToMovingTarget( + pose.getX(), + pose.getY(), + FiringSolutionsV3.speakerTargetX, + FiringSolutionsV3.speakerTargetY, + chassisSpeeds.vxMetersPerSecond, + chassisSpeeds.vyMetersPerSecond, + pose.getRotation().getRadians()); FiringSolutionsV3.updateSpeakerR(distanceToMovingSpeakerTarget); - //shooterAngleToSpeaker = FiringSolutionsV3.getShooterAngleFromSpeakerR(); - shooterAngleToSpeaker = Math.toRadians(interpolation.getShooterAngleFromInterpolation(distanceToMovingSpeakerTarget)); + // shooterAngleToSpeaker = FiringSolutionsV3.getShooterAngleFromSpeakerR(); + + if (elevatorSubsystem.getHeight() > 0.3) { + shooterAngleToSpeaker = + Math.toRadians(interpolation.getShooterAngleFromInterpolationElevatorUp( + distanceToMovingSpeakerTarget)); + } else { + shooterAngleToSpeaker = Math.toRadians( + interpolation.getShooterAngleFromInterpolation(distanceToMovingSpeakerTarget)); + } + + if ((Robot.getAlliance() && pose.getX() < 16.54 - 5) + ^ (!Robot.getAlliance() && pose.getX() > 5)) { + outsideAllianceWing = true; + } else { + outsideAllianceWing = false; + } - SmartDashboard.putNumber("Target Velocity RPM", FiringSolutionsV3.convertToRPM(shooterVelocity)); + SmartDashboard.putNumber( + "Target Velocity RPM", FiringSolutionsV3.convertToRPM(shooterVelocity)); SmartDashboard.putNumber("Calculated Angle Radians", shooterAngleToSpeaker); SmartDashboard.putNumber("Calculated Angle Degrees", Math.toDegrees(shooterAngleToSpeaker)); - SmartDashboard.putNumber("distance", FiringSolutionsV3.getDistanceToTarget(pose.getX(), pose.getY(), FiringSolutionsV3.speakerTargetX, FiringSolutionsV3.speakerTargetY)); + SmartDashboard.putNumber( + "distance", + FiringSolutionsV3.getDistanceToTarget( + pose.getX(), + pose.getY(), + FiringSolutionsV3.speakerTargetX, + FiringSolutionsV3.speakerTargetY)); SmartDashboard.putNumber("R", FiringSolutionsV3.getSpeakerR()); SmartDashboard.putNumber("C", FiringSolutionsV3.C(distanceToMovingSpeakerTarget)); - SmartDashboard.putNumber("quarticA", FiringSolutionsV3.quarticA(distanceToMovingSpeakerTarget, FiringSolutionsV3.speakerTargetZ)); - SmartDashboard.putNumber("quarticC", FiringSolutionsV3.quarticC(distanceToMovingSpeakerTarget, FiringSolutionsV3.speakerTargetZ)); - SmartDashboard.putNumber("quarticE", FiringSolutionsV3.quarticE(distanceToMovingSpeakerTarget)); + SmartDashboard.putNumber( + "quarticA", + FiringSolutionsV3.quarticA( + distanceToMovingSpeakerTarget, FiringSolutionsV3.speakerTargetZ)); + SmartDashboard.putNumber( + "quarticC", + FiringSolutionsV3.quarticC( + distanceToMovingSpeakerTarget, FiringSolutionsV3.speakerTargetZ)); + SmartDashboard.putNumber( + "quarticE", FiringSolutionsV3.quarticE(distanceToMovingSpeakerTarget)); SmartDashboard.putNumber("Distance to Moving Target", distanceToMovingSpeakerTarget); SmartDashboard.putNumber("robot vx", chassisSpeeds.vxMetersPerSecond); SmartDashboard.putNumber("robot vy", chassisSpeeds.vyMetersPerSecond); - double distanceToMovingAmpTarget = FiringSolutionsV3.getDistanceToMovingTarget(pose.getX(), pose.getY(), FiringSolutionsV3.ampTargetX, FiringSolutionsV3.ampTargetY, - chassisSpeeds.vxMetersPerSecond, chassisSpeeds.vyMetersPerSecond, pose.getRotation().getRadians()); + double distanceToMovingAmpTarget = FiringSolutionsV3.getDistanceToMovingTarget( + pose.getX(), + pose.getY(), + FiringSolutionsV3.ampTargetX, + FiringSolutionsV3.ampTargetY, + chassisSpeeds.vxMetersPerSecond, + chassisSpeeds.vyMetersPerSecond, + pose.getRotation().getRadians()); FiringSolutionsV3.updateAmpR(distanceToMovingAmpTarget); diff --git a/src/main/java/frc/robot/subsystems/SwerveSubsystem.java b/src/main/java/frc/robot/subsystems/SwerveSubsystem.java index d9304e4..9e79f9c 100644 --- a/src/main/java/frc/robot/subsystems/SwerveSubsystem.java +++ b/src/main/java/frc/robot/subsystems/SwerveSubsystem.java @@ -1,23 +1,16 @@ package frc.robot.subsystems; -import frc.robot.SwerveModule; -import frc.robot.Constants; -import frc.robot.Robot; -import edu.wpi.first.math.kinematics.ChassisSpeeds; -import edu.wpi.first.math.kinematics.SwerveDriveKinematics; -import edu.wpi.first.math.kinematics.SwerveModulePosition; - -import java.util.Optional; -import java.util.function.BooleanSupplier; - -import org.photonvision.EstimatedRobotPose; +import static edu.wpi.first.units.MutableMeasure.mutable; +import static edu.wpi.first.units.Units.Meters; +import static edu.wpi.first.units.Units.MetersPerSecond; +import static edu.wpi.first.units.Units.Volts; import com.ctre.phoenix6.configs.Pigeon2Configuration; import com.ctre.phoenix6.hardware.Pigeon2; import com.pathplanner.lib.auto.AutoBuilder; -import com.pathplanner.lib.path.PathConstraints; import com.pathplanner.lib.util.HolonomicPathFollowerConfig; import com.pathplanner.lib.util.PIDConstants; +import com.pathplanner.lib.util.PathPlannerLogging; import com.pathplanner.lib.util.ReplanningConfig; import edu.wpi.first.math.Matrix; @@ -25,6 +18,9 @@ import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.geometry.Rotation2d; import edu.wpi.first.math.geometry.Translation2d; +import edu.wpi.first.math.kinematics.ChassisSpeeds; +import edu.wpi.first.math.kinematics.SwerveDriveKinematics; +import edu.wpi.first.math.kinematics.SwerveModulePosition; import edu.wpi.first.math.kinematics.SwerveModuleState; import edu.wpi.first.math.numbers.N1; import edu.wpi.first.math.numbers.N3; @@ -37,18 +33,25 @@ import edu.wpi.first.units.Units; import edu.wpi.first.units.Velocity; import edu.wpi.first.units.Voltage; -import edu.wpi.first.wpilibj.RobotController; import edu.wpi.first.wpilibj.smartdashboard.Field2d; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj.sysid.SysIdRoutineLog; import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.InstantCommand; +import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import edu.wpi.first.wpilibj2.command.WaitCommand; import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine; -import static edu.wpi.first.units.Units.Meters; -import static edu.wpi.first.units.Units.MetersPerSecond; -import static edu.wpi.first.units.Units.Volts; -import static edu.wpi.first.units.MutableMeasure.mutable; +import frc.lib.math.FiringSolutionsV3; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.SwerveModule; + +import org.photonvision.EstimatedRobotPose; + +import java.util.Optional; +import java.util.function.BooleanSupplier; public class SwerveSubsystem extends SubsystemBase { @@ -59,7 +62,8 @@ public class SwerveSubsystem extends SubsystemBase { // Vars private final VisionSubsystem vision; private final SwerveDrivePoseEstimator swerveOdomEstimator; - SwerveModuleState[] swerveModuleStates; + private SwerveModuleState[] swerveModuleStates; + public static boolean followingPath = false; // Characterization stuff private final MutableMeasure m_appliedVoltage = mutable(Volts.of(0)); @@ -70,7 +74,7 @@ public class SwerveSubsystem extends SubsystemBase { new SysIdRoutine.Config(), new SysIdRoutine.Mechanism( (Measure volts) -> { - voltage(volts.in(Units.Volts)); + voltageDrive(volts.in(Units.Volts)); }, this::sysidroutine, this)); @@ -89,87 +93,101 @@ public SwerveSubsystem(VisionSubsystem vision) { // Swerve setup mSwerveMods = new SwerveModule[] { - new SwerveModule(0, Constants.Swerve.Mod0.constants), - new SwerveModule(1, Constants.Swerve.Mod1.constants), - new SwerveModule(2, Constants.Swerve.Mod2.constants), - new SwerveModule(3, Constants.Swerve.Mod3.constants) + new SwerveModule(0, Constants.Swerve.Mod0.constants), + new SwerveModule(1, Constants.Swerve.Mod1.constants), + new SwerveModule(2, Constants.Swerve.Mod2.constants), + new SwerveModule(3, Constants.Swerve.Mod3.constants) }; swerveModuleStates = new SwerveModuleState[] { - new SwerveModuleState(), - new SwerveModuleState(), - new SwerveModuleState(), - new SwerveModuleState() + new SwerveModuleState(), + new SwerveModuleState(), + new SwerveModuleState(), + new SwerveModuleState() }; // Auto setup AutoBuilder.configureHolonomic( this::getPose, // Robot pose supplier - this::setPose, // Method to reset odometry (will be called if your auto has a starting pose) + this::setPose, // Method to reset odometry (will be called if your auto has a + // starting pose) this::getChassisSpeeds, // ChassisSpeeds supplier. MUST BE ROBOT RELATIVE - this::setChassisSpeeds, // Method that will drive the robot given ROBOT RELATIVE ChassisSpeeds + this::setChassisSpeeds, // Method that will drive the robot given ROBOT RELATIVE + // ChassisSpeeds new HolonomicPathFollowerConfig( - new PIDConstants(5.0, 0.0, 0.0), // Translation PID constants - new PIDConstants(5.0, 0.0, 0.0), // Rotation PID constants + new PIDConstants(5, 0, 0), // Translation PID constants + new PIDConstants(5, 0.0, 0.0), // Rotation PID constants 4.5, // Max module speed, in m/s - 0.46, // Drive base radius in meters. Distance from robot center to furthest module. - new ReplanningConfig() // Default path replanning config. See the API for the options here - ), + 0.37268, // Drive base radius in meters. Distance from robot center to + // furthest module. + new ReplanningConfig(true, true, .5, .25)), checkRedAlliance(), this // Reference to this subsystem to set requirements - ); + ); // Swerve obodom swerveOdomEstimator = new SwerveDrivePoseEstimator( Constants.Swerve.swerveKinematics, getGyroYaw(), getModulePositions(), - new Pose2d(1.35, 5.55, new Rotation2d(0)), + Robot.getAlliance() + ? Constants.Vision.startingPoseRed + : Constants.Vision.startingPoseBlue, Constants.Vision.stateStdDevs, Constants.Vision.kSingleTagStdDevs); // Logging - posePublisher = NetworkTableInstance.getDefault().getStructTopic("Fused Pose", Pose2d.struct).publish(); + posePublisher = NetworkTableInstance.getDefault() + .getStructTopic("Fused Pose", Pose2d.struct) + .publish(); swervePublisher = NetworkTableInstance.getDefault() - .getStructArrayTopic("Swerve Module States", SwerveModuleState.struct).publish(); + .getStructArrayTopic("Swerve Module States", SwerveModuleState.struct) + .publish(); - SmartDashboard.putData(gyro); + SmartDashboard.putData("Gyro", gyro); SmartDashboard.putData(this); SmartDashboard.putData("field", m_field); + PathPlannerLogging.setLogActivePathCallback((poses) -> { + m_field.getObject("field").setPoses(poses); + + if (poses.isEmpty()) { + followingPath = false; + } else { + followingPath = true; + } + }); + this.vision = vision; } - /** - * Check alliance for the AutoBuilder. Returns true when red. Using a method for - * better readability - */ + /** Check alliance for the AutoBuilder. Returns true when red. Using a method for better readability */ public BooleanSupplier checkRedAlliance() { return () -> Robot.getAlliance(); } /** Teleop drive method */ - public void drive(Translation2d translation, double rotation, boolean fieldRelative, boolean isOpenLoop) { + public void drive( + Translation2d translation, double rotation, boolean fieldRelative, boolean isOpenLoop) { double translationX = translation.getX(); double translationY = translation.getY(); + SwerveModuleState[] desiredStates; if (fieldRelative) { - swerveModuleStates = Constants.Swerve.swerveKinematics - .toSwerveModuleStates(ChassisSpeeds.discretize(ChassisSpeeds.fromFieldRelativeSpeeds( - translationX, - translationY, - rotation, - getHeading()), 0.02)); + desiredStates = + Constants.Swerve.swerveKinematics.toSwerveModuleStates(ChassisSpeeds.discretize( + ChassisSpeeds.fromFieldRelativeSpeeds( + translationX, translationY, rotation, getHeading()), + 0.02)); } else { - swerveModuleStates = Constants.Swerve.swerveKinematics.toSwerveModuleStates(new ChassisSpeeds(translationX, - translationY, - rotation)); + desiredStates = Constants.Swerve.swerveKinematics.toSwerveModuleStates( + new ChassisSpeeds(translationX, translationY, rotation)); } - SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, Constants.Swerve.maxSpeed); + SwerveDriveKinematics.desaturateWheelSpeeds(desiredStates, Constants.Swerve.maxSpeed); for (SwerveModule mod : mSwerveMods) { - mod.setDesiredState(swerveModuleStates[mod.moduleNumber], isOpenLoop); + mod.setDesiredState(desiredStates[mod.moduleNumber], isOpenLoop); } } @@ -183,22 +201,22 @@ public void setModuleStates(SwerveModuleState[] desiredStates) { } public SwerveModuleState[] getModuleStates() { - /* - SwerveModuleState[] states = new SwerveModuleState[4]; + return swerveModuleStates; + } + + public void updateModuleStates() { for (SwerveModule mod : mSwerveMods) { - states[mod.moduleNumber] = mod.getState(); + swerveModuleStates[mod.moduleNumber] = mod.getState(); } - return states; - */ - return swerveModuleStates; } /** Drive method for Autos */ public void setChassisSpeeds(ChassisSpeeds speed) { ChassisSpeeds targetSpeeds = ChassisSpeeds.discretize(speed, 0.02); - SwerveModuleState[] targetStates = Constants.Swerve.swerveKinematics.toSwerveModuleStates(targetSpeeds); - setModuleStates(targetStates); + SwerveModuleState[] desiredState = + Constants.Swerve.swerveKinematics.toSwerveModuleStates(targetSpeeds); + setModuleStates(desiredState); } public ChassisSpeeds getChassisSpeeds() { @@ -226,13 +244,19 @@ public Rotation2d getHeading() { } public void setHeading(Rotation2d heading) { - swerveOdomEstimator.resetPosition(getGyroYaw(), getModulePositions(), + swerveOdomEstimator.resetPosition( + getGyroYaw(), + getModulePositions(), new Pose2d(getPose().getTranslation(), heading)); } public void zeroHeading() { - swerveOdomEstimator.resetPosition(getGyroYaw(), getModulePositions(), - new Pose2d(getPose().getTranslation(), new Rotation2d(Robot.getAlliance() ? Math.PI : 0))); + swerveOdomEstimator.resetPosition( + getGyroYaw(), + getModulePositions(), + new Pose2d( + getPose().getTranslation(), + new Rotation2d(Robot.getAlliance() ? Math.PI : 0))); } public Rotation2d getGyroYaw() { @@ -249,11 +273,12 @@ public void resetModulesToAbsolute() { * See * {@link SwerveDrivePoseEstimator#addVisionMeasurement(Pose2d, double, Matrix)}. */ - public void addVisionMeasurement(Pose2d visionMeasurement, double timestampSeconds, Matrix stdDevs) { + public void addVisionMeasurement( + Pose2d visionMeasurement, double timestampSeconds, Matrix stdDevs) { swerveOdomEstimator.addVisionMeasurement(visionMeasurement, timestampSeconds, stdDevs); } - public void voltage(double Voltage) { + public void voltageDrive(double Voltage) { for (SwerveModule mod : mSwerveMods) { mod.voltageDrive(Voltage); } @@ -261,38 +286,35 @@ public void voltage(double Voltage) { @Override public void periodic() { + updateModuleStates(); SwerveModulePosition[] modulePositions = getModulePositions(); - for (SwerveModule mod : mSwerveMods) { - SmartDashboard.putNumber("Mod " + mod.moduleNumber + " CANcoder", mod.getCANcoder().getDegrees()); - SmartDashboard.putNumber("Mod " + mod.moduleNumber + " Angle", modulePositions[mod.moduleNumber].angle.getDegrees()); - SmartDashboard.putNumber("Mod " + mod.moduleNumber + " Velocity", mod.getState().speedMetersPerSecond); - } - // Correct pose estimate with multiple vision measurements - Optional OptionalEstimatedPoseFront = vision.getEstimatedPoseFront(); if (OptionalEstimatedPoseFront.isPresent()) { final EstimatedRobotPose estimatedPose = OptionalEstimatedPoseFront.get(); - swerveOdomEstimator - .setVisionMeasurementStdDevs(vision.getEstimationStdDevsFront(estimatedPose.estimatedPose.toPose2d())); + swerveOdomEstimator.setVisionMeasurementStdDevs( + vision.getEstimationStdDevsFront(estimatedPose.estimatedPose.toPose2d())); - swerveOdomEstimator.addVisionMeasurement(estimatedPose.estimatedPose.toPose2d(), estimatedPose.timestampSeconds); + swerveOdomEstimator.addVisionMeasurement( + estimatedPose.estimatedPose.toPose2d(), estimatedPose.timestampSeconds); } - Optional OptionalEstimatedPoseBack = vision.getEstimatedPoseBack(); + Optional OptionalEstimatedPoseBack = vision.getEstimatedPoseBack(); if (OptionalEstimatedPoseBack.isPresent()) { final EstimatedRobotPose estimatedPose2 = OptionalEstimatedPoseBack.get(); - swerveOdomEstimator - .setVisionMeasurementStdDevs(vision.getEstimationStdDevsBack(estimatedPose2.estimatedPose.toPose2d())); + swerveOdomEstimator.setVisionMeasurementStdDevs( + vision.getEstimationStdDevsBack(estimatedPose2.estimatedPose.toPose2d())); - swerveOdomEstimator.addVisionMeasurement(estimatedPose2.estimatedPose.toPose2d(), estimatedPose2.timestampSeconds); + swerveOdomEstimator.addVisionMeasurement( + estimatedPose2.estimatedPose.toPose2d(), estimatedPose2.timestampSeconds); } + // Logging swerveOdomEstimator.update(getGyroYaw(), modulePositions); m_field.setRobotPose(getPose()); @@ -300,85 +322,134 @@ public void periodic() { posePublisher.set(getPose()); swervePublisher.set(swerveModuleStates); - SmartDashboard.putString("Obodom", getPose().toString()); + for (SwerveModule mod : mSwerveMods) { + SmartDashboard.putNumber( + "Mod " + mod.moduleNumber + " CANcoder", mod.getCANcoder().getDegrees()); + SmartDashboard.putNumber( + "Mod " + mod.moduleNumber + " Angle", + modulePositions[mod.moduleNumber].angle.getDegrees()); + SmartDashboard.putNumber( + "Mod " + mod.moduleNumber + " Velocity", + swerveModuleStates[mod.moduleNumber].speedMetersPerSecond); + } + + // SmartDashboard.putString("Obodom", getPose().toString()); SmartDashboard.putNumber("Gyro", getGyroYaw().getDegrees()); SmartDashboard.putNumber("Heading", getHeading().getDegrees()); - + SmartDashboard.putNumber( + "Angle to target", + Math.toDegrees(FiringSolutionsV3.getAngleToMovingTarget( + getPose().getX(), + getPose().getY(), + FiringSolutionsV3.ampTargetX, + FiringSolutionsV3.ampTargetY, + getChassisSpeeds().vxMetersPerSecond, + getChassisSpeeds().vyMetersPerSecond, + getPose().getRotation().getRadians()))); } public void sysidroutine(SysIdRoutineLog log) { - log.motor("drive-left") - .voltage( - m_appliedVoltage.mut_replace( - mSwerveMods[3].getMotorVoltage(), Volts)) - .linearPosition(m_distance.mut_replace(mSwerveMods[3].getPosition().distanceMeters, Meters)) + log.motor("drive-BR") + .voltage(m_appliedVoltage.mut_replace(mSwerveMods[3].getMotorVoltage(), Volts)) + .linearPosition( + m_distance.mut_replace(mSwerveMods[3].getPosition().distanceMeters, Meters)) .linearVelocity( m_velocity.mut_replace(mSwerveMods[3].getMotorVelocity(), MetersPerSecond)); - log.motor("drive-right") - .voltage( - m_appliedVoltage.mut_replace( - mSwerveMods[0].getMotorVoltage() * RobotController.getBatteryVoltage(), Volts)) - .linearPosition(m_distance.mut_replace(mSwerveMods[3].getPosition().distanceMeters, Meters)) + + log.motor("drive-FL") + .voltage(m_appliedVoltage.mut_replace(mSwerveMods[0].getMotorVoltage(), Volts)) + .linearPosition( + m_distance.mut_replace(mSwerveMods[0].getPosition().distanceMeters, Meters)) .linearVelocity( m_velocity.mut_replace(mSwerveMods[0].getMotorVelocity(), MetersPerSecond)); + + log.motor("drive-FR") + .voltage(m_appliedVoltage.mut_replace(mSwerveMods[1].getMotorVoltage(), Volts)) + .linearPosition( + m_distance.mut_replace(mSwerveMods[1].getPosition().distanceMeters, Meters)) + .linearVelocity( + m_velocity.mut_replace(mSwerveMods[1].getMotorVelocity(), MetersPerSecond)); + + log.motor("drive-BL") + .voltage(m_appliedVoltage.mut_replace(mSwerveMods[2].getMotorVoltage(), Volts)) + .linearPosition( + m_distance.mut_replace(mSwerveMods[2].getPosition().distanceMeters, Meters)) + .linearVelocity( + m_velocity.mut_replace(mSwerveMods[2].getMotorVelocity(), MetersPerSecond)); } public Command sysIdQuasistatic(SysIdRoutine.Direction direction) { - return m_sysIdRoutine.quasistatic(direction); + return new SequentialCommandGroup( + new InstantCommand(this::resetModulesToAbsolute, this), + new WaitCommand(0.5), + m_sysIdRoutine.quasistatic(direction)); } public Command sysIdDynamic(SysIdRoutine.Direction direction) { - return m_sysIdRoutine.dynamic(direction); + return new SequentialCommandGroup( + new InstantCommand(this::resetModulesToAbsolute, this), + new WaitCommand(0.5), + m_sysIdRoutine.dynamic(direction)); } + // Pathfinding Commands public Command pathToSource() { if (!Robot.getAlliance()) { - return AutoBuilder.pathfindToPose(new Pose2d(1.21, 0.96, Rotation2d.fromDegrees(58.79)), - new PathConstraints(Constants.Auto.kMaxSpeedMetersPerSecond, Constants.Auto.kMaxAccelerationMetersPerSecondSquared, Constants.Auto.kMaxAngularSpeedRadiansPerSecond, Constants.Auto.kMaxAngularSpeedRadiansPerSecondSquared)); + return AutoBuilder.pathfindToPose( + new Pose2d(1.21, 0.96, Rotation2d.fromDegrees(58.79)), + Constants.Auto.PathfindingConstraints); } else { - return AutoBuilder.pathfindToPose(new Pose2d(15.47, 1.50, Rotation2d.fromDegrees(-59.53)), - new PathConstraints(Constants.Auto.kMaxSpeedMetersPerSecond, Constants.Auto.kMaxAccelerationMetersPerSecondSquared, Constants.Auto.kMaxAngularSpeedRadiansPerSecond, Constants.Auto.kMaxAngularSpeedRadiansPerSecondSquared)); + return AutoBuilder.pathfindToPose( + new Pose2d(15.47, 1.50, Rotation2d.fromDegrees(-59.53)), + Constants.Auto.PathfindingConstraints); } } public Command pathToAmp() { if (!Robot.getAlliance()) { - return AutoBuilder.pathfindToPose(new Pose2d(1.84, 7.59, Rotation2d.fromDegrees(90.37)), - new PathConstraints(Constants.Auto.kMaxSpeedMetersPerSecond, Constants.Auto.kMaxAccelerationMetersPerSecondSquared, Constants.Auto.kMaxAngularSpeedRadiansPerSecond, Constants.Auto.kMaxAngularSpeedRadiansPerSecondSquared)); + return AutoBuilder.pathfindToPose( + new Pose2d(1.84, 7.59, Rotation2d.fromDegrees(90.37)), + Constants.Auto.PathfindingConstraints); } else { - return AutoBuilder.pathfindToPose(new Pose2d(14.74, 7.52, Rotation2d.fromDegrees(90.37)), - new PathConstraints(Constants.Auto.kMaxSpeedMetersPerSecond, Constants.Auto.kMaxAccelerationMetersPerSecondSquared, Constants.Auto.kMaxAngularSpeedRadiansPerSecond, Constants.Auto.kMaxAngularSpeedRadiansPerSecondSquared)); + return AutoBuilder.pathfindToPose( + new Pose2d(14.74, 7.52, Rotation2d.fromDegrees(90.37)), + Constants.Auto.PathfindingConstraints); } } public Command pathToMidfieldChain() { if (!Robot.getAlliance()) { - return AutoBuilder.pathfindToPose(new Pose2d(6.29, 4.08, Rotation2d.fromDegrees(180)), - new PathConstraints(Constants.Auto.kMaxSpeedMetersPerSecond, Constants.Auto.kMaxAccelerationMetersPerSecondSquared, Constants.Auto.kMaxAngularSpeedRadiansPerSecond, Constants.Auto.kMaxAngularSpeedRadiansPerSecondSquared)); + return AutoBuilder.pathfindToPose( + new Pose2d(6.29, 4.08, Rotation2d.fromDegrees(180)), + Constants.Auto.PathfindingConstraints); } else { - return AutoBuilder.pathfindToPose(new Pose2d(10.26, 4.10, Rotation2d.fromDegrees(0)), - new PathConstraints(Constants.Auto.kMaxSpeedMetersPerSecond, Constants.Auto.kMaxAccelerationMetersPerSecondSquared, Constants.Auto.kMaxAngularSpeedRadiansPerSecond, Constants.Auto.kMaxAngularSpeedRadiansPerSecondSquared)); + return AutoBuilder.pathfindToPose( + new Pose2d(10.26, 4.10, Rotation2d.fromDegrees(0)), + Constants.Auto.PathfindingConstraints); } } public Command pathToSourceChain() { if (!Robot.getAlliance()) { - return AutoBuilder.pathfindToPose(new Pose2d(4.18, 2.79, Rotation2d.fromDegrees(59.47)), - new PathConstraints(Constants.Auto.kMaxSpeedMetersPerSecond, Constants.Auto.kMaxAccelerationMetersPerSecondSquared, Constants.Auto.kMaxAngularSpeedRadiansPerSecond, Constants.Auto.kMaxAngularSpeedRadiansPerSecondSquared)); + return AutoBuilder.pathfindToPose( + new Pose2d(4.18, 2.79, Rotation2d.fromDegrees(59.47)), + Constants.Auto.PathfindingConstraints); } else { - return AutoBuilder.pathfindToPose(new Pose2d(12.43, 2.90, Rotation2d.fromDegrees(121.26)), - new PathConstraints(Constants.Auto.kMaxSpeedMetersPerSecond, Constants.Auto.kMaxAccelerationMetersPerSecondSquared, Constants.Auto.kMaxAngularSpeedRadiansPerSecond, Constants.Auto.kMaxAngularSpeedRadiansPerSecondSquared)); + return AutoBuilder.pathfindToPose( + new Pose2d(12.43, 2.90, Rotation2d.fromDegrees(121.26)), + Constants.Auto.PathfindingConstraints); } } public Command pathToAmpChain() { if (!Robot.getAlliance()) { - return AutoBuilder.pathfindToPose(new Pose2d(4.20, 5.30, Rotation2d.fromDegrees(-58.21)), - new PathConstraints(Constants.Auto.kMaxSpeedMetersPerSecond, Constants.Auto.kMaxAccelerationMetersPerSecondSquared, Constants.Auto.kMaxAngularSpeedRadiansPerSecond, Constants.Auto.kMaxAngularSpeedRadiansPerSecondSquared)); + return AutoBuilder.pathfindToPose( + new Pose2d(4.20, 5.30, Rotation2d.fromDegrees(-58.21)), + Constants.Auto.PathfindingConstraints); } else { - return AutoBuilder.pathfindToPose(new Pose2d(12.50, 5.25, Rotation2d.fromDegrees(-120.96)), - new PathConstraints(Constants.Auto.kMaxSpeedMetersPerSecond, Constants.Auto.kMaxAccelerationMetersPerSecondSquared, Constants.Auto.kMaxAngularSpeedRadiansPerSecond, Constants.Auto.kMaxAngularSpeedRadiansPerSecondSquared)); + return AutoBuilder.pathfindToPose( + new Pose2d(12.50, 5.25, Rotation2d.fromDegrees(-120.96)), + Constants.Auto.PathfindingConstraints); } } - -} \ No newline at end of file +} diff --git a/src/main/java/frc/robot/subsystems/VisionSubsystem.java b/src/main/java/frc/robot/subsystems/VisionSubsystem.java index 71d1f96..db858e9 100644 --- a/src/main/java/frc/robot/subsystems/VisionSubsystem.java +++ b/src/main/java/frc/robot/subsystems/VisionSubsystem.java @@ -24,7 +24,6 @@ package frc.robot.subsystems; -import frc.robot.Constants; import edu.wpi.first.apriltag.AprilTagFieldLayout.OriginPosition; import edu.wpi.first.math.Matrix; import edu.wpi.first.math.VecBuilder; @@ -33,24 +32,30 @@ import edu.wpi.first.math.numbers.N3; import edu.wpi.first.wpilibj2.command.SubsystemBase; -import java.util.Optional; +import frc.robot.Constants; +import frc.robot.Robot; + import org.photonvision.EstimatedRobotPose; import org.photonvision.PhotonCamera; import org.photonvision.PhotonPoseEstimator; import org.photonvision.PhotonPoseEstimator.PoseStrategy; import org.photonvision.targeting.PhotonPipelineResult; +import java.util.Optional; + public class VisionSubsystem extends SubsystemBase { private final PhotonCamera aprilTagCameraFront; private final PhotonCamera aprilTagCameraBack; private final PhotonCamera noteCamera; - public final PhotonPoseEstimator photonEstimatorFront; - public final PhotonPoseEstimator photonEstimatorBack; + private final PhotonPoseEstimator photonEstimatorFront; + private final PhotonPoseEstimator photonEstimatorBack; private double lastTimeStampFront = 0; private double lastEstTimestampBack = 0; + private final double maxAcceptableRange = 2.75; + public VisionSubsystem() { aprilTagCameraFront = new PhotonCamera(Constants.Vision.kAprilTagCameraFront); aprilTagCameraBack = new PhotonCamera(Constants.Vision.kAprilTagCameraBack); @@ -58,25 +63,44 @@ public VisionSubsystem() { Constants.Vision.kTagLayout.setOrigin(OriginPosition.kBlueAllianceWallRightSide); - photonEstimatorFront = new PhotonPoseEstimator( //TODO Fix multi tag - Constants.Vision.kTagLayout, PoseStrategy.MULTI_TAG_PNP_ON_COPROCESSOR, aprilTagCameraFront, Constants.Vision.kRobotToCamFront); + photonEstimatorFront = new PhotonPoseEstimator( + Constants.Vision.kTagLayout, + PoseStrategy.LOWEST_AMBIGUITY, + aprilTagCameraFront, + Constants.Vision.kRobotToCamFront); photonEstimatorBack = new PhotonPoseEstimator( - Constants.Vision.kTagLayout, PoseStrategy.MULTI_TAG_PNP_ON_COPROCESSOR, aprilTagCameraBack, Constants.Vision.kRobotToCamBack); - - photonEstimatorFront.setMultiTagFallbackStrategy(PoseStrategy.LOWEST_AMBIGUITY); - photonEstimatorBack.setMultiTagFallbackStrategy(PoseStrategy.LOWEST_AMBIGUITY); + Constants.Vision.kTagLayout, + PoseStrategy.LOWEST_AMBIGUITY, + aprilTagCameraBack, + Constants.Vision.kRobotToCamBack); + + photonEstimatorFront.setLastPose( + Robot.getAlliance() + ? Constants.Vision.startingPoseRed + : Constants.Vision.startingPoseBlue); + photonEstimatorBack.setLastPose( + Robot.getAlliance() + ? Constants.Vision.startingPoseRed + : Constants.Vision.startingPoseBlue); + + // 2024 field quality makes multitag impractical + // photonEstimatorFront.setMultiTagFallbackStrategy(PoseStrategy.LOWEST_AMBIGUITY); + // photonEstimatorBack.setMultiTagFallbackStrategy(PoseStrategy.LOWEST_AMBIGUITY); } - public PhotonPipelineResult getLatestResultATF() { // Get the latest result for the April Tag camera + /** Get the latest result from the front April Tag camera */ + public PhotonPipelineResult getLatestResultATF() { return aprilTagCameraFront.getLatestResult(); } + /** Get the latest result from the back April Tag camera */ public PhotonPipelineResult getLatestResultATB() { return aprilTagCameraBack.getLatestResult(); } - public PhotonPipelineResult getLatestResultN() { // Get the latest result for the Note camera + /** Get the latest result from the Note camera */ + public PhotonPipelineResult getLatestResultN() { return noteCamera.getLatestResult(); } @@ -92,8 +116,7 @@ public Optional getEstimatedPoseFront() { var visionEst = photonEstimatorFront.update(); double latestTimestamp = aprilTagCameraFront.getLatestResult().getTimestampSeconds(); boolean newResult = Math.abs(latestTimestamp - lastTimeStampFront) > 1e-5; - if (newResult) - lastTimeStampFront = latestTimestamp; + if (newResult) lastTimeStampFront = latestTimestamp; return visionEst; } @@ -101,8 +124,7 @@ public Optional getEstimatedPoseBack() { var visionEst = photonEstimatorBack.update(); double latestTimestamp = aprilTagCameraBack.getLatestResult().getTimestampSeconds(); boolean newResult = Math.abs(latestTimestamp - lastEstTimestampBack) > 1e-5; - if (newResult) - lastEstTimestampBack = latestTimestamp; + if (newResult) lastEstTimestampBack = latestTimestamp; return visionEst; } @@ -122,22 +144,22 @@ public Matrix getEstimationStdDevsFront(Pose2d estimatedPose) { double avgDist = 0; for (var tgt : targets) { var tagPose = photonEstimatorFront.getFieldTags().getTagPose(tgt.getFiducialId()); - if (tagPose.isEmpty()) - continue; + if (tagPose.isEmpty()) continue; numTags++; - avgDist += tagPose.get().toPose2d().getTranslation().getDistance(estimatedPose.getTranslation()); + avgDist += tagPose.get() + .toPose2d() + .getTranslation() + .getDistance(estimatedPose.getTranslation()); } - if (numTags == 0) - return estStdDevs; + if (numTags == 0) return estStdDevs; avgDist /= numTags; // Decrease std devs if multiple targets are visible - if (numTags > 1) - estStdDevs = Constants.Vision.kMultiTagStdDevs; + // if (numTags > 1) + // estStdDevs = Constants.Vision.kMultiTagStdDevs; // Increase std devs based on (average) distance - if (numTags == 1 && avgDist > 4) + if (avgDist > maxAcceptableRange) estStdDevs = VecBuilder.fill(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE); - else - estStdDevs = estStdDevs.times(1 + (avgDist * avgDist / 30)); + else estStdDevs = estStdDevs.times(1 + (avgDist * avgDist / 30)); return estStdDevs; } @@ -149,23 +171,23 @@ public Matrix getEstimationStdDevsBack(Pose2d estimatedPose) { double avgDist = 0; for (var tgt : targets) { var tagPose = photonEstimatorBack.getFieldTags().getTagPose(tgt.getFiducialId()); - if (tagPose.isEmpty()) - continue; + if (tagPose.isEmpty()) continue; numTags++; - avgDist += tagPose.get().toPose2d().getTranslation().getDistance(estimatedPose.getTranslation()); + avgDist += tagPose.get() + .toPose2d() + .getTranslation() + .getDistance(estimatedPose.getTranslation()); } - if (numTags == 0) - return estStdDevs; + if (numTags == 0) return estStdDevs; avgDist /= numTags; // Decrease std devs if multiple targets are visible - if (numTags > 1) - estStdDevs = Constants.Vision.kMultiTagStdDevs; + // if (numTags > 1) + // estStdDevs = Constants.Vision.kMultiTagStdDevs; // Increase std devs based on (average) distance - if (/*numTags == 1 &&*/ avgDist > 4) + if (avgDist > maxAcceptableRange) estStdDevs = VecBuilder.fill(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE); - else - estStdDevs = estStdDevs.times(1 + (avgDist * avgDist / 30)); + else estStdDevs = estStdDevs.times(1 + (avgDist * avgDist / 30)); return estStdDevs; } -} \ No newline at end of file +} diff --git a/vendordeps/PathplannerLib.json b/vendordeps/PathplannerLib.json index 787450f..3ec4c12 100644 --- a/vendordeps/PathplannerLib.json +++ b/vendordeps/PathplannerLib.json @@ -1,7 +1,7 @@ { "fileName": "PathplannerLib.json", "name": "PathplannerLib", - "version": "2024.2.4", + "version": "2024.2.6", "uuid": "1b42324f-17c6-4875-8e77-1c312bc8c786", "frcYear": "2024", "mavenUrls": [ @@ -12,7 +12,7 @@ { "groupId": "com.pathplanner.lib", "artifactId": "PathplannerLib-java", - "version": "2024.2.4" + "version": "2024.2.6" } ], "jniDependencies": [], @@ -20,7 +20,7 @@ { "groupId": "com.pathplanner.lib", "artifactId": "PathplannerLib-cpp", - "version": "2024.2.4", + "version": "2024.2.6", "libName": "PathplannerLib", "headerClassifier": "headers", "sharedLibrary": false,