Rug Warrior Pi: Build Blog (a PiDA bot)

Moderator: Steve

Re: Wheel Encoder Adventure Continues

Postby alanmcdonley » Mon Sep 21, 2015 4:33 am

mikronauts wrote:Any luck with the encoders?


alanmcdonley wrote:
Luckily, I found a source for the tiny, tiny Hamamatsu P5587 emitter-detector chip - therobotstorehk has them.


The encoders arrived this week. I have to get some courage to unsolder 10 leads/holes and solder 10 new. I bought four devices so I can mess up the devices but if I lift a pad I may be ....
alanmcdonley
 
Posts: 90
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

Rug Warrior Pi: Shaft Encoders

Postby alanmcdonley » Sun Sep 27, 2015 9:19 pm

Finally have the shaft encoders replaced so I can wire 'em up now.

Image
https://flic.kr/p/yTEG5a
alanmcdonley
 
Posts: 90
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

After long sleep - RugWarriorPi took first steps

Postby alanmcdonley » Tue Jun 07, 2016 9:23 am

My robot declared me AWOL some time back, but I am happy to announce my Pi Droid Alpha enabled Rug Warrior Pi robot ramped up to max forward speed to cruise about four feet, and then ramped to max reverse speed to return approximately to where it left from. (bias drive, no encoder feedback)

For some reason the alt/az servos went to limits when I initialized the pins - have to investigate what that is all about.

I see there is a new PDA_Lib.py so I need to update my code, along with updating the bot to Raspbian-Jessie-lite.

Somewhat in my defense, I just finished two months of spare time doing a comparison test of the Pi B+ vs Pi 3B:

Raspberry Pi Using Pocket Sphinx Speech Recognition Performance Comparison

And the video: https://vimeo.com/169445418

The Pi 3, with four cores, is going to allow so much simultaneous computing - I can't imagine complaining about being resource limits for a quite a while.

Alan
alanmcdonley
 
Posts: 90
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

Progress and setback

Postby alanmcdonley » Thu Jun 09, 2016 4:42 am

Last night was a mix of up and down emotions for me. I wrote a python program to set all the Pi Droid Alpha digital I/o pins to input, and loop printing their values to my ssh console. Every Python program feels like a great personal success right now.

The output showed that the encoders are working. Wow, that is really a success, since I had fried one and the tiny, tiny part is no longer manufactured. It was a lot of work to dissasemble the entire robot to get access to the tiny encoders, solder the new one in place and rewire the connections properly. It felt so good to spin the wheels and see each bit registering.

The program also showed that the wiring for the three bumpers is not good. I tore the bot down and changed the three signal connections but it seems that I need to fix the power connection to the bumpers.

