30 September 2011

Common Ubuntu Problems and their Solutions

-> Error: “E: Could not get lock /var/lib/apt/lists/lock – open (11:   Resource temporarily unavailable)”
        Solution: Change to root user and type the following commands -
             $ su
             # killall -9 apt-get aptitude
             # rm -f /var/lib/apt/lists/lock


         If you further get the same error, then type -
               # rm -f /var/lib/dpkg/lock


Restart Ubuntu GNOME session without Rebooting 

1. Press Ctrl+Alt+T to open the terminal.
2. Type the following command - $sudo /etc/init.d/gdm restart  

 Restore panels in Ubuntu to their default settings
1. Press Ctrl+Alt+T to open the terminal.
2. Type the following commands one by one in terminal
$ gconftool-2 --shutdown
$ gconftool --recursive-unset /apps/panel
$ rm -rf ~/.gconf/apps/panel
$ pkill gnome-panel


Auto Login for a specific user
1. Go to Users And Group settings and disable ask for password when login for that particular user.
2. The open terminal and go to  /etc/lightdm/lightdm.conf
3. Add the line  - 
        autologin-user=<username>
4. Save and exit.


Change Ip settings for Ubuntu server
1. sudo vi /etc/network/interfaces
2. For auto eth0 DHCP, add -
   auto eth0
   iface eth0 inet dhcp
3. For auto eth0 static IP, add -
    auto eth0
    iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
4. Now add the DNS settings by editing resolv.conf file - 
    sudo vi /etc/resolv.conf

Installing Desktop environment on Ubuntu server
1. Update the repository -
     $ sudo apt-get update
2. If you want to install ubuntu desktop, type - 
     $ sudo apt-get install ubuntu-desktop
3. If you want to install desktop environment without addons like mail client or open office, type - 
     $ sudo aptitude install --without-recommends ubuntu-desktop
4. If you want to install some light weight desktop, type - 
     $ sudo apt-get install xubuntu-desktop
5. If you want to install the kde environment, type -
     $ sudo apt-get install kubuntu-desktop

Installing add-apt-repository
1. When you try to add repository on Ubuntu server, most often you get the error -
    sudo : add-apt-repository : command not found
2. The solution is to install python-software-properties
   sudo apt-get install python-software-properties 




29 September 2011

Resetting Compiz to Remove "no taskbar problem" in Ubuntu 11.04 Unity

1. If you don't have compiz configuration manager, then you can install it by going to the terminal  and typing -
   $ sudo apt-get install compizconfig-settings-manager
If you have problem opening the terminal, press Ctrl+Alt+F2 or you can directly run commands in terminal by pressing Alt+F2.


2. Now if you want to change some specific settings in compiz, you can start gconf editor by -
  $ gconf-editor
  This should bring you the Gnome Configuration editor as shown below. From the left side choose:"apps" -> "compiz-1". Now under "compiz-1", go to "plugins". You'll see a lot of setting there which can be changed as required.
After making the changes, reset the unity using the terminal -
   $ unity --reset


3. So, if you successfully messed up Compiz then you can actually reset all those value to the default ones by issuing the below commands in your Terminal.
   $ gconftool-2 --recursive-unset /apps/compiz-1
   $ unity --reset  

27 September 2011

Installing OpenGL on Ubuntu

OpenGL is installed by the graphics driver provider, so you don't need to worry about installing OpenGL. The only thing you require is the GL libraries to work on OpenGL coding.

This can be done by installing glut as follows -

 sudo apt-get install freeglut3 freeglut3-dev

This will install the required libraries in /usr/lib/libglut.a and includes in the /usr/include/GL folder.

To test the library just write any openGL code and compile is using the linker "-lglut" as -

$ g++ helloworld.cpp -lglut



Installing Virtual Box 4.x on Ubuntu 11.04

Install virtualbox 4.x on ubuntu 11.04


1. You need to edit /etc/apt/sources.list by typing
$ sudo gedit /etc/apt/sources.list

2. Add the following line
$ deb http://download.virtualbox.org/virtualbox/debian natty contrib

3. Save and exit the file.
    Now type the following command in terminal -

$ wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -

4. Update source list -
$ sudo apt-get update

5. Now install virtual box by typing - 
$ sudo apt-get install virtualbox-4.0


Note: Ubuntu/Debian users might want to install the dkms package to ensure that the VirtualBox host kernel modules (vboxdrv, vboxnetflt and vboxnetadp) are properly updated if the linux kernel version changes during the next apt-get upgrade. For Debian it is available in Lenny backports and in the normal repository for Squeeze and later. The dkms package can be installed through the Synaptic Package manager or through the following command:

$ sudo apt-get install dkms


24 September 2011

