Syntax error in PoMoCo.py & problems on Mac

Hey guys,

Great news to see that you’ve updated the Hexy page with additional instructions!

… I’m not fluent in python, but I believe there is a syntax error in the code; I get

Traceback (most recent call last):
File “PoMoCo.py”, line 666, in
app = App(root)
File “PoMoCo.py”, line 109, in init
self.con = servitorComm.Controller() # Servo controller
NameError: global name ‘servitorComm’ is not defined

looking at the file, it seems like “servitorComm” should be “servotorComm”. There are 3 instances of this in the file.

Secondly, I’m using a MacBook Air, with Python 2.7.3 and PySerial 2.5 installed, and I get this output whenever I type in “python PoMoCo.py

no serial ports available, just showing graphical
initilizing servos
servos initalizied
opening RC2 Offsets.cfg
automatically loaded offsets from RC2 Offsets.cfg
SHUTTING. DOWN. EVERYTHING. All servos killed.

I get the GUI to show up, but usually clicking on any of the buttons don’t do anything and the GUI promptly hangs afterwards.

Any tips?

Thanks in advance!

The PoMoCo posted on the Github is really out of date. We’re going through the process of updating it at the moment. We should be able to get the most up to date code either today or tomorrow.

Hey Guys,
Thanks so much for the update with the build instructions, Servotor driver, PoMoCo, etc. on one page. This was probably helpful for a lot of people since it took me a while to track everything down before the post. The instructions are great and my build went without a hitch. I figured out the remainder of the build (board position, battery placement, ultrasonic install) with photos around the site. I was really psyched when I saw that you’d posted PoMoCo, but then really bummed when it threw compile errors, and then had issues even after I fixed the typos. Like Em.K posted in this thread, I eventually got to the GUI but then got the same errors that he did. At this point I have a few more questions:

-roboalchemist responded to Em.K’s question saying that the GitHub PoMoCo code is really old. Is there anywhere we can find something more up to date? What are you guys using to demo Hexy at places like Maker Faire?
-I cannot find anywhere that says which servos plug in to which ports on the Servotor. Whats the order?
-I’ve updated my Servotor board with the "Servotor32_1v3.ino sketch. One of the final lines in the Body Assembly instructions says to plug each servo into ports 0, 1, 2, or 3 to zero the servo before tightening down the screw in the servo horn. It seemed like before I updated, the servo would zero at a different place each time I plugged it in. Now that I’ve updated, it seems more consistent but the position will change if I leave the servo connected for more than a few seconds. What does it sound like I’m doing wrong?

Thanks so much in advance and I just want you to know what a phenomenal job you guys are doing. This kit is an amazing opportunity for folks who have the interest but just not the budget required to build a nice hexapod. Not only that but it really feels like a quality product despite the price. Please don’t let some of the obnoxious comments on the boards (mainly the Kickstarter page) get you down! You all are doing awesome work.

Hey Banorific,

I can tell you how I wired it up, I’m pretty certain it’s correct, but roboalchemist will have the de facto say in it.

If you look at the file robot.py, the pin assignments are there.

Hey, PoMoCo has been updated!!!

Line 20 of Robot.py has

        self.RF  = leg(con,'frontRight',24,25,26)
        self.RM  = leg(con,'midRight',20,21,22)
        self.RB  = leg(con,'backRight',16,17,18)

        self.LF  = leg(con,'frontLeft',7,6,5)
        self.LM  = leg(con,'midLeft',11,10,9)
        self.LB  = leg(con,'backLeft',15,14,13)
class leg():

    def __init__(self,con,name,hipServoNum,kneeServoNum,ankleServoNum,simOrigin=(0,3,0)):

I imagine for RF(I guess Right Front?), the hip servo plugs into 24, knee servo into 25, and ankle into 26.

Regarding the centering of the servos… I noticed that the servos will have initial jitter when powered up… so I wait until the RED led comes on… then assume the servos are centered.

So, I updated to Servotor 1.4 and am using the latest PoMoCo on my MBA… and it’s definitely better, but I’m still getting weird behavior - when powered up, the Hexy tries to curl the legs pointing counter-clockwise… I say tries because a couple of the legs aren’t moving as much as the others. The RF hip and ankle also vibrate nonstop(the other legs seem fine).

Clicking on “Belly Flop” makes the legs move, but in an uncoordinated, trying to touch the roof of its body to varying degrees.

I’m gonna take my hexy apart and recalibrate it over the weekend and try new batteries… and if it doesn’t work, I’ll create a new thread.

BTW, PoMoCo now requires pyserial2.6 on the MacBookAir, FWIW.

Keep up the good work, guys!

Thanks for all the help guys! As you can see, all the software and tutorials aren’t really at a ‘release’ quality yet. However I’m sure after a couple weeks of forum questions and people pushing we’ll get there. (especially now that’ I’ll be in the office 24/7 as the new laser cutters just arrived) :wink:

E.Mk is right about the leg hookups, we’ll make that more clear in the documentation now.

