We have the CTRE Mag Encoder, but I don’t understand how can I measure the velocity, in m/s.
First of all, this will depend on how you’re connecting the encoder. If you’re using a breakout board to connect the encoder directly to the roboRIO, you can use the Encoder class to read its output. If you’re connecting the encoder to a Talon SRX, you need to use the Talon SRX object in your code to configure and read the sensor.
Secondly, encoders measure rotational movement (in degrees/s), not linear movement (in m/s). Once you have the rotational speed, you need to multiply it by the distance per rotation to get linear speed. You can calculate this value numerically as the circumference of your wheel multiplied by the gear ratio between the wheel and encoder. Or you can find it experimentally by pushing your robot a known distance a number of times and dividing that distance by the average # of rotations recorded by the encoder.