Hello,
I am working on a project where I am using an SSC-32 controller and four HSR-5980 servo motors. I have two motors moving back and forth (head to tail) and two up and down. Each side of my robot has one motor going up and down, and one back and forth.
My issue is that the two motors on opposite sides of the robot (back and forth motion) are out of sync, i.e. one starts earlier than the other, therefore causing my robot to veer to one side.
Initially I had set the two motors of one side to connect to channels 0 and 1, and the two motors on the other side to connect to channels 16 and 17.
I had suspected that a delay due to channel distance could have been causing my delay in motor function and connected both motors with up and down motion in channels 0 and 1, and the back and forth motion into channels 16 and 17.
This did not solve my problem and I am not suspecting a problem in my code.
I am attaching snippets of my code which controls my movement. I would appreciate help with this issue.
My main aim is to have the motors not delay and start at the same time so that it is not veering to one side while moving forward.
[code]#set all servo’s initial position
ser.write("#0 P"+str(lu)+" #1 P"+str(ru)+"\r") #up
ser.write("#16 P"+str(lb)+" #17 P"+str(rb)+"\r") #back
time.sleep(1)
#Looks at GUI box to see what gait is selected
if Frame.gaitBox.index(ACTIVE)==0:
for i in range(0,runs):
gaitSym(ser, step_ms, step_s)
print ' Run: '+str(i+1)+''
stopVar=isStoped();
if stopVar==0:
break
if Frame.gaitBox.index(ACTIVE)==1:
for i in range(0,runs):
gaitAlt(ser, step_ms, step_s)
print ' Run: '+str(i+1)+''
stopVar=isStoped();
if stopVar==0:
break
if Frame.gaitBox.index(ACTIVE)==2:
for i in range(0,runs):
testProgramTIME(ser, step_ms, step_s)
print ' Run: '+str(i+1)+''
stopVar=isStoped();
if stopVar==0:
break
#set all servo’s initial position
time.sleep(1)
ser.write("#0 P"+str(lu)+" #1 P"+str(ru)+"\r") #up
ser.write("#16 P"+str(lb)+" #17 P"+str(rb)+"\r") #back
time.sleep(1)
print ‘\nSERIAL PORT CLOSED\n\n’
ser.write("#0 P0 #1 P0 #16 P0 #17 P0 \r")
ser.close() # close port
#Symmetrical Gait
def gaitSym(ser, step_ms, step_s):
import serial, msvcrt, time
ser.write("#16 P"+str(lf)+ " #17 P"+str(rf)+" T1000\r") #forward
wait_for_move(ser)
#time.sleep(1)
ser.write("#0 P"+str(ld)+" #1 P"+str(rd)+" T1000\r") #down
wait_for_move(ser)
#time.sleep(1)
ser.write("#16 P"+str(lb)+" #17 P"+str(rb)+" T"+str(step_ms)+"\r") #back
wait_for_move(ser)
#time.sleep(1)
ser.write("#0 P"+str(lu)+" #1 P"+str(ru)+" T1000\r") #up
wait_for_move(ser)
#time.sleep(1)
def wait_for_move(ser):
import serial, msvcrt
ser.flush();
while True:
ser.write(“Q \r”) #Is move done?
if ser.read(1)==".":
#time.sleep(0.01) #might need a delay to not overwhelm motor controller
break
def isStoped():
return stopVar
def stopProg():
global stopVar
stopVar=0
return stopVar
[/code]
I am new to this and I understand if I wasn’t clear, please ask me questions and I will try to answer them.
Thank you.
Nic