1 Star 0 Fork 0

eric/rtctree

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
LGPL-3.0
=======
RTCTree
=======

Introduction
============

RTCTree is a Python library providing an easy-to-use API for interacting
with running RT Components and RTM-based systems running on
OpenRTM-aist-1. It allows developers to manage these systems from
other programs without needing to learn the CORBA API. Components can be
started, stopped, connected together, have their configuration changed,
and so on.

This software is developed at the National Institute of Advanced
Industrial Science and Technology. Approval number H23PRO-1229. The
development was financially supported by the New Energy and Industrial
Technology Development Organisation Project for Strategic Development of
Advanced Robotics Elemental Technologies.

This software is licensed under the GNU Lesser General Public License version 3
(LGPL3). See LICENSE.txt.

Requirements
============

RTCTree requires omniorb-py, including omniidl with the Python backend.
If you have installed OpenRTM-python, you will have these installed
already. If not, you will need to install them manually.

RTCTree requires Python 2.7. It will not function with an earlier version of
Python. It has not been tested with Python 3 and it is likely that several
changes will be necessary to make it function using this version of Python.

Sphinx must be installed to build the documentation.


Installation
============

There are several methods of installation available:


1. (Preferred method) Use pip to install the PyPi package.

 a. Install pip if it is not already installed.
    See https://pip.pypa.io/en/latest/installing/

 b. Execute the following command to install RTCTree::

    $ pip install rtctree

2. Download the source from either the repository (see "Repository," below) or
   a source archive, extract it somewhere, and install it into your Python
   distribution:

 a. Extract the source, e.g. to a directory /home/blag/src/rtctree

 b. Run setup.py to install RTCTree to your default Python installation::

    $ python setup.py install

3. On Windows, use the Windows installer.


Environment variables
=====================

The following environment variables are used:

  ``RTCTREE_ORB_ARGS``
    A list of arguments, separated by semi-colons, to pass to the ORB
    when creating it. Optional.

  ``RTCTREE_NAMESERVERS``
    A list of name server addresses, separated by semi-colons, to parse
    when creating the RTCTree. Each server in the list will be added to
    the tree. Optional.

The only variable that should normally be set by the user is
``RTCTREE_NAMESERVERS``. Set this to a list of name server addresses,
separated by semi-colons, that you want rtcshell to interact with. For
example, in a Bash shell, you can run the following::

 $ export RTCTREE_NAMESERVERS=localhost;192.168.0.1:65346;example.com


The RTC Tree
============

The core of the library is the RTC Tree::

  import rtctree.tree
  tree = rtctree.tree.RTCTree()

This is a file system-like tree built by parsing name servers to find
directories, components and managers. You can treat it exactly the same
way as you treat a normal file system. The tree represents the naming
contexts, managers and components registered all on known name servers
in a tree structure::

 \
 |-+localhost
 | |-+naming_context
 | | |--ConsoleIn0.rtc
 | | |--ConsoleOut0.rtc
 | |
 | |--another_naming_context
 | |--Sensor0.rtc
 |
 |-+192.168.0.5
   |--Motor0.rtc
   |--Controller0.rtc

Each ``directory`` in the tree represents a naming context, which may be
a normal naming context or the root context of a name server. These are
represented by NameServer and Directory objects.

Name servers are treated as directories off the root directory, ``/``.
Below them are ``files`` and sub-directories. A sub-directory represents
a naming context below the root naming context of a name server.

Files are components and managers, represented by the Component and
Manager classes, respectively.

Component objects store a variety of information about the component
they represent. You can access the component's ports, configuration
sets, and so on.  Use these objects to change configuration values,
connect ports to each other, start and stop components, etc.

All nodes in the tree also store the CORBA object reference to the
object they represent. By accessing this object, you can call the IDL
methods. If something is not currently available in RTCTree, calling the
IDL method on the CORBA object directly will be able to achieve what you
want to do.


Building the tree
-----------------

The arguments to the tree factory function determine which name servers
are parsed to build the tree. See that function's documentation for
details. In general, you can pass in a list of server addresses and/or a
list of paths (the first component of each path is treated as a name
server). The environment variable ``RTCTREE_NAMESERVERS`` will also be
checked for any additional name servers to parse. This is a semi-colon
separated list of name server addresses.


Paths
-----

