Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rapid React final code! #33

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open

Rapid React final code! #33

wants to merge 35 commits into from

Conversation

eggaskin
Copy link
Contributor

We can either approve this right away or put takeaways/notes/write-ups in here to put in the final README.

e3l and others added 30 commits January 13, 2022 16:11
KEVIN: Closing thoughts. A lot of things made sense when I realized what RamseteCommand and associated WPILib path following things actually did -- given a trajectory, the path following generates a list of left and right velocities for the drivetrain to follow the trajectory. My confusion from the PID oscillation stemmed from the assumption that the PID loop in the command was for position, so an oscillation would surely cause the robot to move back and forth; it never did because the PID loop was for velocity instead (this is why kI and kD were set to 0 in the example; accelerating to a target velocity is a use case for just a P controller). Oscillations due to a high kP were between 1.9m/s and 2.1m/s and not 1.9m and 2.1m so there was no back and forth driving. Furthermore, the confusion on why the robot stopped before the end position when constants were misconfigured can also be explained by realizing that the list of velocities probably ended, with the constants being incorrect leading to the robot not following the velocities properly and ending in an incorrect spot.

A lot of these confusions could probably have been resolved sooner had I read the docs for RamseteController a little more carefully.

* Initial testing

* Add wheel circumference to hopefully calculate distance

* Add position getting/setting, fix constants

* Slow drive speed, zero sensors

* Start odometry threading

* Odometry package and class

This commit will be overridden by using WPI's builtin odometry classes, but I am pushing it to keep it in history.

* Use WPI odometry class

* Small changes

* navX AHRS

* Merge left and right sensor methods to use odometry class

* Change `new Pose2d()` to `getRobotPosition()`

* Measure the constant!

This can be tested and tuned over time

* Bind A button to zero position

* Change constant to inches, remeasure

* Add better documentation

* Remove joysticks from encoder branch

* Readd odometry thread

Wasn't able to test this that much because the drivetrain became possessed by ghosts, but can test next week on the actual drivetrain.

* Talon -> Spark Max

* Implement preliminary path following command

See comment in FollowPathCommand

* Remove states from `tankSubsystem`

* Inches -> meters

* Add secondary constructor to FollowPathCommand

* Fix turning direction; remove CAN ID 0

* Edit to functional drivetrain state

* Measure some constants

Prepared to do https://docs.wpilib.org/en/stable/docs/software/wpilib-tools/robot-characterization/characterization-routine.html#running-the-characterization-routine and measure the rest on Sunday, then perhaps test finally!

* Measure more constants!

