Compare commits
56 Commits
79568a58b9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41f6e4747f | ||
|
|
7908d4c5df | ||
|
|
2263961829 | ||
|
|
27ea9d96e3 | ||
|
|
01edf1cb01 | ||
|
|
0b4c0e09ff | ||
|
|
6c86b2ed5c | ||
|
|
6885b80d6a | ||
|
|
2472c67adf | ||
|
|
c8d0ee3a03 | ||
|
|
3300d74a78 | ||
|
|
bdffb48ece | ||
|
|
5f44d5304a | ||
|
|
9aa7018812 | ||
|
|
d98dc4e467 | ||
|
|
b0ad34519e | ||
|
|
7b734cc046 | ||
|
|
cdca0230a4 | ||
|
|
56b28100df | ||
|
|
db935eceda | ||
|
|
da28ff48db | ||
|
|
5b6e3ac7b2 | ||
|
|
9585c17bdb | ||
|
|
07eeaffa32 | ||
|
|
8202b012cb | ||
|
|
e5f7b05063 | ||
|
|
5916f4f141 | ||
| 4438560698 | |||
| b2d4647e41 | |||
| 75922f581c | |||
| a429b936d2 | |||
|
|
3b06cbd447 | ||
|
|
7b535a845f | ||
|
|
42e35fca8a | ||
|
|
272f89962a | ||
|
|
52c72e9a61 | ||
|
|
4d1b353e25 | ||
|
|
9d09af20b0 | ||
|
|
ae9a6bd046 | ||
|
|
10b0110315 | ||
| 098f16665a | |||
| 1240160ed7 | |||
| 4068016d36 | |||
|
|
6afc342006 | ||
| f7e88619e9 | |||
| 5c626f33e3 | |||
|
|
673a7fcb82 | ||
|
|
755d79aa18 | ||
|
|
799e3e34c3 | ||
|
|
fbd94fc33d | ||
|
|
9e3bd6e7d3 | ||
|
|
bd853dfc79 | ||
|
|
cb3104152c | ||
|
|
85da1dcad1 | ||
|
|
a92a7a0ea1 | ||
|
|
ba57959f4d |
@@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
|
"System Joysticks": {
|
||||||
|
"window": {
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
},
|
||||||
"keyboardJoysticks": [
|
"keyboardJoysticks": [
|
||||||
{
|
{
|
||||||
"axisConfig": [
|
"axisConfig": [
|
||||||
|
|||||||
@@ -14,6 +14,12 @@
|
|||||||
"type": "deadline",
|
"type": "deadline",
|
||||||
"data": {
|
"data": {
|
||||||
"commands": [
|
"commands": [
|
||||||
|
{
|
||||||
|
"type": "wait",
|
||||||
|
"data": {
|
||||||
|
"waitTime": 3.0
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"data": {
|
"data": {
|
||||||
@@ -36,21 +42,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "named",
|
"type": "deadline",
|
||||||
"data": {
|
"data": {
|
||||||
"name": "Limelighter"
|
"commands": [
|
||||||
}
|
{
|
||||||
},
|
"type": "named",
|
||||||
{
|
"data": {
|
||||||
"type": "named",
|
"name": "Lancer"
|
||||||
"data": {
|
}
|
||||||
"name": "Lancer"
|
},
|
||||||
}
|
{
|
||||||
},
|
"type": "named",
|
||||||
{
|
"data": {
|
||||||
"type": "named",
|
"name": "Aspirer"
|
||||||
"data": {
|
}
|
||||||
"name": "TournerAZero"
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -72,9 +79,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "path",
|
"type": "named",
|
||||||
"data": {
|
"data": {
|
||||||
"pathName": "MonterReservoir"
|
"name": "gauche"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -35,12 +35,6 @@
|
|||||||
"pathName": "Tir"
|
"pathName": "Tir"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "named",
|
|
||||||
"data": {
|
|
||||||
"name": "Limelighter"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "named",
|
"type": "named",
|
||||||
"data": {
|
"data": {
|
||||||
|
|||||||
@@ -14,6 +14,12 @@
|
|||||||
"type": "deadline",
|
"type": "deadline",
|
||||||
"data": {
|
"data": {
|
||||||
"commands": [
|
"commands": [
|
||||||
|
{
|
||||||
|
"type": "wait",
|
||||||
|
"data": {
|
||||||
|
"waitTime": 3.0
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"data": {
|
"data": {
|
||||||
@@ -36,21 +42,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "named",
|
"type": "deadline",
|
||||||
"data": {
|
"data": {
|
||||||
"name": "Limelighter"
|
"commands": [
|
||||||
}
|
{
|
||||||
},
|
"type": "named",
|
||||||
{
|
"data": {
|
||||||
"type": "named",
|
"name": "Lancer"
|
||||||
"data": {
|
}
|
||||||
"name": "Lancer"
|
},
|
||||||
}
|
{
|
||||||
},
|
"type": "named",
|
||||||
{
|
"data": {
|
||||||
"type": "named",
|
"name": "Aspirer"
|
||||||
"data": {
|
}
|
||||||
"name": "TournerA180"
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -72,9 +79,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "path",
|
"type": "named",
|
||||||
"data": {
|
"data": {
|
||||||
"pathName": "MonterMur"
|
"name": "droite"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2025.0",
|
|
||||||
"command": {
|
|
||||||
"type": "sequential",
|
|
||||||
"data": {
|
|
||||||
"commands": [
|
|
||||||
{
|
|
||||||
"type": "path",
|
|
||||||
"data": {
|
|
||||||
"pathName": "TirerSimple"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "named",
|
|
||||||
"data": {
|
|
||||||
"name": "DescendreBalayeuse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "named",
|
|
||||||
"data": {
|
|
||||||
"name": "Limelighter"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "named",
|
|
||||||
"data": {
|
|
||||||
"name": "Lancer"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resetOdom": true,
|
|
||||||
"folder": null,
|
|
||||||
"choreoAuto": false
|
|
||||||
}
|
|
||||||
68
src/main/deploy/pathplanner/autos/Tirgrimpe.auto
Normal file
68
src/main/deploy/pathplanner/autos/Tirgrimpe.auto
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"version": "2025.0",
|
||||||
|
"command": {
|
||||||
|
"type": "sequential",
|
||||||
|
"data": {
|
||||||
|
"commands": [
|
||||||
|
{
|
||||||
|
"type": "path",
|
||||||
|
"data": {
|
||||||
|
"pathName": "tirgrimpe1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "DescendreBalayeuse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "deadline",
|
||||||
|
"data": {
|
||||||
|
"commands": [
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "Lancer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "Aspirer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "GrimperReservoir"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "MonterGrimpeur"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "gauche"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "named",
|
||||||
|
"data": {
|
||||||
|
"name": "DescendreGrimpeur"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"resetOdom": true,
|
||||||
|
"folder": null,
|
||||||
|
"choreoAuto": false
|
||||||
|
}
|
||||||
@@ -3,12 +3,12 @@
|
|||||||
"waypoints": [
|
"waypoints": [
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 3.5732667617689007,
|
"x": 3.6120827389443653,
|
||||||
"y": 5.917574893009986
|
"y": 5.917574893009986
|
||||||
},
|
},
|
||||||
"prevControl": null,
|
"prevControl": null,
|
||||||
"nextControl": {
|
"nextControl": {
|
||||||
"x": 2.266462196861626,
|
"x": 2.3052781740370905,
|
||||||
"y": 5.904636233951498
|
"y": 5.904636233951498
|
||||||
},
|
},
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
@@ -16,11 +16,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 1.1796148359486442,
|
"x": 0.23509272467902986,
|
||||||
"y": 5.917574893009986
|
"y": 5.917574893009986
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 1.7230385164051354,
|
"x": 0.778516405135521,
|
||||||
"y": 5.930513552068473
|
"y": 5.930513552068473
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
|
|||||||
@@ -3,25 +3,25 @@
|
|||||||
"waypoints": [
|
"waypoints": [
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 2.4476034236804565,
|
"x": 1.878,
|
||||||
"y": 4.85660485021398
|
"y": 5.154
|
||||||
},
|
},
|
||||||
"prevControl": null,
|
"prevControl": null,
|
||||||
"nextControl": {
|
"nextControl": {
|
||||||
"x": 1.6971611982881591,
|
"x": 1.1275577746077026,
|
||||||
"y": 4.85660485021398
|
"y": 5.154
|
||||||
},
|
},
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
"linkedName": null
|
"linkedName": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 1.0761055634807417,
|
"x": 1.0372895863052778,
|
||||||
"y": 4.85660485021398
|
"y": 5.011868758915835
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 1.503081312410841,
|
"x": 1.4642653352353772,
|
||||||
"y": 4.869543509272469
|
"y": 5.024807417974324
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
|
|||||||
@@ -3,25 +3,25 @@
|
|||||||
"waypoints": [
|
"waypoints": [
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 2.4476034236804565,
|
"x": 1.878,
|
||||||
"y": 4.85660485021398
|
"y": 5.154
|
||||||
},
|
},
|
||||||
"prevControl": null,
|
"prevControl": null,
|
||||||
"nextControl": {
|
"nextControl": {
|
||||||
"x": 2.3958487874465044,
|
"x": 1.8262453637660478,
|
||||||
"y": 2.695848787446506
|
"y": 2.993243937232526
|
||||||
},
|
},
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
"linkedName": null
|
"linkedName": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 1.0502282453637657,
|
"x": 2.0076890156918683,
|
||||||
"y": 2.4758915834522113
|
"y": 2.2041797432239663
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 2.292339514978602,
|
"x": 3.2498002853067054,
|
||||||
"y": 2.3982596291012843
|
"y": 2.1265477888730393
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
},
|
},
|
||||||
"goalEndState": {
|
"goalEndState": {
|
||||||
"velocity": 0,
|
"velocity": 0,
|
||||||
"rotation": 0.0
|
"rotation": 32.10625595511781
|
||||||
},
|
},
|
||||||
"reversed": false,
|
"reversed": false,
|
||||||
"folder": null,
|
"folder": null,
|
||||||
|
|||||||
@@ -3,25 +3,25 @@
|
|||||||
"waypoints": [
|
"waypoints": [
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 1.0502282453637657,
|
"x": 1.0,
|
||||||
"y": 2.4758915834522113
|
"y": 2.6
|
||||||
},
|
},
|
||||||
"prevControl": null,
|
"prevControl": null,
|
||||||
"nextControl": {
|
"nextControl": {
|
||||||
"x": 1.0408884389937225,
|
"x": 0.9906601936299568,
|
||||||
"y": 2.742159765250622
|
"y": 2.866268181798411
|
||||||
},
|
},
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
"linkedName": null
|
"linkedName": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 1.0502282453637657,
|
"x": 1.0,
|
||||||
"y": 2.7734807417974334
|
"y": 2.9
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 1.0547546338516156,
|
"x": 1.00452638848785,
|
||||||
"y": 2.523521721541598
|
"y": 2.6500409797441646
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
"waypoints": [
|
"waypoints": [
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 1.1796148359486442,
|
"x": 0.29978601997146925,
|
||||||
"y": 5.917574893009986
|
"y": 5.917574893009986
|
||||||
},
|
},
|
||||||
"prevControl": null,
|
"prevControl": null,
|
||||||
"nextControl": {
|
"nextControl": {
|
||||||
"x": 2.3570328102710407,
|
"x": 1.4772039942938657,
|
||||||
"y": 5.982268188302426
|
"y": 5.982268188302426
|
||||||
},
|
},
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 2.4476034236804565,
|
"x": 1.8783024251069897,
|
||||||
"y": 4.85660485021398
|
"y": 5.154194008559203
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 2.382910128388017,
|
"x": 1.8136091298145502,
|
||||||
"y": 5.400028530670471
|
"y": 5.6976176890156935
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
],
|
],
|
||||||
"rotationTargets": [
|
"rotationTargets": [
|
||||||
{
|
{
|
||||||
"waypointRelativePos": 0.2179128348660559,
|
"waypointRelativePos": 0.3240938166311289,
|
||||||
"rotationDegrees": 180.0
|
"rotationDegrees": 180.0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
"waypoints": [
|
"waypoints": [
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 3.5473894436519258,
|
"x": 3.602,
|
||||||
"y": 4.015592011412268
|
"y": 4.015592011412268
|
||||||
},
|
},
|
||||||
"prevControl": null,
|
"prevControl": null,
|
||||||
"nextControl": {
|
"nextControl": {
|
||||||
"x": 2.494897544356074,
|
"x": 2.549508100704148,
|
||||||
"y": 4.011425161481168
|
"y": 4.011425161481168
|
||||||
},
|
},
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 1.7359771754636228,
|
"x": 1.643730569948188,
|
||||||
"y": 4.015592011412268
|
"y": 4.015592011412268
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 2.627549770741877,
|
"x": 2.5679620034542325,
|
||||||
"y": 4.02839075681212
|
"y": 4.011502590673576
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
|
|||||||
54
src/main/deploy/pathplanner/paths/tirgrimpe1.path
Normal file
54
src/main/deploy/pathplanner/paths/tirgrimpe1.path
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"version": "2025.0",
|
||||||
|
"waypoints": [
|
||||||
|
{
|
||||||
|
"anchor": {
|
||||||
|
"x": 3.5991440798858774,
|
||||||
|
"y": 2.3465049928673327
|
||||||
|
},
|
||||||
|
"prevControl": null,
|
||||||
|
"nextControl": {
|
||||||
|
"x": 2.589928673323822,
|
||||||
|
"y": 1.7513266761768898
|
||||||
|
},
|
||||||
|
"isLocked": false,
|
||||||
|
"linkedName": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anchor": {
|
||||||
|
"x": 1.8783024251069897,
|
||||||
|
"y": 2.3465049928673327
|
||||||
|
},
|
||||||
|
"prevControl": {
|
||||||
|
"x": 2.706376604850214,
|
||||||
|
"y": 1.7125106990014274
|
||||||
|
},
|
||||||
|
"nextControl": null,
|
||||||
|
"isLocked": false,
|
||||||
|
"linkedName": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rotationTargets": [],
|
||||||
|
"constraintZones": [],
|
||||||
|
"pointTowardsZones": [],
|
||||||
|
"eventMarkers": [],
|
||||||
|
"globalConstraints": {
|
||||||
|
"maxVelocity": 3.0,
|
||||||
|
"maxAcceleration": 3.0,
|
||||||
|
"maxAngularVelocity": 540.0,
|
||||||
|
"maxAngularAcceleration": 720.0,
|
||||||
|
"nominalVoltage": 12.0,
|
||||||
|
"unlimited": false
|
||||||
|
},
|
||||||
|
"goalEndState": {
|
||||||
|
"velocity": 0,
|
||||||
|
"rotation": 33.11134196037204
|
||||||
|
},
|
||||||
|
"reversed": false,
|
||||||
|
"folder": null,
|
||||||
|
"idealStartingState": {
|
||||||
|
"velocity": 0,
|
||||||
|
"rotation": 180.0
|
||||||
|
},
|
||||||
|
"useDefaultConstraints": true
|
||||||
|
}
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
"robotMass": 51.673,
|
"robotMass": 51.673,
|
||||||
"robotMOI": 6.883,
|
"robotMOI": 6.883,
|
||||||
"robotTrackwidth": 0.546,
|
"robotTrackwidth": 0.546,
|
||||||
"driveWheelRadius": 0.099,
|
"driveWheelRadius": 0.051,
|
||||||
"driveGearing": 6.2,
|
"driveGearing": 6.2,
|
||||||
"maxDriveSpeed": 9.82,
|
"maxDriveSpeed": 9.82,
|
||||||
"driveMotorType": "krakenX60",
|
"driveMotorType": "krakenX60",
|
||||||
"driveCurrentLimit": 120.0,
|
"driveCurrentLimit": 120.0,
|
||||||
"wheelCOF": 1.1,
|
"wheelCOF": 1.2,
|
||||||
"flModuleX": 0.288925,
|
"flModuleX": 0.288925,
|
||||||
"flModuleY": 0.269875,
|
"flModuleY": 0.269875,
|
||||||
"frModuleX": 0.288925,
|
"frModuleX": 0.288925,
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
|||||||
import frc.robot.commands.Aspirer;
|
import frc.robot.commands.Aspirer;
|
||||||
import frc.robot.commands.DescendreBalyeuse;
|
import frc.robot.commands.DescendreBalyeuse;
|
||||||
import frc.robot.commands.DescendreGrimpeur;
|
import frc.robot.commands.DescendreGrimpeur;
|
||||||
|
import frc.robot.commands.DescendreGrimpeurPlus;
|
||||||
|
import frc.robot.commands.Inverser;
|
||||||
import frc.robot.commands.Lancer;
|
import frc.robot.commands.Lancer;
|
||||||
import frc.robot.commands.LancerAspirer;
|
import frc.robot.commands.LancerAspirer;
|
||||||
import frc.robot.commands.LancerBaseVitesse;
|
import frc.robot.commands.LancerBaseVitesse;
|
||||||
@@ -30,9 +32,12 @@ import frc.robot.commands.ModeOposerDemeleur;
|
|||||||
import frc.robot.commands.MonterBalyeuse;
|
import frc.robot.commands.MonterBalyeuse;
|
||||||
import frc.robot.commands.MonterGrimpeur;
|
import frc.robot.commands.MonterGrimpeur;
|
||||||
import frc.robot.commands.ModeAuto.AspirerAuto;
|
import frc.robot.commands.ModeAuto.AspirerAuto;
|
||||||
|
import frc.robot.commands.ModeAuto.BougerDroiteAuto;
|
||||||
|
import frc.robot.commands.ModeAuto.BougerGaucheAuto;
|
||||||
import frc.robot.commands.ModeAuto.GrimperMur;
|
import frc.robot.commands.ModeAuto.GrimperMur;
|
||||||
import frc.robot.commands.ModeAuto.GrimperReservoir;
|
import frc.robot.commands.ModeAuto.GrimperReservoir;
|
||||||
import frc.robot.commands.ModeAuto.LancerAuto;
|
import frc.robot.commands.ModeAuto.LancerAuto;
|
||||||
|
import frc.robot.commands.ModeAuto.LimelighterAuto;
|
||||||
import frc.robot.commands.ModeAuto.RetourMilieuDroite;
|
import frc.robot.commands.ModeAuto.RetourMilieuDroite;
|
||||||
import frc.robot.commands.ModeAuto.RetourMilieuGauche;
|
import frc.robot.commands.ModeAuto.RetourMilieuGauche;
|
||||||
import frc.robot.commands.ModeAuto.TournerVersMur;
|
import frc.robot.commands.ModeAuto.TournerVersMur;
|
||||||
@@ -41,8 +46,8 @@ import frc.robot.generated.TunerConstants;
|
|||||||
import frc.robot.subsystems.Balayeuse;
|
import frc.robot.subsystems.Balayeuse;
|
||||||
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
import frc.robot.subsystems.Grimpeur;
|
import frc.robot.subsystems.Grimpeur;
|
||||||
|
//import frc.robot.subsystems.LEDSubsystem;
|
||||||
import frc.robot.subsystems.Lanceur;
|
import frc.robot.subsystems.Lanceur;
|
||||||
import frc.robot.subsystems.Led;
|
|
||||||
import frc.robot.subsystems.LimeLight3;
|
import frc.robot.subsystems.LimeLight3;
|
||||||
import frc.robot.subsystems.Limelight3G;
|
import frc.robot.subsystems.Limelight3G;
|
||||||
|
|
||||||
@@ -53,7 +58,7 @@ public class RobotContainer {
|
|||||||
Lanceur lanceur = new Lanceur();
|
Lanceur lanceur = new Lanceur();
|
||||||
LimeLight3 limeLight3 = new LimeLight3();
|
LimeLight3 limeLight3 = new LimeLight3();
|
||||||
Limelight3G limeLight3G = new Limelight3G();
|
Limelight3G limeLight3G = new Limelight3G();
|
||||||
Led led = new Led();
|
//LEDSubsystem ledSubsystem = new LEDSubsystem();
|
||||||
CommandXboxController manette = new CommandXboxController(0);
|
CommandXboxController manette = new CommandXboxController(0);
|
||||||
CommandXboxController manette1 = new CommandXboxController(1);
|
CommandXboxController manette1 = new CommandXboxController(1);
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
|
||||||
@@ -63,21 +68,19 @@ public class RobotContainer {
|
|||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1) // Add a 10% deadband
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1) // Add a 10% deadband
|
||||||
.withDriveRequestType(DriveRequestType.OpenLoopVoltage); // Use open-loop control for drive motors
|
.withDriveRequestType(DriveRequestType.OpenLoopVoltage); // Use open-loop control for drive motors
|
||||||
private final SwerveRequest.SwerveDriveBrake brake = new SwerveRequest.SwerveDriveBrake();
|
|
||||||
private final SwerveRequest.PointWheelsAt point = new SwerveRequest.PointWheelsAt();
|
|
||||||
|
|
||||||
private final Telemetry logger = new Telemetry(MaxSpeed);
|
|
||||||
|
|
||||||
public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();
|
public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();
|
||||||
|
|
||||||
|
|
||||||
public RobotContainer() {
|
public RobotContainer() {
|
||||||
|
NamedCommands.registerCommand("droite", new BougerDroiteAuto(drivetrain));
|
||||||
|
NamedCommands.registerCommand("gauche", new BougerGaucheAuto(drivetrain));
|
||||||
NamedCommands.registerCommand("GrimperMur", new GrimperMur(limeLight3,drivetrain));
|
NamedCommands.registerCommand("GrimperMur", new GrimperMur(limeLight3,drivetrain));
|
||||||
NamedCommands.registerCommand("GrimperReservoir", new GrimperReservoir(limeLight3G,drivetrain));
|
NamedCommands.registerCommand("GrimperReservoir", new GrimperReservoir(limeLight3G,drivetrain));
|
||||||
NamedCommands.registerCommand("Lancer", new LancerAuto(lanceur, limeLight3G));
|
NamedCommands.registerCommand("Lancer", new LancerAuto(lanceur, limeLight3G));
|
||||||
NamedCommands.registerCommand("RetourMilieuDroite", new RetourMilieuDroite(drivetrain,limeLight3G));
|
NamedCommands.registerCommand("RetourMilieuDroite", new RetourMilieuDroite(drivetrain,limeLight3G));
|
||||||
NamedCommands.registerCommand("RetourMilieuGauche", new RetourMilieuGauche(drivetrain, limeLight3G));
|
NamedCommands.registerCommand("RetourMilieuGauche", new RetourMilieuGauche(drivetrain, limeLight3G));
|
||||||
NamedCommands.registerCommand("Limelighter", new Limelighter(limeLight3G,drivetrain));
|
NamedCommands.registerCommand("Limelighter", new LimelighterAuto(limeLight3G,drivetrain));
|
||||||
NamedCommands.registerCommand("DescendreBalayeuse", new DescendreBalyeuse(balayeuse));
|
NamedCommands.registerCommand("DescendreBalayeuse", new DescendreBalyeuse(balayeuse));
|
||||||
NamedCommands.registerCommand("Aspirer", new AspirerAuto(balayeuse));
|
NamedCommands.registerCommand("Aspirer", new AspirerAuto(balayeuse));
|
||||||
NamedCommands.registerCommand("TournerA180", new TournerVersReservoir(drivetrain));
|
NamedCommands.registerCommand("TournerA180", new TournerVersReservoir(drivetrain));
|
||||||
@@ -93,11 +96,12 @@ public class RobotContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void configureBindings() {
|
private void configureBindings() {
|
||||||
|
//ledSubsystem.setDefaultCommand(ledSubsystem.updateLEDs());
|
||||||
drivetrain.setDefaultCommand(
|
drivetrain.setDefaultCommand(
|
||||||
drivetrain.applyRequest(() ->
|
drivetrain.applyRequest(() ->
|
||||||
drive.withVelocityY(MathUtil.applyDeadband(-manette.getLeftX()*Math.abs(-manette.getLeftX())*MaxSpeed, 0.05))
|
drive.withVelocityY(MathUtil.applyDeadband(-manette.getLeftX()*Math.abs(-manette.getLeftX())*MaxSpeed*0.7, 0.05))
|
||||||
.withVelocityX(MathUtil.applyDeadband(-manette.getLeftY()*Math.abs(-manette.getLeftY())*MaxSpeed, 0.05))
|
.withVelocityX(MathUtil.applyDeadband(-manette.getLeftY()*Math.abs(-manette.getLeftY())*MaxSpeed*0.7, 0.05))
|
||||||
.withRotationalRate(MathUtil.applyDeadband(-manette.getRightX()*Math.abs(-manette.getRightX())*MaxAngularRate, 0.05))
|
.withRotationalRate(MathUtil.applyDeadband(-manette.getRightX()*Math.abs(-manette.getRightX())*MaxAngularRate*1.5, 0.05))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
//manette 1
|
//manette 1
|
||||||
@@ -107,7 +111,7 @@ public class RobotContainer {
|
|||||||
// manette1.povLeft().whileTrue(drivetrain.sysIdDynamic(SysIdRoutine.Direction.kReverse));
|
// manette1.povLeft().whileTrue(drivetrain.sysIdDynamic(SysIdRoutine.Direction.kReverse));
|
||||||
|
|
||||||
manette.povUp().whileTrue(new MonterGrimpeur(grimpeur));
|
manette.povUp().whileTrue(new MonterGrimpeur(grimpeur));
|
||||||
manette.povDown().whileTrue(new DescendreGrimpeur(grimpeur));
|
manette.povDown().whileTrue(new DescendreGrimpeurPlus(grimpeur));
|
||||||
manette.rightTrigger().whileTrue(new Lancer(lanceur, limeLight3G));
|
manette.rightTrigger().whileTrue(new Lancer(lanceur, limeLight3G));
|
||||||
manette.leftTrigger().whileTrue(new Limelighter(limeLight3G, drivetrain));
|
manette.leftTrigger().whileTrue(new Limelighter(limeLight3G, drivetrain));
|
||||||
manette.leftBumper().whileTrue(new DescendreBalyeuse(balayeuse));
|
manette.leftBumper().whileTrue(new DescendreBalyeuse(balayeuse));
|
||||||
@@ -125,6 +129,10 @@ public class RobotContainer {
|
|||||||
manette1.b().whileTrue(new ModeOposer(lanceur));
|
manette1.b().whileTrue(new ModeOposer(lanceur));
|
||||||
manette1.a().whileTrue(new ModeOposerDemeleur(lanceur));
|
manette1.a().whileTrue(new ModeOposerDemeleur(lanceur));
|
||||||
manette1.y().whileTrue(new ModeOposerBalayeuse(balayeuse));
|
manette1.y().whileTrue(new ModeOposerBalayeuse(balayeuse));
|
||||||
|
manette1.povRight().whileTrue(new BougerDroiteAuto(drivetrain));
|
||||||
|
manette1.povLeft().whileTrue(new BougerGaucheAuto(drivetrain));
|
||||||
|
manette1.povDown().whileTrue(new DescendreGrimpeur(grimpeur));
|
||||||
|
manette1.start().whileTrue(new Inverser(drivetrain));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command getAutonomousCommand() {
|
public Command getAutonomousCommand() {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class DescendreGrimpeur extends Command {
|
|||||||
/** Creates a new DescendreGrimpeur. */
|
/** Creates a new DescendreGrimpeur. */
|
||||||
public DescendreGrimpeur(Grimpeur grimpeur) {
|
public DescendreGrimpeur(Grimpeur grimpeur) {
|
||||||
this.grimpeur = grimpeur;
|
this.grimpeur = grimpeur;
|
||||||
|
addRequirements(grimpeur);
|
||||||
// Use addRequirements() here to declare subsystem dependencies.
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,18 +25,21 @@ public class DescendreGrimpeur extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if(!grimpeur.Limit()){
|
if(!grimpeur.Limit()){
|
||||||
grimpeur.Grimper(-0.4);
|
grimpeur.GrimperGauche(-0.4);
|
||||||
|
grimpeur.GrimperDroit(-0.4);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
grimpeur.Reset();
|
grimpeur.Reset();
|
||||||
grimpeur.Grimper(0);
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
public void end(boolean interrupted) {
|
public void end(boolean interrupted) {
|
||||||
grimpeur.Grimper(0);
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
|
|||||||
50
src/main/java/frc/robot/commands/DescendreGrimpeurPlus.java
Normal file
50
src/main/java/frc/robot/commands/DescendreGrimpeurPlus.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// 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.wpilibj2.command.Command;
|
||||||
|
import frc.robot.subsystems.Grimpeur;
|
||||||
|
|
||||||
|
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
|
||||||
|
public class DescendreGrimpeurPlus extends Command {
|
||||||
|
private Grimpeur grimpeur;
|
||||||
|
/** Creates a new DescendreGrimpeur. */
|
||||||
|
public DescendreGrimpeurPlus(Grimpeur grimpeur) {
|
||||||
|
this.grimpeur = grimpeur;
|
||||||
|
addRequirements(grimpeur);
|
||||||
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the command is initially scheduled.
|
||||||
|
@Override
|
||||||
|
public void initialize() {}
|
||||||
|
|
||||||
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
if(!grimpeur.Limit()){
|
||||||
|
grimpeur.GrimperGauche(-0.4);
|
||||||
|
grimpeur.GrimperDroit(-0.4);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
grimpeur.Reset();
|
||||||
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {
|
||||||
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,33 +5,33 @@
|
|||||||
package frc.robot.commands;
|
package frc.robot.commands;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
import frc.robot.subsystems.Led;
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
|
|
||||||
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
|
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
|
||||||
public class RainBowAnim extends Command {
|
public class Inverser extends Command {
|
||||||
private Led led;
|
CommandSwerveDrivetrain drivetrain;
|
||||||
/** Creates a new RainBowAnim. */
|
boolean inverse = false;
|
||||||
public RainBowAnim(Led led) {
|
/** Creates a new Inverser. */
|
||||||
this.led = led;
|
public Inverser(CommandSwerveDrivetrain drivetrain) {
|
||||||
addRequirements(led);
|
this.drivetrain = drivetrain;
|
||||||
|
addRequirements(drivetrain);
|
||||||
// Use addRequirements() here to declare subsystem dependencies.
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
led.RainBow();
|
drivetrain.getPigeon2().setYaw(drivetrain.getPigeon2().getYaw().getValueAsDouble()+180);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void execute() {}
|
public void execute() {
|
||||||
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
public void end(boolean interrupted) {
|
public void end(boolean interrupted) {}
|
||||||
led.RainBowStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
@@ -4,7 +4,11 @@
|
|||||||
|
|
||||||
package frc.robot.commands;
|
package frc.robot.commands;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import edu.wpi.first.math.controller.PIDController;
|
import edu.wpi.first.math.controller.PIDController;
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
import edu.wpi.first.wpilibj.Timer;
|
import edu.wpi.first.wpilibj.Timer;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
import frc.robot.subsystems.Lanceur;
|
import frc.robot.subsystems.Lanceur;
|
||||||
@@ -16,6 +20,11 @@ public class Lancer extends Command {
|
|||||||
private PIDController pidController;
|
private PIDController pidController;
|
||||||
private Limelight3G limeLight3G;
|
private Limelight3G limeLight3G;
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
|
double vitesse = 0;
|
||||||
|
double botx = 0;
|
||||||
|
double boty = 0;
|
||||||
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
|
|
||||||
/** Creates a new Lancer. */
|
/** Creates a new Lancer. */
|
||||||
public Lancer(Lanceur lanceur, Limelight3G limeLight3G) {
|
public Lancer(Lanceur lanceur, Limelight3G limeLight3G) {
|
||||||
this.lanceur = lanceur;
|
this.lanceur = lanceur;
|
||||||
@@ -28,36 +37,47 @@ public class Lancer extends Command {
|
|||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
if(limeLight3G.getV()){}
|
||||||
pidController = new PIDController(0.0007, 0,0, 0.001);
|
pidController = new PIDController(0.0007, 0,0, 0.001);
|
||||||
timer.reset();
|
timer.reset();
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
double botx = 0;
|
|
||||||
double boty = 0;
|
|
||||||
double[] BotPose = new double[6];
|
double[] BotPose = new double[6];
|
||||||
if(limeLight3G.getV()){
|
if(limeLight3G.getV()){
|
||||||
BotPose = limeLight3G.getBotPoseBlue();
|
if(!alliance.isPresent()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(alliance.get() == Alliance.Blue){
|
||||||
|
BotPose = limeLight3G.getBotPoseBlue();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
BotPose = limeLight3G.getBotPoseRed();
|
||||||
|
}
|
||||||
botx = BotPose[0];
|
botx = BotPose[0];
|
||||||
boty = BotPose[1];
|
boty = BotPose[1];
|
||||||
}
|
vitesse = 410.57 * ((Math.sqrt(Math.pow(Math.abs(4.625594-botx), 2) + Math.pow(Math.abs(4.034536-boty), 2)))) + 2250;
|
||||||
double vitesse = 0.5;
|
}
|
||||||
if(limeLight3G.getV()){
|
// if(limeLight3G.getV()){
|
||||||
vitesse = 410.57 * ((Math.sqrt(Math.pow(Math.abs(4.625594-botx), 2) + Math.pow(Math.abs(4.034536-boty), 2)))) + 2250;
|
|
||||||
System.out.println(vitesse);
|
if(vitesse > 2000){
|
||||||
|
|
||||||
double output = pidController.calculate(lanceur.Vitesse(),vitesse);
|
double output = pidController.calculate(lanceur.Vitesse(),vitesse);
|
||||||
lanceur.Lancer(output);
|
lanceur.Lancer(output);
|
||||||
|
System.out.println(output);
|
||||||
if(lanceur.Vitesse() >= vitesse-800){
|
if(lanceur.Vitesse() >= vitesse-800){
|
||||||
timer.start();
|
timer.start();
|
||||||
if(timer.get() >0.5){
|
if(timer.get() >1){
|
||||||
lanceur.Demeler(1);
|
lanceur.Demeler(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
lanceur.Lancer(3500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package frc.robot.commands;
|
|||||||
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||||
import com.ctre.phoenix6.swerve.SwerveRequest;
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.math.MathUtil;
|
||||||
import edu.wpi.first.wpilibj.DriverStation;
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
@@ -27,6 +28,7 @@ public class Limelighter extends Command {
|
|||||||
double boty;
|
double boty;
|
||||||
double angle;
|
double angle;
|
||||||
double calcul;
|
double calcul;
|
||||||
|
double x;
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
@@ -42,28 +44,69 @@ public class Limelighter extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
double[] BotPose = new double[6];
|
double[] BotPose = new double[6];
|
||||||
System.out.println("e");
|
|
||||||
if (limelight3g.getV()) {
|
if (limelight3g.getV()) {
|
||||||
if(alliance.get() == Alliance.Blue){
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
|
if (!alliance.isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (alliance.get() == Alliance.Blue) {
|
||||||
|
x = 4.6;
|
||||||
BotPose = limelight3g.getBotPoseBlue();
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
BotPose = limelight3g.getBotPoseRed();
|
//x = 11.915394;
|
||||||
|
x = 4.6;
|
||||||
|
BotPose = limelight3g.getBotPoseRed();
|
||||||
}
|
}
|
||||||
|
botx = BotPose[0];
|
||||||
botx = BotPose[1];
|
boty = BotPose[1];
|
||||||
|
angle = BotPose[5];
|
||||||
|
calcul = Math.toRadians(limelight3g.Calcule(boty, 4,botx, x, angle));
|
||||||
|
System.out.println(calcul);
|
||||||
|
//drivetrain.setControl(drive.withRotationalRate(MathUtil.clamp(calcul, -3, 3)));
|
||||||
|
if(calcul > -5 && calcul < 5){
|
||||||
|
drivetrain.setControl(
|
||||||
|
drive.withRotationalRate(0));
|
||||||
|
}
|
||||||
|
else if(calcul > 5){
|
||||||
|
drivetrain.setControl(
|
||||||
|
drive.withRotationalRate(2));
|
||||||
|
}
|
||||||
|
else if(calcul < -5){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(-2));
|
||||||
|
}
|
||||||
|
botx = BotPose[1];
|
||||||
boty = BotPose[0];
|
boty = BotPose[0];
|
||||||
angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
if(angle >180){
|
calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
|
||||||
angle -= 360;
|
if(calcul < -5 && calcul > -180){
|
||||||
|
drivetrain.setControl(
|
||||||
|
drive.withRotationalRate(0.5*(2*Math.PI)));
|
||||||
}
|
}
|
||||||
calcul = limelight3g.Calcule(botx, 4, boty, 4.6, angle) / 10;
|
else if(calcul > 5 && calcul < 180){
|
||||||
|
drivetrain.setControl(
|
||||||
|
drive.withRotationalRate(-0.5*(2*Math.PI)));
|
||||||
|
}
|
||||||
|
else if(calcul < -5){
|
||||||
|
drivetrain.setControl(
|
||||||
|
drive.withRotationalRate(-0.5*(2*Math.PI)));
|
||||||
|
}
|
||||||
|
else if(calcul <= -180){
|
||||||
|
drivetrain.setControl(
|
||||||
|
drive.withRotationalRate(0.5*(2*Math.PI)));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(
|
||||||
|
drive.withRotationalRate(0));
|
||||||
|
}
|
||||||
drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
|
drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
|
||||||
System.out.println(angle);
|
System.out.println(angle);
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// 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.ModeAuto;
|
||||||
|
|
||||||
|
import static edu.wpi.first.units.Units.*;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||||
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
|
import edu.wpi.first.wpilibj.Timer;
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
import frc.robot.generated.TunerConstants;
|
||||||
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
|
|
||||||
|
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
|
||||||
|
public class BougerDroiteAuto extends Command {
|
||||||
|
CommandSwerveDrivetrain drivetrain;
|
||||||
|
Timer timer = new Timer();
|
||||||
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
|
Optional<Alliance> alliance;
|
||||||
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
|
.withDriveRequestType(DriveRequestType.OpenLoopVoltage);
|
||||||
|
/** Creates a new AvanceAuto. */
|
||||||
|
public BougerDroiteAuto(CommandSwerveDrivetrain drivetrain) {
|
||||||
|
this.drivetrain = drivetrain;
|
||||||
|
addRequirements(drivetrain);
|
||||||
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the command is initially scheduled.
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
timer.reset();
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
if(timer.get() < 1.25){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(-1.5));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0));
|
||||||
|
timer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return timer.get() > 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// 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.ModeAuto;
|
||||||
|
|
||||||
|
import static edu.wpi.first.units.Units.*;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||||
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
|
import edu.wpi.first.wpilibj.Timer;
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
import frc.robot.generated.TunerConstants;
|
||||||
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
|
|
||||||
|
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
|
||||||
|
public class BougerGaucheAuto extends Command {
|
||||||
|
CommandSwerveDrivetrain drivetrain;
|
||||||
|
Timer timer = new Timer();
|
||||||
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
|
Optional<Alliance> alliance;
|
||||||
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
|
.withDriveRequestType(DriveRequestType.OpenLoopVoltage);
|
||||||
|
/** Creates a new AvanceAuto. */
|
||||||
|
public BougerGaucheAuto(CommandSwerveDrivetrain drivetrain) {
|
||||||
|
this.drivetrain = drivetrain;
|
||||||
|
addRequirements(drivetrain);
|
||||||
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the command is initially scheduled.
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
timer.reset();
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
if(timer.get() < 1.25){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(1.5));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0));
|
||||||
|
timer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return timer.get() > 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,12 +14,14 @@ import com.ctre.phoenix6.hardware.Pigeon2;
|
|||||||
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||||
import com.ctre.phoenix6.swerve.SwerveRequest;
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.math.MathUtil;
|
||||||
import edu.wpi.first.wpilibj.DriverStation;
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
import frc.robot.generated.TunerConstants;
|
import frc.robot.generated.TunerConstants;
|
||||||
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
import frc.robot.subsystems.LimeLight3;
|
import frc.robot.subsystems.LimeLight3;
|
||||||
|
import frc.robot.subsystems.Limelight3G;
|
||||||
|
|
||||||
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
|
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
|
||||||
public class GrimperMur extends Command {
|
public class GrimperMur extends Command {
|
||||||
@@ -31,9 +33,9 @@ public class GrimperMur extends Command {
|
|||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
double angle;
|
double angle;
|
||||||
|
double pigeonAngle;
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
Pigeon2 pigeon2;
|
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
@@ -48,50 +50,65 @@ public class GrimperMur extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
// if(drivetrain.Equipe()){
|
||||||
|
// angle+=180;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
BotPose = limeLight3.getBotPoseBlue();
|
if(limeLight3.getV()){
|
||||||
botx = BotPose[0];
|
BotPose = limeLight3.getBotPoseBlue();
|
||||||
boty = BotPose[1];
|
botx = BotPose[0];
|
||||||
if(angle < 0){
|
boty = BotPose[1];
|
||||||
angle = angle + 360;
|
if(angle < 0){
|
||||||
}
|
angle = angle + 360;
|
||||||
if(alliance.get() == Alliance.Blue){
|
}
|
||||||
y = 2.961328;
|
if(alliance.get() == Alliance.Red){
|
||||||
x = 1.11;
|
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
angle = 0;
|
System.out.println(pigeonAngle);
|
||||||
if(pigeon2.getYaw().getValueAsDouble() > 355 || pigeon2.getYaw().getValueAsDouble() < 5){
|
y = 3.6;
|
||||||
drivetrain.setControl(drive.withVelocityX(y-boty).withVelocityY(x-botx));
|
x = 15;
|
||||||
|
angle = 180;
|
||||||
|
if(pigeonAngle> 358 || pigeonAngle< 2){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp((-(y-boty)*10), -2, 2)).withVelocityX(MathUtil.clamp((-(x-botx)*10),-2,2)).withRotationalRate(0));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(pigeonAngle>180){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0).withVelocityX(0).withRotationalRate(1));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0).withVelocityX(0).withRotationalRate(-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
|
System.out.println(pigeonAngle);
|
||||||
|
y = 4.4;
|
||||||
|
x = 1.6;
|
||||||
|
angle = 0;
|
||||||
|
if(pigeonAngle> 182 || pigeonAngle< 178){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp(((y-boty)*10), -2, 2)).withVelocityX(MathUtil.clamp(((x-botx)*10),-2,2)).withRotationalRate(0));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(pigeonAngle>0 && pigeonAngle<180){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0).withVelocityX(0).withRotationalRate(-1));
|
||||||
|
System.out.println("x");
|
||||||
|
}
|
||||||
|
else if(pigeonAngle>180){
|
||||||
|
System.out.println("e");
|
||||||
|
drivetrain.setControl(drive.withVelocityY(0).withVelocityX(0).withRotationalRate(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
|
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0).withRotationalRate(0));
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
|
||||||
}
|
|
||||||
else if(pigeon2.getYaw().getValueAsDouble() >180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
|
||||||
x = 11.45966;
|
|
||||||
y = 6.959326;
|
|
||||||
angle = 180;
|
|
||||||
if(pigeon2.getYaw().getValueAsDouble() > 175 && pigeon2.getYaw().getValueAsDouble() < 185){
|
|
||||||
drivetrain.setControl(drive.withVelocityX(y-boty).withVelocityY(x-botx));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5));
|
|
||||||
}
|
|
||||||
else if(pigeon2.getYaw().getValueAsDouble() >180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@@ -103,6 +120,6 @@ public class GrimperMur extends Command {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return (y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05);
|
return (y-boty < 0.2 && y-boty >-0.2) && (x-botx < 0.06 && x-botx > -0.06);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ import com.ctre.phoenix6.hardware.Pigeon2;
|
|||||||
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||||
import com.ctre.phoenix6.swerve.SwerveRequest;
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.math.MathUtil;
|
||||||
import edu.wpi.first.wpilibj.DriverStation;
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
@@ -31,10 +32,10 @@ public class GrimperReservoir extends Command {
|
|||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
double angle;
|
double angle;
|
||||||
|
double pigeonAngle;
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
Pigeon2 pigeon2;
|
Optional<Alliance> alliance;
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
|
||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
.withDriveRequestType(DriveRequestType.OpenLoopVoltage);
|
.withDriveRequestType(DriveRequestType.OpenLoopVoltage);
|
||||||
@@ -48,50 +49,65 @@ public class GrimperReservoir extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
// if(drivetrain.Equipe()){
|
||||||
|
// drivetrain.getPigeon2().setYaw(drivetrain.getPigeon2().getYaw().getValueAsDouble()+180);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
BotPose = limeLight3G.getBotPoseBlue();
|
if(limeLight3G.getV()){
|
||||||
botx = BotPose[0];
|
BotPose = limeLight3G.getBotPoseBlue();
|
||||||
boty = BotPose[1];
|
botx = BotPose[0];
|
||||||
if(angle < 0){
|
boty = BotPose[1];
|
||||||
angle = angle + 360;
|
if(angle < 0){
|
||||||
}
|
angle = angle + 360;
|
||||||
if(alliance.get() == Alliance.Blue){
|
}
|
||||||
y = 5.081328;
|
if(alliance.get() == Alliance.Red){
|
||||||
x = 1.11;
|
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
angle = 180;
|
System.out.println(pigeonAngle);
|
||||||
if(pigeon2.getYaw().getValueAsDouble() < 185 && pigeon2.getYaw().getValueAsDouble() > 175){
|
y = 5.2;
|
||||||
drivetrain.setControl(drive.withVelocityX(y-boty).withVelocityY(x-botx));
|
x = 15.6;
|
||||||
|
angle = 180;
|
||||||
|
if(pigeonAngle< 190 && pigeonAngle> 170){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp((-(y-boty)*10), -2, 2)).withVelocityX(MathUtil.clamp((-(x-botx)*10),-2,2)));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(pigeonAngle>180){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(-1));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pigeonAngle = drivetrain.getPigeon2().getYaw().getValueAsDouble()+180;
|
||||||
|
System.out.println(pigeonAngle);
|
||||||
|
y = 2.6;
|
||||||
|
x = 1.11;
|
||||||
|
angle = 0;
|
||||||
|
if(pigeonAngle> 358 || pigeonAngle< 2){
|
||||||
|
drivetrain.setControl(drive.withVelocityY(MathUtil.clamp(((y-boty)*10), -2, 2)).withVelocityX(MathUtil.clamp(((x-botx)*10),-2,2)).withRotationalRate(0));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(pigeonAngle>0 && pigeonAngle<180){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(-1));
|
||||||
|
System.out.println("x");
|
||||||
|
}
|
||||||
|
else if(pigeonAngle>180){
|
||||||
|
System.out.println("e");
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
|
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0).withRotationalRate(0));
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5));
|
|
||||||
}
|
|
||||||
else if(pigeon2.getYaw().getValueAsDouble() >180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
|
||||||
y = 6.959326;
|
|
||||||
x = 13.57966;
|
|
||||||
angle = 0;
|
|
||||||
if(pigeon2.getYaw().getValueAsDouble() > 355 || pigeon2.getYaw().getValueAsDouble() < 5){
|
|
||||||
drivetrain.setControl(drive.withVelocityX(y-boty).withVelocityY(x-botx));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
|
||||||
}
|
|
||||||
else if(pigeon2.getYaw().getValueAsDouble() >180){
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@@ -103,6 +119,6 @@ public class GrimperReservoir extends Command {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return (y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05);
|
return (y-boty < 0.2 && y-boty >-0.2) && (x-botx < 0.06 && x-botx > -0.06);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,11 @@
|
|||||||
|
|
||||||
package frc.robot.commands.ModeAuto;
|
package frc.robot.commands.ModeAuto;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import edu.wpi.first.math.controller.PIDController;
|
import edu.wpi.first.math.controller.PIDController;
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation;
|
||||||
|
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||||
import edu.wpi.first.wpilibj.Timer;
|
import edu.wpi.first.wpilibj.Timer;
|
||||||
import edu.wpi.first.wpilibj2.command.Command;
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
import frc.robot.subsystems.Lanceur;
|
import frc.robot.subsystems.Lanceur;
|
||||||
@@ -18,6 +22,8 @@ public class LancerAuto extends Command {
|
|||||||
Limelight3G limelight3g;
|
Limelight3G limelight3g;
|
||||||
double botx = 0;
|
double botx = 0;
|
||||||
double boty = 0;
|
double boty = 0;
|
||||||
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
|
|
||||||
/** Creates a new LancerAuto. */
|
/** Creates a new LancerAuto. */
|
||||||
public LancerAuto(Lanceur lanceur, Limelight3G limelight3g) {
|
public LancerAuto(Lanceur lanceur, Limelight3G limelight3g) {
|
||||||
this.lanceur = lanceur;
|
this.lanceur = lanceur;
|
||||||
@@ -30,34 +36,44 @@ public class LancerAuto extends Command {
|
|||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
pidController = new PIDController(0.0007, 0,0, 0.001);
|
pidController = new PIDController(0.0007, 0, 0, 0.001);
|
||||||
|
timer.reset();
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
double[] BotPose = new double[6];
|
double[] BotPose = new double[6];
|
||||||
if(limelight3g.getV()){
|
if (limelight3g.getV()) {
|
||||||
BotPose = limelight3g.getBotPoseBlue();
|
if (!alliance.isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (alliance.get() == Alliance.Blue) {
|
||||||
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
|
} else {
|
||||||
|
BotPose = limelight3g.getBotPoseRed();
|
||||||
|
}
|
||||||
|
|
||||||
botx = BotPose[0];
|
botx = BotPose[0];
|
||||||
boty = BotPose[1];
|
boty = BotPose[1];
|
||||||
}
|
}
|
||||||
double vitesse = 0.5;
|
double vitesse = 0.5;
|
||||||
if(limelight3g.getV()){
|
if (limelight3g.getV()) {
|
||||||
vitesse = 410.57 * ((Math.sqrt(Math.pow(Math.abs(4.625594-botx), 2) + Math.pow(Math.abs(4.034536-boty), 2)))) + 2250;
|
vitesse = 410.57 * ((Math.sqrt(Math.pow(Math.abs(4.625594 - botx), 2) + Math.pow(Math.abs(4.034536 - boty), 2))))
|
||||||
System.out.println(vitesse);
|
+ 2250;
|
||||||
|
System.out.println("lancer");
|
||||||
|
|
||||||
double output = pidController.calculate(lanceur.Vitesse(),vitesse);
|
double output = pidController.calculate(lanceur.Vitesse(), vitesse);
|
||||||
lanceur.Lancer(output);
|
lanceur.Lancer(output);
|
||||||
if(lanceur.Vitesse() >= vitesse-800){
|
if (lanceur.Vitesse() >= vitesse - 800) {
|
||||||
timer.start();
|
timer.start();
|
||||||
if(timer.get() >0.5){
|
if (timer.get() > 1) {
|
||||||
lanceur.Demeler(1);
|
lanceur.Demeler(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
@@ -72,6 +88,6 @@ public class LancerAuto extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return timer.get() > 4;
|
return timer.get() > 4;
|
||||||
//return false;
|
// return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class LimelighterAuto extends Command {
|
|||||||
double boty;
|
double boty;
|
||||||
double angle;
|
double angle;
|
||||||
double calcul;
|
double calcul;
|
||||||
|
double x;
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
@@ -42,7 +43,9 @@ public class LimelighterAuto extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
@@ -50,26 +53,64 @@ public class LimelighterAuto extends Command {
|
|||||||
double[] BotPose = new double[6];
|
double[] BotPose = new double[6];
|
||||||
System.out.println("e");
|
System.out.println("e");
|
||||||
if (limelight3g.getV()) {
|
if (limelight3g.getV()) {
|
||||||
if(alliance.get() == Alliance.Blue){
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
|
if (!alliance.isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (alliance.get() == Alliance.Blue) {
|
||||||
|
x = 4.6;
|
||||||
BotPose = limelight3g.getBotPoseBlue();
|
BotPose = limelight3g.getBotPoseBlue();
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
BotPose = limelight3g.getBotPoseRed();
|
// x = 11.915394;
|
||||||
|
x = 4.6;
|
||||||
|
BotPose = limelight3g.getBotPoseRed();
|
||||||
}
|
}
|
||||||
|
botx = BotPose[0];
|
||||||
botx = BotPose[1];
|
boty = BotPose[1];
|
||||||
boty = BotPose[0];
|
angle = BotPose[5];
|
||||||
angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
|
||||||
if(angle >180){
|
if(calcul > -5 && calcul < 5){
|
||||||
angle -= 360;
|
drivetrain.setControl(
|
||||||
|
drive.withRotationalRate(0));
|
||||||
}
|
}
|
||||||
calcul = limelight3g.Calcule(botx, 4, boty, 4.6, angle) / 5;
|
else if(calcul > 5){
|
||||||
drivetrain.setControl(
|
drivetrain.setControl(
|
||||||
drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
|
drive.withRotationalRate(2));
|
||||||
System.out.println(calcul);
|
|
||||||
if (calcul < 0.2 && calcul > -0.2) {
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0));
|
|
||||||
}
|
}
|
||||||
|
else if(calcul < -5){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(-2));
|
||||||
|
}
|
||||||
|
// botx = BotPose[1];
|
||||||
|
// boty = BotPose[0];
|
||||||
|
// angle = drivetrain.getPigeon2().getYaw().getValueAsDouble();
|
||||||
|
// calcul = limelight3g.Calcule(botx, x, boty, 4, angle);
|
||||||
|
// if(calcul < -5 && calcul > -180){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else if(calcul > 5 && calcul < 180){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(-0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else if(calcul < -5){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(-0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else if(calcul <= -180){
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(0.5*(2*Math.PI)));
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withRotationalRate(0));
|
||||||
|
// }
|
||||||
|
// drivetrain.setControl(
|
||||||
|
// drive.withVelocityX(0).withVelocityY(0).withRotationalRate(calcul));
|
||||||
|
// System.out.println(angle);
|
||||||
|
// if (calcul < 0.2 && calcul > -0.2) {
|
||||||
|
// drivetrain.setControl(drive.withRotationalRate(0));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
drivetrain.setControl(drive.withRotationalRate(0));
|
drivetrain.setControl(drive.withRotationalRate(0));
|
||||||
@@ -86,7 +127,7 @@ public class LimelighterAuto extends Command {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return calcul < 0.1 && calcul > -0.1;
|
return calcul > -5 && calcul < 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ public class RetourMilieuDroite extends Command {
|
|||||||
double angle;
|
double angle;
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
Pigeon2 pigeon2;
|
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
@@ -58,7 +57,7 @@ public class RetourMilieuDroite extends Command {
|
|||||||
x = 2.305;
|
x = 2.305;
|
||||||
angle = 0;
|
angle = 0;
|
||||||
if(limelight3g.getV()){
|
if(limelight3g.getV()){
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >355 || pigeon2.getYaw().getValueAsDouble() < 5){
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >355 || drivetrain.getPigeon2().getYaw().getValueAsDouble() < 5){
|
||||||
if((y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05)){
|
if((y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05)){
|
||||||
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0));
|
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0));
|
||||||
}
|
}
|
||||||
@@ -72,10 +71,10 @@ public class RetourMilieuDroite extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >angle && pigeon2.getYaw().getValueAsDouble() <angle +180){
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >angle && drivetrain.getPigeon2().getYaw().getValueAsDouble() <angle +180){
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5));
|
drivetrain.setControl(drive.withRotationalRate(0.5));
|
||||||
}
|
}
|
||||||
else if(pigeon2.getYaw().getValueAsDouble() >=angle +180){
|
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >=angle +180){
|
||||||
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
||||||
}
|
}
|
||||||
@@ -88,10 +87,10 @@ public class RetourMilieuDroite extends Command {
|
|||||||
angle = 180;
|
angle = 180;
|
||||||
if(limelight3g.getV()){
|
if(limelight3g.getV()){
|
||||||
}
|
}
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5));
|
drivetrain.setControl(drive.withRotationalRate(0.5));
|
||||||
}
|
}
|
||||||
else if(pigeon2.getYaw().getValueAsDouble() >180){
|
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ public class RetourMilieuGauche extends Command {
|
|||||||
double angle;
|
double angle;
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
Pigeon2 pigeon2;
|
|
||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1)
|
||||||
@@ -63,7 +62,7 @@ public class RetourMilieuGauche extends Command {
|
|||||||
x = 2.305;
|
x = 2.305;
|
||||||
angle = 0;
|
angle = 0;
|
||||||
if(limelight3g.getV()){
|
if(limelight3g.getV()){
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >355 || pigeon2.getYaw().getValueAsDouble() < 5){
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >355 || drivetrain.getPigeon2().getYaw().getValueAsDouble() < 5){
|
||||||
if((y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05)){
|
if((y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05)){
|
||||||
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0));
|
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0));
|
||||||
}
|
}
|
||||||
@@ -77,10 +76,10 @@ public class RetourMilieuGauche extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >angle && pigeon2.getYaw().getValueAsDouble() <angle +180){
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >angle && drivetrain.getPigeon2().getYaw().getValueAsDouble() <angle +180){
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5));
|
drivetrain.setControl(drive.withRotationalRate(0.5));
|
||||||
}
|
}
|
||||||
else if(pigeon2.getYaw().getValueAsDouble() >=angle +180){
|
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >=angle +180){
|
||||||
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
||||||
}
|
}
|
||||||
@@ -92,7 +91,7 @@ public class RetourMilieuGauche extends Command {
|
|||||||
x = 13.963;
|
x = 13.963;
|
||||||
angle = 180;
|
angle = 180;
|
||||||
if(limelight3g.getV()){
|
if(limelight3g.getV()){
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >175 && pigeon2.getYaw().getValueAsDouble() < 185){
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >175 && drivetrain.getPigeon2().getYaw().getValueAsDouble() < 185){
|
||||||
if((y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05)){
|
if((y-boty < 0.05 && y-boty >-0.05) && (x-botx < 0.05 && x-botx > -0.05)){
|
||||||
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0));
|
drivetrain.setControl(drive.withVelocityX(0).withVelocityY(0));
|
||||||
}
|
}
|
||||||
@@ -106,10 +105,10 @@ public class RetourMilieuGauche extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
||||||
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
drivetrain.setControl(drive.withRotationalRate(-0.5));
|
||||||
}
|
}
|
||||||
else if(pigeon2.getYaw().getValueAsDouble() >=180){
|
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >=180){
|
||||||
|
|
||||||
drivetrain.setControl(drive.withRotationalRate(0.5));
|
drivetrain.setControl(drive.withRotationalRate(0.5));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ public class TournerVersMur extends Command {
|
|||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
Pigeon2 pigeon2;
|
|
||||||
double force;
|
double force;
|
||||||
double angle;
|
double angle;
|
||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
@@ -38,7 +37,9 @@ public class TournerVersMur extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
@@ -51,11 +52,11 @@ public class TournerVersMur extends Command {
|
|||||||
force = -0.5;
|
force = -0.5;
|
||||||
angle = 180;
|
angle = 180;
|
||||||
}
|
}
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble()>0 && drivetrain.getPigeon2().getYaw().getValueAsDouble()<180){
|
||||||
drivetrain.setControl(drive.withRotationalRate(force));
|
drivetrain.setControl(drive.withRotationalRate(force*180/Math.PI));
|
||||||
}
|
}
|
||||||
else if(pigeon2.getYaw().getValueAsDouble() >180){
|
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble()>180){
|
||||||
drivetrain.setControl(drive.withRotationalRate(-force));
|
drivetrain.setControl(drive.withRotationalRate(-force*180/Math.PI));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +67,6 @@ public class TournerVersMur extends Command {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return pigeon2.getYaw().getValueAsDouble() > angle && pigeon2.getYaw().getValueAsDouble() < angle + 5;
|
return drivetrain.getPigeon2().getYaw().getValueAsDouble()> angle && drivetrain.getPigeon2().getYaw().getValueAsDouble()< angle + 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ public class TournerVersReservoir extends Command {
|
|||||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||||
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond);
|
||||||
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond);
|
||||||
Pigeon2 pigeon2;
|
|
||||||
double force;
|
double force;
|
||||||
double angle;
|
double angle;
|
||||||
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric()
|
||||||
@@ -38,25 +37,34 @@ public class TournerVersReservoir extends Command {
|
|||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {}
|
public void initialize() {
|
||||||
|
alliance = DriverStation.getAlliance();
|
||||||
|
}
|
||||||
|
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if(alliance.get() == Alliance.Blue){
|
if(alliance.isPresent()){
|
||||||
|
if(alliance.get() == Alliance.Blue){
|
||||||
force = 0.5;
|
force = 0.5;
|
||||||
angle = 180;
|
angle = 180;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
force = -0.5;
|
force = -0.5;
|
||||||
angle = 0;
|
angle = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(pigeon2.getYaw().getValueAsDouble() >0 && pigeon2.getYaw().getValueAsDouble() <180){
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() > angle && drivetrain.getPigeon2().getYaw().getValueAsDouble() < angle + 10){
|
||||||
drivetrain.setControl(drive.withRotationalRate(-force));
|
drivetrain.setControl(drive.withRotationalRate(0));
|
||||||
}
|
}
|
||||||
else if(pigeon2.getYaw().getValueAsDouble() >180){
|
else{
|
||||||
drivetrain.setControl(drive.withRotationalRate(force));
|
if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >0 && drivetrain.getPigeon2().getYaw().getValueAsDouble() <180){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(-force*2));
|
||||||
}
|
}
|
||||||
|
else if(drivetrain.getPigeon2().getYaw().getValueAsDouble() >180){
|
||||||
|
drivetrain.setControl(drive.withRotationalRate(force*2));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@@ -66,6 +74,6 @@ public class TournerVersReservoir extends Command {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return pigeon2.getYaw().getValueAsDouble() > angle && pigeon2.getYaw().getValueAsDouble() < angle + 5;
|
return drivetrain.getPigeon2().getYaw().getValueAsDouble() > angle && drivetrain.getPigeon2().getYaw().getValueAsDouble() < angle + 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class MonterGrimpeur extends Command {
|
|||||||
/** Creates a new MonterGrimpeur. */
|
/** Creates a new MonterGrimpeur. */
|
||||||
public MonterGrimpeur(Grimpeur grimpeur) {
|
public MonterGrimpeur(Grimpeur grimpeur) {
|
||||||
this.grimpeur = grimpeur;
|
this.grimpeur = grimpeur;
|
||||||
|
addRequirements(grimpeur);
|
||||||
// Use addRequirements() here to declare subsystem dependencies.
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,23 +26,26 @@ public class MonterGrimpeur extends Command {
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
if(Math.abs(grimpeur.Position()) < grimpeur.PositionFinal()){
|
if(Math.abs(grimpeur.Position()) < grimpeur.PositionFinal()){
|
||||||
grimpeur.Grimper(0.5);
|
grimpeur.GrimperGauche(0.5);
|
||||||
|
grimpeur.GrimperDroit(0.5);
|
||||||
System.out.println("monte");
|
System.out.println("monte");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
grimpeur.Grimper(0);
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
// Called once the command ends or is interrupted.
|
||||||
@Override
|
@Override
|
||||||
public void end(boolean interrupted) {
|
public void end(boolean interrupted) {
|
||||||
grimpeur.Grimper(0);
|
grimpeur.GrimperGauche(0);
|
||||||
|
grimpeur.GrimperDroit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return false;
|
return Math.abs(grimpeur.Position()) > grimpeur.PositionFinal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,286 +1,287 @@
|
|||||||
package frc.robot.generated;
|
package frc.robot.generated;
|
||||||
|
|
||||||
import static edu.wpi.first.units.Units.*;
|
import static edu.wpi.first.units.Units.*;
|
||||||
|
|
||||||
import com.ctre.phoenix6.CANBus;
|
import com.ctre.phoenix6.CANBus;
|
||||||
import com.ctre.phoenix6.configs.*;
|
import com.ctre.phoenix6.configs.*;
|
||||||
import com.ctre.phoenix6.hardware.*;
|
import com.ctre.phoenix6.hardware.*;
|
||||||
import com.ctre.phoenix6.signals.*;
|
import com.ctre.phoenix6.signals.*;
|
||||||
import com.ctre.phoenix6.swerve.*;
|
import com.ctre.phoenix6.swerve.*;
|
||||||
import com.ctre.phoenix6.swerve.SwerveModuleConstants.*;
|
import com.ctre.phoenix6.swerve.SwerveModuleConstants.*;
|
||||||
|
|
||||||
import edu.wpi.first.math.Matrix;
|
import edu.wpi.first.math.Matrix;
|
||||||
import edu.wpi.first.math.numbers.N1;
|
import edu.wpi.first.math.numbers.N1;
|
||||||
import edu.wpi.first.math.numbers.N3;
|
import edu.wpi.first.math.numbers.N3;
|
||||||
import edu.wpi.first.units.measure.*;
|
import edu.wpi.first.units.measure.*;
|
||||||
|
|
||||||
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||||
|
|
||||||
// Generated by the 2026 Tuner X Swerve Project Generator
|
// Generated by the 2026 Tuner X Swerve Project Generator
|
||||||
// https://v6.docs.ctr-electronics.com/en/stable/docs/tuner/tuner-swerve/index.html
|
// https://v6.docs.ctr-electronics.com/en/stable/docs/tuner/tuner-swerve/index.html
|
||||||
public class TunerConstants {
|
public class TunerConstants {
|
||||||
// Both sets of gains need to be tuned to your individual robot.
|
// Both sets of gains need to be tuned to your individual robot.
|
||||||
|
|
||||||
// The steer motor uses any SwerveModule.SteerRequestType control request with the
|
// The steer motor uses any SwerveModule.SteerRequestType control request with the
|
||||||
// output type specified by SwerveModuleConstants.SteerMotorClosedLoopOutput
|
// output type specified by SwerveModuleConstants.SteerMotorClosedLoopOutput
|
||||||
private static final Slot0Configs steerGains = new Slot0Configs()
|
private static final Slot0Configs steerGains = new Slot0Configs()
|
||||||
.withKP(100).withKI(0).withKD(0.5)
|
.withKP(100).withKI(0).withKD(0.5)
|
||||||
.withKS(0.1).withKV(2.66).withKA(0)
|
.withKS(0.1).withKV(2.66).withKA(0)
|
||||||
.withStaticFeedforwardSign(StaticFeedforwardSignValue.UseClosedLoopSign);
|
.withStaticFeedforwardSign(StaticFeedforwardSignValue.UseClosedLoopSign);
|
||||||
// When using closed-loop control, the drive motor uses the control
|
// When using closed-loop control, the drive motor uses the control
|
||||||
// output type specified by SwerveModuleConstants.DriveMotorClosedLoopOutput
|
// output type specified by SwerveModuleConstants.DriveMotorClosedLoopOutput
|
||||||
private static final Slot0Configs driveGains = new Slot0Configs()
|
private static final Slot0Configs driveGains = new Slot0Configs()
|
||||||
.withKP(0.1).withKI(0).withKD(0)
|
.withKP(0.1).withKI(0).withKD(0)
|
||||||
.withKS(0).withKV(0.124);
|
.withKS(0).withKV(0.124);
|
||||||
|
|
||||||
// The closed-loop output type to use for the steer motors;
|
// The closed-loop output type to use for the steer motors;
|
||||||
// This affects the PID/FF gains for the steer motors
|
// This affects the PID/FF gains for the steer motors
|
||||||
private static final ClosedLoopOutputType kSteerClosedLoopOutput = ClosedLoopOutputType.Voltage;
|
private static final ClosedLoopOutputType kSteerClosedLoopOutput = ClosedLoopOutputType.Voltage;
|
||||||
// The closed-loop output type to use for the drive motors;
|
// The closed-loop output type to use for the drive motors;
|
||||||
// This affects the PID/FF gains for the drive motors
|
// This affects the PID/FF gains for the drive motors
|
||||||
private static final ClosedLoopOutputType kDriveClosedLoopOutput = ClosedLoopOutputType.Voltage;
|
private static final ClosedLoopOutputType kDriveClosedLoopOutput = ClosedLoopOutputType.Voltage;
|
||||||
|
|
||||||
// The type of motor used for the drive motor
|
// The type of motor used for the drive motor
|
||||||
private static final DriveMotorArrangement kDriveMotorType = DriveMotorArrangement.TalonFX_Integrated;
|
private static final DriveMotorArrangement kDriveMotorType = DriveMotorArrangement.TalonFX_Integrated;
|
||||||
// The type of motor used for the drive motor
|
// The type of motor used for the drive motor
|
||||||
private static final SteerMotorArrangement kSteerMotorType = SteerMotorArrangement.TalonFX_Integrated;
|
private static final SteerMotorArrangement kSteerMotorType = SteerMotorArrangement.TalonFX_Integrated;
|
||||||
|
|
||||||
// The remote sensor feedback type to use for the steer motors;
|
// The remote sensor feedback type to use for the steer motors;
|
||||||
// When not Pro-licensed, Fused*/Sync* automatically fall back to Remote*
|
// When not Pro-licensed, Fused*/Sync* automatically fall back to Remote*
|
||||||
private static final SteerFeedbackType kSteerFeedbackType = SteerFeedbackType.FusedCANcoder;
|
private static final SteerFeedbackType kSteerFeedbackType = SteerFeedbackType.FusedCANcoder;
|
||||||
|
|
||||||
// The stator current at which the wheels start to slip;
|
// The stator current at which the wheels start to slip;
|
||||||
// This needs to be tuned to your individual robot
|
// This needs to be tuned to your individual robot
|
||||||
private static final Current kSlipCurrent = Amps.of(120);
|
private static final Current kSlipCurrent = Amps.of(120);
|
||||||
|
|
||||||
// Initial configs for the drive and steer motors and the azimuth encoder; these cannot be null.
|
// Initial configs for the drive and steer motors and the azimuth encoder; these cannot be null.
|
||||||
// Some configs will be overwritten; check the `with*InitialConfigs()` API documentation.
|
// Some configs will be overwritten; check the `with*InitialConfigs()` API documentation.
|
||||||
private static final TalonFXConfiguration driveInitialConfigs = new TalonFXConfiguration();
|
private static final TalonFXConfiguration driveInitialConfigs = new TalonFXConfiguration();
|
||||||
private static final TalonFXConfiguration steerInitialConfigs = new TalonFXConfiguration()
|
private static final TalonFXConfiguration steerInitialConfigs = new TalonFXConfiguration()
|
||||||
.withCurrentLimits(
|
.withCurrentLimits(
|
||||||
new CurrentLimitsConfigs()
|
new CurrentLimitsConfigs()
|
||||||
// Swerve azimuth does not require much torque output, so we can set a relatively low
|
// Swerve azimuth does not require much torque output, so we can set a relatively low
|
||||||
// stator current limit to help avoid brownouts without impacting performance.
|
// stator current limit to help avoid brownouts without impacting performance.
|
||||||
.withStatorCurrentLimit(Amps.of(60))
|
.withStatorCurrentLimit(Amps.of(60))
|
||||||
.withStatorCurrentLimitEnable(true)
|
.withStatorCurrentLimitEnable(true)
|
||||||
);
|
);
|
||||||
private static final CANcoderConfiguration encoderInitialConfigs = new CANcoderConfiguration();
|
private static final CANcoderConfiguration encoderInitialConfigs = new CANcoderConfiguration();
|
||||||
// Configs for the Pigeon 2; leave this null to skip applying Pigeon 2 configs
|
// Configs for the Pigeon 2; leave this null to skip applying Pigeon 2 configs
|
||||||
private static final Pigeon2Configuration pigeonConfigs = null;
|
private static final Pigeon2Configuration pigeonConfigs = null;
|
||||||
|
|
||||||
// CAN bus that the devices are located on;
|
// CAN bus that the devices are located on;
|
||||||
// All swerve devices must share the same CAN bus
|
// All swerve devices must share the same CAN bus
|
||||||
public static final CANBus kCANBus = new CANBus("swerve", "./logs/example.hoot");
|
public static final CANBus kCANBus = new CANBus("swerve", "./logs/example.hoot");
|
||||||
|
|
||||||
// Theoretical free speed (m/s) at 12 V applied output;
|
// Theoretical free speed (m/s) at 12 V applied output;
|
||||||
// This needs to be tuned to your individual robot
|
// This needs to be tuned to your individual robot
|
||||||
public static final LinearVelocity kSpeedAt12Volts = MetersPerSecond.of(9.82);
|
public static final LinearVelocity kSpeedAt12Volts = MetersPerSecond.of(9.82);
|
||||||
|
|
||||||
// Every 1 rotation of the azimuth results in kCoupleRatio drive motor turns;
|
// Every 1 rotation of the azimuth results in kCoupleRatio drive motor turns;
|
||||||
// This may need to be tuned to your individual robot
|
// This may need to be tuned to your individual robot
|
||||||
private static final double kCoupleRatio = 3.5714285714285716;
|
private static final double kCoupleRatio = 3.5714285714285716;
|
||||||
|
|
||||||
private static final double kDriveGearRatio = 6.122448979591837;
|
private static final double kDriveGearRatio = 6.122448979591837;
|
||||||
private static final double kSteerGearRatio = 21.428571428571427;
|
private static final double kSteerGearRatio = 21.428571428571427;
|
||||||
private static final Distance kWheelRadius = Inches.of(3.895);
|
// private static final Distance kWheelRadius = Inches.of(3.895);
|
||||||
|
private static final Distance kWheelRadius = Inches.of(2);
|
||||||
private static final boolean kInvertLeftSide = false;
|
|
||||||
private static final boolean kInvertRightSide = true;
|
private static final boolean kInvertLeftSide = false;
|
||||||
|
private static final boolean kInvertRightSide = true;
|
||||||
private static final int kPigeonId = 16;
|
|
||||||
|
private static final int kPigeonId = 16;
|
||||||
// These are only used for simulation
|
|
||||||
private static final MomentOfInertia kSteerInertia = KilogramSquareMeters.of(0.01);
|
// These are only used for simulation
|
||||||
private static final MomentOfInertia kDriveInertia = KilogramSquareMeters.of(0.01);
|
private static final MomentOfInertia kSteerInertia = KilogramSquareMeters.of(0.01);
|
||||||
// Simulated voltage necessary to overcome friction
|
private static final MomentOfInertia kDriveInertia = KilogramSquareMeters.of(0.01);
|
||||||
private static final Voltage kSteerFrictionVoltage = Volts.of(0.2);
|
// Simulated voltage necessary to overcome friction
|
||||||
private static final Voltage kDriveFrictionVoltage = Volts.of(0.2);
|
private static final Voltage kSteerFrictionVoltage = Volts.of(0.2);
|
||||||
|
private static final Voltage kDriveFrictionVoltage = Volts.of(0.2);
|
||||||
public static final SwerveDrivetrainConstants DrivetrainConstants = new SwerveDrivetrainConstants()
|
|
||||||
.withCANBusName(kCANBus.getName())
|
public static final SwerveDrivetrainConstants DrivetrainConstants = new SwerveDrivetrainConstants()
|
||||||
.withPigeon2Id(kPigeonId)
|
.withCANBusName(kCANBus.getName())
|
||||||
.withPigeon2Configs(pigeonConfigs);
|
.withPigeon2Id(kPigeonId)
|
||||||
|
.withPigeon2Configs(pigeonConfigs);
|
||||||
private static final SwerveModuleConstantsFactory<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration> ConstantCreator =
|
|
||||||
new SwerveModuleConstantsFactory<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration>()
|
private static final SwerveModuleConstantsFactory<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration> ConstantCreator =
|
||||||
.withDriveMotorGearRatio(kDriveGearRatio)
|
new SwerveModuleConstantsFactory<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration>()
|
||||||
.withSteerMotorGearRatio(kSteerGearRatio)
|
.withDriveMotorGearRatio(kDriveGearRatio)
|
||||||
.withCouplingGearRatio(kCoupleRatio)
|
.withSteerMotorGearRatio(kSteerGearRatio)
|
||||||
.withWheelRadius(kWheelRadius)
|
.withCouplingGearRatio(kCoupleRatio)
|
||||||
.withSteerMotorGains(steerGains)
|
.withWheelRadius(kWheelRadius)
|
||||||
.withDriveMotorGains(driveGains)
|
.withSteerMotorGains(steerGains)
|
||||||
.withSteerMotorClosedLoopOutput(kSteerClosedLoopOutput)
|
.withDriveMotorGains(driveGains)
|
||||||
.withDriveMotorClosedLoopOutput(kDriveClosedLoopOutput)
|
.withSteerMotorClosedLoopOutput(kSteerClosedLoopOutput)
|
||||||
.withSlipCurrent(kSlipCurrent)
|
.withDriveMotorClosedLoopOutput(kDriveClosedLoopOutput)
|
||||||
.withSpeedAt12Volts(kSpeedAt12Volts)
|
.withSlipCurrent(kSlipCurrent)
|
||||||
.withDriveMotorType(kDriveMotorType)
|
.withSpeedAt12Volts(kSpeedAt12Volts)
|
||||||
.withSteerMotorType(kSteerMotorType)
|
.withDriveMotorType(kDriveMotorType)
|
||||||
.withFeedbackSource(kSteerFeedbackType)
|
.withSteerMotorType(kSteerMotorType)
|
||||||
.withDriveMotorInitialConfigs(driveInitialConfigs)
|
.withFeedbackSource(kSteerFeedbackType)
|
||||||
.withSteerMotorInitialConfigs(steerInitialConfigs)
|
.withDriveMotorInitialConfigs(driveInitialConfigs)
|
||||||
.withEncoderInitialConfigs(encoderInitialConfigs)
|
.withSteerMotorInitialConfigs(steerInitialConfigs)
|
||||||
.withSteerInertia(kSteerInertia)
|
.withEncoderInitialConfigs(encoderInitialConfigs)
|
||||||
.withDriveInertia(kDriveInertia)
|
.withSteerInertia(kSteerInertia)
|
||||||
.withSteerFrictionVoltage(kSteerFrictionVoltage)
|
.withDriveInertia(kDriveInertia)
|
||||||
.withDriveFrictionVoltage(kDriveFrictionVoltage);
|
.withSteerFrictionVoltage(kSteerFrictionVoltage)
|
||||||
|
.withDriveFrictionVoltage(kDriveFrictionVoltage);
|
||||||
|
|
||||||
// Front Left
|
|
||||||
private static final int kFrontLeftDriveMotorId = 6;
|
// Front Left
|
||||||
private static final int kFrontLeftSteerMotorId = 9;
|
private static final int kFrontLeftDriveMotorId = 6;
|
||||||
private static final int kFrontLeftEncoderId = 24;
|
private static final int kFrontLeftSteerMotorId = 9;
|
||||||
private static final Angle kFrontLeftEncoderOffset = Rotations.of(-0.36767578125);
|
private static final int kFrontLeftEncoderId = 24;
|
||||||
private static final boolean kFrontLeftSteerMotorInverted = true;
|
private static final Angle kFrontLeftEncoderOffset = Rotations.of(-0.36767578125);
|
||||||
private static final boolean kFrontLeftEncoderInverted = false;
|
private static final boolean kFrontLeftSteerMotorInverted = true;
|
||||||
|
private static final boolean kFrontLeftEncoderInverted = false;
|
||||||
private static final Distance kFrontLeftXPos = Inches.of(11.375);
|
|
||||||
private static final Distance kFrontLeftYPos = Inches.of(10.625);
|
private static final Distance kFrontLeftXPos = Inches.of(11.375);
|
||||||
|
private static final Distance kFrontLeftYPos = Inches.of(10.625);
|
||||||
// Front Right
|
|
||||||
private static final int kFrontRightDriveMotorId = 7;
|
// Front Right
|
||||||
private static final int kFrontRightSteerMotorId = 5;
|
private static final int kFrontRightDriveMotorId = 7;
|
||||||
private static final int kFrontRightEncoderId = 22;
|
private static final int kFrontRightSteerMotorId = 5;
|
||||||
private static final Angle kFrontRightEncoderOffset = Rotations.of(0.23486328125);
|
private static final int kFrontRightEncoderId = 22;
|
||||||
private static final boolean kFrontRightSteerMotorInverted = true;
|
private static final Angle kFrontRightEncoderOffset = Rotations.of(0.23486328125);
|
||||||
private static final boolean kFrontRightEncoderInverted = false;
|
private static final boolean kFrontRightSteerMotorInverted = true;
|
||||||
|
private static final boolean kFrontRightEncoderInverted = false;
|
||||||
private static final Distance kFrontRightXPos = Inches.of(11.375);
|
|
||||||
private static final Distance kFrontRightYPos = Inches.of(-10.625);
|
private static final Distance kFrontRightXPos = Inches.of(11.375);
|
||||||
|
private static final Distance kFrontRightYPos = Inches.of(-10.625);
|
||||||
// Back Left
|
|
||||||
private static final int kBackLeftDriveMotorId = 10;
|
// Back Left
|
||||||
private static final int kBackLeftSteerMotorId = 11;
|
private static final int kBackLeftDriveMotorId = 10;
|
||||||
private static final int kBackLeftEncoderId = 21;
|
private static final int kBackLeftSteerMotorId = 11;
|
||||||
private static final Angle kBackLeftEncoderOffset = Rotations.of(0.202392578125);
|
private static final int kBackLeftEncoderId = 21;
|
||||||
private static final boolean kBackLeftSteerMotorInverted = true;
|
private static final Angle kBackLeftEncoderOffset = Rotations.of(0.202392578125);
|
||||||
private static final boolean kBackLeftEncoderInverted = false;
|
private static final boolean kBackLeftSteerMotorInverted = true;
|
||||||
|
private static final boolean kBackLeftEncoderInverted = false;
|
||||||
private static final Distance kBackLeftXPos = Inches.of(-11.375);
|
|
||||||
private static final Distance kBackLeftYPos = Inches.of(10.625);
|
private static final Distance kBackLeftXPos = Inches.of(-11.375);
|
||||||
|
private static final Distance kBackLeftYPos = Inches.of(10.625);
|
||||||
// Back Right
|
|
||||||
private static final int kBackRightDriveMotorId = 14;
|
// Back Right
|
||||||
private static final int kBackRightSteerMotorId = 13;
|
private static final int kBackRightDriveMotorId = 14;
|
||||||
private static final int kBackRightEncoderId = 23;
|
private static final int kBackRightSteerMotorId = 13;
|
||||||
private static final Angle kBackRightEncoderOffset = Rotations.of(-0.33203125);
|
private static final int kBackRightEncoderId = 23;
|
||||||
private static final boolean kBackRightSteerMotorInverted = true;
|
private static final Angle kBackRightEncoderOffset = Rotations.of(-0.33203125);
|
||||||
private static final boolean kBackRightEncoderInverted = false;
|
private static final boolean kBackRightSteerMotorInverted = true;
|
||||||
|
private static final boolean kBackRightEncoderInverted = false;
|
||||||
private static final Distance kBackRightXPos = Inches.of(-11.375);
|
|
||||||
private static final Distance kBackRightYPos = Inches.of(-10.625);
|
private static final Distance kBackRightXPos = Inches.of(-11.375);
|
||||||
|
private static final Distance kBackRightYPos = Inches.of(-10.625);
|
||||||
|
|
||||||
public static final SwerveModuleConstants<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration> FrontLeft =
|
|
||||||
ConstantCreator.createModuleConstants(
|
public static final SwerveModuleConstants<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration> FrontLeft =
|
||||||
kFrontLeftSteerMotorId, kFrontLeftDriveMotorId, kFrontLeftEncoderId, kFrontLeftEncoderOffset,
|
ConstantCreator.createModuleConstants(
|
||||||
kFrontLeftXPos, kFrontLeftYPos, kInvertLeftSide, kFrontLeftSteerMotorInverted, kFrontLeftEncoderInverted
|
kFrontLeftSteerMotorId, kFrontLeftDriveMotorId, kFrontLeftEncoderId, kFrontLeftEncoderOffset,
|
||||||
);
|
kFrontLeftXPos, kFrontLeftYPos, kInvertLeftSide, kFrontLeftSteerMotorInverted, kFrontLeftEncoderInverted
|
||||||
public static final SwerveModuleConstants<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration> FrontRight =
|
);
|
||||||
ConstantCreator.createModuleConstants(
|
public static final SwerveModuleConstants<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration> FrontRight =
|
||||||
kFrontRightSteerMotorId, kFrontRightDriveMotorId, kFrontRightEncoderId, kFrontRightEncoderOffset,
|
ConstantCreator.createModuleConstants(
|
||||||
kFrontRightXPos, kFrontRightYPos, kInvertRightSide, kFrontRightSteerMotorInverted, kFrontRightEncoderInverted
|
kFrontRightSteerMotorId, kFrontRightDriveMotorId, kFrontRightEncoderId, kFrontRightEncoderOffset,
|
||||||
);
|
kFrontRightXPos, kFrontRightYPos, kInvertRightSide, kFrontRightSteerMotorInverted, kFrontRightEncoderInverted
|
||||||
public static final SwerveModuleConstants<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration> BackLeft =
|
);
|
||||||
ConstantCreator.createModuleConstants(
|
public static final SwerveModuleConstants<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration> BackLeft =
|
||||||
kBackLeftSteerMotorId, kBackLeftDriveMotorId, kBackLeftEncoderId, kBackLeftEncoderOffset,
|
ConstantCreator.createModuleConstants(
|
||||||
kBackLeftXPos, kBackLeftYPos, kInvertLeftSide, kBackLeftSteerMotorInverted, kBackLeftEncoderInverted
|
kBackLeftSteerMotorId, kBackLeftDriveMotorId, kBackLeftEncoderId, kBackLeftEncoderOffset,
|
||||||
);
|
kBackLeftXPos, kBackLeftYPos, kInvertLeftSide, kBackLeftSteerMotorInverted, kBackLeftEncoderInverted
|
||||||
public static final SwerveModuleConstants<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration> BackRight =
|
);
|
||||||
ConstantCreator.createModuleConstants(
|
public static final SwerveModuleConstants<TalonFXConfiguration, TalonFXConfiguration, CANcoderConfiguration> BackRight =
|
||||||
kBackRightSteerMotorId, kBackRightDriveMotorId, kBackRightEncoderId, kBackRightEncoderOffset,
|
ConstantCreator.createModuleConstants(
|
||||||
kBackRightXPos, kBackRightYPos, kInvertRightSide, kBackRightSteerMotorInverted, kBackRightEncoderInverted
|
kBackRightSteerMotorId, kBackRightDriveMotorId, kBackRightEncoderId, kBackRightEncoderOffset,
|
||||||
);
|
kBackRightXPos, kBackRightYPos, kInvertRightSide, kBackRightSteerMotorInverted, kBackRightEncoderInverted
|
||||||
|
);
|
||||||
/**
|
|
||||||
* Creates a CommandSwerveDrivetrain instance.
|
/**
|
||||||
* This should only be called once in your robot program,.
|
* Creates a CommandSwerveDrivetrain instance.
|
||||||
*/
|
* This should only be called once in your robot program,.
|
||||||
public static CommandSwerveDrivetrain createDrivetrain() {
|
*/
|
||||||
return new CommandSwerveDrivetrain(
|
public static CommandSwerveDrivetrain createDrivetrain() {
|
||||||
DrivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight
|
return new CommandSwerveDrivetrain(
|
||||||
);
|
DrivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Swerve Drive class utilizing CTR Electronics' Phoenix 6 API with the selected device types.
|
/**
|
||||||
*/
|
* Swerve Drive class utilizing CTR Electronics' Phoenix 6 API with the selected device types.
|
||||||
public static class TunerSwerveDrivetrain extends SwerveDrivetrain<TalonFX, TalonFX, CANcoder> {
|
*/
|
||||||
/**
|
public static class TunerSwerveDrivetrain extends SwerveDrivetrain<TalonFX, TalonFX, CANcoder> {
|
||||||
* Constructs a CTRE SwerveDrivetrain using the specified constants.
|
/**
|
||||||
* <p>
|
* Constructs a CTRE SwerveDrivetrain using the specified constants.
|
||||||
* This constructs the underlying hardware devices, so users should not construct
|
* <p>
|
||||||
* the devices themselves. If they need the devices, they can access them through
|
* This constructs the underlying hardware devices, so users should not construct
|
||||||
* getters in the classes.
|
* the devices themselves. If they need the devices, they can access them through
|
||||||
*
|
* getters in the classes.
|
||||||
* @param drivetrainConstants Drivetrain-wide constants for the swerve drive
|
*
|
||||||
* @param modules Constants for each specific module
|
* @param drivetrainConstants Drivetrain-wide constants for the swerve drive
|
||||||
*/
|
* @param modules Constants for each specific module
|
||||||
public TunerSwerveDrivetrain(
|
*/
|
||||||
SwerveDrivetrainConstants drivetrainConstants,
|
public TunerSwerveDrivetrain(
|
||||||
SwerveModuleConstants<?, ?, ?>... modules
|
SwerveDrivetrainConstants drivetrainConstants,
|
||||||
) {
|
SwerveModuleConstants<?, ?, ?>... modules
|
||||||
super(
|
) {
|
||||||
TalonFX::new, TalonFX::new, CANcoder::new,
|
super(
|
||||||
drivetrainConstants, modules
|
TalonFX::new, TalonFX::new, CANcoder::new,
|
||||||
);
|
drivetrainConstants, modules
|
||||||
}
|
);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Constructs a CTRE SwerveDrivetrain using the specified constants.
|
/**
|
||||||
* <p>
|
* Constructs a CTRE SwerveDrivetrain using the specified constants.
|
||||||
* This constructs the underlying hardware devices, so users should not construct
|
* <p>
|
||||||
* the devices themselves. If they need the devices, they can access them through
|
* This constructs the underlying hardware devices, so users should not construct
|
||||||
* getters in the classes.
|
* the devices themselves. If they need the devices, they can access them through
|
||||||
*
|
* getters in the classes.
|
||||||
* @param drivetrainConstants Drivetrain-wide constants for the swerve drive
|
*
|
||||||
* @param odometryUpdateFrequency The frequency to run the odometry loop. If
|
* @param drivetrainConstants Drivetrain-wide constants for the swerve drive
|
||||||
* unspecified or set to 0 Hz, this is 250 Hz on
|
* @param odometryUpdateFrequency The frequency to run the odometry loop. If
|
||||||
* CAN FD, and 100 Hz on CAN 2.0.
|
* unspecified or set to 0 Hz, this is 250 Hz on
|
||||||
* @param modules Constants for each specific module
|
* CAN FD, and 100 Hz on CAN 2.0.
|
||||||
*/
|
* @param modules Constants for each specific module
|
||||||
public TunerSwerveDrivetrain(
|
*/
|
||||||
SwerveDrivetrainConstants drivetrainConstants,
|
public TunerSwerveDrivetrain(
|
||||||
double odometryUpdateFrequency,
|
SwerveDrivetrainConstants drivetrainConstants,
|
||||||
SwerveModuleConstants<?, ?, ?>... modules
|
double odometryUpdateFrequency,
|
||||||
) {
|
SwerveModuleConstants<?, ?, ?>... modules
|
||||||
super(
|
) {
|
||||||
TalonFX::new, TalonFX::new, CANcoder::new,
|
super(
|
||||||
drivetrainConstants, odometryUpdateFrequency, modules
|
TalonFX::new, TalonFX::new, CANcoder::new,
|
||||||
);
|
drivetrainConstants, odometryUpdateFrequency, modules
|
||||||
}
|
);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Constructs a CTRE SwerveDrivetrain using the specified constants.
|
/**
|
||||||
* <p>
|
* Constructs a CTRE SwerveDrivetrain using the specified constants.
|
||||||
* This constructs the underlying hardware devices, so users should not construct
|
* <p>
|
||||||
* the devices themselves. If they need the devices, they can access them through
|
* This constructs the underlying hardware devices, so users should not construct
|
||||||
* getters in the classes.
|
* the devices themselves. If they need the devices, they can access them through
|
||||||
*
|
* getters in the classes.
|
||||||
* @param drivetrainConstants Drivetrain-wide constants for the swerve drive
|
*
|
||||||
* @param odometryUpdateFrequency The frequency to run the odometry loop. If
|
* @param drivetrainConstants Drivetrain-wide constants for the swerve drive
|
||||||
* unspecified or set to 0 Hz, this is 250 Hz on
|
* @param odometryUpdateFrequency The frequency to run the odometry loop. If
|
||||||
* CAN FD, and 100 Hz on CAN 2.0.
|
* unspecified or set to 0 Hz, this is 250 Hz on
|
||||||
* @param odometryStandardDeviation The standard deviation for odometry calculation
|
* CAN FD, and 100 Hz on CAN 2.0.
|
||||||
* in the form [x, y, theta]ᵀ, with units in meters
|
* @param odometryStandardDeviation The standard deviation for odometry calculation
|
||||||
* and radians
|
* in the form [x, y, theta]ᵀ, with units in meters
|
||||||
* @param visionStandardDeviation The standard deviation for vision calculation
|
* and radians
|
||||||
* in the form [x, y, theta]ᵀ, with units in meters
|
* @param visionStandardDeviation The standard deviation for vision calculation
|
||||||
* and radians
|
* in the form [x, y, theta]ᵀ, with units in meters
|
||||||
* @param modules Constants for each specific module
|
* and radians
|
||||||
*/
|
* @param modules Constants for each specific module
|
||||||
public TunerSwerveDrivetrain(
|
*/
|
||||||
SwerveDrivetrainConstants drivetrainConstants,
|
public TunerSwerveDrivetrain(
|
||||||
double odometryUpdateFrequency,
|
SwerveDrivetrainConstants drivetrainConstants,
|
||||||
Matrix<N3, N1> odometryStandardDeviation,
|
double odometryUpdateFrequency,
|
||||||
Matrix<N3, N1> visionStandardDeviation,
|
Matrix<N3, N1> odometryStandardDeviation,
|
||||||
SwerveModuleConstants<?, ?, ?>... modules
|
Matrix<N3, N1> visionStandardDeviation,
|
||||||
) {
|
SwerveModuleConstants<?, ?, ?>... modules
|
||||||
super(
|
) {
|
||||||
TalonFX::new, TalonFX::new, CANcoder::new,
|
super(
|
||||||
drivetrainConstants, odometryUpdateFrequency,
|
TalonFX::new, TalonFX::new, CANcoder::new,
|
||||||
odometryStandardDeviation, visionStandardDeviation, modules
|
drivetrainConstants, odometryUpdateFrequency,
|
||||||
);
|
odometryStandardDeviation, visionStandardDeviation, modules
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
|||||||
private final SwerveRequest.SysIdSwerveTranslation m_translationCharacterization = new SwerveRequest.SysIdSwerveTranslation();
|
private final SwerveRequest.SysIdSwerveTranslation m_translationCharacterization = new SwerveRequest.SysIdSwerveTranslation();
|
||||||
private final SwerveRequest.SysIdSwerveSteerGains m_steerCharacterization = new SwerveRequest.SysIdSwerveSteerGains();
|
private final SwerveRequest.SysIdSwerveSteerGains m_steerCharacterization = new SwerveRequest.SysIdSwerveSteerGains();
|
||||||
private final SwerveRequest.SysIdSwerveRotation m_rotationCharacterization = new SwerveRequest.SysIdSwerveRotation();
|
private final SwerveRequest.SysIdSwerveRotation m_rotationCharacterization = new SwerveRequest.SysIdSwerveRotation();
|
||||||
|
|
||||||
/* SysId routine for characterizing translation. This is used to find PID gains for the drive motors. */
|
/* SysId routine for characterizing translation. This is used to find PID gains for the drive motors. */
|
||||||
private final SysIdRoutine m_sysIdRoutineTranslation = new SysIdRoutine(
|
private final SysIdRoutine m_sysIdRoutineTranslation = new SysIdRoutine(
|
||||||
new SysIdRoutine.Config(
|
new SysIdRoutine.Config(
|
||||||
@@ -254,7 +253,6 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
|||||||
else if(getPigeon2().getYaw().getValueAsDouble() < 0){
|
else if(getPigeon2().getYaw().getValueAsDouble() < 0){
|
||||||
getPigeon2().setYaw(getPigeon2().getYaw().getValueAsDouble()+360);
|
getPigeon2().setYaw(getPigeon2().getYaw().getValueAsDouble()+360);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Periodically try to apply the operator perspective.
|
* Periodically try to apply the operator perspective.
|
||||||
* If we haven't applied the operator perspective before, then we should apply it regardless of DS state.
|
* If we haven't applied the operator perspective before, then we should apply it regardless of DS state.
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
package frc.robot.subsystems;
|
package frc.robot.subsystems;
|
||||||
|
|
||||||
import com.revrobotics.spark.SparkMax;
|
import com.revrobotics.spark.SparkMax;
|
||||||
import com.revrobotics.spark.config.SparkMaxConfig;
|
|
||||||
import com.revrobotics.spark.SparkLowLevel.MotorType;
|
import com.revrobotics.spark.SparkLowLevel.MotorType;
|
||||||
|
|
||||||
import edu.wpi.first.networktables.GenericEntry;
|
import edu.wpi.first.networktables.GenericEntry;
|
||||||
@@ -16,28 +15,44 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
|||||||
|
|
||||||
public class Grimpeur extends SubsystemBase {
|
public class Grimpeur extends SubsystemBase {
|
||||||
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
||||||
SparkMax grimpeur1 = new SparkMax(3,MotorType.kBrushless);
|
SparkMax grimpeur1 = new SparkMax(3, MotorType.kBrushless);
|
||||||
SparkMax grimpeur2 = new SparkMax(12,MotorType.kBrushless);
|
SparkMax grimpeur2 = new SparkMax(12, MotorType.kBrushless);
|
||||||
SparkMaxConfig slaveConfig = new SparkMaxConfig();
|
|
||||||
|
// SparkMaxConfig slaveConfig = new SparkMaxConfig();
|
||||||
DigitalInput limit = new DigitalInput(0);
|
DigitalInput limit = new DigitalInput(0);
|
||||||
private GenericEntry EncodeurGrimpeur =
|
private GenericEntry EncodeurGrimpeur = teb.add("Position haut grimpeur", 100).getEntry();
|
||||||
teb.add("Position haut grimpeur", 105).getEntry();
|
|
||||||
public void Grimper(double vitesse){
|
// public void Grimper(double vitesse){
|
||||||
|
// grimpeur1.configure(slaveConfig, ResetMode.kNoResetSafeParameters,
|
||||||
|
// PersistMode.kPersistParameters);
|
||||||
|
// grimpeur2.configure(slaveConfig.follow(grimpeur1),
|
||||||
|
// ResetMode.kNoResetSafeParameters, PersistMode.kPersistParameters);
|
||||||
|
// grimpeur1.set(vitesse);
|
||||||
|
// }
|
||||||
|
public void GrimperGauche(double vitesse) {
|
||||||
grimpeur1.set(vitesse);
|
grimpeur1.set(vitesse);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GrimperDroit(double vitesse) {
|
||||||
grimpeur2.set(vitesse);
|
grimpeur2.set(vitesse);
|
||||||
}
|
}
|
||||||
public double Position(){
|
|
||||||
|
public double Position() {
|
||||||
return grimpeur1.getEncoder().getPosition();
|
return grimpeur1.getEncoder().getPosition();
|
||||||
}
|
}
|
||||||
public void Reset(){
|
|
||||||
|
public void Reset() {
|
||||||
grimpeur1.getEncoder().setPosition(0);
|
grimpeur1.getEncoder().setPosition(0);
|
||||||
}
|
}
|
||||||
public boolean Limit(){
|
|
||||||
|
public boolean Limit() {
|
||||||
return limit.get();
|
return limit.get();
|
||||||
}
|
}
|
||||||
public double PositionFinal(){
|
|
||||||
return EncodeurGrimpeur.getDouble(105);
|
public double PositionFinal() {
|
||||||
|
return EncodeurGrimpeur.getDouble(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a new Grimpeur. */
|
/** Creates a new Grimpeur. */
|
||||||
public Grimpeur() {
|
public Grimpeur() {
|
||||||
teb.addDouble("encodeur grimpeur", this::Position);
|
teb.addDouble("encodeur grimpeur", this::Position);
|
||||||
|
|||||||
149
src/main/java/frc/robot/subsystems/LEDSubsystem.java
Normal file
149
src/main/java/frc/robot/subsystems/LEDSubsystem.java
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
// /* Generated by Phoenix Tuner X */
|
||||||
|
// package frc.robot.subsystems;
|
||||||
|
|
||||||
|
// import edu.wpi.first.networktables.GenericEntry;
|
||||||
|
// import edu.wpi.first.wpilibj.DriverStation;
|
||||||
|
// import edu.wpi.first.wpilibj.Timer;
|
||||||
|
// import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
|
||||||
|
// import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||||
|
// import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
||||||
|
// import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
// import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||||
|
|
||||||
|
// import com.ctre.phoenix6.CANBus;
|
||||||
|
// import com.ctre.phoenix6.controls.SolidColor;
|
||||||
|
// import com.ctre.phoenix6.hardware.CANdle;
|
||||||
|
// import com.ctre.phoenix6.signals.RGBWColor;
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Subsystem that controls an addressable LED strip using a CANdle.
|
||||||
|
// */
|
||||||
|
// public class LEDSubsystem extends SubsystemBase {
|
||||||
|
// Timer _timer;
|
||||||
|
// boolean q = true;
|
||||||
|
// ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
||||||
|
// private GenericEntry equipe =
|
||||||
|
// teb.add("equipe commence (bleu = ouvert, rouge = fermé)", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
|
||||||
|
// private final CANBus kCANBus = new CANBus("rio");
|
||||||
|
// private final CANdle m_candle = new CANdle(17, kCANBus);
|
||||||
|
// public void Bleu(){
|
||||||
|
// m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(255, 0, 0, 0)));
|
||||||
|
// }
|
||||||
|
// public void Rouge(){
|
||||||
|
// m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 0, 255, 0)));
|
||||||
|
// }
|
||||||
|
// public void Vert(){
|
||||||
|
// m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 255, 0, 0)));
|
||||||
|
// }
|
||||||
|
// public void Noir(){
|
||||||
|
|
||||||
|
// m_candle.setControl(new SolidColor(0, 80).withColor(new RGBWColor(0, 0, 0, 0)));
|
||||||
|
// }
|
||||||
|
// public void Flash(boolean couleur){
|
||||||
|
// Timer timer = new Timer();
|
||||||
|
// if(timer.get() <0.5){
|
||||||
|
// if(couleur){
|
||||||
|
// Bleu();
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// Rouge();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// Noir();
|
||||||
|
// timer.reset();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// public LEDSubsystem() {
|
||||||
|
// setDefaultCommand(updateLEDs());
|
||||||
|
// _timer = new Timer();
|
||||||
|
// _timer.start();
|
||||||
|
// }
|
||||||
|
// public boolean Equipe(){
|
||||||
|
// return equipe.getBoolean(false);
|
||||||
|
// }
|
||||||
|
// /**
|
||||||
|
// * Updates the animations and LEDs of the CANdle.
|
||||||
|
// *
|
||||||
|
// * @return Command to run
|
||||||
|
// */
|
||||||
|
// public Command updateLEDs() {
|
||||||
|
// return run(() -> {
|
||||||
|
// // if(q){
|
||||||
|
// // _timer.reset();
|
||||||
|
// // q = false;
|
||||||
|
// // }
|
||||||
|
// double temps = _timer.get();
|
||||||
|
// System.out.println(temps);
|
||||||
|
// if(Equipe()){
|
||||||
|
// if(temps > 30){
|
||||||
|
// Vert();
|
||||||
|
// }
|
||||||
|
// else if(temps > 52){
|
||||||
|
|
||||||
|
// Bleu();
|
||||||
|
// }
|
||||||
|
// else if(temps > 55){
|
||||||
|
// Flash(true);
|
||||||
|
// }
|
||||||
|
// else if(temps > 67){
|
||||||
|
// Rouge();
|
||||||
|
// }
|
||||||
|
// else if(temps > 70){
|
||||||
|
// Flash(false);
|
||||||
|
// }
|
||||||
|
// else if(temps > 103){
|
||||||
|
// Bleu();
|
||||||
|
// }
|
||||||
|
// else if(temps > 105){
|
||||||
|
// Flash(true);
|
||||||
|
// }
|
||||||
|
// else if(temps > 127){
|
||||||
|
// Rouge();
|
||||||
|
// }
|
||||||
|
// else if(temps > 130){
|
||||||
|
// Flash(false);
|
||||||
|
// }
|
||||||
|
// else if(temps < 140){
|
||||||
|
// Vert();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// if(temps > 110){
|
||||||
|
// Vert();
|
||||||
|
// }
|
||||||
|
// else if(temps > 88){
|
||||||
|
|
||||||
|
// Rouge();
|
||||||
|
// }
|
||||||
|
// else if(temps > 85){
|
||||||
|
// Flash(false);
|
||||||
|
// }
|
||||||
|
// else if(temps > 63){
|
||||||
|
// Bleu();
|
||||||
|
// }
|
||||||
|
// else if(temps > 60){
|
||||||
|
// Flash(true);
|
||||||
|
// }
|
||||||
|
// else if(temps > 33){
|
||||||
|
// Rouge();
|
||||||
|
// }
|
||||||
|
// else if(temps > 30){
|
||||||
|
// Flash(false);
|
||||||
|
// }
|
||||||
|
// else if(temps > 13){
|
||||||
|
// Bleu();
|
||||||
|
// }
|
||||||
|
// else if(temps > 10){
|
||||||
|
// Flash(true);
|
||||||
|
// }
|
||||||
|
// else if(temps < 10){
|
||||||
|
// Vert();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // _timer.stop();
|
||||||
|
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
// 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.subsystems;
|
|
||||||
|
|
||||||
import com.ctre.phoenix.led.CANdle;
|
|
||||||
import com.ctre.phoenix.led.RainbowAnimation;
|
|
||||||
|
|
||||||
import edu.wpi.first.networktables.GenericEntry;
|
|
||||||
import edu.wpi.first.wpilibj.DriverStation;
|
|
||||||
import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
|
|
||||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
|
||||||
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
|
||||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
|
||||||
|
|
||||||
public class Led extends SubsystemBase {
|
|
||||||
ShuffleboardTab teb = Shuffleboard.getTab("teb");
|
|
||||||
private GenericEntry equipe =
|
|
||||||
teb.add("equipe commence (bleu = ouvert, rouge = fermé)", true).withWidget(BuiltInWidgets.kToggleSwitch).getEntry();
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
CANdle CANDle = new CANdle(17);
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
RainbowAnimation rainbowAnim = new RainbowAnimation();
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void bleu(){
|
|
||||||
CANDle.setLEDs(0, 0, 255,0,0,8);
|
|
||||||
CANDle.setLEDs(0, 0, 255,0,16,8);
|
|
||||||
CANDle.setLEDs(0, 0, 255,0,32,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,56,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,72,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,88,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,104,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,120,8);
|
|
||||||
// CANDle.setLEDs(0, 0, 255,0,136,8);
|
|
||||||
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void Vert1(){
|
|
||||||
CANDle.setLEDs(0, 255, 0,0,0,8);
|
|
||||||
CANDle.setLEDs(0, 255, 0,0,16,8);
|
|
||||||
CANDle.setLEDs(0, 255, 0,0,32,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,56,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,72,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,88,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,104,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,120,8);
|
|
||||||
// CANDle.setLEDs(0, 255, 0,0,136,8);
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void Rouge(){
|
|
||||||
CANDle.setLEDs(255, 0, 0,0,0,8);
|
|
||||||
CANDle.setLEDs(255, 0, 0,0,16,8);
|
|
||||||
CANDle.setLEDs(255, 0, 0,0,32,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,48,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,64,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,80,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,96,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,112,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,128,8);
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void Jaune2(){
|
|
||||||
CANDle.setLEDs(255, 255, 0,0,8,8);
|
|
||||||
CANDle.setLEDs(255, 255, 0,0,24,8);
|
|
||||||
CANDle.setLEDs(255, 255, 0,0,40,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,56,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,72,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,88,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,104,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,120,8);
|
|
||||||
// CANDle.setLEDs(255, 255, 0,0,136,8);
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void Rouge2(){
|
|
||||||
CANDle.setLEDs(255, 0, 0,0,8,8);
|
|
||||||
CANDle.setLEDs(255, 0, 0,0,24,8);
|
|
||||||
CANDle.setLEDs(255, 0, 0,0,40,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,56,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,72,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,88,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,104,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,120,8);
|
|
||||||
// CANDle.setLEDs(255, 0, 0,0,136,8);
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void RainBow(){
|
|
||||||
CANDle.animate(rainbowAnim);
|
|
||||||
}
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void RainBowStop(){
|
|
||||||
CANDle.animate(null);
|
|
||||||
}
|
|
||||||
public boolean Equipe(){
|
|
||||||
return equipe.getBoolean(true);
|
|
||||||
}
|
|
||||||
/** Creates a new Led. */
|
|
||||||
public Led() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void periodic() {
|
|
||||||
|
|
||||||
double temps = DriverStation.getMatchTime();
|
|
||||||
if(temps > 20 && temps < 30){
|
|
||||||
Vert1();
|
|
||||||
}
|
|
||||||
if(Equipe()){
|
|
||||||
if(temps > 30 && temps < 55){
|
|
||||||
bleu();
|
|
||||||
}
|
|
||||||
else if(temps > 30 && temps < 80){
|
|
||||||
Rouge();
|
|
||||||
}
|
|
||||||
else if(temps > 80 && temps < 105){
|
|
||||||
bleu();
|
|
||||||
}
|
|
||||||
else if(temps > 105 && temps < 130){
|
|
||||||
Rouge();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
RainBow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(temps > 30 && temps < 55){
|
|
||||||
Rouge();
|
|
||||||
}
|
|
||||||
else if(temps > 30 && temps < 80){
|
|
||||||
bleu();
|
|
||||||
}
|
|
||||||
else if(temps > 80 && temps < 105){
|
|
||||||
Rouge();
|
|
||||||
}
|
|
||||||
else if(temps > 105 && temps < 130){
|
|
||||||
bleu();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
RainBow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// This method will be called once per scheduler run
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ import edu.wpi.first.networktables.NetworkTableEntry;
|
|||||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||||
import frc.robot.LimelightHelpers;
|
import frc.robot.LimelightHelpers;
|
||||||
|
|
||||||
public class LimeLight3 extends SubsystemBase {
|
public class LimeLight3 extends SubsystemBase {
|
||||||
NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight-balaie");
|
NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight-balaie");
|
||||||
NetworkTableEntry pipeline = table.getEntry("pipeline");
|
NetworkTableEntry pipeline = table.getEntry("pipeline");
|
||||||
@@ -22,13 +22,13 @@ public class LimeLight3 extends SubsystemBase {
|
|||||||
}
|
}
|
||||||
public double[] getBotPoseBlue(){
|
public double[] getBotPoseBlue(){
|
||||||
NetworkTable limelightTable = NetworkTableInstance.getDefault().getTable("limelight-balaie");
|
NetworkTable limelightTable = NetworkTableInstance.getDefault().getTable("limelight-balaie");
|
||||||
NetworkTableEntry BotPoseEntry = limelightTable.getEntry("botpose_orb_wpiblue");
|
NetworkTableEntry BotPoseEntry = limelightTable.getEntry("botpose_wpiblue");
|
||||||
double[] BotPose = BotPoseEntry.getDoubleArray(new double[7]);
|
double[] BotPose = BotPoseEntry.getDoubleArray(new double[7]);
|
||||||
return BotPose;
|
return BotPose;
|
||||||
}
|
}
|
||||||
public double[] getBotPoseRed(){
|
public double[] getBotPoseRed(){
|
||||||
NetworkTable limelightTable = NetworkTableInstance.getDefault().getTable("limelight-balaie");
|
NetworkTable limelightTable = NetworkTableInstance.getDefault().getTable("limelight-balaie");
|
||||||
NetworkTableEntry BotPoseEntry = limelightTable.getEntry("botpose_orb_wpired");
|
NetworkTableEntry BotPoseEntry = limelightTable.getEntry("botpose_wpired");
|
||||||
double[] BotPose = BotPoseEntry.getDoubleArray(new double[7]);
|
double[] BotPose = BotPoseEntry.getDoubleArray(new double[7]);
|
||||||
return BotPose;
|
return BotPose;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,28 @@ NetworkTable table = NetworkTableInstance.getDefault().getTable("limelight-tag")
|
|||||||
}
|
}
|
||||||
public double Calcule(double x1, double x2, double y1, double y2, double angle)
|
public double Calcule(double x1, double x2, double y1, double y2, double angle)
|
||||||
{
|
{
|
||||||
return Math.atan((x2 - x1) / (y2 - y1)) * (180 / Math.PI) - angle;
|
// if(x1 > x2){
|
||||||
|
// if(y1 > y2){
|
||||||
|
// return Math.atan(90-((x2 - x1) / (y2 - y1))) * (180 / Math.PI) - angle;
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// return Math.atan((x2 - x1) / (y2 - y1)) * (180 / Math.PI)+90 - angle;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// if(y1 > y2){
|
||||||
|
// return Math.atan((x2 - x1) / (y2 - y1))* (180 / Math.PI)+270 - angle;
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// return Math.atan(90-((x2 - x1) / (y2 - y1))) * (180 / Math.PI)+180 - angle;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
if(y1 > y2){
|
||||||
|
return Math.toDegrees(Math.atan((x2 - x1) /(y2 - y1))) - angle;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return Math.toDegrees(-Math.atan((x2 - x1) / (y2 - y1))) - angle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void periodic() {
|
public void periodic() {
|
||||||
|
|||||||
Reference in New Issue
Block a user