Installing OpenCV 2.3 on Ubuntu 11.04

Building and installing OpenCV 2.3 on Ubuntu 11.04 -
1. Install the OpenCV dependencies by typing following commands.

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev
To cover all the dependencies install -
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install pkg-config
sudo apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3
sudo apt-get install libpnglite-dev libpngwriter0-dev libpngwriter0c2
sudo apt-get install zlib1g-dbg zlib1g zlib1g-dev
sudo apt-get install libjasper-dev libjasper-runtime libjasper1
sudo apt-get install pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools
sudo apt-get install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs
sudo apt-get install ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev
sudo apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0  libgstreamer0.10-dev
sudo apt-get install libxine1-ffmpeg  libxine-dev libxine1-bin
sudo apt-get install libunicap2 libunicap2-dev
sudo apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils
sudo apt-get install swig
sudo apt-get install libv4l-0 libv4l-dev
sudo apt-get install python-numpy

Further optional dependencies could be checked and installed from the configure option during building. For more info go to OpenCV site.

2. Download the OpenCV 2.3 source from here or type following command -
   wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3.1/OpenCV-2.3.1a.tar.bz2/

3. Extract the OpenCV tar file (preferably in your home directory)
    tar -xvf OpenCV-2.3.1a.tar.bz2

4. Now create the build directory for opencv
    $ cd OpenCV-2.3.1
    $ mkdir opencv.build
    $ cd opencv.build

5. Configure, make and install the code -
    $ cmake ..
    $ make
    $ sudo make install

6. Open the .bashrc file from your home folder
    $ gedit .bashrc
     and add the following at the end of the file -

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/<username>/OpenCV-2.3.1/opencv.build/lib
    export PKG_CONFIG_PATH=/home/<username>/OpenCV-2.3.1/lib/opencv.build/pkgconfig
    alias gcv="g++ `pkg-config --cflags opencv` `pkg-config --libs opencv`"

7. Now test building the samples -
    $ cd /home/<username>/OpenCV-2.3.1/samples/c
    $ chmod a+x build_all.sh
    $ ./build_all.sh
   If the samples are successfully compiled, then your opencv is ready to use.

8. Since we added an alias in the bashrc file named "gcv", you can compile any opencv code just by using this alias as -
    $ gcv hellocv.cpp

6 September 2011

Using dynamixel motors in ROS in Ubuntu 10.10


The Dynamixel AX-12 Servo from Robotis is one of the advanced actuator on the market, in this price range. It is widely used in hobby robotics. The Dynamixl AX-12 robot servo has the ability to track its speed, temperature, shaft position, voltage, and load. These parameters are coded on 10 bits each. Also, the algoirthm used to maintain shaft position on the AX-12 actuator can be adjuste individually for each servo, allowing you to control the speed and strength of the motor's response. All of the sensor management and position control is handled by the servo's build-in microcontroller (ATMega 8). The Dynamixel AX-12 servos are different from regular hobby servos. They connect to a serial bus, and each has an ID number.

The above is the picture shows how a Dynamixel AX-12 motor looks like. The figure below shows the pin configuration and has to be kept in mind while connecting it to power source or to other motors.
I am using 3 Dynamixel AX-12 serially connected as daisy chain and is interfaced with the computer using USB2Dyanamixel. This device also has its SDK in C so that the motor movements and values could be easily accessed from ROS nodes. The figure below is of the USB2Dynamixel dongle device.
I am working on Ubuntu 10.10 with 2.6.35-28-generic kernel version. Its recommended by Dynamixel SDK providers to use kernel greater than 2.6.21 as the code regarding FT232RL is already added to the kernel code so you don't have to install this. 

Just download the Dynamixel SDK for linux from here.

The SDK for linux folder composes of the following folder after making it -
/include  :this contains header files to use Dynamixel SDK
/src         :this folder contains the Dynamixel SDK source files
/lib          :this contains the compiled library files
/example :there are examples to control Dynamixel motors

I copied the dynamixel.h header file into standard header folder i.e. /usr/include and libdxl.a library into /usr/lib so that it may work as any linux shared library. After doing all this, the system is ready to interact with the motors using the C code. The motors must be connected to the computer using USB2Dynamixel connected to any of the USB port.

Before going to the coding, its better to go through the AX-12 manual and also through the Dynamixel APIs in C. The address values and pin configurations should be seen as it will be required while programming to know the addresses. This can be accessed from here. 

Here is a sample program which I used for rotating three motors connected serially.

#include <stdio.h>
#include <termio.h>
#include <unistd.h>
#include <dynamixel.h>
#include <termios.h>

