element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi Chef Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Pi Chef Design Challenge
  • More
  • Cancel
Pi Chef Design Challenge
Blog The Spice of Pi - Glenn Blog #9
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: glennvanderveer
  • Date Created: 27 Mar 2018 2:04 AM Date Created
  • Views 554 views
  • Likes 6 likes
  • Comments 1 comment
  • google voice hat
  • pi chef*
  • google aiy voice kit
  • google speech api
Related
Recommended

The Spice of Pi - Glenn Blog #9

glennvanderveer
glennvanderveer
27 Mar 2018

On Sunday, I plugged in the lifting servo after unplugging the spinning servo, and just blindly ran the code for my angle testing.  I had completely forgotten that the servo was not the same as the spinning servo, and had a much smaller range of motion.  The servo ended up moving and tried to go further than the lifter barrel had tolerance for.  You can see the lifter assembly quite well at the beginning of the video in Dougs blog number 8.  So, I actually broke the screw flange on the inner lifter.  Not a huge deal, as these parts were 3d printed.  I had some unsticky glue that I used to tack the 2 pieces back together so I could get the proper angles for lifting the bottles.

 

Tonight, I added code in to select the right bottle location and lift it.  Unfortunately it still causes a segmentation fault that I don't seem to be able to find the reason for.  I will have to cut back on some bottle code so I can reduce the complexity and get it working with 2 or 3 bottles and then add more bottles until I am complete. 

 

#!/usr/bin/env python3

 

 

import logging

import subprocess

import sys

import aiy.assistant.auth_helpers

import aiy.audio

import aiy.voicehat

from google.assistant.library import Assistant

from google.assistant.library.event import EventType

from gpiozero import AngularServo

import time

 

 

logging.basicConfig(

    level=logging.INFO,

    format="[%(asctime)s] %(levelname)s:%(name)s:%(message)s"

)

 

 

def power_off_pi():

    aiy.audio.say('Good bye!')

    subprocess.call('sudo shutdown now', shell=True)

 

 

 

 

def reboot_pi():

    aiy.audio.say('See you in a bit!')

    subprocess.call('sudo reboot', shell=True)

 

 

 

 

def say_ip():

    ip_address = subprocess.check_output("hostname -I | cut -d' ' -f1", shell=True)

    aiy.audio.say('My IP address is %s' % ip_address.decode('utf-8'))

 

 

def get_spice(SpinAngle, LiftAngle):

    spinner=AngularServo(6,min_angle=-180, max_angle=180,frame_width = 10/1000)

    lifter = AngularServo(5,min_angle = -45, max_angle = 30, frame_width = 10/1000)

    spinner.detach()

    lifter.detach()

    lifter.angle = -20

    time.sleep(1)

    spinner.angle = SpinAngle

    print ('Moving platter')

    time.sleep(4)

spinner.detach()

    lifter.angle=LiftAngle

    print ('Lifting bottle')

    time.sleep(1)

lifter.detach()

    print ('Enjoy your spice!')

 

 

 

