BarrettHand BH8-280 software setup - Linux

Ubuntu/Debian

The BarrettHand software version 4.4.x will run in Linux under the 32-bit version of Ubuntu 9.10. This software is installable with a Debian package, which contains the source code and precompiled binaries that are ready to run the demos, examples, and GUI for these versions of Ubuntu. Double-clicking on the Debian package will download and install all dependencies automatically and is the easiest way to get started running and developing software for the BarrettHand quickly. If you are not running Ubuntu version 9.10, which this software was tested with, it may be possible to build the GUI, demos, and examples from the BarrettHand source code provided in the "tgz" compressed version of the software.


Using the BarrettHand software and notes for the Debian Package


In the past the Debian package has been compiled to run on Ubuntu 7.10 and some of these notes are left here. However, there aren't newer versions of wxWidgets available that are needed for the BHControl GUI for Gutsy (Ubuntu 7.10). Barrett is not planning on generating a Debian installer packages for older versions of Ubuntu. In addition to the build-essential package the BarrettHand Debian software package contains dependencies on libwxgtk2.8-d and libglut3-dev for the Control GUI. Ubuntu 9.10 has repositories to download these but if you are using Ubuntu 7.10 then you will need to add additional repositories to the end of /etc/apt/sources.list in order to install the BarrettHand software with the Debian package. Instead of editing this file by hand you may goto System -> Administration -> Software Sources -> Third Party Software and add these lines one at a time.

deb http://old-releases.ubuntu.com/ubuntu/ gutsy main universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ gutsy-updates main universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ gutsy-security main universe multiverse

If the BarrettHand software is installed using the Debian package it will be in the directory:

/usr/local/Barrett/BHand

If you have installed the software with the Debian package you should be all set to run an example. To do so, open a terminal and issue:

cd /usr/local/Barrett/BHand/examples/Supervisory
./Supervisory

The example should start and will ask for a COM port. Hit "1" and the enter key for /dev/ttyS0 (or a different number for other com ports). See the notes further below if you are using a USB to serial adapter. There are other demos and examples to try in the BHand directory. If the software was installed with the Debian package then you will have the build-essential package installed on your system and will be able to rebuild the example by issuing:

make clean
make

When you have the GUI installed and are ready to run it, open a terminal and issue:

cd /usr/local/Barrett/BHand/bhcontrol
./BHControl

The CodeBlocks package is required to build or rebuild the GUI and can be downloaded and installed with Synaptic Package Manager in Ubuntu 9.10. In the future there may be additional support for other IDEs like Eclipse. On Ubuntu 7.10 you will have to download the sources online from http://www.codeblocks.org/downloads. In addition, if you are using Ubuntu 7.10, you will need to download and install libgtk2.0-dev using Synaptic Package Manager in order to compile CodeBlocks. The older version of !Codeblocks 8.02 was found to be available at: http://www.codeblocks.org/downloads/6. Extract the package to the desktop and from a terminal issue these commands to build and install CodeBlocks:

cd Desktop/codeblocks-8.02-src
./configure
make -j4
make install
ldconfig

You may rebuild the BarrettHand Control GUI or the API library with CodeBlocks but to do so may require the appropriate permissions to modify files in /usr/local/Barrett (at least for Ubuntu 9.10). Running CodeBlocks as root will solve issues with permissions and allow you to rebuild the GUI.

To build or rebuild the BarrettHand Control GUI:

  • Start CodeBlocks by either:
    • Launching it in Applications -> Programming -> Code::Blocks IDE
    • Opening a terminal and issuing: sudo codeblocks
  • Open the CodeBlocks project file BHControl (in /usr/local/Barrett/BHand/bhcontrol/BHControl.cbp)
  • Select the build target: Build -> Build Target -> Linux Release
  • Click Build -> Build and Run or press F9

The binary for the API library is not required to build the Control GUI. Presently, it is only used to build the demos to illustrate how to use a Makefile to build from the API library instead of including "bhand.cpp".

To build or rebuild the BarrettHand API Library:

  • Open the CodeBlocks project file BHand in the API directory
  • Select the build target: Build -> Build Target -> Linux Release
  • Build by clicking Build -> Build

Additional Info for BarrettHand Libraries, Headers, and Makefiles


