element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs RWPi: Life of a Wimpy Robot
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: alanmcdonley
  • Date Created: 4 Jul 2016 2:23 PM Date Created
  • Views 454 views
  • Likes 1 like
  • Comments 0 comments
Related
Recommended

RWPi: Life of a Wimpy Robot

alanmcdonley
alanmcdonley
4 Jul 2016

My "Whimpy Robot" is in the test phase now. Things I learned through this exercise:

    • Python Class structure
    • Initializing class objects
    • Thinking with "self"
    • Threading (creating, managing, killing)
    • Multi-threading with SPI to MCP3008 and MCP23S17 (critical sections, mutex variable)
    • "Thinking asynchronous": (fire and forget, fire-go_away-then-resynchronize)
    • Use of debugLevel to control print statements
    • Maintaining state for objects and threads
    • Publishing and consuming information for other objects
    • Making decisions about self state and state of other objects
    • Handling control-C to gracefully shutdown all objects and threads
    • Designing and coding for reuse

 

So here is a sample run that shows:

    • Whimpy Robot startup

 

    • Whimpy is "Happy"

 

    • Whimpy is "Bumped" (from the REAR)
      • -decides escape path is straight forward
      • -checks coast is clear to move
      • -moves 4"

 

    • Whimpy is "Happy" again

 

    • Whimpy is "Bumped" (from the FRONT)
      • -decides escape path requires a 180 degree turn
      • -after the turn, decides coast is not clear
      • -decides to try an additional 45 degree turn
      • -checks this new escape path is clear
      • -moves 4"

 

    • Whimpy is "Happy" again

 

    • Control-C occurs - Whimpy shuts down gracefully

 

Life of a Whimpy Robot:  (RWPi = Rug Warrior Pi robot)

 

pi@raspberrypi:~/RWPi $ ./whimpy.py

Starting Main

Robot__init__

UltrasonicDistance: readingsPerSec: 10

pollBumpers started with 0.100 interval

UltrasonicDistance: reading thread told to start

pollUltrasonicDistance started with 0.100s cycle

Motors: worker thread readingsPerSec: 20

Motors worker thread told to start 2016-07-04 09:40:04.233426

Motors: pollMotors thread started with 0.050000 at 2016-07-04 09:40:04.236642

waiting for threads to start

 

I'm happy now

 

********* RWPi STATUS *****

2016-07-04 09:40:06.258264

battery.volts(): 8.1

battery.hoursOfLifeRemaining(): 10 h 26 m

currentsensor.current_sense(): 524 mA

irDistance.inInches: 26.9

usDistance.inInches: 28.8

bumpers: NONE

 

I've been bumped! (REAR)

Checking if escape path is clear

Forward path is clear for: 8 inches

Moving fwd half my size

starting travel 3.5 at 1

waitForStopped or 60.0

 

I'm happy now

 

********* RWPi STATUS *****

2016-07-04 09:40:12.003888

battery.volts(): 8.1

battery.hoursOfLifeRemaining(): 10 h 25 m

currentsensor.current_sense(): 528 mA

irDistance.inInches: 28.1

usDistance.inInches: 26.9

bumpers: NONE

 

I've been bumped! (FRONT)

 

* Turning to CW180 as escape path

waitForStopped or 60.0

Checking if escape path is clear

Forward path is clear for: 2 inches

 

* Turning to CCW45 as escape path

waitForStopped or 60.0

Checking if escape path is clear

Forward path is clear for: 15 inches

Moving fwd half my size

starting travel 3.5 at 1

waitForStopped or 60.0

 

I'm happy now

 

********* RWPi STATUS *****

2016-07-04 09:41:13.900162

battery.volts(): 8.1

battery.hoursOfLifeRemaining(): 10 h 24 m

currentsensor.current_sense(): 508 mA

irDistance.inInches: 48.0

usDistance.inInches: 0.0

bumpers: NONE

 

^C

** Control-C Detected

robot.cancel() called

bumpers.cancel() called

Motors.cancel() called

Waiting for Motors.control Thread to quit

do_run went false. Stopping pollMotors thread at 2016-07-04 09:41:52.735483

UltrasonicDistance.cancel() called

Waiting for UtrasonicDistance.readThread to quit

do_run went false. Stopping pollUltrasonicDistance thread

do_run went false. Stopping pollBumpers thread

myPDALib.PiExit():  PDALib.pi.stop() called

whimpy.py says: Bye Bye

pi@raspberrypi:~/RWPi $

 

  • Sign in to reply
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