int getch(void)
{
  int ch;
  struct termios oldt;
  struct termios newt;
  tcgetattr(STDIN_FILENO, &oldt); /*store old settings */
  newt = oldt; /* copy old settings to new settings */
  newt.c_lflag &= ~(ICANON | ECHO); /* make one change to old settings in new settings */
  tcsetattr(STDIN_FILENO, TCSANOW, &newt); /*apply the new settings immediatly */
  ch = getchar(); /* standard getchar call */
  tcsetattr(STDIN_FILENO, TCSANOW, &oldt); /*reapply the old settings */
  return ch; /*return received char */
}

// Control table address
#define P_GOAL_POSITION_L 30
#define P_GOAL_POSITION_H 31
#define P_PRESENT_POSITION_L 36
#define P_PRESENT_POSITION_H 37
#define P_MOVING 46

/** Motor IDs of all three motors motors */
#define MOTOR1      18
#define MOTOR2      17
#define MOTOR3      15

// Id of the currently connected dynamixel
#define DEFAULT_BAUDNUM 1 // 1Mbps
#define DEFAULT_ID 15

void PrintCommStatus(int CommStatus);
void PrintErrorCode(void);

int main()
{
        int baudnum = 1;
        /*
         * One digit of motor represents 0.3515625 degrees.
         * One degree represents 2.8444444 values of motor turn
         */
        int GoalPos[2] = {512, 512};
        /**
         * Middle Motor limits - [ -92.109, 101.25  ]
         */
        int GoalPosMotor2[2] = { 250, 800 };
        /**
         * Base Motor limits - [-180, 180 ];
         */
        int GoalPosMotor1[2] = { 0, 1024 };
        /**
         * Top Motor limits - [ 77.344, 125.859 ];
         */
        int GoalPosMotor3[2] = { 292, 870 };
        //int GoalPos[2] = {0, 4095}; // for Ex series
        int index = 0;
        int deviceIndex = 0;
        int Moving, PresentPos;
        int CommStatus;

        printf( "\n\nRead/Write example for Linux\n\n" );
        ///////// Open USB2Dynamixel ////////////
        if( dxl_initialize(deviceIndex, baudnum) == 0 )
        {
                printf( "Failed to open USB2Dynamixel!\n" );
                printf( "Press Enter key to terminate...\n" );
                getchar();
                return 0;
        }
        else
                printf( "Succeed to open USB2Dynamixel!\n" );
        int turnValue = 512;
        dxl_write_word( 18, 32, 100 );
        dxl_write_word( 17, 32, 100 );
        dxl_write_word( 15, 32, 100 );
        dxl_write_word( BROADCAST_ID, P_GOAL_POSITION_L, turnValue );

        while(1)
        {
                printf( "Press Enter key to continue!(press ESC and Enter to quit)\n" );
                char c = getch();
                if(c == 0x1b)
                     break;
                if(c == 'a')
                    turnValue-=1;
                if(c == 'd')
                    turnValue+=1;

                 printf("Turn value - %d\n", turnValue);
                // Write goal position

                dxl_write_word( 18, P_GOAL_POSITION_L, 900 );
                dxl_write_word( 17, P_GOAL_POSITION_L, 400 );
                dxl_write_word( 15, P_GOAL_POSITION_L, 700 );
                do
                {
                        // Read present position
                        PresentPos = dxl_read_word( DEFAULT_ID, P_PRESENT_POSITION_L );
                        CommStatus = dxl_get_result();

                        if( CommStatus == COMM_RXSUCCESS )
                        {
                                printf( "%d   %d\n",GoalPos[index], PresentPos );
                                PrintErrorCode();
                        }
                        else
                        {
                                PrintCommStatus(CommStatus);
                                break;
                        }

                        // Check moving done
                        Moving = dxl_read_byte( DEFAULT_ID, P_MOVING );
                        CommStatus = dxl_get_result();
                        if( CommStatus == COMM_RXSUCCESS )
                        {
                                if( Moving == 0 )
                                {
                                        // Change goal position
                                        if( index == 0 )
                                                index = 1;
                                        else
                                                index = 0;
                                }

                                PrintErrorCode();
                        }
                        else
                        {
                                PrintCommStatus(CommStatus);
                                break;
                        }
                }while(Moving == 1);
        }

        // Close device
        dxl_terminate();
        printf( "Press Enter key to terminate...\n" );
        getchar();
        return 0;
}

