TASRobotics / RaidZero-FRC-2019

Competition code for 2019 season
1 stars 0 forks source link

SparkMax Encoder API #78

Open LouisAsanaka opened 5 years ago

LouisAsanaka commented 5 years ago

This is not an urgent issue, but there might be some inefficiencies when getting the encoder positions on from the SparkMaxes. The CANSparkMax class has a method getEncoder(), which for some reason instantiates a new CANEncoder object every time it is called. Using the SparkMaxPrime class in raidzero.robot.components changes this, as only one encoder object is created throughout the object's lifetime.

qsctr commented 5 years ago

Where can you see that it instantiates a new object every time?

LouisAsanaka commented 5 years ago

In the CANSparkMax class, line 213.

qsctr commented 5 years ago

Okay, sure. In this case constructing an instance of CANEncoder does not seem too expensive since the class seems to only contain a pointer to the CANSparkMax object. But if you want to open a PR for this then that's fine.