OpenRAVE Documentation

Working With the Source Code

These guidelines are for OpenRAVE Developers using Linux.

Building

In order to compile debug, just do:

make DEBUG=d

This will create a builddebug folder independent of the original build folder.

Can setup colorgcc and ccache for easier development by executing the following setupgcc.bash script inside the ~/.bashrc file:

#!/bin/bash
# install ccache and colorgcc if they are not installed
if [ -z "`which ccache`" ]; then
  echo Installing ColorGCC ...
  sudo apt-get install ccache
fi

# Color GCC
if [ -z "`which colorgcc`" ]; then
  echo Installing ColorGCC ...
  sudo apt-get install colorgcc
fi
if [ ! -z "`which colorgcc`" ]; then
  export CC="colorgcc"
  alias gcc='colorgcc'
  for C in `grep /usr/bin /etc/colorgcc/colorgccrc | sed -e 's/# //' -e 's/:.*//'`; do
    if [ ! -e /usr/local/bin/${C} ]; then
      echo "Installing colorgcc wrapper in $HOME/bin for ${C}... "
      sudo ln -s /usr/bin/colorgcc /usr/local/bin/${C}
    fi
  done
fi

# generate .colorgcc by inserting ccache with .*: /usr/bin/.*  (Ryohei Ueda)
looks_like_path() {
    local arg=$1
    local result=`echo "$arg" | grep -c /`
    if [ "$result" != "0" ]; then
        echo true
        return 0
    else
        echo false
        return 1
    fi
}

# clear you .colorgccrc
if [ -e $HOME/.colorgccrc ]; then
    echo "clearing $HOME/.colorgccrc"
    echo > $HOME/.colorgccrc
fi

while read line
do
    if [ "`echo $line | grep -c -e '^[a-zA-Z0-9].*:'`" != "0" ]; then
        local second_arg="`echo $line | cut -f2 -d:`"
        if [ "`looks_like_path $second_arg`" = "true" ]; then
            
            echo `echo $line | sed "s/: /: ccache /g"` >> $HOME/.colorgccrc
        else 
            echo $line >> $HOME/.colorgccrc
        fi
    else
        echo $line >> $HOME/.colorgccrc
    fi
    
done < /etc/colorgcc/colorgccrc

### Color Make
#if [ -z "`which colormake`" ]; then
#  echo Installing ColorMake ...
#  sudo apt-get install colormake
#fi
#if [ ! -z "`which colormake`" ]; then
#  alias make='colormake'
#  if [ ! -e /usr/local/bin/make ]; then
#    sudo ln -s /usr/bin/colormake /usr/local/bin/make
#  fi
#fi

Note that this will create symlinks to the compilers inside /usr/local/bin.

Indenting C++ Files

OpenRAVE C++ code should automatically be run with uncrustify before being committed. Currently OpenRAVE requires uncrustify version >=0.57. First put .uncrustify.cfg in your $HOME directory.

Run a C++ file before committing to OpenRAVE:

uncrustify --no-backup myfile.cpp

Automatic Indention shows how to automate calling uncrustify when saving the C++ file in Emacs.

Auto-Completion

To get auto-completion for the OpenRAVE C++ API using Collection of Emacs Development Environment Tools (CEDEC), make sure to put the following Lisp code in your .emacs file:

(defun openrave-package-path ()
  (save-excursion
    (with-temp-buffer
      (call-process "openrave-config" nil t nil "--cflags-only-I")
      (goto-char (point-min))
      (re-search-forward "^-I\\(.*\\)[ \\|$]")
      (match-string 1))))

(setq openrave-base-dir (openrave-package-path))
(semantic-add-system-include openrave-base-dir 'c++-mode)
(semantic-add-system-include openrave-base-dir 'c-mode)
(add-to-list 'auto-mode-alist (cons openrave-base-dir 'c++-mode))
(add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat openrave-base-dir "/openrave/config.h"))

Automatic Indention

It is possible to setup emacs to automatically call uncrustify when saving a file by downloading the emacs-uncrustify pakcage, setting its path in the emacs load path, and putting the following in your .emacs file:

(require 'uncrustify)
(setq uncrustify-uncrustify-on-save t)
(setq uncrustify-args "-l CPP")

Bookmarks

Using the bm.el library for getting bookmarks. If using bookmarks with uncrustify, have to add the following code to your .emacs file:

(add-hook 'uncrustify-init-hooks 'bm-buffer-save)
(add-hook 'uncrustify-finish-hooks 'bm-buffer-restore)

Questions/Feedback

Having problems with OpenRAVE?