Skip to main content

A python robotic framework and tools

Project description

:lizard: pyGecko

My robot software.

  • Doesn't use ROS, ROS is a pain to install and maintain on macOS and various linux systems
    • Uses some of the same ideas, constructs, architecture ideas, APIs but not strictly adhering to them
  • Uses Zero MQ as the inter-process communication (uses both TCP and UDS) instead of RPC-XML
    • looked at Google's protobuf, but was more complex than I needed
    • using msgpack to serialize data currently, but could be changed to something different
    • instead of roscore use geckocore.py as the message hub
      • produces performance data (see below)
    • instead of roslaunch use geckolaunch.py
  • json - config and launch files
  • All of this runs on Raspberry Pi 3
    • Also runs on macOS (UNIX)

Architecture

  • GeckoCore is a hub that tracks what computer publishes what topic and prints node cpu/memory usage
    • Actually, when gecko processes start up, they tell geckocore their pid numbers so it can track usage using psutil library
    • Obviously this only works on processes located on the same machine as geckocore
    • GeckoCore really just displays info and keeps track of publisher topics/addresses
  • Any number of pubs can talk to any number of sub ... it is not a one-to-one relationship
  • Pubs/Subs can exist on remote machines
    • If a Pub/Sub is on a remote machine, then it's performance data is not displayed
    • There currently is no mechanism to get the remote performance data

geckocore.py

  1. Binder opens a random port for data
    1. Note: either a publisher or a subscriber can bind to a port
  2. Binder tells GeckoCore the topic and address/port
  3. GeckoCore acknowledges the binder
  4. A connector wants to connect to a topic and asks GeckoCore for the address/port
  5. GeckoCore:
    1. If topic is found, return the address/port and an ok status
    2. If topic is not found, returns None
  6. Connector connects to the binder with the given address/port
    1. Binder: only 1 per port, can be either pub or sub
    2. Connecter: can be many per port, can be pub or sub

This is the main message hub. GeckoCore also is passed the PIDs for processes on the local machine and prints performance data on each process:

+========================================
| Processes Performance
| [24790] GeckoCore............. cpu:  0.3%  mem:  0.0%
| [24793] pub_ryan.............. cpu:  0.1%  mem:  0.0%
| [24795] pub_mike.............. cpu:  0.1%  mem:  0.0%
| [24796] sub_mike.............. cpu: 20.5%  mem:  0.0%
| [24797] pub_sammie............ cpu:  0.1%  mem:  0.0%
| [24798] sub_sammie............ cpu: 20.5%  mem:  0.0%
+------------------------------
| ESTABLISHED Connections
| pub_mike............ 192.168.86.22:50551 --> 192.168.86.22:50557
| sub_mike............ 192.168.86.22:50557 --> 192.168.86.22:50551
| pub_sammie.......... 192.168.86.22:50554 --> 192.168.86.22:50558
| sub_sammie.......... 192.168.86.22:50558 --> 192.168.86.22:50554
+------------------------------
| LISTEN Connections
| GeckoCore........... 192.168.86.22:11311
| pub_ryan............ 192.168.86.22:50548
| pub_mike............ 192.168.86.22:50551
| pub_sammie.......... 192.168.86.22:50554
+========================================
| Published Topics <topic>@tcp://<ip>:<port>
|  1: ryan@tcp://192.168.86.22:50548
|  2: mike@tcp://192.168.86.22:50551
|  3: sammie@tcp://192.168.86.22:50554
+========================================
========================================
 Geckocore [65975]
-------------
 Key: local
 Host IP: 10.0.1.57
 Listening on: 224.3.29.110:11311
-------------
Known Services [6]
 * hello:........................ tcp://10.0.1.57:65303
 * hey there:.................... tcp://10.0.1.57:65304
 * ryan:......................... tcp://10.0.1.57:65310
 * mike:......................... tcp://10.0.1.57:65311
 * sammie:....................... tcp://10.0.1.57:65312
 * scott:........................ tcp://10.0.1.57:65313

Binders [6]
 [65993] hello................. cpu:  0.0%  mem:  0.0%
 [65994] hey there............. cpu:  0.0%  mem:  0.0%
 [66008] ryan.................. cpu:  0.1%  mem:  0.0%
 [66010] mike.................. cpu:  0.1%  mem:  0.0%
 [66012] sammie................ cpu:  0.1%  mem:  0.0%
 [66014] scott................. cpu:  0.1%  mem:  0.0%