/** Printing communication result */
void PrintCommStatus(int CommStatus)
{
        switch(CommStatus)
        {
        case COMM_TXFAIL:
                printf("COMM_TXFAIL: Failed transmit instruction packet!\n");
                break;

        case COMM_TXERROR:
                printf("COMM_TXERROR: Incorrect instruction packet!\n");
                break;

        case COMM_RXFAIL:
                printf("COMM_RXFAIL: Failed get status packet from device!\n");
                break;

        case COMM_RXWAITING:
                printf("COMM_RXWAITING: Now recieving status packet!\n");
                break;

        case COMM_RXTIMEOUT:
                printf("COMM_RXTIMEOUT: There is no status packet!\n");
                break;

        case COMM_RXCORRUPT:
                printf("COMM_RXCORRUPT: Incorrect status packet!\n");
                break;

        default:
                printf("This is unknown error code!\n");
                break;
        }
}

/** Print error bit of status packet */
void PrintErrorCode()
{
        if(dxl_get_rxpacket_error(ERRBIT_VOLTAGE) == 1)
                printf("Input voltage error!\n");

        if(dxl_get_rxpacket_error(ERRBIT_ANGLE) == 1)
                printf("Angle limit error!\n");

        if(dxl_get_rxpacket_error(ERRBIT_OVERHEAT) == 1)
                printf("Overheat error!\n");

        if(dxl_get_rxpacket_error(ERRBIT_RANGE) == 1)
                printf("Out of range error!\n");

        if(dxl_get_rxpacket_error(ERRBIT_CHECKSUM) == 1)
                printf("Checksum error!\n");

        if(dxl_get_rxpacket_error(ERRBIT_OVERLOAD) == 1)
                printf("Overload error!\n");

        if(dxl_get_rxpacket_error(ERRBIT_INSTRUCTION) == 1)
                printf("Instruction code error!\n");
}


This program can be compiled using the following line - 
$ g++ main.cpp -o output -ldxl -lm

For integrating it with ros, we just need to add the library in the CMakeLists.txt as -
target_link_libraries(<executable name> -ldxl -lm)


References - 

Using Qt Libraries in ROS


Modify the CMakeLists.txt file to include the qt library while compilation. Add the following lines at the end of the default generated CMakeLists.txt file -


find_package(Qt4)
include(${QT_USE_FILE})
# This is necessary as all ui files etc will get dumped in the bottom of the
# binary directory.
include_directories(${CMAKE_CURRENT_BINARY_DIR})

##############################################################################
# Sections
##############################################################################

