Pololu maestro controller and Python issue

Hello I’m new to the pololu servo controller. I checked out the python code, on GitHub, to control the maestro and wrote the following:

Import maestro
servo = maestro.Controller(‘/dev/ttyAMA0’)

servo = runScriptSub(‘Sequence 6’)

In the maestro control center, I created a Sequence 6. I then copied all sequences to script and hit the apply settings button.

I now have a sequence called Sequence_6 in the script tab.

My issue is whatever I call it in python I get NameError: name ‘Sequence_6’ is not defined.
I’ve tried it in quotes, without quotes, with a space, with an underscore but nothing seems to work.

I’m running python 3.7.3 on a Raspberry Pi 4.
Any help would be greater appreciated.

Hello.

It sounds like you are using the maestro.py library. The runScriptSub function expects a subroutine number, not the name of the subroutine, so that line should probably look something like this:

servo.runScriptSub(6)

That function uses the Maestro’s “Restart Script at Subroutine” command, which is documented in the “Serial Script Commands” section of the Maestro user’s guide. I recommend reading the description for that command to understand how to use it. In particular, please note that the subroutine is numbered based on the order it is defined in your script, not based on how you name it, and the subroutine should not end with the RETURN command.

- Patrick

Patrick,

Thank you so much. That did the trick. I thought if you renamed a sequence you could call the new name.

-Mark

1 Like