From f11ce98e1e3e9741aabfcdc615494b4d6d5630bb Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Thu, 12 Nov 2015 17:51:00 -0800 Subject: [PATCH] Clean Up Code for FRC 3501-Spark Code: Restructure codebase --- .classpath | 7 ++ .project | 18 +++ bin/org/usfirst/frc3501/RiceCatRobot/OI.class | Bin 0 -> 1189 bytes .../usfirst/frc3501/RiceCatRobot/Robot.class | Bin 0 -> 2662 bytes .../RiceCatRobot/RobotMap$Direction.class | Bin 0 -> 1429 bytes .../frc3501/RiceCatRobot/RobotMap.class | Bin 0 -> 1665 bytes .../RiceCatRobot/commands/CloseClaw.class | Bin 0 -> 1272 bytes .../RiceCatRobot/commands/DriveFor.class | Bin 0 -> 2151 bytes .../RiceCatRobot/commands/MoveArmFor.class | Bin 0 -> 1653 bytes .../RiceCatRobot/commands/OpenClaw.class | Bin 0 -> 1232 bytes .../RiceCatRobot/commands/ToggleClaw.class | Bin 0 -> 1053 bytes .../commands/ToggleCompressor.class | Bin 0 -> 993 bytes .../RiceCatRobot/commands/TurnFor.class | Bin 0 -> 1825 bytes .../frc3501/RiceCatRobot/subsystems/Arm.class | Bin 0 -> 1270 bytes .../RiceCatRobot/subsystems/Claw.class | Bin 0 -> 1814 bytes .../RiceCatRobot/subsystems/DriveTrain.class | Bin 0 -> 2801 bytes build.properties | 4 + build.xml | 30 +++++ src/org/usfirst/frc3501/RiceCatRobot/OI.java | 30 +++++ .../usfirst/frc3501/RiceCatRobot/Robot.java | 69 +++++++++++ .../frc3501/RiceCatRobot/RobotMap.java | 41 +++++++ .../RiceCatRobot/commands/CloseClaw.java | 36 ++++++ .../RiceCatRobot/commands/DriveFor.java | 77 +++++++++++++ .../RiceCatRobot/commands/MoveArmFor.java | 61 ++++++++++ .../RiceCatRobot/commands/OpenClaw.java | 37 ++++++ .../RiceCatRobot/commands/ToggleClaw.java | 36 ++++++ .../commands/ToggleCompressor.java | 43 +++++++ .../RiceCatRobot/commands/TurnFor.java | 54 +++++++++ .../frc3501/RiceCatRobot/subsystems/Arm.java | 48 ++++++++ .../frc3501/RiceCatRobot/subsystems/Claw.java | 50 ++++++++ .../RiceCatRobot/subsystems/DriveTrain.java | 107 ++++++++++++++++++ 31 files changed, 748 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/OI.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/Robot.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/RobotMap$Direction.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/RobotMap.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/commands/CloseClaw.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/commands/MoveArmFor.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/commands/OpenClaw.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/commands/ToggleClaw.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/commands/ToggleCompressor.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/commands/TurnFor.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/subsystems/Claw.class create mode 100644 bin/org/usfirst/frc3501/RiceCatRobot/subsystems/DriveTrain.class create mode 100644 build.properties create mode 100644 build.xml create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/OI.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/Robot.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/RobotMap.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/commands/CloseClaw.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/commands/MoveArmFor.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/commands/OpenClaw.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleClaw.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleCompressor.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/commands/TurnFor.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/subsystems/Claw.java create mode 100644 src/org/usfirst/frc3501/RiceCatRobot/subsystems/DriveTrain.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..daf6ebb --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..f42f1b9 --- /dev/null +++ b/.project @@ -0,0 +1,18 @@ + + + 2015-FRC-Spark + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature + + diff --git a/bin/org/usfirst/frc3501/RiceCatRobot/OI.class b/bin/org/usfirst/frc3501/RiceCatRobot/OI.class new file mode 100644 index 0000000000000000000000000000000000000000..2c6d8ad11bf0c594ceb1247e305340d7b98353ba GIT binary patch literal 1189 zcmb7DZBG+H5Pp^xjvj}UB7%ZaK(R&ScvYl`N{w1=ECJF4zg@4(b@6)J++8L9EFpo! zCj0<@lyUZ2i6$U1m+Z{!-aPZn+mD~$&jG9;uc3=!TKbOJ3=V`Jgyw;7FRv~vnmfYg zc`MwJ6&aePf`&Ll^3eKXnXctIW~p+>?U2E6`9b(zehorle`ZJ*d9`UCHH6tlBh3|+ zL-Y3^Ifi~;IJG}qw2&?w?la6^;aq8kq4a_akgdojsAMP|$K`ohZ}>b2Bw^^CE7v+= z=-CjS2sasGnQWOMo|jdwBZi~_1N{l4a8tw3UwQ3PCcJK77`MnxHYvs7VwAR!=C&`q za5wb1RnPTel%kaiX%VDlgL^veU|ho(!_Xza8@P*m3|d1WxE_IK+Ne=62~v1YE?d@+ zX1Mq766%=1luBTlGRhRPl0o!6OAb$1sz*q7!eq z$9-YHE4>Gnw+(vxMzOl^oX#a;0VFB@AZaO# rUChr{ z(kVFpDH4vxX6QWbW^5g;=#qE>n*};2oq~O_oKM?c%1q~Mfz6YyW#(o~&r$zZgl+!3 zQxb?aCmke@jw7DR`UIWpcnaMbb_>Ls<|wefU=}5wR_xjoc@296jy5%2GgCTx&=mn| zP9g$b!#)9HJy6VvK?7Iaw@0Lp{J4|?8FlBp=n{g~1 zr|_JHae@77`(hpD%|gaVTJu!M*`CB{oDpcx+RS;$HwzX^sXrQfOpX4}eoVPcNSsw^ zZ}rOTPTjY2wp&yrBX|MlHB1O>x@O)qjhtD?8p)t9C0@iNP24iC(lr?zJFYS1IR!uI zd$yS$3*#bhNz8&%$oAAxbxdJe!)1XjYnVwSkrL2~3MofEUC}Cf)wxe`c1-nDM-_23 zb~JH|YLeLz=I#}VSzHm==sDSW|GZ1ij&+?md`w_gH5iYpcwNJ50^Mt;U{zD%4ZO)b zGxD=RnKmYK1GfyOx-O(bG7sz4oyYr#;+xGD0@ z+TLl)cie)yNKPWJE+TXGTX%@vc(Ts5nV)%J@BrJ4zO&Y+8j<#|QXG!-tH2y(BJ} z{=CG;_=JHl(<|VK(D;w{)bpJJ`b^?;1=Kmm!Ivr*?6_O-JvYY`C4JMn&f&8%^Yo-! z_AL9Hqo$%BOr`|I_~{tn zeFqu9A@t%f4q_N5_?d}g1eaMSS1^is9K#J9XQQ6LU5w!yoWu_t>px)}6@DLn!5RF4 dL_;(mtt8|N`q2?Kw(;4rvz^iWl9CpD^$*exdV~M~ literal 0 HcmV?d00001 diff --git a/bin/org/usfirst/frc3501/RiceCatRobot/RobotMap$Direction.class b/bin/org/usfirst/frc3501/RiceCatRobot/RobotMap$Direction.class new file mode 100644 index 0000000000000000000000000000000000000000..5d821e15ecc340e677d9e1cf7ce32d71016d7b1e GIT binary patch literal 1429 zcmbVL?^6;{6g|%c7I0O50~8>$F%4h5H+c7fX09BgWwCY4x;a>qiQfvBKcd zEK57BHIGjjBE17CRu9P;iCoW&uD57N^dE(|;sHahm)4zQxUWCR+h0=<$4l~DZ`Mph zYqb(RQf|uJw#6Mwp7W~BwpG(N4L;(bYojmnbJVSB)J@H9Tl8(KCmrV|`;xp)C6%0M z>Xy)`w`8Ok!vB3=NYl+7OvT7A5?y3D73BT{D3bL=B-e>Zh7*yzCL-Ak@Qrbk5z|5L z9L5Oc@e%q$m_MI?fK~i=q;vSs5D?&jLx7+F<4yr41bE~UU{Zi5vH(*8OuGe`@wt9d zKB(y8EIRk}hc literal 0 HcmV?d00001 diff --git a/bin/org/usfirst/frc3501/RiceCatRobot/RobotMap.class b/bin/org/usfirst/frc3501/RiceCatRobot/RobotMap.class new file mode 100644 index 0000000000000000000000000000000000000000..7668172ba1968da1a1885dfbe82e5345d413fb20 GIT binary patch literal 1665 zcma)+O>^5s7{~u>Cw84EO`DdM0BH#|&?KcwNyA%1Q^%4Wx3(2ljyuD}BRgtQ5K>06 z+wa7U=D-XGJ^&|<9J%ljxH9}#HfEDkt)=q(%dece{cg@DnaqHfEH|9r=(*PC`m%7SIy zn24%Q>px^xccAjx9+34E6nsnNoo+?MlS?yI_p5<1GS=KyONV_7Z_W5a?OguF& zu)eW*)@bD{?y=QLu&g(#&oK2%R>SR7+Eq5BT0CsJHfLlNc7Oci=3jq*xGiw0B3oG< z0wuMa<}M0cR)T%T?zsoHO|L)M0w3ndyqxD_1*>~3ce22n74EResu)@90SeB_s~h3z693ano|vw_dB!HD12 z;^eiL9F;hRFAS_>Lxuawz@xER`mg*XWe$O_4cx;l(jBzM=6=^4l6K{j$a? z-a8tr{O@Y4>U|F@(|&G|-`DiYepTZS$aggRGWnx({IO=Q=5tqLm2XXBrRP!2Cd)I) zZ%G}*jPIYZ%X8KyHd*NdYIiw%^;~;{Pfzjr8+>_+o$GjfiYGr&oWma9OPJw%g<)>N zz-{s>s+m^(SMbzMf|>jZ%4gSqhW)?0+GWsDxfo*u)Ui)0p)qw{C96lAcPvkH&2c^Z#r8^YhpD9{^TRQITL+cHBcF@D7CQ`Nn~3 zEw7drja^~!s_E}K4aYYur`0msP0y&>j>oIEd7?sLnBvXAIOzx@Dy5Yz8pr3ijcQcI zka{ZG!hgn)EY0jQC{?G)H6)SI(T7w9{TNW8Gfejs63Wq$MUF5Q>0nr@^{n!OhWEkq zc}p5FPbwN1hI9;Lgdy$nw}EiE$1q>2{o7FeoKulDay8NBTS2SA-958mbB5uXW1058 z=?b~;9xDEkAoyx;nSXb=!l2343DXuIc?M&+sbZXA@YsB38n)R!H0q%-9k+0s`s)Nf zL%tTi7LKvwind?(U2e82X%xxz=2mfYYjdwyt!>v|RBP+6G~C5K6_X4jS5)bk!Zd^0 zks!NG>{0}ezU|ZTVb~0nzvouq(^zLPr(%|&{J&$-F^?2O#yZbf8Vd}%j2wNX7)@If z-UfBVJL1hSPOsBgV(6D+Er#K2N(C!AR#B$l32(c@N%lb9H?21>%}#eHN#3UVelo>f zH|Y41rq!LmwfKgRqs+!hUyyCV1VtuE{|u0#6{VJ*D(#*jK`TI?{f6}HDYP>Tex-c^ z*XWrIYjh|Wppa*gmp7yP7)6103a-bjwJs}jiW|ds&MaYgY literal 0 HcmV?d00001 diff --git a/bin/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.class b/bin/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.class new file mode 100644 index 0000000000000000000000000000000000000000..c4bf05dcfea903b752e8b83bf5ab61caf72f3b0b GIT binary patch literal 2151 zcmbVN-ES0C6#w1*n(pkh+jfgeOBE>n*o88sOIvD@ZP{g&wg|ROl`87&>}?skyVK0f zqLBEc@lhWEQ4(J8L1H4Y#b{!m^}(3nlcYprp z`yT-u$BKji!?0j&xk>?xo(m*1Isal9iz-GhVI#&%@>4tf+1QoEUr6- zSz#EN-IbzC^qjVKC|5HhjL1o&VmPN5#s_jw1(9522xZM8mk~rTE*lh$ zm5l3LLKj2V6XGbN6LG=tc?A-h#CE@e1L788i`(20Cp`)dxhJ-xSq|lkzt8om!=va& zQo;a3>lN*)rk1qIiaLMIc6eDq3Wq5YW|j2!%(`O3R4-UY#hG_3u9YVQ@}PpFP)Tov zlODw_C*v5>5{4NPI~XZclOsf6P2iL$@u7j7i1ir8C7fVLKSdcRcu}NA%AcQmeQGWj z$^3Lne4j;e3X>8t41NC(RlyWaQ}~Ob2No>NAbuxyPoZ5c*lx`H?r|+ABAdUZ-A_gy zuSj^AVRTm-J3=Wqi)n_KX6agyyA4Xo9mrAOBAGwEyGAx2QNPm{+5FX8h?vePm=~dG zIz5%0@nYkXiew&nYLSeu&(J*YX!p&Jy5{hr zOr`g(f=i;jeoqnr(Ai0%;_74M(lz>8+?YJ=Hex zAo4*3M0e6EAS&OTsYhv!kVXs&jm@;XNSYy<T?t15b}w3eHy3CxWSyxW(0TD8_N}8k^)0$L@PaoT z-0rcHNOqC;eT35OdK8oi!S@(KZw;N@buR^$cz`|+?#Kp)XhjF3_wa##MpIh{CRT5L zj@AcwsRP-T4V?KBzi*S@xQ(92j%HSGe&L&(^Gv>Kkk{ePd$LanyTx06L~6w0wR^bU zVDK1+1y6HnoBT-}7Cn>x29r96H#}La#zBNN2$9GoH;4x)>jx=>J@kV0(sR>?X?o@^ z(QXBYaSccCAqMd=y<4AP2)F6E`WnOd4r%;C+J9gKe_<4VV~mLxNya#9$H}equ!NtU zCGsevX>7PlP7Zg`|0UkUTYfR*X(v*dXt=seNx7KI5C{Wrvb?~8EoCH`mj02x z^$}ipDbs|Rc80$9SMW{kFig#$2kq|JbH4AKv)}pW-#_00IElK6oWRL2dhB-M zM=FXF_fh08EY8ilca$%yUUDaFgo*2i?Y0**WA{e*TwaXYD`8~95SWn7j{DQPa=WqI zwN&Hjmb+W+h6$Ll^h3rAh?+nlQEeFsjMhILepg>F3zV8Fl76DXKwz=nGs!g78{YbO zZ7Ylz#j`3<$vJ`3)3q;xsH_PX)vzfols?gVmSyRxl-E+fNE3$y4*gFjEgVEy z=XltLi9UTCvvE|{QHT>SO87qVXX$qmS;9CbO-u+Zd_lWyOz9Tn?%gh-g5xF}fyvLq zv2g-3?5h{G1?GEqCGIrh7jYunu}e8F7yo`wJ@d0Lj|CIo3AjCpKg6&(4vPYIEE6KG zu1l%qYE0MkOONA}jqi1FM(x)9o5l0*Q#SVWtJTEwpHX$$!&)j{;oHPdWHXh?L*4H4 zHZI^I&yOXWP4RFD@-m=DzX}o=MV<9THZ8(kwsA>6jI|neB44g3t)TMG)XhHio_oyl zY7oe%+VbL9#wM-_RC<=XH6EO+?E#?*mI5Qg<`aKQU&;Q=^`T+l5b09`A!19M_A4_SlcbZ7Uj$kmO zxy-Y^8*=`_!3S^g%?3uDKQOw9BRfI|k ziSipv@5AgS=3ZgAYh8K?JGGvsRWs$GiyCIKpa?8X5POnbQxte*7o(FgF4NCIZdkYB zEPlw!kv!?VD%~2+aoO|hZ?H%;K%x(=1><%8HJ!WE-6Ch$uUXQ~?V_xFL^((jYA2&y z%F6A_ICk1*@ri*&KJ(Hpw7%_@Rktw~h^5mmIGd<_3~+{Y%ew#y89)vz49Vd~T;ZxU LJ&vomeqrQ4^C(#? literal 0 HcmV?d00001 diff --git a/bin/org/usfirst/frc3501/RiceCatRobot/commands/OpenClaw.class b/bin/org/usfirst/frc3501/RiceCatRobot/commands/OpenClaw.class new file mode 100644 index 0000000000000000000000000000000000000000..9702213982737854740e651c98c65a806906823e GIT binary patch literal 1232 zcmb7@T~8B16o%h{+HJQB#UfvVS`@H+$doTpt0bh6grq5i5=^|?ZU-2$-L3l}>TmK! zE->-JAK;HNp4lxeMqAth(L_5B+25`2j!nthJ5e z3O|sRD4W57TXzF)xy`2OGDAR&ov|%WWw#-8^doKH4w7kPFrdL;nCs~ya${f+S;AQ4gUnZYs{F9-fA#~>^ttk0 z(!p@oKn}wUDNlR|r6+ubr9$QZ4b`qVCDlf@A{|i;n|0wGnsr++xz*L&OiC*%@?u9B0cEx(8~?qf>BB*V~|`O)OI>74Ld)R%z=cu4WOVZbm_iC#;W z?|ae-YJn%rW+{a{33sdc-RkaPesBM6wOrYLr{ghZG(2G#zCmPQ7IO?*OL1(6(1n;C ze>$M!lPC&Jd=gd|(522}QNsd5@wS&@UYTW1}d39|n41b66@J~e} znx*$CtTJTO%e<--4P{{6zy^vmb<$UdR4E*)&rlD-^TJl3)OyVgJxlCJb#DWzPEnRs z2$-hv=%?QUNYaWXl%5*xw$Mi_z*zW>)WQYyOALLZeIM@8b1>2jAVI4PvKUd7aXm&c zM!N*YJFLw%D}8~9+@niOcR@P60u5&h!`C3`4&-SEvfYMcBQFJodiED8_B2X@F>*D2 z4VUfUIEwB5-gI#jxfKFM*tM_ZCT=lyHc8H=ZbUurI9nu*ii&mHQYnJ6?dHNd9yWUm NXKoNOyokKL`~%&{{lfqN literal 0 HcmV?d00001 diff --git a/bin/org/usfirst/frc3501/RiceCatRobot/commands/ToggleClaw.class b/bin/org/usfirst/frc3501/RiceCatRobot/commands/ToggleClaw.class new file mode 100644 index 0000000000000000000000000000000000000000..743e4e161badbde810fd147134086531cdd61ee2 GIT binary patch literal 1053 zcmbVKO>fgc5Pj>ob(6Xc4M}JyA1S4!1%wMNT#C3v>M78wje4lWVdHGmEsh;|*A)0C z{RLdOfcTI&@B{c!z^wBrgcJ$c-kllGdo%lHfByRZ1Hd*m99Rt7QQYy_4AA zdc672JCMGpaeWXqBklQ7r^CaR@)}XQ9f(@M&mGtdtD=>7=UwUbuw(_Yc{WJ*YCRak z^ivs1{fr^AzH!80*P@olA%m=oDNHlu>oOECl1@{^4c-g{L!ln|JUHU9G=4v5>r<&1 zp49)R;T?vY=|b{Az7ttoLczfT!`ei$R09{6QKZ&=Iy=Lo$t|d)sop9rI?6M8?PO8L zqJt|8n-eSkg>_NERfZXzs=pU9uw#a~L(TnH&w016jw9X(KhY#?88=+qM3sb>YOgB@ zK*ArJAGchr7{#-G5UF&KMi#Y8%BWM(qC^qWIx9mh;yCGQ6U!Y&N$iVVX(p2&-GK*Z z{58ii2u0Tkm?n$nNvlKN7VV7osk`4W^N|b-Ia+hH11@aLV>Y$YB#O+DXQBgwmy~J# zl|CU)?`M=Q;AGyzw!ffc2s2}Z3n-#6Mp)_-E>T_)*1m)CZ!(!flomNON?aS3YV>=p z4C)lf_=@Wn$fm~fsN8&d*b)_^dD1gFLuIUF25gZk+(wm{jT-m+6)gJ$c|9r2L4l<) k3Tr6C>ae$arfu_$H0%MZV?Z_pu1yB6`~%2vC+%zf4@o1$?EnA( literal 0 HcmV?d00001 diff --git a/bin/org/usfirst/frc3501/RiceCatRobot/commands/ToggleCompressor.class b/bin/org/usfirst/frc3501/RiceCatRobot/commands/ToggleCompressor.class new file mode 100644 index 0000000000000000000000000000000000000000..e3c3c34365a36d8dc228b21c410da839e1962f93 GIT binary patch literal 993 zcmbVK!EVz)5Ph3CF>xINfrN$vErmcS2!je2T5*ZgQ{d26Jyhbbakl9eCu^ zfD0EmfW(0h;G+<;j&UMX6bV_{of*%YdGls}{`&p{z!Pk^C^0-!dK9F|vDAqPj&->8 z^wHyBPllq$&7K-46NG9!=96I(9H`MK59BP-STJf?%cB20~_;UX@%XfoVcSUgk4$7Qsr7zvas!m!>yTaTG) z+a9i<<6@a%ZBed|t5~rNCsqPdk;FT)`0GAySk;`wsMrS9eB88wN@BP+4E24(!`Cl( zoa^SvWS53cPO>V(Ze&SLjLZIj%HMG6Kn&>Z09CSRZFIWi zZPCr>u55n8xzA*j;L+*P4ft?S$5LixNffD*=iq!%;6C~GADe+~ZO}$$Kvn=71@Kkg zx$^}VzM}mBer8+JfbbO`8Y;#V;KM2jozP+-#v~2D;wk%oUj@R%))ArhJ%WVc`z2mzT&)1L;xGI|+^Q(Qw>^f3v zIgO{swq~j8BcKJ+_UJ4i$^yyIX-i*Vs(QA2T|I9Iq??W}?a=XDfz|3jh7r&E*8Xhy z*o_#en~v**w*+qF%dZ7d*cC{Wyr$FbUYj zr`?c#-D@z=DRNz}){s zGVl(rF|nraJd<_ba@g_fgKHCX8o@U~DBFQq?t5;e{&>a7=AVvbtY~;wU~M3cGocLb z$Ev`P<=a+MMj=?Xe7UT;KZ|t(*HzBRo$b5#>Z#kWqNuF(xmsx1Uvd1ZH?>XKc(K5j^TYP~`asCj)#cPKc`6Y4~${)(w1Ts{evi6F#o`f`e#VuqdabX%5vhliO@^Wh8;8np zngs$T$@vmSF~t&2V*!`3h#9OgpvtyOW4%XXgPJ7b6XX2d#!bB6OY-|3qs;@{>Lyn{ z!oBWgm{L#2WB7+3(P#2cbu#fh{+#$-ZsUXm=Gdxv#?DhJkk`T~PMfDVB@kQ8krKzP zM`?lHsz~Cb%Bugs(kTehukOcv#}!&ByJYbQ4^NzRj+6RFm%!>NfMgFKh8@1fP(z)k Nn*CXPiqGy`_#0qkhLivR literal 0 HcmV?d00001 diff --git a/bin/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.class b/bin/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.class new file mode 100644 index 0000000000000000000000000000000000000000..46953347586352bb758814aeb693a074e0ef5616 GIT binary patch literal 1270 zcmb7C+fEZv6kUg2rc8%IYq`lC)M?9QKtN428Z1#Xg$GJVe4MsZ7-&1q%v9pDAK@j& zSL36Jg3-he@S}|DOlu*A#MnvC+54Qm*Is+=^YhoY9{|>HM?sH(;kXAz%d6V1=NnbG zyt=-;V(i*wD{uO{PRa2NuT}D1c)nHlj19N0AS|F;m6mbRw2gKet(sjrGRjW9ZZ;}L z@lS?8xMo#-ftkYP8TpN!r{+P+bngm8T>IdVvC(^W!}jkBgfiKEBIKQlr6L4PLkztN z5&~2IKvU6&0U4fTe&$JbzZU{mG(-@U)}RIjQGxz~-LQ6A^^)c8nWdT~kSaK3v$k)# zw)8uPVgJzf1Xc?FDHVH4$yPS4s@baf`L;SNTV>h3R>R6W4c~QYlH+D}U&SP*6-)^v zj?Cw#Q8OC{#eo+S1A(%j!9vMi3g%q&AejL+BylB_TEU87ckb6bt7q zsR7g!yPm!Pt#+YR7y-19!@C48eJS1?@vi*?Pd3vQ>~V)*T*|Q`m(_EEiGaG!zA{ud zdjT}wB^mFMT}H literal 0 HcmV?d00001 diff --git a/bin/org/usfirst/frc3501/RiceCatRobot/subsystems/Claw.class b/bin/org/usfirst/frc3501/RiceCatRobot/subsystems/Claw.class new file mode 100644 index 0000000000000000000000000000000000000000..99b47d35d0cc620d456d55563fa3482ef87384f3 GIT binary patch literal 1814 zcmb7E+fEx-6kP`o3?7CMoO_y*6e!qE!f#ie9cDx?cgV>6adh}Zq%dN;NdG?MDO<-C!5^HDMwc381d2aoc zw%@R-2QC7GQQ%2Ga2oOe}@`ckx6Bw?>w)2`vcSffWp^Vb#QsFxWp)Y=^Oqr|j&L<{b|+Os1_ZFn$DRw8LjEwGku4n(q?( zy@R;4i-q?%^A>k^@r~BPgEzRstrnKwU}7ID&-d^{3*|p?vAz2i!~3Xk_gM>TN|AQ- z@wC2Etj;uRlgBj_Fvb2aFok*C=2e_K!ffdXGYx%(9LfAdtUmmVb^cX{RQVYFg6w}3 CrI?if literal 0 HcmV?d00001 diff --git a/bin/org/usfirst/frc3501/RiceCatRobot/subsystems/DriveTrain.class b/bin/org/usfirst/frc3501/RiceCatRobot/subsystems/DriveTrain.class new file mode 100644 index 0000000000000000000000000000000000000000..1cc56541d28e7d5e7f51f632ecb5bab2714e57bc GIT binary patch literal 2801 zcmbVOTT@e46#fn&IRp*?Ap&0TLe&tk1_iAsh?t;&0TmE0wdzSYgaaYLb54x3FMaBZ zZ_aeuhqe!$ahz!%I&~DabvonpP1~8yl!yKSe?p%+?eyC_CxO;DP8$aH+H0?G?X|yk z3D5uf?gs!p_&`O4fTHvQEU#CG2I}F&6De z%rb8pQ-tac-q6$3M!-YQw>|JH0 zGiTZg4#)pr8M7>EErW5mtlJ{KBN~n(puj6nXpu4;S#y(1hA|@xCMN6#G#p320#%&r z4nx!^i9&S^>x;nRD+Ma1VMw5Acv#f)xh`@|6JS(hStn~rXMCf#Jw|4#F^af~(+UFf z`b|BO)-$QdnC{GJ7{fS&(-X86B*y$WiwPCy6olW%j%@WYeM!S4rWj6aVq|*gT5M=A zcJ1<+@gW5YpWJ|H4Hrb}JPeLqEjrMBYqjhycT+p*=*b1TbF);VTS6l7Br->$Z!_* zTP{HiQ$be4DGU>_JgujB;N)3mWK6`n#wnjEgI=#`5JMqm%<8$c6D`a!PNT_e&Pp05 zO;Lt*YeR6K$N;lGlF1lWG_BjVVXIi?ha7lfH;6pS^xk}2Lr0kRO7Ae;kHm%%j zzvNRr_p$R4LJ!d)72e8{VsFO-bOf<)1znW(7Nl=wG(G%#gmHksm5imHKU=W@?JS#v zXha`^h;luNjfkTOQ(P~g89G|9fK9XkCxwh1hwu(}Z0pjy2DuYwbs~Tj^orZLtX&&Rt!}T_5`CM9_4A^a^)X1wY5Wp_&sIu zC(7daj_AMd?<|WySr*UxU%_{k#j_{e_uplTynJVW=rKm_CaT{h zl_B6FYeA6Sk4uz1xJV3# z8{+wVuX+!?p>SS^)Fj0|ERBMpyfDa@)GjJ7jq|-~M~k;bT|s7zNsB!L46<)duvel8 zA%-x&Fb=S94s)mtl8;lId=ofLuFi2VPU3w^AL2Yd!ZdEPr|yu^kICidWb#W~!CkzE zuW=O*a1Bpz9Z%VF&yc_i82A;lGAm1RmaLYtvWg`)E33F6vvQjg*P`U5-zrynP?DZ8 z+QR7_X3(ac%Daowlalm;IV_xtEN_6nX=9*9`vb@8n*Kz<<6+{RQqy + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org/usfirst/frc3501/RiceCatRobot/OI.java b/src/org/usfirst/frc3501/RiceCatRobot/OI.java new file mode 100644 index 0000000..8477f98 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/OI.java @@ -0,0 +1,30 @@ +package org.usfirst.frc3501.RiceCatRobot; + +import org.usfirst.frc3501.RiceCatRobot.commands.ToggleClaw; +import org.usfirst.frc3501.RiceCatRobot.commands.ToggleCompressor; + +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.buttons.JoystickButton; + +public class OI { + public static Joystick leftJoystick; + public static Joystick rightJoystick; + public static JoystickButton trigger; + public static JoystickButton toggleCompressor; + public static JoystickButton toggleClaw; + + public OI() { + System.out.println("OI is open"); + leftJoystick = new Joystick(RobotMap.LEFT_STICK_PORT); + rightJoystick = new Joystick(RobotMap.RIGHT_STICK_PORT); + + trigger = new JoystickButton(rightJoystick, RobotMap.TRIGGER_PORT); + + toggleClaw = new JoystickButton(rightJoystick, RobotMap.TOGGLE_PORT); + toggleClaw.whenPressed(new ToggleClaw()); + + toggleCompressor = new JoystickButton(rightJoystick, + RobotMap.TOGGLE_COMPRESSOR_PORT); + toggleCompressor.whenPressed(new ToggleCompressor()); + } +} \ No newline at end of file diff --git a/src/org/usfirst/frc3501/RiceCatRobot/Robot.java b/src/org/usfirst/frc3501/RiceCatRobot/Robot.java new file mode 100644 index 0000000..f82f4b2 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/Robot.java @@ -0,0 +1,69 @@ +package org.usfirst.frc3501.RiceCatRobot; + +import org.usfirst.frc3501.RiceCatRobot.subsystems.Arm; +import org.usfirst.frc3501.RiceCatRobot.subsystems.Claw; +import org.usfirst.frc3501.RiceCatRobot.subsystems.DriveTrain; + +import edu.wpi.first.wpilibj.Compressor; +import edu.wpi.first.wpilibj.IterativeRobot; +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.command.Scheduler; + +public class Robot extends IterativeRobot { + static Timer timer; + public static OI oi; + public static DriveTrain driveTrain; + public static Arm arm; + public static Claw claw; + public static Compressor compressor; + + public void robotInit() { + RobotMap.init(); + driveTrain = new DriveTrain(); + arm = new Arm(); + claw = new Claw(); + oi = new OI(); + compressor = new Compressor(RobotMap.COMPRESSOR_PORT); + } + + public void autonomousInit() { + } + + public void autonomousPeriodic() { + Scheduler.getInstance().run(); + } + + public void teleopInit() { + System.out.println("running teleopInit"); + } + + public void teleopPeriodic() { + Scheduler.getInstance().run(); + + } + + public void operate() { + driveTrain.arcadeDrive(OI.rightJoystick.getY(), + OI.rightJoystick.getTwist()); + claw.doTriggerAction(); + if (OI.leftJoystick.getRawButton(8)) { + arm.setArmSpeeds(0.3); + } else if (OI.leftJoystick.getRawButton(9)) { + arm.setArmSpeeds(-0.3); + } else if (OI.leftJoystick.getRawButton(6)) { + arm.setLeft(0.3); + } else if (OI.leftJoystick.getRawButton(7)) { + arm.setLeft(-0.3); + } else if (OI.leftJoystick.getRawButton(11)) { + arm.setRight(-0.3); + } else if (OI.leftJoystick.getRawButton(10)) { + arm.setRight(0.3); + } + if (Math.abs(OI.leftJoystick.getY()) < 0.05) { + arm.setArmSpeeds(0); + + } else { + arm.fineTuneControl(OI.leftJoystick.getY()); + } + } +} \ No newline at end of file diff --git a/src/org/usfirst/frc3501/RiceCatRobot/RobotMap.java b/src/org/usfirst/frc3501/RiceCatRobot/RobotMap.java new file mode 100644 index 0000000..4bf6e4a --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/RobotMap.java @@ -0,0 +1,41 @@ +package org.usfirst.frc3501.RiceCatRobot; + +import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.DoubleSolenoid.Value; + +/** + * The RobotMap is a mapping from the ports sensors and actuators are wired into + * to a variable name. This provides flexibility changing wiring, makes checking + * the wiring easier and significantly reduces the number of magic numbers + * floating around. + */ +public class RobotMap { + public final static int LEFT_STICK_PORT = 0, RIGHT_STICK_PORT = 1; + public final static int TRIGGER_PORT = 1, TOGGLE_PORT = 2, + TOGGLE_COMPRESSOR_PORT = 11; + public static final int DRIVE_FRONT_LEFT = 4, DRIVE_FRONT_RIGHT = 5, + DRIVE_REAR_LEFT = 3, DRIVE_REAR_RIGHT = 6; + public static final int DRIVE_LEFT_A = 3, DRIVE_LEFT_B = 4, + DRIVE_RIGHT_A = 2, DRIVE_RIGHT_B = 1; + + public static final double DISTANCE_PER_PULSE = ((3.66 / 5.14) * 6 * Math.PI) / 256; + + public static final int ARM_LEFT = 2, ARM_RIGHT = 7; + public static final double ARM_HIGH_SPEED = 0.5, ARM_LOW_SPEED = 0.5; + + // Claw + public static final int SOLENOID_FORWARD = 0, SOLENOID_REVERSE = 1, + MODULE_NUMBER = 0; + public final static Value open = DoubleSolenoid.Value.kForward, + close = DoubleSolenoid.Value.kReverse; + public static double DRIVE_DEAD_ZONE = 0.25; + // Compressor + public static final int COMPRESSOR_PORT = 0; + + public static void init() { + } + + public static enum Direction { + LEFT, RIGHT, DOWN, UP, FORWARD, BACKWARD; + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/CloseClaw.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/CloseClaw.java new file mode 100644 index 0000000..eb0eea2 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/CloseClaw.java @@ -0,0 +1,36 @@ +package org.usfirst.frc3501.RiceCatRobot.commands; + +import edu.wpi.first.wpilibj.command.Command; + +import org.usfirst.frc3501.RiceCatRobot.Robot; + +/** + * + */ +public class CloseClaw extends Command { + + public CloseClaw() { + requires(Robot.claw); + } + + protected void initialize() { + System.out.println("IN INIT CLOSECLAW"); + } + + protected void execute() { + Robot.claw.closeClaw(); + System.out.println("Closing claw"); + } + + protected boolean isFinished() { + System.out.println("Claw Closed"); + return !Robot.claw.isOpen(); + } + + protected void end() { + + } + + protected void interrupted() { + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java new file mode 100644 index 0000000..b935311 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java @@ -0,0 +1,77 @@ +package org.usfirst.frc3501.RiceCatRobot.commands; + +import org.usfirst.frc3501.RiceCatRobot.Robot; +import org.usfirst.frc3501.RiceCatRobot.RobotMap.Direction; + +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.command.Command; + +/** + * This command takes a time in seconds which is how long it should run + * + */ +public class DriveFor extends Command { + private double seconds; + private Timer timer; + private Direction direction; + + public DriveFor(double seconds, Direction direction) { + this.seconds = seconds; + this.direction = direction; + + } + + @Override + protected void initialize() { + timer = new Timer(); + timer.reset(); + timer.start(); + } + + @Override + protected void execute() { + System.out.println(timer.get()); + if (direction == Direction.FORWARD) { + if (timer.get() < seconds * 0.2) { // for the first 20% of time, run + // the robot at -.5 speed + Robot.driveTrain.arcadeDrive(-0.3, 0); + } else if (timer.get() >= seconds * 0.2 + && timer.get() <= seconds * 0.8) { // for the +20% - 75% + // time, move the robot + // at -.3 speed. + Robot.driveTrain.arcadeDrive(-0.5, 0); + } else if (timer.get() < seconds) { + Robot.driveTrain.arcadeDrive(-0.25, 0); + } else { + Robot.driveTrain.arcadeDrive(0, 0); + } + } else if (direction == Direction.BACKWARD) { + if (timer.get() < seconds * 0.2) { + Robot.driveTrain.arcadeDrive(0.3, 0); + } else if (timer.get() >= seconds * 0.2 + && timer.get() <= seconds * 0.8) { + Robot.driveTrain.arcadeDrive(0.5, 0); + } else if (timer.get() < seconds) { + Robot.driveTrain.arcadeDrive(0.25, 0); + } else { + Robot.driveTrain.arcadeDrive(0, 0); + } + } + } + + @Override + protected boolean isFinished() { + return timer.get() > seconds; + } + + @Override + protected void end() { + Robot.driveTrain.arcadeDrive(0, 0); + } + + @Override + protected void interrupted() { + end(); + } + +} \ No newline at end of file diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/MoveArmFor.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/MoveArmFor.java new file mode 100644 index 0000000..e94f859 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/MoveArmFor.java @@ -0,0 +1,61 @@ +package org.usfirst.frc3501.RiceCatRobot.commands; + +import org.usfirst.frc3501.RiceCatRobot.Robot; +import org.usfirst.frc3501.RiceCatRobot.RobotMap; +import org.usfirst.frc3501.RiceCatRobot.RobotMap.Direction; + +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.command.Command; + +/** + * This command takes a time in seconds which is how long it should run to move + * arm up or down + * + */ +public class MoveArmFor extends Command { + private double seconds; + private Timer timer; + private Direction direction; + + /* + * @param Direction must be up or down + */ + public MoveArmFor(double seconds, Direction direction) { + this.seconds = seconds; + this.direction = direction; + } + + @Override + protected void initialize() { + timer = new Timer(); + timer.start(); + } + + @Override + protected void execute() { + if (direction == Direction.UP) { + Robot.arm.setArmSpeeds(-RobotMap.ARM_LOW_SPEED); + } else if (direction == Direction.DOWN) { + Robot.arm.setArmSpeeds(RobotMap.ARM_LOW_SPEED); + } + } + + @Override + protected boolean isFinished() { + if (timer.get() > seconds) { + Robot.arm.setArmSpeeds(0); + } + return timer.get() > seconds; + } + + @Override + protected void end() { + Robot.arm.setArmSpeeds(0); + } + + @Override + protected void interrupted() { + end(); + } + +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/OpenClaw.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/OpenClaw.java new file mode 100644 index 0000000..bece53b --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/OpenClaw.java @@ -0,0 +1,37 @@ +package org.usfirst.frc3501.RiceCatRobot.commands; + +import edu.wpi.first.wpilibj.command.Command; + +import org.usfirst.frc3501.RiceCatRobot.Robot; + +/** + * Opens claw by reversing solenoids. + * + */ +public class OpenClaw extends Command { + + public OpenClaw() { + requires(Robot.claw); + } + + protected void initialize() { + System.out.println("IN INIT OPENCLAW"); + } + + protected void execute() { + Robot.claw.openClaw(); + System.out.println("Opening Claw"); + } + + protected boolean isFinished() { + System.out.println("Claw Opened"); + return Robot.claw.isOpen(); + } + + protected void end() { + + } + + protected void interrupted() { + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleClaw.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleClaw.java new file mode 100644 index 0000000..f746056 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleClaw.java @@ -0,0 +1,36 @@ +package org.usfirst.frc3501.RiceCatRobot.commands; + +import org.usfirst.frc3501.RiceCatRobot.Robot; + +import edu.wpi.first.wpilibj.command.Command; + +/** + * + */ +public class ToggleClaw extends Command { + + public ToggleClaw() { + + } + + protected void initialize() { + Robot.claw.toggleOn = !Robot.claw.toggleOn; + } + + protected void execute() { + if (Robot.claw.toggleOn && Robot.claw.isOpen()) { + Robot.claw.closeClaw(); + } + } + + protected boolean isFinished() { + return true; + } + + protected void end() { + + } + + protected void interrupted() { + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleCompressor.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleCompressor.java new file mode 100644 index 0000000..5f3fad1 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/ToggleCompressor.java @@ -0,0 +1,43 @@ +package org.usfirst.frc3501.RiceCatRobot.commands; + +import org.usfirst.frc3501.RiceCatRobot.Robot; + +import edu.wpi.first.wpilibj.command.Command; + +/** + * + */ +public class ToggleCompressor extends Command { + + public ToggleCompressor() { + } + + // Called just before this Command runs the first time + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + if (Robot.compressor.enabled()) { + Robot.compressor.stop(); + } else { + Robot.compressor.start(); + } + + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return true; + } + + // Called once after isFinished returns true + protected void end() { + + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/TurnFor.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/TurnFor.java new file mode 100644 index 0000000..9be3779 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/TurnFor.java @@ -0,0 +1,54 @@ +package org.usfirst.frc3501.RiceCatRobot.commands; + +import org.usfirst.frc3501.RiceCatRobot.Robot; +import org.usfirst.frc3501.RiceCatRobot.RobotMap.Direction; + +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.command.Command; + +public class TurnFor extends Command { + private double seconds; + private Timer timer; + private Direction direction; + + public TurnFor(double seconds, Direction direction) { + this.seconds = seconds; + this.direction = direction; + } + + @Override + protected void initialize() { + timer = new Timer(); + timer.start(); + } + + @Override + protected void execute() { + if (direction == Direction.LEFT) { + Robot.driveTrain.arcadeDrive(0, -0.5); + } else if (direction == Direction.RIGHT) { + Robot.driveTrain.arcadeDrive(0, 0.5); + } else { + Robot.driveTrain.arcadeDrive(0, 0); + } + } + + @Override + protected boolean isFinished() { + System.out.println(timer.get()); + System.out.println(seconds); + if (timer.get() > seconds) { + Robot.driveTrain.arcadeDrive(0, 0); + } + return timer.get() > seconds; + } + + @Override + protected void end() { + } + + @Override + protected void interrupted() { + end(); + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java new file mode 100644 index 0000000..2ba6b5b --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java @@ -0,0 +1,48 @@ +package org.usfirst.frc3501.RiceCatRobot.subsystems; + +import org.usfirst.frc3501.RiceCatRobot.RobotMap; + +import edu.wpi.first.wpilibj.CANJaguar; +import edu.wpi.first.wpilibj.command.Subsystem; + +public class Arm extends Subsystem { + private CANJaguar left, right; + + public Arm() { + left = new CANJaguar(RobotMap.ARM_LEFT); + right = new CANJaguar(RobotMap.ARM_RIGHT); + } + + public void initDefaultCommand() { + } + + public void fineTuneControl(double d) { + if (Math.abs(d) < 0.05) { + d = 0; + } else if (d > 0) { + d *= d; + } else { + d *= -d; + } + setArmSpeeds(d); + } + + public void setLeft(double speed) { + left.set(-speed); + } + + public void setRight(double speed) { + right.set(-speed); + } + + public void setArmSpeeds(double speed) { + setLeft(speed); + setRight(speed); + } + + public void stop() { + left.set(0); + right.set(0); + } + +} \ No newline at end of file diff --git a/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Claw.java b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Claw.java new file mode 100644 index 0000000..100eff4 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Claw.java @@ -0,0 +1,50 @@ +package org.usfirst.frc3501.RiceCatRobot.subsystems; + +import org.usfirst.frc3501.RiceCatRobot.OI; +import org.usfirst.frc3501.RiceCatRobot.Robot; +import org.usfirst.frc3501.RiceCatRobot.RobotMap; +import org.usfirst.frc3501.RiceCatRobot.commands.CloseClaw; +import org.usfirst.frc3501.RiceCatRobot.commands.OpenClaw; + +import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.command.Subsystem; + +public class Claw extends Subsystem { + + private DoubleSolenoid solenoid; + public boolean toggleOn = false; + + public Claw() { + solenoid = new DoubleSolenoid(RobotMap.MODULE_NUMBER, + RobotMap.SOLENOID_FORWARD, RobotMap.SOLENOID_REVERSE); + } + + public void initDefaultCommand() { + } + + public void closeClaw() { + solenoid.set(RobotMap.close); + } + + public void openClaw() { + solenoid.set(RobotMap.open); + } + + public boolean isOpen() { + return solenoid.get() == RobotMap.open; + } + + public void doTriggerAction() { + if (!Robot.claw.toggleOn) { + if (OI.rightJoystick.getRawButton(RobotMap.TRIGGER_PORT)) { + if (Robot.claw.isOpen()) { + new CloseClaw().start(); + } + } else { + if (!Robot.claw.isOpen()) { + new OpenClaw().start(); + } + } + } + } +} diff --git a/src/org/usfirst/frc3501/RiceCatRobot/subsystems/DriveTrain.java b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/DriveTrain.java new file mode 100644 index 0000000..9307c78 --- /dev/null +++ b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/DriveTrain.java @@ -0,0 +1,107 @@ +package org.usfirst.frc3501.RiceCatRobot.subsystems; + +import org.usfirst.frc3501.RiceCatRobot.RobotMap; + +import edu.wpi.first.wpilibj.CANJaguar; +import edu.wpi.first.wpilibj.Encoder; +import edu.wpi.first.wpilibj.CounterBase.EncodingType; +import edu.wpi.first.wpilibj.command.Subsystem; + +public class DriveTrain extends Subsystem { + private CANJaguar frontLeft, frontRight, rearLeft, rearRight; + private Encoder leftEncoder, rightEncoder; + + public DriveTrain() { + frontLeft = new CANJaguar(RobotMap.DRIVE_FRONT_LEFT); + frontRight = new CANJaguar(RobotMap.DRIVE_FRONT_RIGHT); + rearLeft = new CANJaguar(RobotMap.DRIVE_REAR_LEFT); + rearRight = new CANJaguar(RobotMap.DRIVE_REAR_RIGHT); + leftEncoder = new Encoder(RobotMap.DRIVE_LEFT_A, RobotMap.DRIVE_LEFT_B, + false, EncodingType.k4X); + rightEncoder = new Encoder(RobotMap.DRIVE_RIGHT_A, + RobotMap.DRIVE_RIGHT_B, false, EncodingType.k4X); + leftEncoder.setDistancePerPulse(RobotMap.DISTANCE_PER_PULSE); + rightEncoder.setDistancePerPulse(RobotMap.DISTANCE_PER_PULSE); + } + + public void resetEncoders() { + leftEncoder.reset(); + rightEncoder.reset(); + } + + public double getRightSpeed() { + // Returns in per second + return rightEncoder.getRate(); + } + + public double getLeftSpeed() { + return leftEncoder.getRate(); + } + + public double getRightDistance() { + // Returns distance in in + return rightEncoder.getDistance(); + } + + public double getLeftDistance() { + // Returns distance in in + return leftEncoder.getDistance(); + } + + public void setMotorSpeeds(double leftSpeed, double rightSpeed) { + if (Math.abs(leftSpeed) < RobotMap.DRIVE_DEAD_ZONE) { + leftSpeed = 0; + } + if (Math.abs(rightSpeed) < RobotMap.DRIVE_DEAD_ZONE) { + rightSpeed = 0; + } + this.frontLeft.set(leftSpeed); + this.frontRight.set(-rightSpeed); + this.rearLeft.set(leftSpeed); + this.rearRight.set(-rightSpeed); + } + + public void arcadeDrive(double yVal, double twist) { + if (yVal < 0 && Math.abs(yVal) < 0.1125) { + yVal = 0; + } else if (yVal > 0 && Math.abs(yVal) < 0.25) { + yVal = 0; + } else if (yVal > 0) { + yVal -= 0.25; + } else if (yVal < 0) { + yVal += 0.15; + } + if (Math.abs(twist) < RobotMap.DRIVE_DEAD_ZONE) { + twist = 0; + } + + double leftMotorSpeed; + double rightMotorSpeed; + // adjust the sensitivity (yVal+rootof (yval)) / 2 + yVal = (yVal + Math.signum(yVal) * Math.sqrt(Math.abs(yVal))) / 2; + // adjust the sensitivity (twist+rootof (twist)) / 2 + twist = (twist + Math.signum(twist) * Math.sqrt(Math.abs(twist))) / 2; + if (yVal > 0) { + if (twist > 0) { + leftMotorSpeed = yVal - twist; + rightMotorSpeed = Math.max(yVal, twist); + } else { + leftMotorSpeed = Math.max(yVal, -twist); + rightMotorSpeed = yVal + twist; + } + } else { + if (twist > 0.0) { + leftMotorSpeed = -Math.max(-yVal, twist); + rightMotorSpeed = yVal + twist; + } else { + leftMotorSpeed = yVal - twist; + rightMotorSpeed = -Math.max(-yVal, -twist); + } + } + setMotorSpeeds(leftMotorSpeed, rightMotorSpeed); + } + + @Override + protected void initDefaultCommand() { + } +} -- 2.30.2