These will probably have to be remeasured with the Robot Characterization tool. When testing pathfinding with these, the robot immediately swerves sharply to the left (which it shouldn't be doing). It might have something to do with the right encoder readings being inverted during characterization (left reports 4 meters, right reports -4), but I've tried setting various options in the config to try and fix that to no avail. Will definitely look into it further at some point.

* Revert constants, invert gyro, invert left motors

* Fix inverted gyro error in resetPosition

* New constants!

Recharacterized using process described in https://www.chiefdelphi.com/t/the-future-of-pathweaver/393014/82. `Kp` might need to be tuned, as does `ENCODER_TICKS_TO_METERS` most likely.

* Update WPILib and vendor packages to 2022

Also push experimental changes to PID constants and auton testing, which still doesn't quite work

* Add preliminary shuffleboard code

* Move odometry to `tankSubsystem`

With the new REV version, CANSparkMaxes with the same can ID cannot be created (it throws errors which kill the robot program)

* Measure new constants with sysid

Hopefully these ones work better!

* `Field2d`, new constants

* Cleanup, remove elevator subsystem

* Change angle entry to use a gyro complex widget

Co-authored-by: pinkbluesky <[email protected]>
Brownout!
At this point we are using shooter like develop, so even though I haven't reviewed all this code I'm going to merge it. Let's actually use develop hooray.

* Recreate shooter branch from refactored Ethan code

* Skeleton `shoot()` method, some cleanup

* Add hood SparkMax

* Remember to add a constant 😳

* PID testing

* editing jetson socket so it's using constants instead of bigdata

* add networktables

* Add Jetson NT testing code

* Update NetworkTables data to match vision code

* Clean up

* editing jetson socket so it's using constants instead of bigdata

* Update NetworkTables data to match vision code

* Clean up

* Add httpcamera for testing camera stream

* Update Jetson stuff

* Jetson refactoring

* Add velocity closed loop testing code

* Jetson restructuring, `periodic()` skeleton code

* Rename shooter to turret

Shooting has been delegated to internals!

* Jetson camera wrapper

* added elevator and tank implementation

* Tank drive code, untested

* add elevator config

* reviewed added code, default commands added

* elevator commands and controller setup

* Working tank and elevator subsystems

* overhaul subsystem structure + overhaul config file

* fix end method in dtcommand

* improved handling of elevatorUpIsPositive const

* change elevator command structure

* put in config txt thing again

* Use `WPI_TalonSRX`, `DifferentialDrive`

* Use builtin `squareInput`

* Add third set of Talons

* Remove `DifferentialDrive`

* Revert "Add third set of Talons"

This reverts commit 1b5ea6d.

* add joystick code

* Add joystick capability

* Add controller switching

* code for testing gyro, ecoder, limit switch, and color+distance sensor. Supposed to print values from sensors. Need to import rev library.

* sensor testing code

* skeleton code for internal subsystem. Includes 2 color sensors, a talon (will replace w/ cim), a method that determines when to activate/deactivate motor based on color.

* Merge commit part 2

* Internals refactoring

* Initiate InternalSubsystem in RobotContainer

* shooter request updates

* added a skeleton method for launching ball into shooter

* Add `turntableAligned()` for internals

* Change initialization to constructor arguments

* Skeleton climb code, cleanup

* Intake skeleton

* Use intake enum, add intake commands

* Reformat to 4 spaces

Finally, my master plan is complete 😈

In all seriousness, all the new files being created in each branch were all using 4 space indents and the constant refactorings to preserve an unliked indent size inherited from 2 (3?) years ago was getting annoying. 4 space is the future!

* Initialize new subsystems in RobotContainer

* Fix tank spacing, better comments

* added motorport2 constant

* added a ballDetected method, updated fields to include another motor, undefined ball count method

* Restructure intake position, PID constant splitting

* Implement new climb design

* updateBallCount

* Intake / internals integration

* merge

* Ball count tracking code

* Jetson constants organization, better reject logic

* Set up shuffleboard for PID testing

* Fix internals motor flow

* Use enum for turret mode

* got rid of TODOs

* Roughly implement the climb plan

It's pretty complex.

* 775 instead of NEO for turret hood

* Update internals with IR sensors

* Use command groups for climb

* Implement module states for turret

This is so that a) drivers know what the status of the shooter is and b) internals can reject quicker (on orange) instead of waiting for a perfectly lined up shot.

* Final-ish button bindings

* Final rebase commit

* `GRTSubsystem` changes, subsystem implementation

* Implement driver intake running

* Non-conflicting motor ports

* New constants, third tank NEO

* Turntable blind spot logic, soft limits

* Degree conversion constant stubs

* Remove mjpg prefix in jetson

* Working vision :D

* Temporary intake + DT testing code

The drivetrain and intake rollers work as expected, but the intake deploy was not moving the motor upwards (despite the percent output being set correctly). I'd advise whoever's testing this tomorrow to see if running the current code and pressing the A button causes the talon to begin blinking green (positive percent output); if it does, then it's a motor issue, otherwise its a code issue (which is weird, because `deploy.get()` seems to say that the deploy controller is indeed being set to the proper percent output).

* Replace exit with staging sensor

This should work because staging initially stops the ball the moment it detects it (when the top of the ball is at the sensor). While staging still detects the ball (for the entire diameter of the ball as it moves up) we keep spinning the top, and as long as the bottom of the ball is still seen by staging when the top of the ball reaches the turret this code should work. We can repurpose the `shotRequested = false` code which runs when the ball leaves internals to also handle ball count decrementation.

* Testing of subsystems, lowered periodic loop times, moved localization to thread

* Enforce style

* Better `ModuleState` names

* Jetson reformatting

* Fix internals current drawn method

* More subsystem testing and some refactoring

* Enforce style again.

