Mega monitoring 2 encoders (max 10,000 ticks / s) while communicating with ROS

Currently I have 2 encoders which have 5 ticks per mm of forward travel (encoder Copal RE30E-500-213-1) and my robot can go up to 1 m/s of speed (max 10,000 ticks / s). I also have the Arduino Mega communicating with ROS using rosserial (as this Arduino also handles the steering servo and a linear actuator based on commands from ROS).

I haven't wired up the encoders yet but I'm wondering if the Mega will be able to handle the interrupts or if I'll need an external encoder shield or maybe a 2nd Arduino solely dedicated to the encoders so that I don't miss any ticks.

Currently the mega performs a loop without publishing or subscribing to ROS in 25 microseconds and performs a loop with publishing to ROS in 1500 microseconds. It checks in with ROS (to determine if it needs to publish to undertake a subscriber action) every 100 loops so average loop time is approx 40 microseconds, (25*99 + 1500)/100 = 39.75.

Since my encoders will be interrupting every 100 microseconds at 1 m/s (which I'll be going the majority of the time), is it safe to use these encoders with ISRs and be confident I won't miss any ticks? Also I don't know much about serial communications. I saw another post about an encoder interrupt messing up serial communications. That to me is not an issue but if for some reason the ROS loop (which takes 1500 microseconds) slows down the ISR or can't do an ISR mid serial connection and I miss ticks, that is a big deal.

I want to achieve the best encoder accuracy possible. Do you have any recommendations on how I can achieve that? Using a 2nd Arduino is fine but I'll then have to either communicate the encoder values to ROS directly or to the first Arduino which will then send them to ROS.

Thanks.

Two encoders of 10kHz is possible if the Mega has nothing else to do.
The Serial uses interrupts, the I2C uses interrupts, and some libraries turn off the interrupts from some time.
I think you need an external encoder counter chip.

Thanks for the response!

I implemented it and I'm getting some intermittent encoder drift. Is there any encoder shield or external counter you would recommend?

I don't see that many options online and I don't see any in stores in my country (Canada) so I'll have to ship internationally. This means I prefer not to experiment too much as shipping will cost more than the part most likely.

If anyone has some recommendations I'd really appreciate it.

Thanks.

Some chips have a clock output. Some have a interface to read the counter value, that is a lot easier. For example the LS7366R.
I found this example: GitHub - werdroid/Arduino_LS7366R: Synchronous use of two LS7366R decoders on Arduino env.

The logic is simple, perhaps it can be made with two TTL logic chips. However, I can't find a schematic for that.

Using a dedicated Arduino is possible, but I don't know if that is 99% or 100% reliable.
According to https://gammon.com.au/interrupts, a slow 16 MHz Arduino board requires at least 5 µs for an interrupt. When optimized register reading/writing is used, only a few more microseconds are needed. That means that a pulse every 100 µs is no problem at all.

A optimized read of an input pin takes 0.125 µs.
A normal digitalRead takes 3.5 µs.

Another approach: use the encoder signal as clock signal for the counters. This way you can read up to 1/2 the clock frequency without any processor overhead (so you can count an 8 MHz signal on a 16 MHz processor). I've done 1.4 MHz on an 8 MHz ATtiny84 (the fastest I got the pulses to generate, the 555 should be able to do double).

This are quadrature encoders but of course you only need to count one signal to know the distance.