The Debian package will install binaries for libraries that are dependencies for the BarrettHand in /usr/local/lib. The library files, which are required third party dependencies for controlling the hand, that are automatically installed by the BarrettHand software are:

libctb-barrett-0.14.a
libctb-barrett-0.14.so
libPocoFoundationBarrett.so

Notice that the filenames for the third party CTB and POCO libraries have been renamed to include "barrett" or "Barrett" in order to not stomp on a users installation of the CTB or POCO libraries. Barrett did not want it to be possible that the BarrettHand software would overwrite the users libraries so we renamed them to make sure they were unique. When developing these applications users should link to these libraries (in /usr/local/Barrett/BHand/thirdparty/lib or the copies of these in /usr/local/lib). However, the required header files are only available in /usr/local/Barrett/BHand/thirdparty/include. See the examples, which show how a Makefile may include and link the required third party headers and libraries along with the BarrettHand source code file "bhand.cpp" and header file "bhand.h". If you would rather link to the BarrettHand library instead of including the "bhand.cpp" source file in a Makefile then take look at the demos that illustrate how to do that.


Compressed "tgz" file


The rest of this file describes how to build the BarrettHand Control GUI, BarrettHand API Library, Examples, and Demos from the provided source files for Ubuntu with the compressed tgz file. These instructions are not necessary if installing on Ubuntu 7.10 or 9.10. For these platforms it is recommended to install the BarrettHand Software with the provided Debian package, which will download dependencies so that you can get started with running and developing software for the BarrettHand quickly. In case you don't want to install the BarrettHand software with the Debian package below are alternative installation instructions to get started with the software provided in the .tgz file for the BarrettHand software.


GNU C++ Compiler


If you do not already have the build-essential package installed then you may install it from a terminal using the following line:

sudo apt-get install build-essential

Installing Third Party Dependencies for Ubuntu


Install and build third party open source dependencies for the BarrettHand API Library:

1) Build the CTB Serial Port library included by Barrett (Location: thirdparty/sources/ctb-0.14). It is necessary to use the version supplied by Barrett in Linux.

Open a terminal and issue the commands

cd thirdparty/sources/ctb-0.14/build
make DEBUG=0 GPIB=0
sudo su
make DEBUG=0 GPIB=0 install
ldconfig

Also, in order to use the CodeBlocks IDE project files without changes, you will need rename the CTB libraries. Rename these by issuing these commands:

cd /usr/local/lib
mv libctb-0.14.a libctb-barrett-0.14.a
mv libctb-0.14.so libctb-barrett-0.14.so

2) Build the POCO library. Version 1.3.6 is the version that was tested and is included in thirdparty/sources). You should also be able to download the latest version if you wish.

Simple instructions are provided that will work for most users that do not already have a version of POCO installed. If a different version of POCO is installed already see below for notes on how to setup a special minimal copy of POCO just for the BarrettHand.

Do one of the following:

  • Download libpoco-dev using Synaptic Package Manager (version 1.3.3 or later)
  • Get a copy of the POCO source files (version 1.3.3 or later). Use the version provided or download "The Economy Package" source code from http://pocoproject.org/download/

Unpackage poco into a temporary directory

gunzip poco-X.Y.tar.gz
tar -xf poco-X.Y.tar
cd poco-X.Y

You only need to Build only the libraries that the BarrettHand Software requires

./configure --no-tests --no-samples --omit=XML,Util,Net
make -s -j4 Foundation-libexec

Install POCO to /usr/local

sudo make -s Foundation-libexec install

Also, in order to use the CodeBlocks IDE project files without changes, you will need rename the POCO library. Rename it by issuing these commands:

cd /usr/local/lib
mv libPocoFoundation.so libPocoFoundationBarrett.so

Notes on having multiple versions of POCO: If you want to have a separate version of POCO just for the BarrettHand then don't execute sudo make -s Foundation-libexec install. Instead, copy the header files to a location outside of /usr/local/include and include them when you build the API. Also, rename the libPocoFoundation.so as shown above. That file can be copied to /usr/local/lib manually.

At this point you may compile the examples or continue the building dependencies for the GUI.

If you want to build the BarrettHand Control GUI from the source files you will need to build these third party open source dependencies:

3) Install the wxWidgets library (2.8.10 or later)