* Attempt turret `r` and `theta` state system

* Bare bones intake testing

* Internals color sensor thread

* Measure color constants, reduce IO waste

* More testing setup

* Upgrade to WPILib 2022.3.1

* Update encoder value; comment out internals

* Button binding fix, use integrated encoders for DT

Also, experimental style changes! Unsure how I like the comma separated declaration, but it is certainly less wordy than repeating `private final JoystickButton` 8 times.

* Intake, internals, turret testing

- Commented out PowerController (it was causing power drops and stuttering, will test causes and try fixes later)
- Bind turntable and hood to mech controller joysticks
- Bind left trigger to internals, right to intake
- Preliminary internals restructuring to replace I2C onboard color sensor

* Boolean state for storage rejection checking

* More internals testing

* Internals testing part 2 -- dummy shoot method

It works half of the time! See slack for details about inconsistencies

* Shooter testing

- Bind mech y to turn on flywheel, mech b to turn off
- Manual override of internals motors on mech triggers

Co-authored-by: pinkbluesky <[email protected]>
Co-authored-by: unknown <[email protected]>
Co-authored-by: eggaskin <[email protected]>
Co-authored-by: Ayeeti <[email protected]>
Co-authored-by: Ippyb <[email protected]>
* 2-ball internals code, turret enum renaming

Needs testing.

* Fix motor conditions

* Testing code

Testing on Monday or Tuesday!

* Fix infinite storage state updates

* more print statements + failsafes, will probably rewrite but just to save

* internals, but now on transition timers

* auton 1-ball start & total ball count

Co-authored-by: eggaskin <[email protected]>
* Shuffleboard thread, untested

* ShuffleboardManager simplified to update all GRTNetworkTableEntry objects, converted to using a singleton

* Working Shuffleboard, GRTNetworkEntry infers entry type

* Implemented shuffleboard for all subsystems
* Remove redundant sensor ball ints

* Remove references to exit IR

Exit will not exist on robot 2 and is not being used on robot 1.

* Auton intial ball count setting

* nearly finalized internals code (plus jetson and minus double shot logic)

* Some comments on internals, jetson initialization

* final (probably) internals code!

Co-authored-by: eggaskin <[email protected]>
* Initial test with chained paths

* Start on auton sequences

This introduces some semi-sketchy callback logic to InternalSubsystem to implement a "WaitUntilShotFired" command. Perhaps we should think of a better way to do this.

* changed turret turntable CIM/Talon to NEO/SparkMax

* Turret encoder constants and PID tuning framework

* Small progress on tuning

* Odometry based turret tracking

* Tuned turret controller and implemented drivetrain tracking

* Merge Ethan's feedforward / relative angle code

* Fix discrepancies in cherry picking

* Flywheel configuring

* Copy flywheel gear ratio from `develop`, rebase

* Driver override for intake with 2 second buffer

* Intake limit switch

* Ring light toggling

* Rudimentary turntable FF

* Turntable limit switches, angle constraining

* Turret lazy tracking

* Turntable testing, runtime error fixes

* Turret interpolation framework

* climb testing code (without turret testing, comment in/out as needed)

* Climb port shuffling

* Fixed intake logic bug

* PID constants after turret tuning

* Hood constants

* Reenable turret angle locking

* Use GRTNetworkTableEntry to hopefully improve loop overrun

* Use NetworkTable callbacks

* Changed shoot command to not use a callback

* Touched up turret PID, remove threaded pose estimation, reset pose on construct

* Flywheel PID tuning setup

* Tune flywheel PIDF

* Add ball coordinates to constants

* Tune min and max angles, theta FF

* Shooter testing

* Measure encoder + path following constants

The measured `kP` seems scarily high, but unsure if this is a SysId issue or not (I had trouble getting data analysis to work properly). Will test hopefully soon.

* Add interpolation table entries, fix logic

* Merge `rtheta` into `shooter-testing`, closes #24

* Turret setInitialPose method

* Working `rtheta` + interpolation

* Initial position setting in RobotContainer

* Clean things up, add more debug flags

* Correct `setInitialPose` logic

* Tweaks for easier testing + jetson thread sleeps + jetson debugging + L + ratio

