pct


Namepct JSON
Version 0.0.39 PyPI version JSON
download
home_pagehttps://github.com/perceptualrobots/pct/tree/master/
SummaryPerceptual Control Theory with Python
upload_time2024-09-10 19:02:27
maintainerNone
docs_urlNone
authorRupert Young
requires_python>=3.6
licenseApache Software License 2.0
keywords pct control systems robotics psychology
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Perceptual Control Theory


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

With this library you can create and run simple or complex hierarchies
of perceptual control systems as well as make use of the power of the
Python platform and its rich set of packages.

In the context of this library a single control system comprising a
perceptual, reference, comparator and output function is called a Node.
The functions therein can be configured by the user.

A hierarchy is defined by a collection of nodes.

## Install

`pip install pct`

## Import

Examples of importing the library functionality.

`import pct as p`

`from pct.hierarchy import Hierarchy`

`from pct import *`

## How to use

Import modules from the PCT library.

``` python
from pct.nodes import PCTNode
```

For the purposes of this example define a world model. This would not be
required if the real world is used, or a simulation such as OpenAI Gym.

``` python
def velocity_model(velocity,  force , mass):
    velocity = velocity + force / mass
    return velocity

# World value
mass = 50
```

Create a PCTNode, a control system unit comprising a reference,
perception, comparator and output function. The default value for the
reference is 1. With the history flag set, the data for each iteration
is recorded for later plotting.

``` python
pctnode = PCTNode(history=True)
```

Call the node repeatedly to control the perception of velocity. With the
verbose flag set, the control values are printed. In this case the
printed values are the iteration number, the (velocity) reference, the
perception, the error and the (force) output.

``` python
for i in range(40):
    print(i, end=" ")
    force = pctnode(verbose=True)
    velocity = velocity_model(pctnode.get_perception_value(), force, mass)
    pctnode.set_perception_value(velocity)
```

    0 0.000 0.000 0.000 0.000 
    1 0.000 0.000 0.000 0.000 
    2 0.000 0.000 0.000 0.000 
    3 0.000 0.000 0.000 0.000 
    4 0.000 0.000 0.000 0.000 
    5 0.000 0.000 0.000 0.000 
    6 0.000 0.000 0.000 0.000 
    7 0.000 0.000 0.000 0.000 
    8 0.000 0.000 0.000 0.000 
    9 0.000 0.000 0.000 0.000 
    10 0.000 0.000 0.000 0.000 
    11 0.000 0.000 0.000 0.000 
    12 0.000 0.000 0.000 0.000 
    13 0.000 0.000 0.000 0.000 
    14 0.000 0.000 0.000 0.000 
    15 0.000 0.000 0.000 0.000 
    16 0.000 0.000 0.000 0.000 
    17 0.000 0.000 0.000 0.000 
    18 0.000 0.000 0.000 0.000 
    19 0.000 0.000 0.000 0.000 
    20 0.000 0.000 0.000 0.000 
    21 0.000 0.000 0.000 0.000 
    22 0.000 0.000 0.000 0.000 
    23 0.000 0.000 0.000 0.000 
    24 0.000 0.000 0.000 0.000 
    25 0.000 0.000 0.000 0.000 
    26 0.000 0.000 0.000 0.000 
    27 0.000 0.000 0.000 0.000 
    28 0.000 0.000 0.000 0.000 
    29 0.000 0.000 0.000 0.000 
    30 0.000 0.000 0.000 0.000 
    31 0.000 0.000 0.000 0.000 
    32 0.000 0.000 0.000 0.000 
    33 0.000 0.000 0.000 0.000 
    34 0.000 0.000 0.000 0.000 
    35 0.000 0.000 0.000 0.000 
    36 0.000 0.000 0.000 0.000 
    37 0.000 0.000 0.000 0.000 
    38 0.000 0.000 0.000 0.000 
    39 0.000 0.000 0.000 0.000 

Using the plotly library plot the data. The graph shows the perception
being controlled to match the reference value.

``` python
import plotly.graph_objects as go
fig = go.Figure(layout_title_text="Velocity Goal")
fig.add_trace(go.Scatter(y=pctnode.history.data['refcoll']['constant'], name="ref"))
fig.add_trace(go.Scatter(y=pctnode.history.data['percoll']['variable'], name="perc"))
```