Open Synaptic Package Manager found in System -> Administration

Select the following package and install it

libwxgtk2.8-dev

4) Install OpenGL and GLUT

Open Synaptic Package Manager found in System -> Administration

Select and install the following package

libglut3-dev


Building the Examples


To build Monitor Strain, RealTime, and Supervisory examples open a terminal. The examples do not require the BarrettHand API library binary and instead directly include the BarrettHand source files.

In the terminal:

  1. CD to the example directory (examples/supervisory, examples/realtime, etc)
  2. Issue: "make" to build the example
  3. Run it with "./Supervisory" or whatever the output name is

Code Blocks IDE


Code Blocks is a cross platform IDE that may be used to build the BarrettHand Control GUI and/or the BarrettHand API Library.

Open Synaptic Package Manager found in System -> Administration

Select the following package and install it

codeblocks

1) To build and run the BarrettHand Control GUI

  • Start CodeBlocks by launching it in Applications -> Programming -> Code::Blocks IDE
  • Open the CodeBlocks project file BHControl (in /usr/local/Barrett/BHand/bhcontrol/)
  • Select the build target: Build -> Build Target -> Linux Debug
  • Click Build -> Build and Run or press F9

2) To build the BarrettHand API Library

  • Open the CodeBlocks project file BHand in the API directory
  • Select the build target: Build -> Build Target -> Linux Debug
  • Build by clicking Build -> Build

Building the Demos


To build bh45demo and ForceResponse demos first create the BarrettHand static library. Follow the directions above for the CodeBlocks IDE and how to build the BarrettHand API Library.

To build a single demo from the terminal:

  1. CD to the demo directory (demos/bh45demo, demos/ForceResponse, etc)
  2. Issue: "make" to build the demo

Hardware Notes


The BarrettHand API uses the CTB library for a cross-platform serial port library. It only uses the names /dev/ttyS0, /dev/ttyS1, etc. If you want to use a USB to Serial adapter then one way to do that would be to create a symbolic link from a Terminal:

rm /dev/ttyS0
ln -s /dev/ttyUSB0 /dev/ttyS0

To verify a serial connection with the Hand that is not dependent on the GUI you may use Minicom that may be downloaded with Synaptic Packet Manager. It is a program for Linux that is similar to Hyperterminal. Configure the baud rate, device name ("/dev/ttyS0", "/dev/ttyUSB0", etc.), and verify that commands such as "HI" can be sent to the hand. Start minicom from a terminal with:

minicom -s

To actually make the USB to serial adapter work after a reset, one way is to create a script as shown below and add it to /etc/init.d

#! /bin/sh
rm /dev/ttyS0
ln -s /dev/ttyUSB0 /dev/ttyS0

and run:

update-rc.d myusbtoserial.sh defaults

Installing PCAN


The Debian package will install the PCAN USB adapter automatically. If you are installing the driver yourself, you may follow these steps to use the PCAN driver:

  1. Create a symbolic link to the kernel header files
    cd /usr/src
    uname -r (to find out which linux kernel is being used)
    ls (check to ensure the headers are available for this kernel, PCAN requires /usr/src/linux/include/linux/verson.h)
    

If you do not already have the symbolic link "linux" you may create it with:

ln -s linux-headers-2.6.31-14-generic linux (substitute your linux header's directory)
  1. Make and install PCAN library
    cd peak-linux-driver-6.20
    make NET=NO
    su -c "make install"
    
  1. Load the PCAN loadable kernel module
    cd driver
    sudo modprobe pcan
    

Launching BHControl GUI ()


Launching BHControl may require a known display and you may see an error similar to the one below.

Xlib: extension "GLX" missing on display ":0.0". Xlib: extension "GLX" missing on display ":0.0". freeglut OpenGL GLX extension not supported by display ':0.0'

Try to install graphics drivers so the that OpenGL will work for the GUI. A search online for your version of Ubuntu and the graphics manufacturer will probably return useful information for installing these graphics drivers. If you have Ubuntu 7.10 and an Nvidia card, you may try the Envy GUI found with the following link: http://linuxgamingtoday.wordpress.com/2008/01/24/install-nvidia-drivers-using-envy-in-ubuntu.

Last modified 2 years ago Last modified on Jul 7, 2015, 8:12:36 PM