FRC2706 / FRC2706/RCVI_2019_Prototypes
Add setSamplesToAverage() to LidarLitePWM.java and test to find best number of samples to average
- Dominant language
- Java
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
I found out that the Counter class that is used in LidarLitePWM.java has a method setSamplesToAverage(samplesToAverage) that allows the measurements of period obtained by using the getPeriod() method to be averaged over a number of samples set by the user. This is exactly what we need to average the measurements to hopefully reduce the amount the noise. As far as I can tell, all you need to do is call the method in the constructor for the LidarLitePWM class after where the counter class is created, i.e. after the to call
counter = new Counter(source);
and around where the other methods for counter setup, such as
counter.setMaxPeriod(1.0);
counter.setSemiPeriodMode(true);
are made.
We need to add the call to
setSamplesToAverage(samplesToAverage);
in the class and test it for differents values of samplesToAverage to see what gives the best (i.e smoothest) results.
Here is a description of the method from the source code of the counter class.
/**
* Set the Samples to Average which specifies the number of samples of the timer to average when
* calculating the period. Perform averaging to account for mechanical imperfections or as
* oversampling to increase resolution.
*
* @param samplesToAverage The number of samples to average from 1 to 127.
*/
public void setSamplesToAverage(int samplesToAverage) {
CounterJNI.setCounterSamplesToAverage(m_counter, samplesToAverage);
}
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.