Solve Challenge

Now we can go and try to do some work on the PiWars challenges. The first one that seems simple enough to solve autonomously is Hungry Cattle. Since we have a distance sensor which can detect wall orientations (over troughs and other potential obstacles on the floor of the arena), we can easily devise a plan on how to move about and get to the right places.

For instance, to go to the left trough (and only on that side) we can make Flig to go forward from the 'barn' all the way to around 750mm forward (actually 750 - half Flig's length), then turn for 90º counter-clockwise and then straight forward until we get to 100-110mm and we'll be at the right place to tip over rice.

Now, I mentioned tipping over rice - we first need a container for rice. As it is barn it would be only fitting if container is farm themed - something like a barrel! A few hours with FreeCAD and here are some designs:

Barrel FreeCAD 1Barrel FreeCAD 2

This particular print seems perfect for sporting some wood filled filament and as I have two different kinds - lighter and darker it could look really well. So, as it is designed from several different parts, it can be printed separately and put together later. But, some parts I decided to print with two materials at once and make slightly stronger bond. A good few hours later it came out of the printer and when put together it looked like this:

Printed Barrel 1Printed Barrel 2Printed Barrel 2Printed Barrel 4

Now, when barrel was mounted on the back of Flig, only thing Flig was supposed to do is to lean forward, open the flap and let the rice flow out. But... the angle that is formed with Flig kneeling down on the front legs wasn't enough for all the rice to flow out. So, next was a fix! Mounting it at some angle fixed it:

Barrel At Angle 1Barrel At Angle 2

That fixed it quite nicely. Also, added some detailing on top cover and the flap. Now they look like really made of planks of wood.

Here's what it looked like in action:

From there it wasn't hard to finish other two trough movements. So, an algorithm for all three troughs goes like this:

  • trough 1 (left): move forward to 675mm of the fall, turn 90º CCW, move forward 110mm, tip food, turn 90º CCW move forward 110mm - end
  • trough 2 (far, right): go towards far corner until around 200mm away from it turn 45º CW, turn sensor to the right and move sideways 240mm from far wall, then move straight to 100mm from the wall, tip food, turn 90º CW, got 100mm of (the closest wall), turn 90º CW and move 100mm from the (left) wall
  • trough 3 (near, right): go to 150mm of (right) wall, move sideways to 200mm of (near) wall, for 100mm of (right) wall tip food, turn 90º CW, go to 100mm of the (near) wall, turn 90º CW, move forward to 100mm of (left) wall

And... that's it! Unfortunately, Flig is not fast enough to do it more than once in 5 minutes.

As you can see our barrel couldn't hold enough feed for all three troughs and Flig had to return back to barn to pick some more. Due to narrow opening at the top of the barrel not everything as suited for fast reloading so I had to devise some carefully calibrated containers with enough feed to fill in the barrel, fill it quickly without wasting it and for amount to be appropriate to fill troughs almost to the brim:

Carefully Calibrated Amount of Feed