Ptolemy II/CapeCode

(This page may be found at http://accessors.org/wiki/Main/PtolemyII)

The CapeCode Accessor Host is an extension of http://ptolemy.org/ptolemyII, 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:

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:

svn co https://repo.eecs.berkeley.edu/svn-anon/projects/eal/ptII/trunk ptII
cd ptII
export PTII=`pwd`
./configure
$PTII/bin/ant
$PTII/bin/vergil

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
svn update
$PTII/bin/ant

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 SVN repository as above is preferred.

If you are attending the Tutor 2017 Workshop (Dec. 5, 2017), and use the installers, then please reinstall CapeCode just before attending the workshop. If you use subversion to install CapeCode, then please update using svn.

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:

$PTII/bin/capecode

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.

References