Shop OBEX P1 Docs P2 Docs Learn Events
Robotics with the Boe-Bot — Parallax Forums

Robotics with the Boe-Bot

GenetixGenetix Posts: 1,754
edited 2013-06-27 12:29 in Learn with BlocklyProp
I am stuck on how to do Project 2 at the end of Chapter 4 where it asks to write a program to make the Boe-Bot navigate in a circle. I know I need to make the inner wheel turn faster than the outer wheel but I don't know by how much.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-06-19 05:44
    Actually, the inner wheel has to turn slower than the outer wheel for the BoeBot to move in a circle. Try drawing the two circles and measuring them. The outer circle is bigger (longer line) than the inner one, so the wheel has to move faster along the outer circle to make it around in the same time. As you make the circles bigger, the difference in the circumferences changes. The difference in the radiuses stays the same because the BoeBot's wheelbase (distance between the wheels) is fixed. You go from there ... How big a circle do you want? How fast do the wheel motors go? It varies a little from motor to motor and depends on the battery voltage.
  • GenetixGenetix Posts: 1,754
    edited 2013-06-19 14:00
    I knew the inner wheel would move around faster but I forgot that the outer wheel needs to travel more in the same amount of time. I guess from what you are saying that I need to do this by trial and error.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-06-19 14:47
    Once you get a circle, try a figure 8. There's a thread in the robotics forum where forum members have posted videos of their robots performing a figure 8. It would be great to have a new entry (from you).

    I explained a bit about programming a robot to perform a figure 8 in post #35 of my cheap bot thread. The instructions assume one is programming in Spin but the concepts should apply to any programming language.

    I've found it's important for the voltage to the servos be regulated in order to have a robot move consistently. The drop in voltage as a battery pack discharges will cause the speed of the servos to change as the voltage changes. It was very frustrating trying to get a robot to perform a figure 8 with unregulated servo power.
  • ajwardajward Posts: 1,130
    edited 2013-06-19 16:25
    Genetix wrote: »
    I knew the inner wheel would move around faster but I forgot that the outer wheel needs to travel more in the same amount of time. I guess from what you are saying that I need to do this by trial and error.

    Of course you can do the circle by trial and error, but consider doing one by working out the math of the whole thing. It's fun! Of course that's just me. But, once you work out the math you have a greater understanding of how the critter works.

    Amanda
  • GenetixGenetix Posts: 1,754
    edited 2013-06-19 21:46
    Watching Erco do a Figure-8 makes it seem easy and it looks quite simple once I can get the Boe-Bot to make a circle. I also looked at that programming thread and saw something about using a regulated power supply. My math is kinda rusty but given some time I will figure it out even if I have to do it using the Brute-Force method.
  • rondorondo Posts: 6
    edited 2013-06-21 17:46
    Genetix wrote: »
    Watching Erco do a Figure-8 makes it seem easy and it looks quite simple once I can get the Boe-Bot to make a circle. I also looked at that programming thread and saw something about using a regulated power supply. My math is kinda rusty but given some time I will figure it out even if I have to do it using the Brute-Force method.

    haha! i know the feeling Genetix, I have been working on my boebot for a good part of a week (roughly 12 hours in) - i am taking a class in college and one of our testing projects is to get it to move in basic directions first
    and of course a figure 8 is in it. It has been the most challenging part yet - it does move in a "figure 8" but not perfect yet. I did get it to move in a circle first, but only in one direction *this was part of class project*, i didnt even stop to think about doing it the oppisite direction.

    Like i said its gotta be tweaked just right, you have checked out Erco's challenge, and you prolly seen some code on page 4, this is a short-cut method, and to be honest it will not work like his did (servos, batteries, electronics in general, etc.) but you could use that as a template. I wouldnt suggest it cause you will eventually end up tweaking it to make it do what you want. I basically wrote for circle right and then circle left, getting it smoothed through transistion is kind of a challege, but not "brute-force" - use some troubleshooting methods, here some info that you might think will help ;) it helped me a bit the first few hours of coding (btw i abosultely hate programming and math, but yet i can do it...sometimes gracefully haha. i am an electronics technology major at my JC here.)

    (source : boebotteacher.com) - good read has helped me tons.



    DirectionLeftRight

    CW ( <750 )
    Backward
    Forward


    Still ( =750 )
    Still
    Still


    CCW ( >750 )
    Forward
    Backward



    if you run

    PULSOUT 13, 650
    PULSOUT 12, 650

    see what you get, work it from there - make one a little faster than the other. etc.

    baby steps :)

    i am not using the standard battery holder (4xAA) i am using 4/3 A 2100mAh @ 1.2v (6x) [ 1.2v * 6 = 7.2v ] roughly puts out 8.90v peaked - i run it to about 7.80v and there is a difference. try using a lipo pack as they will keep V up a little better then a good old NiMh/NiCad pack, lol or what we did in our lab, really really really long jumpers and a DC PSU @ 9.01v. dont do that tho, its overkill for this small bot and you will get tangled! should have taken pix.

    Ronnie
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-06-21 19:51
    rondo wrote: »
    i am not using the standard battery holder (4xAA) i am using 4/3 A 2100mAh @ 1.2v (6x) [ 1.2v * 6 = 7.2v ] roughly puts out 8.90v peaked - i run it to about 7.80v and there is a difference.

    Ronnie,

    Welcome to the forum. Are you running the CR servos directly off the battery? If so, you my greatly reduce the life of the servos. Some servos can handle 7.2V but these high voltage servos are the exception. Most servos shouldn't be powered above 6V.

    I thought I'd try giving an early attempt at a hexapod some extra power by running the servos off of a two cell LiPo. It was only a matter of seconds before I burned out one of the servos.

    A figure 8 with CR servos is pretty much impossible without using a regulated voltage source. The distance the robot travels at various speed settings will change as the battery voltage changes. I have a link to some inexpensive switching regulator in the BOM section of my cheap bot thread.

    This is the method I used to set the servo speeds.
    PRI SetSpeedTurn(localSpeed, turnAmount)
    '' A positive turn is counter clockwise.
      targetSpeed[PORT] := localSpeed - turnAmount
      targetSpeed[STARBOARD] := localSpeed + turnAmount
      pulseLength[PORT] := STOP + targetSpeed[PORT]  
      pulseLength[STARBOARD] := STOP - targetSpeed[STARBOARD]
      Refresh
      result++
    

    It's in Spin but hopefully it will make sense to those familiar with PBASIC.

    In the above equations, I'm setting the pulse of each servo (PORT for left and STARBOARD for right). I'll convert the pulse length to those used by the BS2. For a ccw turn, I'd set "localSpeed" to 50 and "turnAmount" to 12. For a cw turn, I'd use -12 for "turnAmount" and leave "localSpeed" at 50.

    The turn amount ends up increasing the speed of one motor while slowing the other one down a bit. The constant "STOP" is the pulse length used to stop the servo (750 in the BS2's case).

    One would want to add PULSOUT statements where the Spin code calls the "Refresh" method (a method in Spin is kind of line a subroutine in PBASIC). You'd also want to add a pause to the loop and a way of keeping track of how long you've been turning. I kept track of the time elsewhere in the program.

    The code:
    PULSOUT 13, 650
    PULSOUT 12, 650
    

    Will just turn the robot in place.

    This:
    PULSOUT 13, 788
    PULSOUT 12, 688
    

    Should give you a circle. (Assuming pin 13 is the left servo, switch the pulse amounts if the pins are switched.)
  • GenetixGenetix Posts: 1,754
    edited 2013-06-21 19:56
    I eventually want to get encoders for my Boe-Bot in addition to a Ping kit. I am considering maybe even getting a 2nd Boe-Bot since not all of the accessories can be added. You can't use a gripper with the Ping bracket because they both mount in the front. The tank treads look really cool and the crawler would be nice to watch. Of course not using wheels means encoders are useless unless there is a way to modify them to work. I had gotten a Boe Boost when it was on sale so I can use that for some extra power. I know how to make the Boe-Bot turn so it's just a matter of fine tuning it to turn just the right amount. I was thinking of getting out my caliper and taking some measurements to see how misaligned things are. Being that the body is sheet metal and the servos are molded plastic there is a good chance something is off. The slop in the servos I can't do anything about unless I want to get several new servos and try to find a pair that are similar. There is a point where it's overkill so try the simple stuff first. I have most of the Stamps-in-class kits (except SumoBot) but I still want to get Production Control.
  • rondorondo Posts: 6
    edited 2013-06-21 21:52
    Duane Degn wrote: »
    Ronnie,

    Welcome to the forum. Are you running the CR servos directly off the battery? If so, you my greatly reduce the life of the servos. Some servos can handle 7.2V but these high voltage servos are the exception. Most servos shouldn't be powered above 6V.

    I thought I'd try giving an early attempt at a hexapod some extra power by running the servos off of a two cell LiPo. It was only a matter of seconds before I burned out one of the servos.

    A figure 8 with CR servos is pretty much impossible without using a regulated voltage source. The distance the robot travels at various speed settings will change as the battery voltage changes. I have a link to some inexpensive switching regulator in the BOM section of my cheap bot thread.

    This is the method I used to set the servo speeds.
    PRI SetSpeedTurn(localSpeed, turnAmount)
    '' A positive turn is counter clockwise.
      targetSpeed[PORT] := localSpeed - turnAmount
      targetSpeed[STARBOARD] := localSpeed + turnAmount
      pulseLength[PORT] := STOP + targetSpeed[PORT]  
      pulseLength[STARBOARD] := STOP - targetSpeed[STARBOARD]
      Refresh
      result++
    

    It's in Spin but hopefully it will make sense to those familiar with PBASIC.

    In the above equations, I'm setting the pulse of each servo (PORT for left and STARBOARD for right). I'll convert the pulse length to those used by the BS2. For a ccw turn, I'd set "localSpeed" to 50 and "turnAmount" to 12. For a cw turn, I'd use -12 for "turnAmount" and leave "localSpeed" at 50.

    The turn amount ends up increasing the speed of one motor while slowing the other one down a bit. The constant "STOP" is the pulse length used to stop the servo (750 in the BS2's case).

    One would want to add PULSOUT statements where the Spin code calls the "Refresh" method (a method in Spin is kind of line a subroutine in PBASIC). You'd also want to add a pause to the loop and a way of keeping track of how long you've been turning. I kept track of the time elsewhere in the program.

    The code:
    PULSOUT 13, 650
    PULSOUT 12, 650
    

    Will just turn the robot in place.

    This:
    PULSOUT 13, 788
    PULSOUT 12, 688
    

    Should give you a circle. (Assuming pin 13 is the left servo, switch the pulse amounts if the pins are switched.)

    hey Duane, I am running some old CR servos pulled form an old project (i think the life is or has been reduced already, but they both run at about the same RPM when measure with a fixed voltage source)
    Our parallax ones where bummed from factory (both didn't spin - yes after calibrations and before, they are just defective, no big deal - so i grabbed the ones i could find without spending any money hehe)

    I didn't know about running so much Voltage to it could damage them, due to the fact that we use a 9v battery attached to the BOE-BOT. suppose when we get out parallax kit ones back, ill use a lipoly pack or l-ion pack, if i want to run a lipoly pack whats the safest 3.3? obviously there's a 7.4 or 11.1, too much and i do not have a voltage regulator attached (could though i think i have a 78xx chip around). ill have to read up on some packs that are ok with the boebot, prehaps ill just go grab some rechargable AA's. suggestions would be awesome hehe.

    as for my code yes it spins in a circle i think CCW (i think..) anyways if you can make one slow than the other or faster than the other you can make it a circle, well thats how i went over it in my head, just seemed easier to understand this way.

    Thanks for the info and help! ill be cranking on the code this weekend in my spare time hopefully get it working perfectly!! hehe.
  • GenetixGenetix Posts: 1,754
    edited 2013-06-22 12:06
    Duane, I followed that E-Bay link to the power supply and I see the specs are listed but there is no schematic or instructions. I've also has mixed results getting things from E-Bay many years ago. I will try your code when I get a chance but your Bot is considerable different from a Boe-Bot. Interesting design though.

    Rondo, Parallax is very good at replacing defective products. I haven't yet had to replace anything but I have seen numerous people on the Forums have issues and Parallax sent the replacements. Give them a call about your CR servos and see what they say.

    Brian
  • rondorondo Posts: 6
    edited 2013-06-22 14:47

    Rondo, Parallax is very good at replacing defective products. I haven't yet had to replace anything but I have seen numerous people on the Forums have issues and Parallax sent the replacements. Give them a call about your CR servos and see what they say.

    Brian

    Brian yes they are I haven't had any problems contacting Parallax. I should be receiving some CR servos by Monday or Tuesday. I think I might just stop by on Tuesday. Yes at Parallax hehe im about 25 mins away.
  • GenetixGenetix Posts: 1,754
    edited 2013-06-22 21:25
    rondo wrote: »
    Brian yes they are I haven't had any problems contacting Parallax. I should be receiving some CR servos by Monday or Tuesday. I think I might just stop by on Tuesday. Yes at Parallax hehe im about 25 mins away.

    You are so lucky Rondo to live so close to Parallax! It would take me most of the day to drive there from here in Orange County. Others on here live in other states and so are in other countries. Everytime I order something from Parallax it takes about a week to arrive. Hopefully you will be a frequent visitor and customer.

    Brian
  • rondorondo Posts: 6
    edited 2013-06-22 23:01
    Genetix,

    no kidding! Yep i feel as i will be pretty frequent, i have never done any type of robotics, mainly electronics (discrete parts etc...just from school and some own little projects like audio amps, capacitor banks for airsoft guns etc). I do like it a ton and its requiring me to do a little more research and "playing" than i thought, and it is fun seeing how your code can make something so little do something like figure 8s or even navigate a maze, follow cats, or even program a little turret with the ping sensor hehe.

    w00t have a little time tomorrow to wrench on some code see if i can get a figure 8!! ...or perhaps baby steps, circle haha.

    ill definitely post up my boe-bot when its all completed - main goal right now is to navigate a maze with some obstacles and obstructions, and..stealth objects... cant wait!! :)

    the parallax boards and site is filled with a ton of information and resources! im sure if i run into a snag there a few members here that have alittle knowledge to throw my way if needed, but im pretty stubborn and ill end up trial and error technique to find out what does and doesnt work hehe.

    Thanks!

    -Ronnie
  • GenetixGenetix Posts: 1,754
    edited 2013-06-23 17:10
    Ronnie, you will find that most of the forum members are very helpful although a few prefer that you figure it out for yourself and will guide you to the information that you need. Don't be afraid to ask even stupid questions as someone will answer them. As for school projects the general rule is that you need to do the work yourself so you can ask as many questions as you like an even ask for guidance on how to do something but you will not be given your completed project. Sometimes though someone might have done something similar or you might be pointed to a project that you shows how to do something you need to do. Just be sure you credit someone else if you borrow their design or code.

    Brian
  • rondorondo Posts: 6
    edited 2013-06-23 22:36
    Genetix
    Thanks for the awesome words of support. Definitely in with doing my own work....like I said I hate coding but gotta learn it and its super easy im just being a baby about it hehe. You know at first coffee or beer isnt the greatest...then...haha not the same but im sure you get the pic. ..or better its like math. Gotta use it.

    Ronnie
  • GenetixGenetix Posts: 1,754
    edited 2013-06-24 11:49
    Ronnie,
    I don't know what your background is but learn to document your code. It makes it easier for yourself and others to understand when you look at it later.

    Brian
  • rondorondo Posts: 6
    edited 2013-06-27 12:29
    Genetix,
    I have some good practices with programming and have been looking at code for a good while, and we are working in teams, coding with more than one person gets a little crazy, keeping notes helps a ton.
    Well i have gotten my boe-bot now to navigate with some whiskers, gotta modify the head/contact pins a little to get it the way i want, code is looking pretty good and it can navigate through our little maze (not all the way through, but enough - hasnt completed the maze yet, but still have to put a few more sensors on the kit.

    -ronnie
Sign In or Register to comment.