Blogs are like buses - you wait all month to post one, and then three come along at the same time.
But what else are the Christmas holidays for if not working on Pi Wars and catching up on the blog.
So - the task we've been focusing all our attention on so far is the "Tidy The Toys" challenge. From the previous two posts, we can find the toys, and move in a straight line. Also, using the sonar sensor on the front of the robot, we know whereabouts we are in the arena when travelling fowards and backwards. So now - to solve the actual challenge of finding the blocks, picking them up and stacking them in the target area.
Originally I was going to use solid wooden blocks. However, these proved to be quite heavy and were liable to slip from the grabber's grasp. So I made some out of plywood. I was going to paint them, but the templates I printed for cutting them out actually work quite well. The only issue is that the ink runs if they get wet - and using the kitchen as as the testing site is a little precarious. If they get too bad, I'll cover them in some coloured cardboard or paper.
Before I could attempt the challenge, we needed to build an arena. My original plan was to get some wooden planks and hinge the corners. Then paint the whole thing black. However I found that I could get some black plastic 'Foamex' sheets cut to size from cutplasticsheeting.co.uk By getting 8 sheets (2 for each side) I could build the arena by taping them together. They were packaged with stiff right angled cardboard supports to protect them, and I used these to tape to the corners to make the arena square. The whole thing cost £48 - which was about the same price as buying the wood and paint, but with much less effort.
The main loopfor the Tidy The Toys challenge code consists of a state machine that goes through the tasks we need to perform. We set the current state to the current task (eg. finding the Red block, or moving backwards to a fixed position) and process that until complete. Then we move to the next task.
I just create a list of tasks then to complete the challenge. eg:
- MOVE BACKWARDS TO 75cm
- SPIN RIGHT
- MOVE FORWARDS TO 20cm
- SPIN LEFT
- LOCATE BLUE BLOCK
- MOVE TO BLUE BLOCK
- PICK UP BLUE BLOCK
etc.
This approach means that, for testing, I can just set up a subset of the steps and don't have to worry too much about complicated transitions.
So, by using the sonar sensor, together with the horizon finder, we can move to fixed positions around the arena. Then using the coloured block finder we can find the blocks and move towards them. We use the sonar sensor again to get an accurate distance from the blocks to pick them up and set them down.
Does it work? Well - today we had success for the first time. All 3 blocks stacked in the target area - and we managed to do this 3 times in a row.
The video below shows one attempt we managed to film - although there is a small point when dropping off the blue block in the target area where we tap the wall slightly.
I think we can make it a bit quicker, but for now I'm going to put this challenge to bed.
So - I guess we need to start thinking about the other 3 challenges!
No comments:
Post a Comment