StatTracker
This is a rudimentary PathfinderPlugin that tracks various statistics related to Pathfinder usage. It's primarily intended for debugging and profiling purposes, providing insights into the performance of the Pathfinder library, such as the "ticks per second" rate.
Key Concepts
- Ticks Per Second (TPS): A key metric tracked by this plugin, indicating how smoothly Pathfinder is running. A higher TPS generally means better performance.
- Total Distance: Tracks the cumulative distance traveled by the robot.
- Followers Finished: Counts the number of
Followerobjects that have completed their execution.
Fields
KEY_TPS
A static String constant representing the key used in the Voyager data map to store the calculated ticks per second. Its value is "pf_tps".
KEY_TICKS
A static String constant representing the key used in the Voyager data map to store the total number of ticks processed. Its value is "pf_ticks".
SECOND_MS_DURATION
A static double constant representing the duration of one second in milliseconds (1000).
Methods
getName()
Returns the name of the plugin, which is "StatTracker".
onTick(Voyager voyager)
This method is called during each tick of the Voyager instance. It updates the internal tick count, calculates the distance traveled since the last tick, and updates the rolling average for ticks per second. It then publishes the current TPS and total ticks to the Voyager data map.
onFinishFollower(Voyager voyager, Follower follower)
This method is called whenever a Follower completes its execution. It increments the followersFinished counter.