PDA

View Full Version : [Question(s)] Problem interfacing to PyPose on Arbotix controller from vanilla Python over FTDI



RufusMcgillicutty
06-11-2018, 07:59 PM
Hi,
I'm the new proud owner of a PhantomX turret.
I'm able to run PyPose.py and store/play poses, sequences, etc.
But I'd like to interface directly from a python 2.7 script like below, which should simply relax one of my two Dynamixels.

#!/usr/bin/env python
import time, sys, serial
from ax12 import *
from driver import Driver
from ax12 import P_MOVING, P_GOAL_SPEED_L


print("Turret example starting... ")


try:
driver = Driver(port="/dev/tty.usbserial-AI05H2WC", baud=38400, interpolation=True, direct=False)
print 'Opened port {} at {} baud'.format( port, baud)
except:
print('Could Not Open Port ' + port, 0)
sys.exit()

print("relaxing servos...")
driver.setReg(1,24,[0])


It almost works, but the serial response always times out in Driver.getPacket at
d = self.ser.read()
Turret example starting...
*Driver __init__(port=/dev/tty.usbserial-AI05H2WC,baud=38400,interpolation=True,direct=Fals e
Opened port /dev/tty.usbserial-AI05H2WC at 38400 baud
*Driver.setReg(index=1,regstart=24,values=[0]
*Driver.execute
prefix: FF FF index(1) length(4) ins(3) param_val(24) param_val(0) checksum(223)
*Driver.getPacket
Fail Read



(I've added the debug messages in teal, but "Fail Read" is printed by Driver.getPacket())
I've tried lengthening the ser.timeout, and I'm debug printing exactly the same hex ser.write(.) from Driver.execute.

First - am I trying to do something stupid? Obviously pypose.ino was made to be used with PyPose.py. I don't want to go to ROS, but maybe there's some other Arbotix controller code meant to interface to a linux host running python over FTDI?

Second - assuming this should work, I'm sort of at my wit's end. I think I've stared at it too long. Is there some way to split this problem?

Thanks for any advice!

RufusMcgillicutty
06-19-2018, 04:52 PM
I figured it out. The Arbotix controller, (just like any Arduino?) reboots when establishing a serial connection.
It works like a champ after I put a 7 second delay after instantiating the Driver object:
...
driver = Driver(port="/dev/tty.usbserial-AI05H2WC", baud=38400, interpolation=True, direct=False)
time.sleep(7)
...