PiWars 2019 - Optical Flow
Monday was one of those days.
Mike and I discussed an issue which plagued us last year - motion feedback.
We had absolutely no way of getting feedback from either the motors or the wheels. This caused some particular problems for our autonomous challenges, in particular the “Over the Rainbow” challenge. The challenge required our robot to rotate in the middle of the box until it found a particular colour of ball, then drive towards the ball. We used OpenCV to process the output from the PiCamera and it worked really well at finding the coloured balls. Unfortunately when the code told the robot to stop rotating, the robot didn’t stop quickly enough and tended to overshoot the target ball (by about 45 degrees!). Without any feedback on our position or rotation our code had no way to know it had overshot or to correct itself.
This year we’re going to have something. We’ve discussed using a gyroscope or magnetometer module for motion feedback, we don’t have one at the moment though. Mike has an Optical Flow sensor. We’re pretty sure we can achieve the same result.
The optical flow sensor works exactly like your optical mouse. In fact, the chip on this flow sensor is designed for a high end mouse. It has an SPI interface and can be powered from either 5V or 3.3V so it can work directly with a Raspberry Pi without needing to have an Arduino in between.
The chip on the sensor module is able to do some processing on board. It is able to read at up to 65K frames per second. It is able to give the deltaX and deltaY value (change in x and y positions), but rotations will confuse the chip. We will want feedback on rotation - the chip will also give us the frames (only 80x80px) so they should be fairly trivial to process in openCV, which has native methods for optical flow.
On Monday we managed to get the pins soldered to the module and wired up correctly to an old Raspberry Pi B (r2.0). We weren’t able to find a library that the Pi can run. There is an Arduino lib so we intend to use that as a base for creating our own library for Python. Watch this space.
3D Printing Wheels
More progress was made on the printing of the mecanum wheels discussed in previous posts. The wheel hubs take about 1.5hrs each to print and it takes about 2 hours to print a batch of 10 rollers.
We now have enough wheel hubs and enough rollers for 3 wheels. Just need to print the last batch and we’re golden!
The next job with the wheels will be cutting down 40 axles for the rollers to spin on.