Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Initial Intake (#9)
Browse files Browse the repository at this point in the history
* starting intake because nothing else for me to do

* starting intake because nothing else for me to do

* updating Pipfile.lock

* adding encoders

* added intaking command

* beginings of pid

* fixing SwerveControllerCommand

* buttons work now

* added commands and update incase we aren't quick enough when building to not relie sololy on pid

* fixed isse with crashing when pressinng button

* updating pipenv to be congruent with main

* fixing black formating

* adding the limit switches to the intake to allow intake only when its not

* put intake on network tables

* add pyproject.toml

* fix conversion factor

* add debug statements to intakesuck command

* run the command correctly >:(

* typing in intake suck @\kredcool

* log intake limit switch

* make intake invert correctly and move correctly

* intake works well****

* moving the intake works

* Update rio/constants.py

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update rio/subsystems/intake.py

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update rio/subsystems/intake.py

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* updating makefile to not have skips

---------

Co-authored-by: kredcool <[email protected]>
Co-authored-by: dublUayaychtee <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Feb 14, 2024
1 parent 9b5326e commit 821a6a4
Show file tree
Hide file tree
Showing 11 changed files with 265 additions and 19 deletions.
2 changes: 1 addition & 1 deletion rio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sim: ## Run the simulator
python -m robotpy sim

deploy: ## Deploy to the robot (with netconsole)
python -m robotpy deploy --nc
python -m robotpy deploy --nc

push: ## Deploy to the robot (push only, no netconsole)
python -m robotpy deploy
Expand Down
11 changes: 4 additions & 7 deletions rio/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions rio/commands/intakeRotationMAN.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import commands2

from subsystems.intake import IntakeSubsystem


class IntakeRotationMAN(commands2.Command):
def __init__(self, angle: float, subsystem):
"""
allows people to rotate the intake
"""
super().__init__()

# local subsystem instance
self.intakeSubsystem = subsystem

# requested speed
self.angle = angle

# TODO change current limit later in amps
self.intakeSubsystem.liftCurrentLimit(1)

def execute(self):
self.intakeSubsystem.manualLift(self.angle)

def end(self, interrupted: bool):
self.intakeSubsystem.manualLift(0)
return True
29 changes: 29 additions & 0 deletions rio/commands/intakeRotationPID.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import commands2

from subsystems.intake import IntakeSubsystem


class IntakeRotationPID(commands2.Command):
def __init__(self, angle, subsystem):
"""
rotates the intake
supposed to be used with
presets
"""
super().__init__()

# local subsystem instance
self.intakeSubsystem = subsystem

# requested speed
self.angle = angle

# TODO change current limit later in amps
self.intakeSubsystem.liftCurrentLimit(1)

def initialize(self):
self.intakeSubsystem.lift(self.angle)

def end(self, interrupted: bool):
self.intakeSubsystem.lift(0)
return True
27 changes: 27 additions & 0 deletions rio/commands/intakeSuck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import commands2

from subsystems.intake import IntakeSubsystem


class IntakeSuck(commands2.Command):
def __init__(self, speed: float, subsystem: IntakeSubsystem):
"""
takes in the rings
"""
super().__init__()

# local subsystem instance
self.intakeSubsystem = subsystem

# requested speed
self.speed = speed

# TODO change current limit later in amps
self.intakeSubsystem.intakeCurrentLimit(30)

def execute(self):
self.intakeSubsystem.intake(self.speed)

def end(self, interrupted: bool):
self.intakeSubsystem.intake(0)
return True
24 changes: 24 additions & 0 deletions rio/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,14 @@ class ModuleConstants:


class OIConstants:
# driver controller
kDriverControllerPort = 0
kDriveDeadband = 0.075

# operator controller
kOpControllerPort = 1
kIntakeButton = 1


class AutoConstants:
kMaxSpeedMetersPerSecond = 3
Expand All @@ -139,3 +144,22 @@ class AutoConstants:
kThetaControllerConstraints = TrapezoidProfileRadians.Constraints(
kMaxAngularSpeedRadiansPerSecond, kMaxAngularSpeedRadiansPerSecondSquared
)


class IntakeConstants:
# CANSparkMax ports
kliftCanId = 9
kIntakeCanId = 10

# inversion
kLiftInversion = False
kIntakeInversion = False

# conversion factor
kLiftConversion = 1 # Configured feb 12 by joe

# lift pid
kLiftP = 0
kLiftI = 0
kLiftD = 0
kLiftFF = 0
30 changes: 30 additions & 0 deletions rio/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Use this configuration file to control what RobotPy packages are installed
# on your RoboRIO
#

[tool.robotpy]

# Version of robotpy this project depends on
robotpy_version = "2024.2.1.1"

# Which extra RobotPy components should be installed
# -> equivalent to `pip install robotpy[extra1, ...]
robotpy_extras = [
# "all",
# "apriltag",
"commands2",
"cscore",
"navx",
# "pathplannerlib",
# "phoenix5",
# "phoenix6",
# "playingwithfusion",
"rev",
# "romi",
# "sim",
# "xrp",
]

# Other pip packages to install
requires = []
28 changes: 25 additions & 3 deletions rio/robotcontainer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import math

import commands2
import wpimath
# vendor libs
import wpilib

import wpimath
from commands2 import cmd
from commands2.button import CommandJoystick

Expand All @@ -15,8 +15,19 @@
from wpimath.geometry import Pose2d, Rotation2d, Translation2d
from wpimath.trajectory import TrajectoryConfig, TrajectoryGenerator

import commands2

from commands2 import cmd
from commands2.button import CommandJoystick, CommandXboxController

from constants import AutoConstants, DriveConstants, OIConstants

from subsystems.drivesubsystem import DriveSubsystem
from subsystems.intake import IntakeSubsystem

from commands.intakeSuck import IntakeSuck
from commands.intakeRotationPID import IntakeRotationPID
from commands.intakeRotationMAN import IntakeRotationMAN


class RobotContainer:
Expand All @@ -30,10 +41,14 @@ class RobotContainer:
def __init__(self) -> None:
# The robot's subsystems
self.robotDrive = DriveSubsystem()
self.intake = IntakeSubsystem()

# The driver's controller
self.driverController = CommandJoystick(0)

# the operators controller
self.opController = CommandXboxController(OIConstants.kOpControllerPort)

# Configure the button bindings
self.configureButtonBindings()

Expand All @@ -51,7 +66,7 @@ def __init__(self) -> None:
OIConstants.kDriveDeadband, # TODO: Use constants to set these controls
)
* 0.3,
wpimath.applyDeadband(
-wpimath.applyDeadband(
self.driverController.getRawAxis(0),
OIConstants.kDriveDeadband, # TODO: Use constants to set these controls
)
Expand All @@ -74,6 +89,13 @@ def configureButtonBindings(self) -> None:
instantiating a :GenericHID or one of its subclasses (Joystick or XboxController),
and then passing it to a JoystickButton.
"""
# intaking
self.opController.x().whileTrue(IntakeSuck(0.4, self.intake))
self.opController.y().whileTrue(IntakeSuck(-0.4, self.intake))

# moving intake
self.opController.pov(0).whileTrue(IntakeRotationMAN(1, self.intake)) # out
self.opController.pov(180).whileTrue(IntakeRotationMAN(-1, self.intake)) # in

def disablePIDSubsystems(self) -> None:
"""Disables all ProfiledPIDSubsystem and PIDSubsystem instances.
Expand Down
4 changes: 4 additions & 0 deletions rio/simgui-ds.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
{
"guid": "Keyboard0",
"name": "Driver Joystick"
},
{
"guid": "030000006d0400001dc2000014400000",
"useGamepad": true
}
]
}
16 changes: 8 additions & 8 deletions rio/simgui-window.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
"MainWindow": {
"GLOBAL": {
"fps": "120",
"height": "720",
"maximized": "0",
"height": "1033",
"maximized": "1",
"style": "0",
"userScale": "2",
"width": "1280",
"xpos": "447",
"ypos": "289"
"width": "1920",
"xpos": "0",
"ypos": "20"
}
},
"Window": {
"###FMS": {
"Collapsed": "0",
"Pos": "5,540",
"Size": "283,146"
"Size": "283,140"
},
"###Joysticks": {
"Collapsed": "0",
"Pos": "291,574",
"Size": "796,138"
"Size": "796,240"
},
"###NetworkTables": {
"Collapsed": "0",
Expand Down Expand Up @@ -58,7 +58,7 @@
"Robot State": {
"Collapsed": "0",
"Pos": "5,20",
"Size": "92,99"
"Size": "92,116"
}
}
}
Loading

0 comments on commit 821a6a4

Please sign in to comment.