def process_event(assistant, event):

    status_ui = aiy.voicehat.get_status_ui()

    if event.type == EventType.ON_START_FINISHED:

        status_ui.status('ready')

        if sys.stdout.isatty():

            print('Say "OK, Google" then speak, or press Ctrl+C to quit...')

 

 

    elif event.type == EventType.ON_CONVERSATION_TURN_STARTED:

        status_ui.status('listening')

 

 

    elif event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED and event.args:

        print('You said:', event.args['text'])

        text = event.args['text'].lower()

        if text == 'power off':

            assistant.stop_conversation()

            power_off_pi()

        elif text == 'reboot':

            assistant.stop_conversation()

            reboot_pi()

        elif text == 'jar 1':

            assistant.stop_conversation()

            get_spice(-176,-20)

        elif text == 'jar 2':

            assistant.stop_conversation()

            get_spice(-155,-20)

        elif text == 'jar 3':

            assistant.stop_conversation()

            get_spice(-155,20)

        elif text == 'jar 4':

            assistant.stop_conversation()

            get_spice(-135,-20)

        elif text == 'jar 5':

            assistant.stop_conversation()

            get_spice(-113,-20)

        elif text == 'jar 6':

            assistant.stop_conversation()

            get_spice(-113,20)

        elif text == 'jar 7':

            assistant.stop_conversation()

            get_spice(-95,-20)

        elif text == 'jar 8':

            assistant.stop_conversation()

            get_spice(-73,-20)

        elif text == 'jar 9':

            assistant.stop_conversation()

            get_spice(-73,20)

        elif text == 'jar 10':

            assistant.stop_conversation()

            get_spice(-53,-20)

        elif text == 'jar 11':

            assistant.stop_conversation()

            get_spice(-31,-20)

        elif text == 'jar 12':

            assistant.stop_conversation()

            get_spice(-31,20)

        elif text == 'jar 13':

            assistant.stop_conversation()

            get_spice(-18,-20)

        elif text == 'jar 14':

            assistant.stop_conversation()

            get_spice(10,-20)

        elif text == 'jar 15':

            assistant.stop_conversation()

            get_spice(10,20)

        elif text == 'jar 16':

            assistant.stop_conversation()

            get_spice(36,-20)

        elif text == 'jar 17':

            assistant.stop_conversation()

            get_spice(58,-20)

        elif text == 'jar 18':

            assistant.stop_conversation()

            get_spice(58,20)

        elif text == 'jar 19':

            assistant.stop_conversation()

            get_spice(85,-20)

        elif text == 'jar 20':

            assistant.stop_conversation()

            get_spice(107,-20)

        elif text == 'jar 21':

            assistant.stop_conversation()

            get_spice(107,20)

        elif text == 'jar 22':

            assistant.stop_conversation()

            get_spice(129,-20)

        elif text == 'jar 23':

            assistant.stop_conversation()

            get_spice(151,-20)

        elif text == 'jar 24':

            assistant.stop_conversation()

            get_spice(151,20)

 

 

 

    elif event.type == EventType.ON_END_OF_UTTERANCE:

        status_ui.status('thinking')

 

 

    elif event.type == EventType.ON_CONVERSATION_TURN_FINISHED:

        status_ui.status('ready')

 

 

    elif event.type == EventType.ON_ASSISTANT_ERROR and event.args and event.args['is_fatal']:

        sys.exit(1)

 

 

 

 

def main():

    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()

    with Assistant(credentials) as assistant:

        for event in assistant.start():

            process_event(assistant, event)

 

 

 

 

if __name__ == '__main__':

    main()

 

 

Design Challenge Links:

Pi Chef Design Challenge

About the challenge

The other challengers

The kit

Terms & Conditions

Summaries by Charles Gantt

 

Project Links:

Blog Doug 1 - The Concept

Blog Glenn 1 - AIY Voice Kit Unboxing

Blog Doug 2 - The Block Diagram and Bill of Materials

Blog Doug 3 - Spice Jar Lift Mechanism

Blog Glenn 2 - Firmware Considerations

Blog Doug 4 - Carousel Design

Blog Doug 5 - Platter Rotation Mechanism

The Spice of Pi - Blog Glenn 3

Blog Doug 6 - 3D Printed Platter Parts

Blog Doug 7 - Main Drive Assembly

Blog Doug 8 - Working Carousel

Blog Doug 9 - Google Assistant

Blog Doug 10 - Pi Enclosure

The Spice of Pi - Glenn blog #4

The Spice of Pi - Glenn blog #5

The Spice of Pi - Glenn blog # 6

The Spice of Pi - Glenn Blog # 7

The Spice of Pi - Glenn Blog #8

  • Sign in to reply
  • genebren
    genebren over 7 years ago

    Good update.  Looks like things are coming together nicely.  Oops, on the servo connects, I have done something like that before.  It's nice when all the servos are the same, so as to avoid over-driving them, but it is necessary at times to be running a mixed lot of servos.  Good luck on your final steps!

    Gene

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube