Recent Changes - Search:

edit SideBar

Ptolemy II/CapeCode

(This page may be found at

The CapeCode Accessor Host is an extension of, an actor-oriented modeling and design environment. For a tutorial on CapeCode, see the tutorial page. An example of a swarmlet rendered in Vergil, the graphical block-diagram editor for Ptolemy II, is:

This block diagram realizes a simple augmented-reality application that identifies devices or services in the field of view of a video camera and dynamically instantiates an accessor that provides an interface to the device or service. Following the instructions below, you can run this application.

Installing Ptolemy II and CapeCode

To use the most recent Accessors work, you should install the repository version, not the 10.0 release because we will be relying on up-to-the-minute updates. If you are unable to do this, the nightly build installers will be far more up-to-date than 10.0 release. Windows users: see the CapeCode Windows Installation instructions.

Installing the most up-to-date version of CapeCode using Git

Make sure you have a recent Java Development Kit (JDK) installed.

At this time, Java 1.8 (aka Java 8) is preferred over Java 9 for building from sources. The installers will not work with Java 9.

To build from sources, the javac Java compiler is required, which is part of the JDK, but not part of the JRE. To verify that javac is present, enter in a terminal window:

javac -version

You should see something like "javac 1.8.0_152". Then download and build Ptolemy II:

git clone --depth=50 --branch=master --single-branch
cd ptII
export PTII=`pwd`

Notice that the third line sets an environment variable PTII. You may wish to set that environment variable in your command-line profile so that it is always available. For example, I have in my .bash_profile file in my home directory the following line:

export PTII=/Users/eal/ptII

Anytime after intalling Ptolemy II, you can update to the latest version as follows:

cd $PTII
git pull

Installing CapeCode using prebuilt installers

If the above fails or is too difficult for some reason, you can use the installers from the nightly build as explained below. This will give you the most up-to-date version at the time you perform the installation, but to update to a newer version, you will have to reinstall. This is why installing from the Git repository as above is preferred.

  • The platform specific installers include the CapeCode sources, ant, node and npm. Note that Node 8.x will not work with the Node Host because of npm design flaws, so node 7.10.1 and npm 3.10.10 are included
  • The installer requires that a Java 1.8 Java Runtime Environment (JRE) be installed.
    • The Java 1.9 JRE will not work with the installer at this time.
    • If you plan on compiling Java files, then instead of installing just the JRE, install the Java Development Kit (JDK).
  • After installing either the JDK or JRE, choose one of the nightly build installers below:
  • Source: capecode0.3.devel.tar.gz
    • The source tar.gz file is not often tested, but could be used to install if git is not working, for example if the target machine does not have access to

For more information, see the more detailed instructions. If you plan to do any Java programming to extend Ptolemy II, then we recommend installing Eclipse and setting up Ptolemy II as a Java project.

Running CapeCode

Once you have installed Ptolemy II, you can run CapeCode with the following command:


This will bring up the welcome window, which looks like this:

We suggest browsing the links here, particularly the Tour.

To directly execute a simple demo that uses your machine's built-in camera, try:

$PTII/bin/capecode $PTII/ptolemy/actor/lib/jjs/modules/imageFilters/demo/imageFilters/Random.xml

Tutorial documents and solutions are available with the following command:

$PTII/bin/capecode $PTII/ptolemy/demo/CapeCode/CapeCode.xml

To execute a more interesting demo that creates a networked application, try:

$PTII/bin/capecode $PTII/ptolemy/actor/lib/jjs/modules/webSocket/demo/WebSocketChat/Client.xml

This demo is a chat client. The comments in the demo include a link to the chat server, which you must also run for the chat client to work. Click on the annotation that mentions the Server model and the run the Server model by clicking on the Run icon in the tool bar (it looks like play button). Then you can run the chat client and type into the dialog. You can start any number of chat clients and they will all connect to the same chat server. The chat server uses WebSockets to communicate with all clients. You can browse these models and open each of the icons (right click and select Open Actor) to see how the accessors are implemented.

See Also

Edit - History - Print - Recent Changes - Search
Page last modified on December 14, 2020, at 06:04 PM