* Flywheel disabling when robot is moving

* Read latest jetson line

* Tuned intake deploy PID

* Networktable callbacks, add periodic PID back

* Stop entrance if 5 seconds have passed

* More debug flags

We should test the tolerance logic

* Finish red sequences, `GRTAutonSequence` abstraction

* Blue auton sequences

* Auton sequence abstraction

* Distance and theta offsets, controller bindings

* Distance offset in interpolation logic

* Preliminary testing routine

* Merge with new offset methods

* Camera server automatic capture, cleanup, constants

* Merge auton code, more cleanup

* Offset and intake gamepad tweaks

* smoll debugs

* Intake 'auto deploy' returns to state position when rollers are not powered, rather than default of 'RAISED'

* Climb PID testing framework

* Fix intake logic error, turret cleanup

* add turret freezing and tweak driver commands to match doc

* Some cleanup

* Jetson disabling on shuffleboard, hopefully fix intake

* Manual climb control on right mech joystick

* Intake internals check shuffleboard button, auton ball localization change

* Force shot when button pressed twice

* Move climb to right mech joystick

* Debug flag to skip auton if needed

* Fix climb, troubleshoot shooter

* more comp tuning

* turret low hub mode

* Shuffleboard auton sequences as int

* drivetrain slowmode, shooting logic shifts, beginning of pleb auto

* climb tweaks

* more adjustments, post-comp push

* low hub lock turret

* Internals transition states

* Decorate auton with timeouts

* Interpolation clamping

* Clamp distance offset between max-min and -(max-min)

* Pleb auton path shot requested logic

* Skip auto option, driver override flywheel logic

* Auto 2 ball fixes

* GRTNetworkTable abstraction

* final comp tweaks

* Even more shuffleboard abstraction, pilot with turret

Co-authored-by: eggaskin <[email protected]>
Co-authored-by: unknown <[email protected]>
Co-authored-by: pinkbluesky <[email protected]>
Final code from Silicon Valley Regional, April 10, 2022.

* `GRTShuffleboardLayout`, `.list()`, positions in code

* Position and size methods for shuffleboard layout

* Internals debugging and networktables

* Move `.addEntry()` to list-like `.at()` position syntax

* Auton chooser, split up localize coordinate method

* 2 ball auto + more debug networktables

* Run intake in `DeployIntakeCommand`, `PlebAutonSequence` restructuring

* Put hood and flywheel refs on shuffleboard, reset offsets on vision data

* internals and turret tweaks

* Separate driver and auto intake override, partially revert PlebAutonSequence changes

* Jetson data pairing

* Shoot 2 balls at once, rtheta feedforward, turntable tolerance fix

* tweaked and tested shooter interpolation table

* Two ball fixes

* Only shoot two balls without delay when they are the same color

* `.widget()`, better internals shuffleboard updating

* Intake shuffleboard organization

* Climb shuffleboard organization

* Intake top limit switch + reset abstraction

* Preliminary intake deploy tuning

* Intake tuning, shuffleboard manual zero

* Turret `setValue()` organization

* Don't force if the turret is retracted

* Limit current caps to add to below sustainable current

Also, remove climb from brownout calculations as it will be dormant outside of climb and during climb we don't want to be limiting it.

* Move `getTotalCurrentDrawn()` to the `GRTSubsystem` level

* Preemptively avoid `NaN` errors

Hopefully this was the issue with brownout limits

* Uncomment jetson

* Shuffleboard limits and draws

* Drive controller trigger freezing

* Turn off flywheel while driver is supplying power to DT

* Changed left bumper to hold (rather than toggle), disable brownout for now

* Driver override internals, intake power restraining, theta offset reset on vision data

* increased back intake power

* SVR Practice round tweaks, includes: internals force also forces flywheel, less sensitive r offset, remove double-a force logic in favor of non-buggy internals force, working lower hub, faster intake, disabled intake continue-lowering-until-lim-switch logic

* last intake code burnt out a motor so i'm a lil scared, here's some sketchy offsetting code for the intake instead!

* SVR Quals Day 1: climb limits, internals force forces flywheel then internals after delay

* auto force shot using internals forcing

Co-authored-by: unknown <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants