Shop OBEX P1 Docs P2 Docs Learn Events
I throw myself onto the mercy of the Forum, I'm making my propeller freeze — Parallax Forums

I throw myself onto the mercy of the Forum, I'm making my propeller freeze

vanmunchvanmunch Posts: 568
edited 2011-02-02 20:36 in Propeller 1
I think it's solved. I'll let you know in a day or two. Thanks!

Hello,

I thought that I had been making great progress on my robot until I let it take more than one step. I found that the program freezes so I'm guessing that I'm writing over one part of the program with another or something. I've whittled down the program so that it's just using three of the six legs and it doesn't bother trying to touch the ground (its a hexapod that has toe sensors that allow it to know if it's touching the ground or if the side of the foot hits something). The program still freezes, but now it goes through about 4 cycles before it stops. I've never had a programing class so it might be something as simple as my IF statements etc.

Quick overview of how the robot works. It has a "master direction" (normally determined by the direction the Ping))) is looking) that is the direction the robot want to walk. The hexapod is round with six legs spaced at 60 degree intervals. Using the master direction and the leg placement, the program determines how much of movement should be done with the hips or with the foot. The program then determines the legs' start and end values for the hip and foot. Once this is done the leg moves the hip a little bit, checks to see if the toe sensor is touching something, if it isn't it moves on to the next hip . This repeats until all of the hips are in their starting positions. Then it does the same with the feet. The program freezes irregardless of whether or not the toe sensor detects something and the program seems to like to freeze during the middle of the "foot" placement phase.

Thanks again for your time. Any suggestions would be greatly appreciated.

Dave
vanmunch

Comments

  • LeonLeon Posts: 7,620
    edited 2011-02-01 14:28
    It might be a hardware problem caused by poor circuit design or layout.
  • wjsteelewjsteele Posts: 697
    edited 2011-02-01 14:42
    Leon wrote: »
    It might be a hardware problem caused by poor circuit design or layout.

    Or it might not, but that sure seemed like a quick way to insult the poor guy! :-)

    Vanmunch, with just a very quick glance I don't see any repeat loops in your code... how are you getting it to repeat the next sequence?

    Bill
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-02-01 15:05
    Vanmunch,

    As Bill suspects, I think you are managing your loops incorrectly.

    You have method A call method B which then calls C. Method C calls method A in order to loop the program. This is wrong. Off with your head. (So much for mercy of the forum.) Okay not off with your head but you probably need to work through some of the Propeller Education Kit tutorials (find it from the Help menu).

    You need a repeat loop.
    PUB MethodA
     
      repeat
        MethodB
        ' returns from MethodB here ready to loop again.
     
    PUB MethodB
     
      if x == somethingYouCareAbout
        MethodC
        ' back from MethodC here
    'program returns to MethodA now
     
    PUB MethodC
      do other stuff
    'program returns to MethodB
    

    Okay, we'll give you a suspended sentence.

    I'm really glad you're using the Propeller. Your robots are about to be even cooler!
    Don't give up on the Prop, you be glad you learned to use it.

    Duane
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-02-01 16:21
    I looked through your code some more.

    Here's an example of the problem.

    MoveHipsGroup0 calls MoveHipLPaw which calls MoveHipRF which calls MoveHipLR which calls MoveHipsGroup0 (Now we are back where we started.)

    This kind of code will work for a little while but before long you'll run out of stack space.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-01 16:46
    Hey, I like your robot!

    Just out of interest, what sort of motors/servos are you using?

    Re recursive loops, back in the olden days you could have cheated and used GOTO and had your code jumping all over the place. But it isn't too hard to rewrite code so it doesn't do this. To distill books worth (nay, University courses) of knowledge into something very simple, there is a concept called Top Down Programming, where you start at the top and work down. (The opposite is a subsumption architecture where you work on moving a joint, then a leg and work up. Check out the robotics work by Rodney Brooks http://en.wikipedia.org/wiki/Rodney_Brooks).

    So
    repeat
      {
          moverobotforward
      }
    
    and then you might add something
    repeat
      {
          checkforthreats
         if threats == true
         {
             runaway
         }
         else
         {
           moveforward
         }
      }
    
    And then you can start to flesh out what moveforward does in terms of individual joint movements.

    I think you already have 99% of the actual code working, it is just the big picture stuff about how the main loop works.
  • vanmunchvanmunch Posts: 568
    edited 2011-02-01 16:55
    @ Duane Degn Ha Ha Ha! Thanks! I had a sneaky suspicion that it had something to do with the mysterious "stack" stuff that I had read about in the PE since it worked for a while and then seemed to run out. I'll work on this some more tonight/tomorrow and let you know if I got it to work, but I think if I do something like this:

    PUB MoveHips

    repeat
    LeftFrontHip
    ' returns from LeftFrontHip here ready to loop again.

    PUB LeftFrontHip

    if LeftFrontHipPosition == HipStartingPostition
    RightRearHip
    LeftFrontHipPosition := LeftFrontHipPosition +1
    ' back from RightRearHiphere
    'program returns to MoveHips now

    PUB RightRearHip
    if RightRearHipPosition == RightRearHipPostition
    RightRearHipPosition := RightRearHipPosition + 1

    'program returns to LeftFrontHip


    ... and I don't need to tell "RightRearHip" to go to "LeftFrontHipPosition" because it automatically goes back to it


    Thanks again everyone!

    Dave
    vanmunch
  • vanmunchvanmunch Posts: 568
    edited 2011-02-01 17:01
    @ Dr_Acula
    Sorry, I was just writting. The servos are Hi-tech 645 MG being controled with two propeller servo controlers. I'll post some more information on the robot, but I think my wife is about ready to go to supper without me. :)

    Thanks for the further explination, that helps a lot!
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-01 18:07
    Great youtube video. I like the penguin. Those servos are 9.6kg/cm - now that is some grunt! But I'd better not chat too much - your supper is getting cold.
  • vanmunchvanmunch Posts: 568
    edited 2011-02-01 18:27
    @ Dr_Acula I'm glad you like the video, the price of the servos make you think twice before you go for it, but you can really never have ones that are too strong because you always end up making it as bigg as possiable. Just watch your fingures!

    "...supper getting cold..." if only you knew... We live in the center of the US, Iowa, and right now we're in the middle of a huge blizzard. Everythings closed, even work! :)
  • HughHugh Posts: 362
    edited 2011-02-02 00:55
    Top marks for achieving so much without repeat loops!
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-02 02:25
    Good point Hugh. Indeed the humble 'repeat' loop in spin can make life a lot easier.

    I always wanted to make a hexapod. I did once go and buy 18 servos but the power to weight ratio was too low. I think the secret is the metal gears.

    So it is really cool watching your robot walk because I know how hard (and expensive) it is to get these things working.

    I see it was walking around in the snow. I've heard Iowa gets really really cold. Right now here in Australia our biggest problem is wind as we are being attacked by this giant cyclone. Someone has gone and put a picture of the cyclone on a scale map of the USA. See attached.

    You mentioned watching your fingers. If one of those legs gets jammed, what gives out first? The gears, the joints or does the motor stall? Do you need current sensors on the servos?
    660 x 476 - 107K
  • vanmunchvanmunch Posts: 568
    edited 2011-02-02 16:25
    Hey Guys,

    I was able to work on it some more today, so I might have something to show by the end of the weekend. I'll have to post the new and improved code so that you can let me know if there are any other lurking icebergs in my code.

    With these servos the motor will just stall, but if you get your finger caught at the joint, it will give you a blood blister. The servos that you really have to watch out for are the ones with 444 oz of torque, but those also cost ~100 US so I guess they pinch your wallet too. :)

    As far as getting it to walk, I just watched what other people videos looked like and did trial and error. The body was designed and sold by the folks at Lynxmotion
    http://www.lynxmotion.com/
    and I've used the basic design a couple of times. Let me know if you want more info. I'll be posting my "Farming robot" in the projects forum in a couple of weeks. Thanks again for your help and watch out for that cyclone!

    Dave
    vanmunch
  • vanmunchvanmunch Posts: 568
    edited 2011-02-02 20:36
    Thanks for the heads-up on Rodney Brooks. I'm an entomologist who loves insect behavior and BEAM robotics. The kind of bottom-up program design is what you see in insects and is, I guess how I design the program for my robots. One funny entomology example of "bottom-up" is that "primitive" insects do not have all of their brains in one place. Rather they have a nervous system structure that is "stepladder" shaped. There's typically two main cords that run the length with shorter sections connecting the two like the rungs of the ladder. What's particularly interesting are that the points (ganglia) where the rung meets the longer nerve cords. It's kind of like a little brain that can control local function. The more "advance" insects are generally defined in part by how the "rungs" are localized in the head and with cords that are closer together. Cockroaches are somewhere in the middle. Motor control of the hind legs by the "head brain" can be overruled by an aggregation of "rungs" in its' hind end. Sooo when the hairs on its' hind end feel the wind move (caused by your hand trying to kill it) the single only has to travel to the mini brain in it's hind end which makes the judgment call to make the hind legs move. This allows the cockroach to react faster, but it also causes it to run without it's "head" knowing why it's running. You can get them to run straight into walls, off tables...

    I'm curious, what is the "normal" computer science approach/mentality to programming?
Sign In or Register to comment.