just632 / cinderella-1942

Other
0 stars 0 forks source link

my main issue with the current state of the repo #3

Open just632 opened 9 months ago

just632 commented 9 months ago

what makes code DRY ?

"Don't repeat yourself" (DRY) is a principle of software development aimed at reducing repetition of information which is likely to change, replacing it with abstractions that are less likely to change, or using data normalization which avoids redundancy in the first place.

what makes code DAMP ?

DAMP (Descriptive And Meaningful Phrases) promotes the readability of the code. To maintain code, you first need to understand the code. To understand it, you have to read it. Consider for a moment how much time you spend reading code. It's a lot. DAMP increases maintainability by reducing the time necessary to read and understand the code.

the point

is that the code is neither reusable nor readable

the solution ?

refactoring code so that :

using java's features to our advantage we can simply create custom builder classes that hold our state and get feed our context and data using simple methods like in this example

the point is not that we need to constantly look for small improvements

its that we need to take a step back ones in a while and rethink our big improvement that work , so not to leave a mess to our successor

[^1]:

// this is just a example for code that gets repeated a few times.
// instead of being made into a separate method with a self explaining name.
m_swerve.drive(
      new Translation2d(0, 0).times(Constants.Swerve.maxSpeed), 
      0 , 
      true, 
      true
    );
// after looking up the drive method implementation 
// i still don't understand what are the two booleans supposed to do...
// to be specific the second one...
// TF isOpenLoop supposed to mean ???
// and why should i care each time i try to move the robot autonomously...
just632 commented 9 months ago

isOpenLoop is used when translating controller inputs to movement

i ether realized a huge issue in the code or i need to sleep ill check the first option after i wake up...

from what i read now the feedforward.calculate mathod used in setSpeed mthod of the Swerve module assumes that the motor is static as refrenced someware hare

calculate
     public double [calculate](https://first.wpi.edu/wpilib/allwpilib/docs/release/java/src-html/edu/wpi/first/math/controller/SimpleMotorFeedforward.html#line.81)​(double velocity)

     Calculates the feedforward from the gains and velocity setpoint (acceleration is assumed to be zero).
 Parameters:
      velocity - The velocity setpoint.
 Returns:
      The computed feedforward.

so if i understood correctly after driving the robot a bit the calculations are all wrong as they didn't reference the motors velocity so each time the methods called will the robot drives it gets a bit worse

i have a hunch that the issue gets way worse when driving turning and rotating the robot at the same time.