Close

More Power Igor

A project log for Cardware

An educational system designed to bring AI and complex robotics into the home and school on a budget.

morningstarMorning.Star 10/21/2017 at 10:360 Comments

Well, finally I was let down by a lack of amps, the batteries I have just arent strong enough to move the limbs without at least doubling them. And I'll need to upgrade the regulators. Such is life...

I added a little bit of code to the Pi's monitor. The raw_input() function was going to be replaced by an open() and list() on a script containing mnemonics.

def injector():
  global port,done,packet
  
  print 'Starting input thread.'
  
  joints=['anklex','ankley','knee','hipx','hipz']
  cmds=['movs','movm','movf','movi']
  syms=['s','m','f','i']
  rngs=[15,10,5,1]
  while not done:
    cmd=-1
    spd=-1
    srv=-1
    agl=-1
    print '->',
    i=raw_input('')
    if i!='':
      inp=i.split(' ')
      if len(inp)==3:
        srv=0
        if inp[0] in cmds: cmd=cmds.index(inp[0])
        if inp[1] in joints: srv=joints.index(inp[1])+1
        try:
          agl=int(inp[2])
        except: agl=-1
        if cmd>-1:
          spd=rngs[syms.index(cmds[cmd][3])]
        if cmd>-1 and srv>-1 and agl>-1 and spd>-1:
          checksum=1+srv+agl+spd # int(i1)+int(i2)+int(i3)+int(i4)+int(i5)
          chk2=(checksum & 65280)/256
          chk1=(checksum & 255)
          port.write(chr(chk1)+chr(chk2)+chr(1)+chr(srv)+chr(agl)+chr(spd)+chr(0))
          sleep(1)
    else: done=True

This would allow me to program motions for the servos, if they actually moved. They hum, but they just dont have the juice.

Closing existing port... Port not open
Clearing buffers...
Connected!
Starting input thread.
-> movm knee 255
Servo: 10 10 128
Move: 10 128
Move: 9 140
Move: 8 153
Move: 7 166
Move: 6 178
Move: 5 191
Move: 4 204
Move: 3 216
Move: 2 229
Move: 1 242
-> movm knee 128
Servo: 10 10 255
Move: 10 255
Move: 9 242
Move: 8 229
Move: 7 216
Move: 6 204
Move: 5 191
Move: 4 178
Move: 3 166
Move: 2 153
Move: 1 140
-> movm anklex 0
Move: 10 128
Move: 9 115
Move: 8 102
Move: 7 89
Move: 6 76
Move: 5 64
Move: 4 51
Move: 3 38
Move: 2 25
Move: 1 12
-> movm anklex 128
Move: 10 0
Move: 9 12
Move: 8 25
Move: 7 38
Move: 6 51
Move: 5 64
Move: 4 76
Move: 3 89
Move: 2 102
Move: 1 115
-> movm anklex 255
Move: 10 128
Move: 9 140
Move: 8 153
Move: 7 166
Move: 6 178
Move: 5 191
Move: 4 204
Move: 3 216
Move: 2 229
Move: 1 242
-> movi anklex 128
Move: 1 255
-> movi anklex 0
Move: 1 128
-> movs anklex 0
Move: 15 0

 This is the above code interacting with a live processor controlling the servos. For now I have just defined the following instructions.

These execute over time inside the Atmel without further instruction, freeing up the ports and main processor for the task of observing the sensors and interjecting to compensate. It isnt ideal, but it is a lot faster than trying to directly control the servos over those serial links.

I'm going to take a little break from this for a while. Or I will begin to dislike it... And I need to paint, and play my guitar some to chill out.

Discussions