I guess success or setback, it is time playing and learning. I need to not let times when my computers or robot are "sick" affect me. (It doesn't help to have gloomy weather this week, even though we really need the water.)

Off to work to pay for all these toys.
alanmcdonley
 
Posts: 90
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

And the bumpers are working!

Postby alanmcdonley » Fri Jun 10, 2016 4:52 am

I feel so elated to report I figured out my bumper problem. I had designed the connections to be active low using the internal pull-ups of the MCP23S17 but forgot this during my time away from my bot.

I used the (private/unsupported) PDALib.setDioBit(reg, pin) function to set the pull-ups and voila - I've got three working negative logic bumpers (rear, left, right). With the skirt on, this gives the bot 6 usable bump directions:

    front (left + right)
    left (front)
    right (front)
    left rear (left+rear)
    right rear (right+rear)
    rear
and "I'm in real trouble" (left+right+rear)

Here is my program:
Code: Select all
#!/usr/bin/python
#
# bumbers.py   BUMPER TEST
#
# 10Jun2016 - changed pins for PDALib v0.93

import PDALib
import time
import sys
import signal

# ################# BUMPER TEST ###########

# Bumpers are on
# DIO 18   Left Front
# DIO 17   Right Front
# DIO 16   Rear
# Wired to use internal pull-ups of the MCP23S17
# Bumper value is negative logic - 0 means bumper activated, normal 1

LeftBumper=18
RightBumper=17
RearBumper=16

# ################## CONTROL-C HANDLER
# Callback and setup to catch control-C and quit program
def signal_handler(signal, frame):
  print '\n** Control-C Detected'
  PDALib.LibExit()
  sys.exit(0)

# Setup the callback to catch control-C
signal.signal(signal.SIGINT, signal_handler)
# ##################

# Set Bumper DIO channels as input for now
PDALib.pinMode(LeftBumper,PDALib.INPUT)
PDALib.pinMode(RightBumper,PDALib.INPUT)
PDALib.pinMode(RearBumper,PDALib.INPUT)

# Set internal pull-ups on bumper channels
PDALib.setDioBit( PDALib.DIO_GPPU, 8 )  # set LeftBumper  pin 16 pull-up
PDALib.setDioBit( PDALib.DIO_GPPU, 9 )  # set RightBumper pin 17 pull-up
PDALib.setDioBit( PDALib.DIO_GPPU, 10 ) # set RearBumper  pin 18 pull-up

# Loop displaying bumpers and encoders
while True:
    print "Left  Bumper:", PDALib.digitalRead(LeftBumper)
    print "Right Bumper:", PDALib.digitalRead(RightBumper)
    print "Rear  Bumper:", PDALib.digitalRead(RearBumper)
    print "\n"
    time.sleep(1)
#end while


alanmcdonley
 
Posts: 90
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

Re: After long sleep - RugWarriorPi took first steps

Postby mikronauts » Tue Jun 14, 2016 10:56 am

Welcome back!

I'll check out your comparison and video, I've been meaning to play with voice recognition on the Pi...

alanmcdonley wrote:My robot declared me AWOL some time back, but I am happy to announce my Pi Droid Alpha enabled Rug Warrior Pi robot ramped up to max forward speed to cruise about four feet, and then ramped to max reverse speed to return approximately to where it left from. (bias drive, no encoder feedback)

For some reason the alt/az servos went to limits when I initialized the pins - have to investigate what that is all about.

I see there is a new PDA_Lib.py so I need to update my code, along with updating the bot to Raspbian-Jessie-lite.

Somewhat in my defense, I just finished two months of spare time doing a comparison test of the Pi B+ vs Pi 3B:

Raspberry Pi Using Pocket Sphinx Speech Recognition Performance Comparison

And the video: https://vimeo.com/169445418

The Pi 3, with four cores, is going to allow so much simultaneous computing - I can't imagine complaining about being resource limits for a quite a while.

Alan
mikronauts
 
Posts: 119
Joined: Tue Sep 16, 2014 6:58 pm

Rug Warrior Pi: Up alone all night

Postby alanmcdonley » Wed Jun 15, 2016 6:56 am

There is a natural anthropomorphism that happens when I spend a lot of time programming a robot. At first it is a just a bunch of hardware with no "life", but eventually I start to feel squeamish about issuing the shutdown command, like I am cheating an artificial intelligence (an AI) out of experiences. Ridiculous, but it happens.

Back in '99 and 2000, I programmed my Rug Warrior Pro bot for some of the "Vehicles: Experiments in Synthetic Psychology" , V. Braitenberg and wrote an article "I Sense, Therefore I Feel Moody (Behavior Management in Robots)"

There is a point at which I trust the robot will not harm itself if I leave it "experiencing" and turn my attention to something else for a while. Last night was that time.

I left it running two python programs - one the HC-SR04 ultrasonic distance sensor test. The second program is an analog pins test, running at sudo level. I have the 4-cell unregulated battery tap connected to ADC0 and my current sensor connected to ADC7. The two SG90 tilt/pan servos were holding at centers.

I started the programs after a full charge of the 7.2 v 5000 mAH cell bank last night, with the 4-cell tap reading 4.87v, and the system drawing 310mA.

This morning after 10 hours the system was at 4.5v drawing 335mA.

Based on "surviving" 10 hours without supervision, I decided to "leave the robot up", and left for work.

It will "decide on its own" to shutdown at 3.9 volts today, with the shutdown time on the remote terminal shell.

I'm starting to feel this is my robot's "ITS ALIVE!" moment.
alanmcdonley
 
Posts: 90
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

Re: Rug Warrior Pi: Build Blog (a PiDA bot)

Postby mikronauts » Wed Jun 15, 2016 9:58 am

Very cool!
mikronauts
 
Posts: 119
Joined: Tue Sep 16, 2014 6:58 pm

Rug Warrior Pi: Battery Life Test

Postby alanmcdonley » Fri Jun 17, 2016 9:34 pm

After several repeats, I've identified my safety shutdown voltage - 10 readings of 6.7v leaves 10 minutes charge.

If I waited to the sometimes recommended 0.9v per cell discharge limit ( 5.4v ), I would have less than a minute of juice left to shutdown.

So with a battery of six 5000 mAh NiMH C-cells, my robot will sit quietly under my desk for 10 hours 45 minutes waiting for my return to hook it up to recharge, which takes about 4 hours to replenish the roughly 3000 mAh run.

PDF and Spreadsheet of results attached.

Also published with Pi Droid Alpha mention at: Alan's Blog on element14

Code: Select all
#
# battery_life.py  BATTERY LIFE TEST
#
# The 7v2 unregulated through 2:1 divider must be connected to
#      ADC6 (pin 6) for this test
#
# This test will loop reading the voltage on ADC6 and current (pin 7)
#      UNTIL voltage drops below 5.3v (6x0.9v - 1.5% error) 10 times,
#      then will issue a shutdown now
#
# Start this test with $ sudo python battery_life.py
#

import PDALib
import myPDALib
import time
import sys
import signal
import currentsensor
import os
import datetime
import sys

def signal_handler(signal, frame):
  print '\n** Control-C Detected'
  myPDALib.PiExit()
  sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)

nLow = 0
while True:

  print ("current_sense(): %.0f mA" % currentsensor.current_sense(1000))
  V_now = myPDALib.readVoltage(6) * 2.0  # 2:1 resistor divider
  if (V_now < 5.3):   #if 7v2 < 5.3v  (6*0.9-.01)
          nLow+=1
          print "nLow:***************",nLow     
  print ( "voltage: %.2f" % V_now)
  print datetime.datetime.now()
  print "\n"
  time.sleep(1)
  if (nLow >9):
          print "\n"
          os.system("sudo shutdown -h now")
          sys.exit(0)
# end while

myPDALib.PiExit()
 
 


Attachments
Battery Life Result.jpg
Battery Life Result.jpg (251.59 KiB) Viewed 3989 times
Last edited by alanmcdonley on Sat Jun 18, 2016 7:29 am, edited 1 time in total.
alanmcdonley
 
Posts: 90
Joined: Thu Jul 23, 2015 10:50 am
Location: Boynton Beach, Florida

Re: Rug Warrior Pi: Build Blog (a PiDA bot)

Postby mikronauts » Sat Jun 18, 2016 7:00 am

Great data!

Eventually you might want to make some sort of charge station for your bot that it can go to when low on battary, for a self-initiated recharge.
mikronauts
 
Posts: 119
Joined: Tue Sep 16, 2014 6:58 pm

PreviousNext

Return to Pi Droid Alpha

Who is online

Users browsing this forum: No registered users and 1 guest

cron