The PoMoCo posted on the github now (we updated last night) is the stuff we were running at maker faire. We’ve only run it under OSX, though, so we have to go through and test on all the OSes to make sure its working right. In particular, we need to create our own installer for PySerial 2.6, as it seems the last windows installer that project published was 2.5. (2.6 added a sweet auto-find-the-serial-port feature that we sorta hacked into existence with 2.5, but their’s was way cleaner).

One thing that helps a lot with the shaking is to get the servos centered. Adjusting the offsets so that they’re all perfectly centered helps a lot (i.e. legs don’t shake when they’re on the ground). You’ll notice in PoMoCo that there’s offests you can make, and then save and load those offsets in the file menu. Even if you build the it with the servos ‘centered’, they’re still a tiny bit off.

From your description, I have to ask, does it curl up like a dead spider? That’s a sign the batteries are getting too low.

That was easier than I thought. I built windows install packages for PySerial 2.6 (turns out they never did that on the source forge):
arcbotics.com/products/hexy/start/

Alright… here’s what I did to center the motors. The jitters and the weirdness seems to be that the servos were all stuck trying to hit 2500. Trying because some servos can’t and jitter nonstop. I added the following code to Servotor32, line 198, right after the loop that sets all the servos to go to position 2500;


  for(int i=0; i<32; i++){
    changeServo(i,1500);
  }

Now, when I try to center the servos as per the instructions here, the servos don’t jitter!

Good catch! We’ve made the change to the new firmware. We’re trying to get a new update with a lot of cool features out before Christmas. If we can’t do it by then, we’ll at release one with what we have done.

I feel really stupid because I can’t even get PoMoCo to load, let alone the GUI. I’ve got PoMoCo 1.0 – is that too old? I’m also using Python 3.3.0, Arduino Leonardo and Servotor 32_1v7.

I installed PoMoCo 1.0 and Python 2.7.3 today, and PoMoCo is loading fine on my machine (Windows 7 64bit). Can you tell us what type of OS you have and what error message (if any) is displayed? You also should install PySerial 2.6 (as stated on the start guide, arcbotics.com/products/hexy/start/)

Edit: apologies masopomodoro, somehow I hadn’t noticed this was a Mac thread. Please ignore the above :slight_smile: )

What does this mean:

“PoMoCo may be launched by changing into the PoMoCo directory and running the following:”

How do you change into any directory let alone a PoMoCo one?

This is the step I can’t get past.

[quote=“masopomodoro”]What does this mean:

“PoMoCo may be launched by changing into the PoMoCo directory and running the following:”

How do you change into any directory let alone a PoMoCo one?

This is the step I can’t get past.[/quote]
This is referring to using the Terminal command line interface to start the PoMoCo application. I’ve never used a Mac, but google tells me the Terminal program is found in the Utilities folder within the Applications folder. When you open it, it will look like a black box with some white writing in it and it will be referencing a default directory (somwhere on your hard disk). The instruction:

“PoMoCo may be launched by changing into the PoMoCo directory…”

… is telling you that you need to change the current directory that Terminal is referencing to reference the one in which you have downloaded and unzipped the PoMoCo program. Somewhere on your machine you’ll have the PoMoCo.py file waiting, this folder location will be the path. So you’d change directory by using a ‘cd’ command:

cd path

Where path is the full directory structure to the folder that contains PoMoCo.py.

I hope this gives some information. If you’re still stuck, I’ll let someone who knows more about Mac OS fill you in with the rest of the details.

Here’s a good tutorial for how to work in terminal:
guides.macrumors.com/Terminal

We’re working on making a cleaner install package so you won’t have to use terminal in the future. I think it kind of defeats the ‘easy robot’ mentality. Add one more thing to the ToDo list :wink:

So I used the termini to open PoMoCo.py, but it put me exactly where I had been when I double clicked on it, which is to say, I was still unable to launch the GUI.

This is what the end of the message said on the PoMoCo.py directory:

global function for running move files

def move(moveName):
    print "Preforming move:",moveName
    moveName = moveName.replace(' ','')
    if moveName in sys.modules:
        reload(sys.modules[moveName])
    else:
        __import__(moveName)
__builtins__.move = move

GUI.startGUI(controller)
# the program only reaches here if the GUI has been closed
del hexy
del controller    
print "quitting!"
os._exit(0)

Nothing?

I’ve been emailing with masopomodoro, and got it running with him. Turns out there was some confusion as to how to run the python file. (going to the directory and running ‘python PoMoCo.py’)

It’s not exactly running, but I do have the GUI.

When I try to run python, it won’t connect to the servotor:

$ python PoMoCo.py
Attempting to connect to Servotor
Trying Windows Method
Connection to Servotor failed. No robot movement will occur.
initilizing servos
servos initalizied
Killing all servos

Got new batteries, ready to go – what do I do now?

Are you connecting via USB or Bluetooth?

Either way, it may take a minute or so to connect. You might see the “failed to connect” error even though, in the background, PoMoCo is still trying different serial ports.

I’m having similar problems on a Mac and can’t get the GUI to load.
I’m connected as far as I can tell thru Bluetooth (solid light) but I’m not sure
I’m working python right. I think I’m in python pomoco directory but I keep getting errors
About no module named serial or move or hexy not defined and of course no GUI. Am i supposed to be in terminal or idle?
My Mac is running 10.6.8
Help.