M0o+ Shepherd's Pi

How M0o+ completes Shepherd's Pi

The last of the three “prescribed” challenges is Shepherd’s Pi.

In this challenge there are 6 sheep which need herding into a pen, and 3 wolves which must not be “killed” (knocked over).

Challenge Decisions

I started out hoping to do all three challenges autonomously, but when it came down to it I’ve had to complete Shepherd’s Pi via remote control.

There’s a few factors contributing to that - largely, I didn’t leave myself enough time to be confident that I’d succeed, so I decided to focus on completing it well via remote control, rather than poorly autonomously.

I also don’t have particularly good/sophisticated localisation on M0o+, and the camera wouldn’t get a good view of the playing pieces with a sheep-herding attachment on the end of the boom stuck in the way.

Moving the camera would be a big undertaking, and after all the troubles I had with making the camera reliable I didn’t want to embark on moving it with just a couple of weeks to go.

I didn’t attempt to add a gate, which offers the same number of points as one sheep for opening and another for closing - I think doing so would slow me down by more than two sheep’s worth of time, and time is already quite tight.

Lastly, I also didn’t attempt to add any kind of whistle control. This could theoretically be a lot of relatively easy points, but could also be pretty unreliable, especially in the noisy Makespace environment where I planned to record the challenge.

So having chosen the most straightforward non-autonomous, no-whistle, no-gate route, there’s really only one part to this challenge:

The Sheep Grabber

The boom on M0o+ is more than capable of lifting the sheep over the walls of the pen, so the robot just needs a way to grab sheep and pick them up.

Grabber sketches

None of these sketches match what I actually built… Just part of the process

After a bit of sketching I settled on a design which can grab a sheep on the two short sides. It has two jaws which pivot, and a piece of elastic on the underside which is constantly trying to pull the jaws shut. To open them, there’s a servo on the top which pulls on the jaws with string.

I much prefer this design over rigid linkages, because it means in the “closed” state the servo is completely unloaded - it’s not pushing against the sheep. I was worried that if I had a rigid setup then I’d need to be very careful not to burn out the servo by “squeezing” sheep all the time.

The elastic also means that the jaws are relatively free to move around whilst still keeping a tight grip on the sheep, so they stay quite secure even when swinging around.

For the actual gripping surface I started off using some silicone O-rings, but I changed that later on to use foam instead.

When I started playing around with trying to collect the sheep it was very obvious that collecting them one at a time was not going to be fast enough, so I tried grabbing two at a time with the jaws.

Due to slight differences in the construction of my cardboard sheep, the jaws wouldn’t always get a good grip on both of them, so I redesigned the jaws to be longer (for more gripping surface) and also to use some foam instead of the O-rings, which is better at compensating for differences in the sizes of the sheep. With that, I can reliably pick up two sheep at a time and lift them into the pen.

Lifting two sheep over the pen wall

The East Devon Pi-rates wrote an excellent blog post going through the different options and timings, in particular noting that it would be very easy to exceed the size limit with an attachment designed to grab multiple sheep. With my design, while the front sheep may protrude beyond the size limit, the parts of the robot itself do not. In fact, at maximum extension it’s not actually possible for my boom to exceed the 500 mm limit.

They also say:

Collecting the sheep in pairs is not an option within these timings.

Which I’m afraid I must respectfully disagree with! With careful driving, collecting in pairs, it’s quite possible for M0o+ to complete a run and return to the barn in ~1m25s, so 3 runs in 5 minutes is doable.


One thing which proved difficult was getting the sheep well-aligned in the jaws of the grabber, so I modified my Nature’s Bounty apple bucket design to make a flat surface at the front of the robot, which aligns the sheep by just driving in to them.

Robot with shover attached


While I haven’t taken on the challenge of navigating the course autonomously, I did add code so that a couple of buttons would move the boom to common positions (like the “grab a sheep” position) to save some time and effort when running the challenge.

Course manoeuvring

M0o+ is just about small enough to navigate around the course between all the pieces without needing to move any of the wolves.

I start by picking up and delivering the pair directly North of the Barn, then push the third down, through a gap between the wolves to pick up the fourth. After dropping off 3 and 4 right by the “gate”, I grab the last two and lift them over the wall to the East.

I’ve tried to show the route taken on the diagram below:

Route taken to grab sheep

Course diagram courtesy of Pi Wars

This can be quite fast if I do well with the driving, and is just about possible (though difficult) without touching the wolves.

As with the other challenges, I used the nice camera gear and the Robot Club course at Makespace to film the challenge.

Course set up for filming