This following code is only for the purposes of displaying image of the
graph generated by the above code.

``` python
from IPython.display import Image
```

``` python
Image(url='http://www.perceptualrobots.com/wp-content/uploads/2020/08/pct_node_plot.png')
```

<img src="http://www.perceptualrobots.com/wp-content/uploads/2020/08/pct_node_plot.png"/>

This shows a very basic example of the use of the PCT library. For more
advanced functionality see the API documentation at
https://perceptualrobots.github.io/pct/.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/perceptualrobots/pct/tree/master/",
    "name": "pct",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "pct, control systems, robotics, psychology",
    "author": "Rupert Young",
    "author_email": "rupert@perceptualrobots.com",
    "download_url": "https://files.pythonhosted.org/packages/1e/04/c7ea3455a1a20c71162729ac05defb42076284ec484636725d3ec63f7bb1/pct-0.0.39.tar.gz",
    "platform": null,
    "description": "# Perceptual Control Theory\r\n\r\n\r\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\r\n\r\nWith this library you can create and run simple or complex hierarchies\r\nof perceptual control systems as well as make use of the power of the\r\nPython platform and its rich set of packages.\r\n\r\nIn the context of this library a single control system comprising a\r\nperceptual, reference, comparator and output function is called a Node.\r\nThe functions therein can be configured by the user.\r\n\r\nA hierarchy is defined by a collection of nodes.\r\n\r\n## Install\r\n\r\n`pip install pct`\r\n\r\n## Import\r\n\r\nExamples of importing the library functionality.\r\n\r\n`import pct as p`\r\n\r\n`from pct.hierarchy import Hierarchy`\r\n\r\n`from pct import *`\r\n\r\n## How to use\r\n\r\nImport modules from the PCT library.\r\n\r\n``` python\r\nfrom pct.nodes import PCTNode\r\n```\r\n\r\nFor the purposes of this example define a world model. This would not be\r\nrequired if the real world is used, or a simulation such as OpenAI Gym.\r\n\r\n``` python\r\ndef velocity_model(velocity,  force , mass):\r\n    velocity = velocity + force / mass\r\n    return velocity\r\n\r\n# World value\r\nmass = 50\r\n```\r\n\r\nCreate a PCTNode, a control system unit comprising a reference,\r\nperception, comparator and output function. The default value for the\r\nreference is 1. With the history flag set, the data for each iteration\r\nis recorded for later plotting.\r\n\r\n``` python\r\npctnode = PCTNode(history=True)\r\n```\r\n\r\nCall the node repeatedly to control the perception of velocity. With the\r\nverbose flag set, the control values are printed. In this case the\r\nprinted values are the iteration number, the (velocity) reference, the\r\nperception, the error and the (force) output.\r\n\r\n``` python\r\nfor i in range(40):\r\n    print(i, end=\" \")\r\n    force = pctnode(verbose=True)\r\n    velocity = velocity_model(pctnode.get_perception_value(), force, mass)\r\n    pctnode.set_perception_value(velocity)\r\n```\r\n\r\n    0 0.000 0.000 0.000 0.000 \r\n    1 0.000 0.000 0.000 0.000 \r\n    2 0.000 0.000 0.000 0.000 \r\n    3 0.000 0.000 0.000 0.000 \r\n    4 0.000 0.000 0.000 0.000 \r\n    5 0.000 0.000 0.000 0.000 \r\n    6 0.000 0.000 0.000 0.000 \r\n    7 0.000 0.000 0.000 0.000 \r\n    8 0.000 0.000 0.000 0.000 \r\n    9 0.000 0.000 0.000 0.000 \r\n    10 0.000 0.000 0.000 0.000 \r\n    11 0.000 0.000 0.000 0.000 \r\n    12 0.000 0.000 0.000 0.000 \r\n    13 0.000 0.000 0.000 0.000 \r\n    14 0.000 0.000 0.000 0.000 \r\n    15 0.000 0.000 0.000 0.000 \r\n    16 0.000 0.000 0.000 0.000 \r\n    17 0.000 0.000 0.000 0.000 \r\n    18 0.000 0.000 0.000 0.000 \r\n    19 0.000 0.000 0.000 0.000 \r\n    20 0.000 0.000 0.000 0.000 \r\n    21 0.000 0.000 0.000 0.000 \r\n    22 0.000 0.000 0.000 0.000 \r\n    23 0.000 0.000 0.000 0.000 \r\n    24 0.000 0.000 0.000 0.000 \r\n    25 0.000 0.000 0.000 0.000 \r\n    26 0.000 0.000 0.000 0.000 \r\n    27 0.000 0.000 0.000 0.000 \r\n    28 0.000 0.000 0.000 0.000 \r\n    29 0.000 0.000 0.000 0.000 \r\n    30 0.000 0.000 0.000 0.000 \r\n    31 0.000 0.000 0.000 0.000 \r\n    32 0.000 0.000 0.000 0.000 \r\n    33 0.000 0.000 0.000 0.000 \r\n    34 0.000 0.000 0.000 0.000 \r\n    35 0.000 0.000 0.000 0.000 \r\n    36 0.000 0.000 0.000 0.000 \r\n    37 0.000 0.000 0.000 0.000 \r\n    38 0.000 0.000 0.000 0.000 \r\n    39 0.000 0.000 0.000 0.000 \r\n\r\nUsing the plotly library plot the data. The graph shows the perception\r\nbeing controlled to match the reference value.\r\n\r\n``` python\r\nimport plotly.graph_objects as go\r\nfig = go.Figure(layout_title_text=\"Velocity Goal\")\r\nfig.add_trace(go.Scatter(y=pctnode.history.data['refcoll']['constant'], name=\"ref\"))\r\nfig.add_trace(go.Scatter(y=pctnode.history.data['percoll']['variable'], name=\"perc\"))\r\n```\r\n\r\nThis following code is only for the purposes of displaying image of the\r\ngraph generated by the above code.\r\n\r\n``` python\r\nfrom IPython.display import Image\r\n```\r\n\r\n``` python\r\nImage(url='http://www.perceptualrobots.com/wp-content/uploads/2020/08/pct_node_plot.png')\r\n```\r\n\r\n<img src=\"http://www.perceptualrobots.com/wp-content/uploads/2020/08/pct_node_plot.png\"/>\r\n\r\nThis shows a very basic example of the use of the PCT library. For more\r\nadvanced functionality see the API documentation at\r\nhttps://perceptualrobots.github.io/pct/.\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Perceptual Control Theory with Python",
    "version": "0.0.39",
    "project_urls": {
        "Homepage": "https://github.com/perceptualrobots/pct/tree/master/"
    },
    "split_keywords": [
        "pct",
        " control systems",
        " robotics",
        " psychology"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "94a65ff0203fae35a343f937da8a7cf7a6bc7f1f0e19693457d0be8be341366f",
                "md5": "17557c4000f5f9930eb2147d7ba1da3c",
                "sha256": "2cb7c34adf8cd57b7f75f5f772b97e5e9330adc81c26da33cdf9e24fb25d0b2d"
            },
            "downloads": -1,
            "filename": "pct-0.0.39-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "17557c4000f5f9930eb2147d7ba1da3c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 95248,
            "upload_time": "2024-09-10T19:02:25",
            "upload_time_iso_8601": "2024-09-10T19:02:25.575499Z",
            "url": "https://files.pythonhosted.org/packages/94/a6/5ff0203fae35a343f937da8a7cf7a6bc7f1f0e19693457d0be8be341366f/pct-0.0.39-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e04c7ea3455a1a20c71162729ac05defb42076284ec484636725d3ec63f7bb1",
                "md5": "9d93561afd0950f07a00bb9f18b78e51",
                "sha256": "cd04f1d0447f63fa4d8d0aa8788d937c95a5eb471cda783560c2c34ed5ed1d1d"
            },
            "downloads": -1,
            "filename": "pct-0.0.39.tar.gz",
            "has_sig": false,
            "md5_digest": "9d93561afd0950f07a00bb9f18b78e51",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 91774,
            "upload_time": "2024-09-10T19:02:27",
            "upload_time_iso_8601": "2024-09-10T19:02:27.462406Z",
            "url": "https://files.pythonhosted.org/packages/1e/04/c7ea3455a1a20c71162729ac05defb42076284ec484636725d3ec63f7bb1/pct-0.0.39.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-10 19:02:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "perceptualrobots",
    "github_project": "pct",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pct"
}
        
Elapsed time: 3.10077s