Skip to content

Swerve improvement #8

@roterrex

Description

@roterrex

Targeted at someone who feals they mostly understand the code (not neel)

(build in a branch!!!!!!!!)

  1. read up on creation of new 'Units'
    https://docs.wpilib.org/en/stable/docs/software/basic-programming/java-units.html

  2. Read through the 'ServeModule' and 'DriveSub' code with a focus on the angles used for the robot and individual wheels.
    You should notice there are three types of angles,

  • angles relative to the field (CCW positive, 0 = the angle facing from the blue driver station towards the red DS)
  • angles relative to the robot (CCW positive, 0 = forward (i think))
  • angles relative to each module (CCW positive, 0 = such that the FR module is aligned with robot rel and each other module is +- 90/180 degrees from that)
  1. Create a new 'Unit' class that will store an 'Angle' 'Unit'
  • the class must accept any of the above 3 angle forms

  • the class must be able to return any of the above three forms

  • you may use any of the three as base unit (robot rel may be easiest though)

  • Note1: you will need either access to or to pass 'details.angularOffset()' to get the offset to/from module rel

  • Note2: 'Note1' might be easiest achieved by creating a local instance of the new unit with the current modules offset in 'SwerveModule'
    i.e. final UnitName currentModuleRelative = new UnitName(details.angularOffset(), "currentModuleRelative", "cMR");

  • Note3: you will need to access 'imu.getAngle()' to get the offset to/from field rel

The final goal is to have a 'Unit' for swerve that can abstract away which relative we are talking about.
Rather than multiple functions to return different rels (robot rel, module rel mainly) you return this 'Unit' and it converts as needed.
No risk of getting the Rel wrong and sending modules every which way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions