Download and Install
Full Software Listings
An Orca components written in Python (plus python installation notes).
The examples inlude a single remote getData() call (puricepython.py), subscribing (pureicepythonsubscribe.py), plotting in 2D (pureicepythonplotranges.py) and 3D (pureicepythonplot3dranges.py).
Note 1: These install notes have not been tested or checked so please be patient if trying this out. Note 2: If python moves into mainstream Orca, this section should be moved to the main orca installation notes
Python can be used as a rapid prototyping tool and debug tool. It has many built-in and stable third party packages for things such as 2d/3d plotting (matplotlib), linear algebra and numerical routines (scipy), etc. Note that it's not intended to replace the C++ implementation of Orca but to augment it. To install python and the dependencies used in these examples type the following
# apt-get install python python-scipy python-matplotlib python-gtk2
Follow the instructions for installing Ice from source (orca_doc_installdebian_icefromsource) but replace Ice-[VERSION] with IcePy-[VERSION].
Make sure that the installed Ice python scripts are in your path. You may want to add a snippet to your
~/.bashrc file similar to the one below. Replace [VERSION] with the version of IcePy you've just installed. Change the directory if you've modified the default install directory.
export ICEPY_HOME=/opt/IcePy-[VERSION] export PYTHONPATH=$ICEPY_HOME/python:$PYTHONPATH
Currently there is only the ability to generate python interfaces but there is no equivalent to libOrcaIce yet. Work is currently underway to wrap libOrcaIce using the boost.python wrapper. For now, if you want to use python, you must interface directly with the Ice API. Examples of Orca and python working together can be found in <ORCA_SRC>/src/examples/pureicepython and a tutorial can be found below Connecting to an Orca interface using the Python Ice API
To generate the python interfaces you need to have installed python and you must turn on the BUILD_PYTHON parameter in cmake. The easiest way to do this is type "ccmake ." in the top level directory of the Orca source. Scroll down the list until the cursor is on the line for BUILD_PYTHON. Press "Enter" to turn it on. Configure and generate the make files. Then make and install orca:
$ make # make install
Make sure that the installed Orca python scripts are in your path. You may want to add a snippet to your
~/.bashrc file similar to the one below. Replace [VERSION] with the version of Orca you've just installed. Change the directory if you've modified the default install directory.
Example code intended for component developers.
To test the pure ice python component, follow the directions of the Quick-Start Guide. After Laser2d is up and running, start the pureicepython example which will connect to the server, get a single laser scan, and exit. The following line must be executed from the build directory of pureicepython.
$ python pureicepython.py --Ice.Default.Locator='IceGrid/Locator:default -p 12000'
Note that pureicepython does not use any configuration files. All connection parameters are hard-wired into the code, so you have to follow the directions of the tutorial exactly, otherwise it will not work.
You can use the same command for the other examples by replacing "puricepython" with "pureicepythonsubscribe", "pureicepythonplotranges", or "pureicepythonplot3dranges".
Note that the plotting examples are very inefficient. matplotlib (the plotting tool used in these examples) provides a more complicated way of just redrawing the bits that have changed. An example will be committed in the near future.
If you get errors like
/opt/IcePy-3.2/python/Ice.py:34: RuntimeWarning: Python C API version mismatch for module IcePy: This Python has API version 1013, module IcePy has version 1012. import IcePy python: Types.cpp:2975: PyObject* IcePy_defineException(PyObject*, PyObject*): Assertion `((type)->ob_type == &PyClass_Type)' failed. Aborted
You may need to use an older version of Python. Check the version by typing
$ python -V
If it's Python 2.5, you'll need to change the symbolic link for python so it points to python 2.4:
# ln -s /usr/bin/python2.4 /usr/bin/python
When using matplotlib (the plotting tool) you may experience a problem with the plot not updating at all. This can be caused by matplotlib using the wrong backend. To debug this note the backend used when the script starts execution
matplotlib version 0.90.1 verbose.level helpful interactive is False units is True platform is linux2 numerix numpy 1.0.3 backend TkAgg version 8.4
The solution is to select the GTKAgg backend in line 20 of the following file
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)