Let's Make Robots!

How to build your first robot - Part II - navigation

 

Your browser is not able to display this multimedia content.

Your browser is not able to display this multimedia content.

AttachmentSize
clean_navigation.BAS6.17 KB

This is Part II of How to build your first robot - tutorial.

you can just take the cool navigation-code in here and have fun with it, or you can follow the whole instruction, or the parts that you like. I try to make it as general and open as possible.

Here is part III of this tutorial - I recomend that you browse this as well!


Progress:

You have made a robot, something like this: How to build your first robot

You have read my deep thoughts on how to move on with the programming "Don't program your robot.. Teach it!", and you have made tricks with your robot, messed around with it, had some fun and is ready to move on.

Perhaps you have tried out this little trick of seeing what your robot sees.

You have seen on the video of "Making Skiwalker", and seen on the pictures of "Yellow Drum Machine" (the pics in the bottom) - that you do not need much for materials to make a robot; Melt-glue, double sided tape, sticks, and you are go!

If so, this part II should be a breeze! You can make this robot in 45 minutes, no sweat.

 

First, let's make the robot on the picture above. Try to duplicate the main parts, that is the main task here.

It shuld not need much explantion, it is excaxtly like the one from How to build your first robot - only differences:

  • Instead of Sharp sensor, I use SRF05
  • The servo is a smaller one, and a fast one - you can get these in any size and speed
  • The gearing on the motors is lower, so I have a faster robot (though it is not a speed-king, lol)
  • instead of just taping it all together, I have used 3 sticks to form some sort of a "chassis"

The closer you get to this, the easier it will be to follow the rest, but of course you can just do it your way, with whatever parts you have etc.

In the first tutorial I wrote that you could make some fancy code for the robot.

I now present you for some code that I have made, it is what is used on the video. It is an example, there are thousands and millions of ways to evolve, you should do it your way. This is just to try to open your eyes, and share what I have learned after countless hours of trial and error.

Try to alter some of the numbers to tune in to your setup, and read the guidelines in the code. That way you can get a robot like the one on the video, and we are going to use that as a base for Part III in this tutorial...


Find the attached code in the top of the post.


.. And the screwdriver-trick on the video?

Well.. Look for places where the code says

servo Servopin,head

and add, just after it

servo 1,head

If you are adding another servo on pin 1.

Think about what to attach instead of the screwdriver?

Something with an LED on? And insert some on/off in the code for the LED? Or a fan? or.. :D

 

Stay tuned. This bot is getting more enhancements now..

And if some of the comments below does not make sense, please understand that I am changing this over time, so the comments may have been for an earlier text here :)

Thanks, and do post what robots you make, to inspire back. Thank you.

/ Fritsl

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Sorry but where is the code? I don´t find it...

 

Just below the main image.. When you are logged in :)
would you by any chance be able to send me the code for this robot ?

Is that it on the top of the page?

the thing at the top is it but it is complicated.
was wondering if i could have the code exacly like it was entered in the programe editor?
That is it. The excact code used on the video, right there.

Hi Fritsl,

Yerstday I have build my first robots starting from your tutorial. (well, not exactly the firts robot, the really first was the laugthing pumpking...;) ).

I have build it using the picaxe board and write my own code. I was not so much satisfied for its motion, so I take a look to you code.

It's interesting, probably I'll rewrite my own code. I have just one question about your code: as I can read, MayTurn is an 'undocumente' variable. But how can it work? You NEVER assign a value to MayTurn!!

When you write

MayTurn = MayTurn + 1

I read undefined = undefined + 1

;)

(also, you never reset  MayTurn)

 

 

Hey, cool you may have found an easter egg in my code :D

No.. the way it works is that I am playing around, and sometimes I make something that I figure others would have interest in. Then I try to strip it down to the essentials, omit all irelevant parts etc.. and then go public with it.

Aparently there was some left over with this variable, some function that I wanted to delete but not got rid of 100%.. but you can just omit it.

Actually you should be proud of yourself, as I think perhaps some 50 other people, at least have downloaded and used the code.. and you are the first one to realize this :)

----- UPDATE

Now I had a look at the code, and what you say? There is plenty of use of the variable. The only thing wrong, as I see it just now is that it may overflow at some points.. But it should not matter for the function of it.

As I read it (though I may be wrong) it is a variable used in a set of rules that ensures that the robot does not start spinning around for ever if it is placed in an open space.

You see, many beginners robots only avoid obstacles, but the robot using this code will also be curious, and find doorways etc. And so if "everything looks interesting" for it, it should not go crazy, but take a dessicion.. and that is a part of what that variable should do.

However, Try to omit it everywhere, it will be a cool way to learn.

Just write ' before every line / routine it is used in, and see what happens.

Try to see how much of the code you can omit and still get a working robot! That will be a great way to see what the parts does, and how :)

 

Well,

 the code I have write for my robot it's very comparable to yours.

 I haven't a code for avoiding obstacles near left and near right.But my bot bot 'search' something interesting and go to it.

(interesting ? what's interesting? this is a Big question... ;) )

Your code is very very helpful; I think everyone must read you code carefully and after write its own program.

What I have notice is that MayTurn is used correctly but never initialized. Probably all registers are set to zeros and everything works, but it's not correct/clean.

Also it's never resetted to a start value:

look the subroutine ForwardLeft_middle:

     If MayTurn < MaxNumberTurns then
    MayTurn = MayTurn + 1
    end if

Ok, what happen if  MayTurn values reach 5 (==MaxNumberTurns) ? It never change to another value, isn't it?

And look the subroutine Sharp_R:

 Sharp_R:
    If MayTurn > 0 then
        ....
    end if
return


So robot EVER turn.

 

As written to jka above, it is NOT an error that I do not "initialize" the variable, god forbid! :)

When that is said, I agree, there may be a ghost in the machine in the program - I guess when tidying up the code for public release I never got 100% finished with that part.. but then again, it leaves up some fun for you :)

You should have a look at the red/green illustration on this project to understand what I mean by "interesting".