Nodes in the tree are addressed using paths. A path is a list of
strings, each representing a level in the tree one deeper than the
previous list item.  Absolute paths are necessary to address into the
tree object. Addressing from nodes allows relative paths, provided that
the path exists below the node.

When represented as text, these paths resemble file system paths. The
root of the tree is represented by ``/`` (``\`` on Windows systems). The
first level of entries are name server addresses. Entries below the
first level are components, managers and naming contexts (which are
represented as directories). The utility function parse_path will parse
a text string path into a list of path entries that can be used to
address nodes in the tree.

For example, the path ``/localhost/naming_context/ConsoleIn0.rtc``
represents the component ``ConsoleIn0.rtc``, registered in the
``naming_context naming`` context on the name server running at
``localhost``. When used to find the node in the tree representing this
component, the path should be a Python list::

  ['/', 'localhost', 'naming_context', 'ConsoleIn0.rtc']


Useful functions
----------------

Useful member functions of the RTCTree class and node classes that will
be of particular interest are shown below. This is not a complete list
of all available functionality. Users are encouraged to check the full
API documentation for additional functionality, and examine the rtcshell
source code for usage examples.

  ``RTCTree.has_path``
    Checks if a path is present in the tree.  Use this to quickly check
    if a component exists.
  ``RTCTree.get_node``
    Retrieves a node from the tree based on a path. Use this to get
    components, directories, etc. from the tree.
  ``RTCTree.is_component``
    Tests if the given path points to a Component object.  Tree nodes
    have a property, is_component, that performs the same function
    directly on a node. is_directory, is_manager and is_nameserver
    functions and properties are also available.
  ``RTCTree.iterate()``
    Use this function to perform an action on every node in the tree, or
    only those nodes matching a given filter. The return result of each
    call will be returned from iterate as a list.  This function is
    particularly useful. See rtcshell's rtls command for an example of
    using iterate().


  ``Node.children``
    This property gives a list of the node's children. You can use this,
    for example, to get all the components in a directory of the tree.
  ``Node.full_path``
    The full path of the node from the root of the tree.
  ``Node.name``
    The name of this node; i.e. its entry in the tree.
  ``Node.parent_name``
    The name of this node's parent (if it has one).
  ``Node.root``
    Given a node, use this property to get the root node of the tree it
    is in, on which you can perform nearly all functions you can perform
    on the tree object.


  ``Component.activate_in_ec()``
    Activate the component in the execution context at the given index.
    For most components, only one EC is present and so the index should
    be 0.
  ``Component.deactivate_in_ec()``
    Deactivate the component in an execution context.
  ``Component.reset_in_ec()``
    Reset the component in an execution context.
  ``Component.state_in_ec()``
    Get the state in a specific execution context.
  ``Component.alive``
    Test if the component is alive.
  ``Component.owned_ecs``
    The list of execution contexts owned by the component.
  ``Component.participating_ecs``
    The list of execution contexts the component is participating in.
  ``Component.state``
    The overall state of the component, created by merging its state in
    each execution context.
  ``Component.state_string``
    The overall state of the component as a string.
  ``Component.disconnect_all()``
    Disconnect all connections from all ports of this component.
  ``Component.get_port_by_name()``
    Find a port of this component by name.
  ``Component.ports``
    The list of the component's ports. Similar lists exist for input,
    output and service ports.  Component.connected_ports The list of the
    component's ports that are connected. Similar lists exist for
    connected input, output and service ports.
  ``Component.object``
    Get the CORBA LightweightRTObject that this component wraps.
  ``Component.activate_conf_set``
    Activate a configuration set by name.
  ``Component.set_conf_set_value``
    Set the value of a parameter in a configuration set.
  ``Component.active_conf_set``
    The currently-active configuration set.
  ``Component.active_conf_set_name``
    The name of the currently-active configuration set.
  ``Component.conf_sets``
    The list of configuration sets.


  ``Port.connect()``
    Connect this port to another port.
  ``Port.disconnect_all()``
    Disconnect all connections on this port.
  ``Port.get_connection_by_dest()``
    Get a connection on this port by the destination port.
  ``Port.get_connection_by_name()``
    Get a connection on this port by its name.
  ``Port.connections``
    The connections on this port.
  ``Port.is_connected``
    Checks if this port is connected or not.
  ``Port.name``
    The name of this port.
  ``Port.object``
    The CORBA PortService object that this component wraps.
  ``Port.name``
    The port's owner (usually a Component object).
  ``Port.porttype``
    The type of the port (DataInPort, DataOutPort or CorbaPort).


  ``Connection.disconnect()``
    Remove this connection between ports.
  ``Connection.ports``
    The list of ports involved in this connection.

  ``ConfigurationSet.has_param()``
    Checks if a parameter is present in the configuration set.
  ``ConfigurationSet.set_param()``
    Sets the value of a parameter in this configuration set.


  ``ExecutionContext.activate_component()``
    Activate a component within this execution context.
  ``ExecutionContext.deactivate_component()``
    Deactivate a component within this execution context.
  ``ExecutionContext.reset_component()``
    Reset a component within this execution context.
  ``ExecutionContext.get_component_state()``
    Get the state of a component within this execution context.
  ``ExecutionContext.running``
    Check if this execution context is running or not.


  ``Manager.create_component()``
    Create a new component instance.
  ``Manager.delete_component()``
    Destroy a component instance.


  ``dict_to_nvlist()``
    Converts a Python dictionary into a CORBA namevalue list.
  ``nvlist_to_dict()``
    Converts a CORBA namevalue list into a Python dictionary.


API naming conventions
======================

RTCTree follows the standard Python naming conventions as laid out in
PEP8_.

Most importantly, the private, internal API functions begin with an
underscore (``_``). If a function begins with an underscore, it is not
intended for use outside the class and doing so could lead to undefined
behaviour. Only use those API functions that do not begin with an
underscore and have a docstring in your programs.

.. _PEP8: http://www.python.org/dev/peps/pep-0008/


Further documentation and examples
==================================

For further documentation, see the generated API documentation.

For examples, see the rtshell set of utilities. These illustrate using
RTCTree to perform most of the actions possible using RTSystemEditor.


Repository
==========

The latest source is stored in a Git repository at github_.  You can
download it as a zip file or tarball by clicking the "Download Source"
link in the top right of the page.  Alternatively, use Git to clone the
repository. This is better if you wish to contribute patches.

::

 $ git clone git://github.com/gbiggs/rtctree.git

.. _github: http://github.com/gbiggs/rtctree


Changelog
=========

4.2
---

 - Implemented support for FSM4RTC (@yosuke)
 - Added doctests (@yosuke)

4.1
---

 - Switched setup from distutils to setuptools
 - Dropped support for Python 2.6

4.0
---

 - Added complete support for the ExecutionContext interface.
 - Support for the Logger SDO interface.
 - Support for the ComponentObserver SDO interface.
 - Support three-or-more port connections.
 - Deprecated Port.get_connection_by_dest()
 - Added Port.get_connections_by_dest()
 - Added Port.get_connections_by_dests()
 - Fixed a bug where finding a connection with a given destination would return
   all connections on the port.

3.0.1
-----

- Compatibility release for rtshell-3.0.1.

3.0
---

 - Do not treat exceptions while parsing managers as fatal
 - Other zombie-catching improvements
 - Detect zombie managers
 - New API calls to get composite component information
 - New API call to get a connection from a port by ID
 - Added API ability to give away the ORB
 - Added path formatter
 - Pretty-print exceptions
 - Other performance improvements (e.g. removed double parsing)
 - Added ability to restrict parsed paths (improves startup speed)
 - Added Zombie node
 - New API call to make a component exit
 - Removed defunct create_rtctree call
 - Exposed remove_node API call
 - Changed node.full_path to return a list, added node.full_path_str


2.0
---

 - Parse more information about execution contexts
 - Added the ability to use a provided ORB instead of creating one
 - Exposed the reparse_connections() method
 - New API call to get the ORB used for a node
 - New API call to unbind a name from a context
 - Allow access to more CORBA objects
 - Catch more zombies
 - Handle unknown CORBA object types
 - Handle the case of unknown port owners
 - Added locks to make RTCTree objects thread-safe
 - Added API for forcing a re-parse of any object in the tree
 - Cleaned up ``__init__`` functions for proper inheritence handling
 - New API call to get the state of a component in a specific EC
 - New API call to update the state of a component in a specific EC
GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

简介

OpenRTM 展开 收起
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/erichong007/rtctree.git
[email protected]:erichong007/rtctree.git
erichong007
rtctree
rtctree
master

搜索帮助