file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/local/*.hpp)

QT4_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
QT4_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
QT4_WRAP_CPP(QT_MOC_HPP ${QT_MOC})

##############################################################################
# Sources
##############################################################################

file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)

##############################################################################
# Binaries
##############################################################################

rosbuild_add_executable(qgoo ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
target_link_libraries(qgoo ${QT_LIBRARIES})



2 September 2011

Single Installer for OpenNI, NITE and Sensor Kinect on Windows

While searching for proper installation methods to setup Kinect using OpenNI and NITE on my Windows 7 64-bit system, I came across a very interesting site named ZigFu. I faced a lot of trouble integrating the working NITE and OpenNI sdk with the Unity for 3D game development.

The Zigfu OpenNI installer lets you set up your entire development environment in one click. It bundles together OpenNI, NITE and SensorKinect and configures them automatically. They also provide a Unity package which can be directly imported into Unity with basic functionalities.

The required links -
1. Download Installer
2. Download Unity Package
3. Zigfu Website

1 September 2011

Installing Kinect Windows 7 64-bit (using OpenNI and NITE)

The OpenNI organization is an industry-led, not-for-profit organization formed to certify and promote the compatibility and interoperability of Natural Interaction (NI) devices, applications and middleware. PrimeSense, the company behind Kinect, released OpenNI framework and NITE middleware. This means that we can now have access to features such as real-time skeleton tracking, gesture recognition, wave detection and much more!

The latest binaries and source codes can be downloaded from the OpenNI download website  -
1. Sources
2. Binaries
3. Avin Sensor Binaries (This can be downloaded form the git repository of avin2 project)

Download the following binaries and sources from the OpenNI site if you are using Windows 7 64-bit or download corresponding binaries for 32bit systems -
1. PrimeSense Sensor Module (stable / unstable) - (Filename : avin2-SensorKinect-<version>)
2. OpenNI binaries (stable / unstable) - (Filename: openni-win32-<version>)
3. OpenNI Compliant Middleware Binaries(NITE)  - (Filename: NITE-Win64-<version>)

Installation instructions -
Step 1: Disable User Access Control : http://windows.microsoft.com/en-US/windows-vista/Turn-User-Account-Control-on-or-off
Step 2: Uninstall everything, OpenNI, NITE, any Kinect Sensor Driver, Kinect Virtual Camera or any other driver related to Kinect.
Step 3: Install the downloaded OpenNI binary.
Step 4: Extract avin zip into a folder. Now go to avin extracted folder -> platform->win32->driver. Install the driver according to your system(32/64 bit). Now go the the avin extracted folder->Bin and install Sensor Kinect 32.
Step 5: Install downloaded NITE binary.Step 6: Hold "Win" key and press "R" button. Then type "Sysdm.cpl" and press enter.
Step 7: Go to advanced tab and click on "Environment Variables". From system variables select "Path" and         click "Edit". Then go to the end of the string at variable value field and add a ";" character and then your  "Kinect Sensor Driver" installation address plus "/Bin".
  And your Kinect Sensor Driver installation directory was, e.g. -
 "C:\Program Files (x86)\Prime Sense\Sensor"
 Click Ok and then Ok again. And again Ok.

Restart your PC.

After restarting your PC connect the kinect to any of the USB ports and wait for automatic installation to be complete. Three devices will be detected namely - Motor, Camera and Audio device.
Your installation is complete. Now try checking your installation by running NITE samples.

After this you have to write the licence information in the data xmls installed with the above setups. You can download the xmls from here and replace the default xml files in the Data folder of the the OpenNI and NITE package which are installed in Program Files folder by default.

Now your tools are ready to integrate with anything.

Other reference sites -
1. http://www.kinectdevs.com/forums/kinect-virtual-camera-kinect-webcam-f17/kinect-drivers-and-64bit-windows-t13.html
2. http://www.studentguru.gr/blogs/vangos/archive/2011/01/20/how-to-successfully-install-kinect-windows-openni-nite.aspx
3. http://code.google.com/p/vr-simon/wiki/InstallingKinect
4. http://www.kinecthacks.nl/kinect-tutorial-3-setting-up-openni-and-nite-on-windows-for-kinect/
5. http://www.codingbeta.com/?p=10

24 August 2011

Installing Kinect on Windows 7 64-bit (Microsoft Kinect SDK)

System Requirements
* Windows 7 (x86 or x64)
* Dual Core or Faster
* 2 GB Ram
* Windows 7 compatible graphics card that supports Directx 9.0
* Kinect Sensor
* Microsoft Visual Studio 2010 Express or Other Visual Studio 2010 edition
* .Net Framework 4.0
*  For C++ Skeletal Viewer samples: Microsoft DirectX® SDK - June 2010 or later version
    Runtime for Microsoft DirectX® 9 
* For Speech sample (x86 only):
     Microsoft Speech Platform Runtime, version 10.2 (x86 edition)
     Microsoft Speech Platform - Software Development Kit, version 10.2 (x86 edition)
     Kinect for Windows Runtime Language Pack, version 0.9
     (acoustic model from Microsoft Speech Platform for the Kinect for Windows SDK Beta)



Installation
To install this beta SDK:
  1. Make sure the Kinect device is not plugged in to the USB port on your computer.
     
  2. Remove any other drivers for the Kinect device, including earlier versions of the Microsoft Kinect drivers.
     
  3. Close Visual Studio.
    Note: You must close Visual Studio before installing the SDK and then restart it after installation to pick up the MSRKINECTSDK environment variables that the SDK requires.
     
  4. From the download location for the beta SDK package, double-click the link for your system: 32-bit or 64-bit.
To load the Microsoft Kinect drivers:
  1. Make sure the Kinect device is plugged into an external power source.
     
  2. After installing the beta SDK, plug your Kinect device into the PC's USB port.
     
  3. All the drivers, including audio, will load seamlessly.
If the driver is installed correctly:
  1. You should see a blinking green LED on the Kinect sensor.
     
  2. The Kinect sensor should appear in Device Manager as the following nodes under “Microsoft Kinect”:
    • Microsoft Kinect Audio Array Control
    • Microsoft Kinect Camera
    • Microsoft Kinect Device
  3. The Kinect sensor's microphone array should appear under Sound, Video and Game Controllers in Device Manager as : Kinect USB Audio     

Useful Pages 

29 June 2011

Installing PyDev plugin for Eclipse IDE


PyDev is a Python IDE for Eclipse, which may be used in Python, Jython and IronPython development.
It comes with many goodies such as:
  • Django integration
  • Code completion
  • Code completion with auto import
  • Syntax highlighting
  • Code analysis
  • Go to definition
  • Refactoring
  • Mark occurrences
  • Debugger
  • Remote debugger
  • Tokens browser
  • Interactive console
  • Unittest integration
  • Code coverage
  • and many others
To install the plugin into already installed Eclipse IDE -
1. Start the Eclipse IDE, you will see a welcome screen like this -


2. Go to Help -> Install new Software
    This will look like this -


3. Type the following url resource into the text box so that it will download the required plugins from there and install something like this. It will look something like this after typing everything -


4. Click "Next" and "OK" to continue installing PyDev.
5. Select "I accept the terms of the license agreement", then click "Finish". The installer will begin to download the plug-in.
6. A following window will appear after download is complete. Check the box and click on OK.




7. When the installation is complete, you will be asked if you want to restart Eclipse. Select "Yes". You may see a Subclipse Usage  dialog, just uncheck the box and continue.

26 June 2011

Installing PVM on Ubuntu 10.10 64 bit


PVM is a software system that allows you to combine a number of computers which are connected over a network into a Parallel Virtual Machine. This machine can consist of computers with different architectures, running different flavors of the Unix/Linux operating systems, and can still be treated as if it were a single parallel machine.

The simpler way to install PVM is
1. Go to the synaptic package manager and install pvm, libpvm3, xpvm.
2. Or type in terminal $sudo apt-get install pvm

Check if the PVM libraries in /usr/lib/pvm3  or in /usr/local/lib/pvm3 and include files in /usr/include directory.

Configuring PVM to work on different machines -
1. Find out which computers are available. You can use any computer on which you have an account,    and on which PVM is installed.

2. Edit or create the file .rhosts in your home directory. This file must have an entry for every computer you want to use. The entry is in the form of the name of the computer and your login name on that machine:
 ucs.orst.edu  kowallih
dogby.physics.edu hans

If your login name is the same on all machines, then you can leave the field with the login name blank, but it doesn’t hurt to put it in.

3. Set the environment variables in the .bashrc file.
export PVM_ROOT="/usr/lib/pvm3"
export PVM_ARCH=`$PVM_ROOT/lib/pvmgetarch`
export XPVM_ROOT=/usr/bin/xpvm
export PVM_RSH=`which ssh`

4. Create directories for your executables:
    $mkdir $HOME/pvm3/bin/PVM ARCH
where PVM ARCH is the PVM code for the architecture. Although this step is not necessary for PVM to work, it will make your life much easier if you are going to use PVM on computers with different architectures. You can find the code for each computer’s via the PVM function pvmgetarch.

The PVM console
The PVM console is the interface between the parallel virtual machine and the user. You use it to start and stop processes, to display information about the state of the virtual machine, and most importantly, to start and stop PVM on local and remote machines.

Step 1: Starting PVM Log into one of the computers you want to include in
PVM and enter:
pvm>

Step 2: Adding hosts This is done from the PVM prompt:
pvm> add <hostname>
where hostname is the name of the computer you want to add. This will start PVM
on the specified hosts and, if successful, will produce a message such as:
1 successful
HOST DTID
banana 140000
You can continue to add additional hosts as desired.

Step 3: Checking your configuration You display the configuration of your
parallel virtual machine from the PVM prompt:
pvm> conf
This will give you information about the hosts configured, their PVM identification
number and their architecture.

Step 4: Deleting hosts Sometimes it is necessary to remove hosts from the virtual
machine to test or debug a program:
pvm> delete <hostname>

Step 5: Leaving the console If you are done with setting up your virtual machine,
and if you don’t need any of the other functions of the console, you close the
console but keep PVM running:
pvm> quit

Step 6: Stopping PVM To stop PVM after your parallel program has finished,
enter the PVM console, and then from the PVM prompt:
> pvm From Unix shell
pvm> halt From PVM prompt
This stops PVM on all the machines and kills all programs running under PVM.
This is the best and easiest way to stop PVM.

A simple hello.c code to check the library.

#include <stdio.h>
#include <pvm3.h>

int main()
{
  int mytid;

  mytid = pvm_mytid();
  printf("My TID is %d\n", mytid);
  pvm_exit();
  return 0;
}

Compiling the code - 
$gcc hello.c -o hello -lpvm3
A simple master program master.c

#include <stdio.h>
#include <stdlib.h>
#include <pvm3.h>

int main()
{
  int myTID;
  int x = 12;
  int children[10];
  int res;

  myTID = pvm_mytid();
  printf("Master: TID is %d\n", myTID);

  res = pvm_spawn("slave", NULL, PvmTaskDefault, "", 1, children);
  if (res<1) {
    printf("Master: pvm_spawn error\n");
    pvm_exit();
    exit(1);
  }

  pvm_initsend(PvmDataDefault);
  pvm_pkint(&x, 1, 1);

  pvm_send(children[0], 1);

  pvm_recv(-1, -1);
  pvm_upkint(&x, 1, 1);

  printf("Master has received x=%d\n", x);

  pvm_exit();

  return 0;
}

A simple client program slave.c

#include <stdio.h>
#include <pvm3.h>

int main()
{
  int myTID, masterTID;
  int x = 12;

  myTID = pvm_mytid();
  printf("Slave: TID is %d\n", myTID);

  pvm_recv(-1, -1);
  pvm_upkint(&x, 1, 1);
  printf("Slave has received x=%d\n", x);

  sleep(3);
  x = x + 5;

  pvm_initsend(PvmDataDefault);
  pvm_pkint(&x, 1, 1);

  pvm_send(pvm_parent(), 1);

  pvm_exit();

  return 0;
}

Compiling the above code - 
$gcc -o master master.c -lpvm3
$gcc -o slave slave.c -lpvm3
Now copy the slave binary to the standard pvm folder so that master may know where to get the binary to spawn it.





25 June 2011

Installing CUDA 4.0 on Windows 7 64bit

Download and Install  -
1. Install CUDA developer driver.
    You can get cuda developer driver for notebooks from here.
    You can get cuda developer driver general from here.
    Double click “devdriver_3.2_winvista-win7_32_263.06_general” to install.
2. Install CUDA Toolkit. You can download cuda toolkit from here.
    Double click “cudatoolkit_3.2.16_win_32” to install.
3. Install CUDA Sdk from here.
    Double click “gpucomputingsdk_3.2.16_win_32” to install.
4. Install Visual Studio 2008 from Microsoft.

      All CUDA downloads can be done directly from its site.

After installation of all these drivers and SDKs, run the examples in the CUDA SDK to make sure everything works. If they work, you have successfully installed the correct CUDA driver.

Visual Studio Settings
Copy all files in -
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\extras\visual_studio_integration\rules
to directory -
C:\Program Files\Microsoft Visual Studio 9.0\VC\VCProjectDefaults

Now start Visual Studio 2008 and go to -
Tools -> Option -> Project and Solution -> VC++ Directory
1. To the Executable files drop down add -
    C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\bin
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin

2. To the Include files drop down add -
    C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\inc
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include

3. To the Library files drop down add -
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include
    C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\lib\x64


Now your visual studio environment is ready to build cuda projects.

24 May 2011

Setting up Xerces XML parsing library in ubuntu

The Apache project's Xerces-C libraries support the DOM approach to XML parsing. The entire XML file is imported into memory and the data is held as nodes in a data tree which can be traversed for information.

The Xerces-C C++ parser home page: http://xml.apache.org/xerces-c/

1. Go to your working directory.
2. Download the compressed file from here. 
3. Unpack the downloaded file: tar -xzf xerces-c-3.0.1.tar.gz
4. Go to unpacked directory: cd xerces-c-3.0.1
5. ./configure --prefix=/opt
6. Build: make
7. Install: sudo make install     

This will install development files such as include header files and libraries in "/opt" so compiler flags and linker flags are required:
  • Compiler flags: -I/opt/include
  • Linker flags: -L/opt/lib -lxerces-c 
 Compiling a sample program named parser.cpp - 
g++ -g -Wall -pedantic -I/opt/include -L/opt/lib -lxerces-c parser.cpp -DMAIN_TEST -o parser 

Get the complete program from - 
http://www.yolinux.com/TUTORIALS/XML-Xerces-C.html 

Useful Links - 
1. http://xerces.apache.org/xerces-c/
2. http://xerces.apache.org/xerces-c/api-2.html
3. http://www.yolinux.com/TUTORIALS/XML-Xerces-C.html
4. http://en.wikipedia.org/wiki/Xerces
5. http://www.artima.com/cppsource/xml_data_binding.html
 

23 May 2011

Installation instructions for GALib on Ubuntu

Download the current version of GALib from here.

Extract it in your home folder and go to that folder from terminal.

Edit the file 'makevars'. This file contains the compiler flags that are unique for each cpu/os/compiler, as well as the destination directory for doing 'make install'.

To build the library and the non-graphic examples:
% make
To install GAlib on your system:
% make install

20 May 2011

Setting up GAUL(Genetic Algorithm Utility Library) on Ubuntu

Instructions for installation from source code -

1. Download GAUL library from here. There are some example programs available
    on the same site. You can download them for testing and using different            
    functionalities of GAUL.

2. If you want to enable the S-Lang and OpenMPI functionality of GAUL, then
    install the openmpi library first and slang library. SLang can be downloaded
    from here.

    For compiling slang, extract the compressed file in your home folder and type
    these commands  -
    $ cd slang-2.1.4
    $ ./configure
    $ make
    $ sudo make install

3. Now extract the GAUL compressed files into your home folder and go into that
    folder and type the following commands -
    $ cd gaul-devel-0.1850-0
   
    In its simplest form, compilation is achieved by typing:
$ ./configure && make
  
    Or, if you don't have S-Lang installed - type:
$./configure --enable-slang=no && make


    Two additional configuration options that you may find useful are:
$ ./configure --enable-efence=yes # Link with the electric fence malloc debugger.
$ ./configure --enable-mpi=yes    # Link with the MPI message passing libraries 
for parallel code
 
4. Finally type -
$ sudo make install
 
5. Now open the .bashrc file from you home directory and add the following line to it.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
6. For compiling any program with gaul libraries, use the following linkers - 
-lgaul -lgaul_util -lm 
Eg: - gcc test_utils.c -lgaul -lgaul_util -lm 

18 May 2011

Installing Open RAVE on Ubuntu

Install from the package manager

Type these commands in the terminal -  
sudo add-apt-repository ppa:openrave/release
sudo apt-get update
sudo apt-get install openrave

Compile From Sources

Get latest stable source code (constantly updated):
svn co https://openrave.svn.sourceforge.net/svnroot/openrave/tags/latest_stable openrave
 
Visit OpenRAVE

Open MPI on Ubuntu

A. Install OpenMPI

$ sudo apt-get install libopenmpi-dev openmpi-bin openmpi-doc
$ sudo apt-get install ssh
 

B. Configure SSH

$ ssh-keygen -t dsa
$ cd ~/.ssh
$ cat id_dsa.pub >> authorized_keys

C. MPI Program Example

Filename: MPI_Hello.c

#include <stdio.h>
#include <mpi.h>

int main(int argc, char** argv) 
{
    int myrank, nprocs;

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

    printf("Hello from processor %d of %d\n", myrank, nprocs);

    MPI_Finalize();
    return 0;
}

D. Compilation

$ mpicc MPI_Hello.c -o MPI_Hello

E. Execution

$ mpiexec -n 5 MPI_Hello


F. Integrated Development Environment

We will use Geany as an IDE to make compilation process easier and faster. To compile MPI program with Geany, follow these steps:
  1. Install Geany.
    $ sudo apt-get install geany
     
  2. Download MPI tags file and copy to ~/.config/geany/tags/
    $ wget http://auriza.site40.net/docs/paralel/openmpi.c.tags
    $ cp openmpi.c.tags ~/.config/geany/tags/
     
  3. Start Geany, and write MPI program example above.                                             
  4. Compilation setting: Build - Set Includes and Arguments.
    Compile: mpicc -Wall "%f" -o "%e"                                                                  Execute: mpiexec -n 5 "%e"
   5.To compile program: click Compile
   6. To execute program: click Execute.


 

17 May 2011

Installing ROS (Diamondback) on Ubuntu


If you need to install from source, please see source (download-and-compile) installation instructions.
Contents
  1. Ubuntu install of Diamondback
    1. Installation
      1. Configure your Ubuntu repositories
      2. Setup your sources.list
      3. Set up your keys
      4. Installation
      5. Environment setup
    2. Tutorials

Installation



Configure your Ubuntu repositories


Configure your Ubuntu repositories to allow "restricted," "universe," and "multiverse." You can follow the Ubuntu guide for instructions on doing this.

Setup your sources.list


Setup your computer to accept software from ROS.org.
  • Ubuntu 10.04 (Lucid)
    • sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu lucid main" > /etc/apt/sources.list.d/ros-latest.list'
      
      
    Ubuntu 10.10 (Maverick)
    • sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu maverick main" > /etc/apt/sources.list.d/ros-latest.list'

Set up your keys


  • wget http://packages.ros.org/ros.key -O - | sudo apt-key add -

Installation


Make sure you have re-indexed the ROS.org server:
  • sudo apt-get update
There are many different libraries and tools in ROS. We provided four default configurations to get you started. You can also install ROS stacks individually.
  • Desktop-Full Install: (Recommended): ROS, rx, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception
    • sudo apt-get install ros-diamondback-desktop-full

    Desktop Install: ROS, rx, rviz, and robot-generic libraries
    • sudo apt-get install ros-diamondback-desktop

    ROS-Base: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.
    • sudo apt-get install ros-diamondback-ros-base

    Individual Stack: You can also install a specific ROS stack (replace underscores with dashes of the stack name):
    • sudo apt-get install ros-diamondback-STACK
      e.g.
      sudo apt-get install ros-diamondback-slam-gmapping

Environment setup


It's convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched:

echo "source /opt/ros/diamondback/setup.bash" >> ~/.bashrc
. ~/.bashrc

If you have more than one ROS distribution installed, ~/.bashrc must only source the setup.bash for the version you are currently using.

If you just want to change the environment of your current shell, you can type:
source /opt/ros/diamondback/setup.bash

Now if you are setting ROS for localhost then add these two lines to bashrc file.
export ROS_MASTER_URI=http://localhost:11311 
export ROS_HOSTNAME=localhost