Connections [8]
 [65995] hello................. cpu: 20.7%  mem:  0.0%
 [65996] hello................. cpu: 20.9%  mem:  0.0%
 [65997] hey there............. cpu: 21.0%  mem:  0.0%
 [65998] hey there............. cpu: 20.8%  mem:  0.0%
 [66011] mike.................. cpu: 19.0%  mem:  0.0%
 [66013] sammie................ cpu: 19.0%  mem:  0.0%
 [66015] scott................. cpu: 19.4%  mem:  0.0%
 [66009] ryan.................. cpu: 18.7%  mem:  0.0%

geckolaunch.py

geckolaunch.py allows you to launch a bunch of processes quickly using a launch file. A launch file is just a simple json file where each line takes the form: [file, function, kwargs]. Here is an example:

{
  "processes":
  [
    ["process", "publish", {"topic": "hello"}],
    ["process", "publish", {"topic": "hey there"}],
    ["process", "subscribe2", {"topic": "hello"}],
    ["process", "subscribe2", {"topic": "hello"}],
    ["process", "subscribe2", {"topic": "hey there"}],
    ["process", "subscribe2", {"topic": "hey there"}],
    ["process", "subscribe2", {"topic": "cv"}],
    ["process", "subscribe2", {"topic": "cv"}],
    ["process", "pcv", {"topic": "cv"}]
  ],
  "geckocore": {
      "host": "localhost"  # or hostname.local
  }
}

geckopy

See the examples, but this acts like a rospy and helps make writing pub/sub processes easy. See the /examples folder to see it in action.

  • init_node: this sets up the the process for communications with geckocore
  • logxxx: prints log messages
    from pygecko import geckopy
    geckopy.loginfo('this is a info message')  # just send a string
    geckopy.logwarn('this is a warning message')
    geckopy.logerror('this is a error message')
    geckopy.logdebug('this is a debug message')
    
  • Subscriber: creates a subscriber and appends the callback function to an array in geckopy
  • Publisher: creates a publisher and returns it
  • Rate: given a frequency of how often a loop should run (i.e., 10Hz), the returned object will dynamically set the sleep interval to achieve the rate. Ex:
    from pygecko import geckopy
    rate = geckopy.Rate(20)  # run loop at 20 Hz
    while True:
        rate.sleep()
    

Basic User API

  • geckopy.*
    • init_node(kwargs)
    • logX(test, topic='log')
      • X: Error, Debug, Info, Warning
    • is_shutdown()
    • Publisher(topics, addr=None, queue_size=10, bind=True)
    • Subscriber(topics, callback=None, addr=None, bind=False)

Change Log

Date Version Notes
2019-May-18 1.3.0 working with c++
2019-Mar-02 1.2.0 set multicast as the default method to find nodes
2018-Oct-28 1.1.0 simplified and removed geckocore as the main hub
2018-Sep-16 1.0.3 implemented a multicast connection process
2018-Sep-16 1.0.2 dropping python 2.7 support, only 3.7+
2018-Sep-11 1.0.1 working, but still need to flush it out some more
2018-Jul-28 1.0.0 totally nuked everything from orbit and started over
2017-May-14 0.8.3 updates and refactor
2017-Apr-02 0.8.2 fix pypi doc and refactor
2017-Mar-19 0.7.0 refactored
2017-Mar-12 0.6.0 changed messages from dict to classes
2016-Dec-26 0.5.0 refactor
2016-Oct-09 0.4.1 published to PyPi
2010-Mar-10 0.0.1 init

MIT License

Copyright (c) 2010 Kevin J. Walchko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygecko-1.3.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

pygecko-1.3.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file pygecko-1.3.0.tar.gz.

File metadata

  • Download URL: pygecko-1.3.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pygecko-1.3.0.tar.gz
Algorithm Hash digest
SHA256 258180c2c9de1d08b048970534a35b6b2d0997aebc5ef5b9241e3136b53f1385
MD5 34b1b6d59144ff083eec4b7301a778c5
BLAKE2b-256 b4b02feeb025489a9eaf03a597511aba2f63b4a3724be74d1cf85670bfa13092

See more details on using hashes here.

File details

Details for the file pygecko-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: pygecko-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pygecko-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d901e8e8f7716b594744e0f4aa70c4f1d50e6325bf86048fdefadcabce6b986
MD5 f4d9ceebecee843737622b2fad4ad84d
BLAKE2b-256 8ca07409bdd79ab46ca5f4bbc4caf642d7d537e3517ddcc236554aa592f73193

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page