CrossTheRoadElec / Phoenix5-Examples

HERO C#, FRC C++/Java, future platforms.
116 stars 169 forks source link

SRX Mag Encoder Absolute position under SIM #57

Open Crossle86 opened 2 years ago

Crossle86 commented 2 years ago

I am setting the value of the pwm measured absolute position during sim with: simCollection.setPulseWidthPosition() and then reading with: talon.getSensorCollection().getPulseWidthPosition() This seems to work fine accepting that the absolute position is a virtual concept without the hardware. However, in the log I am seeing this during sim runs: CTR: CAN frame not received/too-stale. Talon SRX 2 GetPulseWidthPosition

Is this expected? Anything to worry about?

JCaporuscio commented 2 years ago

So the CAN data that has sensor collection's absolute position is sent slowly by default. Simulation timings in Windows aren't absolute - they can fluctuate. So what's likely happening is the already slow frame is exceeding the timeout for the too-stale error code.

Use talon.setStatusFramePeriod to speed up the appropriate frame (in this case Status 8). I would choose something around 100ms or faster depending on how quickly you want the data.