setPos not working in PoMoCo

I spent some time last night trying to figure out some problems in PoMoCo. I can get the GUI running, but I have no movement.

I originally posted here: PoMoCo: Connection to Servoter failed. but I think that the problem may be more appropriate for a new thread.

Here is a summery:

System: Windows 7

I cannot set servo positions within PoMoCo.
For example, if I run servotorComm.py by itself and create a new object “conn” for a controller and achieve a successful connection, the following results in no movement.

conn = Controller()
conn.servos[5].setPos(deg=30)

Therefor, all move commands do not work in the command line or as implemented by the GUI.
If I type the following while running PoMoCo without the GUI

move(‘Tilt Left’)

I get

Preforming move: Tilt Left

but no movement occurs.

No errors messages are generated. I know that I have communication because I can send ‘C’ and ‘K’ commands. For example, if I run through PoMoCo except without the GUI, I can successfully send a center command with:

hexy.con.serialHandler.ser.write(“C\n”)

Does anyone have any ideas? Are there previous versions of PoMoCo and servotor32 somewhere that I could try in order to make sure it is not something having to do with a revision (No offense meant. The Arcbotics team has done a great job. It just seems like a logical thing to check since we all make mistakes.).

Thanks in advance for any help.

Hi DustinM,

try “self.con.servos[servoNmbr].setPos(1500)” to move one of the servos.

Regards Yggdrasil

Thanks Yggdrasil. I tried the above command for a few different servo positions and servos and it did not work.

I was also trying to enter in commands directly in the serial monitor.

They all seem to work except for the position one. Do I have the syntax right?

eg. #5P1600

By the way, in Python I tried the following for the controller object “conn”

conn.servos[5].setPos(deg=30)
conn.servos[5].setPos(1500)
conn.servos[5].setPos(500)

To be explicit, I also started up a new process running PoMoCo without the GUI and ran

hexy.con.servos[5].setPos(1500)
hexy.con.servos[5].setPos(2500)

All with no movement.

Hi,

sorry I forget to explain my code line. The self-anchor only works in the GUI-object. Here is a full example which should works for you. I hope you can adapt is to your whishes:

  1. Add a button to the GUI (open GUI.py and add this code to the init method)

self.testButton = Button(self.frame, text="Test 1",fg="green", command=self.mytest) self.testButton.grid(row=0,column=0)

  1. Add the eventhandler (open GUI.py and add the mytest method ) I.E.
    def mytest(self):
        servo = 6
        self.con.servos[servo].setPos(1000)
        ## if you want wrote to the serial port use
        # ser = self.con.serialHandler.ser;
        # ser.write('C\n')

A comment to your approach:
I’m not sure if it’s possible to create a second controller with ‘conn = Controller()’. I would recommend to use the object, which is already initialized by the software.

Regards Yggdrasil

Sorry I should be clear, the Conn object was from when I was running servotorComm only without PoMoCo. There is a commented out line at the bottom from when someone ran a similar test. It is true that only one object at a time can open the port.

I also used the PoMoCo defined robot object “hexy” in a different test more similar to the one you mention. I will try your suggestion with the GUI when my batteries are recharged.

Shouldn’t I also be able to send the position commands directly through the arduino port interface though just like ‘C’, ‘K’ and ‘V’? After all, servo.setPos() calls the servo.move() function which uses the ‘#[servo Number]P[Servo Position in Microseconds]’ syntax to communicate with servotor32 directly as shown here https://github.com/ArcBotics/Hexy/wiki/Servotor32.

I tried this and sometimes it will twitch, but most of the time it is nothing. This tells me that the problem is not even in PoMoCo, but maybe has to do with the board, servotor32, or communication.

Are you sure your servos are getting (enough) power?

The first time I tried anything, it didn’t work at all because I’d forgotten to attach power to the “servo” plug on the board :blush: Even now, using an older set of NiMH batteries, the voltage drops pretty quickly to where the servos no longer repond. First time this happened I thought something had broken, but it was just low voltage.

Works best with fresh batteries with a full charge.

Yeah it sucks power fast. It almost made me almost think that there was a short somewhere.

I will try it with a DC power supply at the University tomorrow.

I originally was using alkalines, but I went out and bought some NiMh rechargables to see if that would help. They do have a lower nominal voltage than most alkalines, but it is well within the range of the voltage range printed on the board. At its lowest it went to 5.2V.

First thing first: is PoMoCo connecting to the controller in the first place? (the command line window that launches when PoMoCo does should let you know).

The problem turned out to be latency in the USB ports caused by a power saving setting used on Laptops. The OS suspends the USB ports when they are not active. Here is the proper change:

Control Panel >> Power Options >> Edit Plan Settings >> Change Advanced Power Settings

USB Selective Suspend Setting >> Plugged In

Change To
"Disabled"

The other change I made was

Control Panel >> Power Options >> Edit Plan Settings >> Change Advanced Power Settings >> PCI Express >>

Link State Power Management

Change To
"Off"

This worked on an HP Envy Laptop running Windows 7

This may be worth including in the Documentation since it is very non-obvious (at least to me).

Good to know. I added a troubleshooting section to the wiki:
github.com/ArcBotics/Hexy/wiki/Troubleshooting