Shop OBEX P1 Docs P2 Docs Learn Events
Question regarding movement of robot? — Parallax Forums

Question regarding movement of robot?

LEO678LEO678 Posts: 5
edited 2011-05-27 09:28 in Robotics
I know that this might sound easy but I need help...

Its regarding the distance travelled by the Boe-Bot

I know how to make it move forward, using Pulsout and also make it turn right or left
But i want to know, which code would I use if i want to make it travel in a direction for a specific distance.
Please can someone help or lead me to the right direction, thanks!

Comments

  • LEO678LEO678 Posts: 5
    edited 2011-05-26 14:56
    sorry, used with BS2
  • W9GFOW9GFO Posts: 4,010
    edited 2011-05-26 15:04
    Actually, it is not easy. To travel a distance accurately there needs to be some form of feedback - a way to measure how far the wheels have turned. The Boe Bot does not come with this ability but you can purchase an encoder kit for it.

    Without the encoder the best you can is to run the motors for a specific period of time. It will not be accurate and it will be a little different every time but you can come pretty close. One thing you can do to improve accuracy is to come to a full stop after every move rather than stringing moves together. For example, go forward, then stop for half a second, then turn, stop, go forward,stop, etc... While stopped you should still be sending centering pulses (PULSOUT 750) to the wheel servos so that they don't coast.

    Rich H
  • ercoerco Posts: 20,256
    edited 2011-05-26 15:07
    No built-in way to do this accurately. You can experiment with the speed times a certain timing interval, or number of pulsout loops to go so far, but it will vary with battery condition, floor surface, and other factors. Just going reasonably straight is a good challenge with a BoeBot. If you need more accuracy, you will want to add Parallax' wheel encoder kit. See http://www.parallax.com/dl/docs/prod/datast/ApplyEncoder.pdf

    Edit: Rich types faster than I do! :)

    And he points out a little-known but very useful fact: pulsout 750's apply dynamic braking to a CR servomotor. If you simply stop sending pulses, the motor will coast down to a stop more slowly, likely overshooting your intended location.
  • LEO678LEO678 Posts: 5
    edited 2011-05-26 15:18
    what if i measure the distance...
    Another thing is how does the LOOP work? So if DO and LOOP, it will keep on going straight, where as I need to make it go straight then stop at a point then right...If i do loop, wouldnt i keep going straight forever? The distance i need to travek straight, that i can do like trial and error but the loop is the problem...

    btw if i dont loop and go pulsout, wouldnt it keep on going on and on?
  • LEO678LEO678 Posts: 5
    edited 2011-05-26 15:23
    OR I could measure the speed of the boebot then measure my distance and cacluate the time it would take for it to move to the position where i want it to turn.

    while in loop, i could make it go straight with a WHILE condition...and run a counter along with it with time (Pause 1000) and i could set that the loop would go on until myCounter= (i would enter the time calculated)...

    now i just need help with while, how do i put it in the loop? any sample codes?
  • W9GFOW9GFO Posts: 4,010
    edited 2011-05-26 15:26
    One thing that is really great about Parallax is the wealth of documentation and educational materials that they provide freely. The answers to your questions can be found easily. Have you used the 'Help' feature of the Basic Stamp editor? Have you worked through Robotics with the Boe-Bot?

    Do you need help locating these resources?

    Rich H
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-26 15:27
    DO and LOOP just mark the beginning and end of a loop. You use UNTIL or WHILE to set conditions for the loop to stop. Read the chapter on the DO statement in the Basic Stamp Syntax and Reference Manual for details. You should become familiar with the Reference Manual, the "What's a Microcontroller?" tutorial, and the "Robotics with the BoeBot" tutorial, all downloadable from Parallax (click on Downloads on the main Parallax webpage). "Robotics" discusses how servo motors work.
  • LEO678LEO678 Posts: 5
    edited 2011-05-26 15:31
    i did and i am looking at it rite now...too bad we rnt allowed to take boebots home from school :(
  • ercoerco Posts: 20,256
    edited 2011-05-27 09:28
    LEO678: Even without the boebot, you can take your code home (even a hardcopy) to examine. It is good practice to mentally execute your code line by line to "become" a processor yourself. It can be quite helpful to understand how the computing process works. In all cases (except low battery or hardware/wiring error), the Stamp/robot does exactly as it is programmed. Often that is quite different from what we want/intended, so we need to close the gap between the two. It takes effort, but over time you will be able to locate potential errors in programs, and you will learn how to avoid such problems as you write new code.
Sign In or Register to comment.