Sample program for Hokuyo URG

Sample programs to implement URG's library. These programs can be executed in Windows, Linux and Mac
C++ programs are implemented according to boost and STL. To install boost and SDL please refer below pages.


Construction of development environment


Windows

Some part of library depends on SDL and boost.
About following environment, each library installation method is explained.



Visual Studio 2005

SDL installation on Visual studio

  • Explains the method of using SDL on Visual Studio.
    Specifically sets the include path and library path.
    • In the beginning, create the Win32 console application project that uses SDL, then define SDL_Init() inside the main().SDL_Init() has include and SDL functions.

vc_main_program.png

add a postscript #include <SDL.h> and SDL_Init(0).S

  • Download and upzip SDL_devel.zip. This time place it in the project folder.

sample_and_sdl_folder.png

Place the SDL_devel in project folder

  • add SDL_devel\include in "add" -> "Include directory".

vc_add_include.png

  • Add SDL_devel\lib "Add" -> "Library directory".

vc_add_lib_path.png

  • Add SDL.lib SDLmain.lib by "Add existing file".

vc_add_lib.png

  • After that, press F5 to build.
    • There is chances of getting error message 「Program cannot be executed because there is no SDL.dll」. This error can be solved by placing the SDL.dll in the same folder of execution file. SDL.dll will be SDL_devel\lib.
      add_dll_folder.png


Boost installation on Visual studio

  • Boost Consulting Company is distrubuting Boost installer for Visual Studio for free of cost.

boost_vc_setup.png

Execution screen of installer

  • By executing the installer, the installation and the setting can be done according to the instruction.

MinGW

Please specify g++ while installing MinGW

mingw_gpp_window.png

Check g++

Install SDL on MinGW

  • Download and compile SDL-1.2.XX.tar.gz from a href="http://www.libsdl.org">SDL site
    $ tar zxvf SDL-1.2.XX.tar.gz 
    $ cd SDL-1.2.XX/
    $ ./configure --prefix=/mingw && make
    $ make install

    $ tar zxvf SDL_net-1.2.X.tar.gz
    $ cd SDL_net-1.2.X/
    $ ./configure --prefix=/mingw && make
    $ make install
    Moreover,SDL.dll is necessary to execute the compiled file from MinGW. SDL.dll will be in MinGW/bin/.


Install Boost on MinGW

  • Download and compile the file boost-1.34.x from Boost site

$ tar zxvf boost_1_34_X.tar.gz
$ cd boost_1_34_X/
$ configure && make
$ bjam.exe -sTOOLS=mingw --prefix=/mingw install

$ cd /mingw/include/
$ mv boost_1_34_X/boost boost



Qt

QT is a cross-platform application development framework, widely used for the development of GUI programs.QT is a product of Trolltech company.

In URG programming guide, QT is used to create an sample application.
Therefore, QT is necessary to build application from the sample source code. Moreover, Boost library is also used in sample application. please refer Install Boost on MinGW to install Boost .


QT Installation

QT has commercial version and Open source version. Here installation method using Open source is explained.
GPL license is applied to those application created using Open Source version.

  • download package
  • Install Package
    • After the user agrees to the license article, installation procedure can be advanced by go on clicking the Next button.



qt_installer_first.png

Image of installer



  • However, While installing even MinGW, please check "Download and install minimal MinGW installation." as in this image.

qt_installer_mingw.png

While installing even MinGW.


Example of compling the QT project.

After QT is installed, move to project folder and execute qmake && make to complete compilation.

Compilation example

% ls *.pro             # Check if project file exists or not?
UrgDrawWidget.pro
% qmake
% make
/usr/local/Trolltech/Qt-4.4.0/bin/uic UrgViewerWindowForm.ui -o ui_UrgViewerWindowForm.h
...(The compilation message is omitted.)...
g++ -Wl,(omission) -lpthread


In case of Windows environment, according to installation method

  There is possibility of error
make[1]: C:Qt4.4.3bin/moc.exe: Command not found


This problem can be solved by replacing \ with / in path specification of moc.exe in Makefile.Release.

Before correction

	C:\Qt\4.4.3\bin/moc.exe (Omitted) 

After correction

	C:/Qt/4.4.3/bin/moc.exe (omitted) 


Execution and Distribution of Qt program

  • DLL of QT is necessary to execute the programs that are compiled in QT. Please refer FAQ of QT for more details.

Linux

Some parts of library depend on SDL and boost.
In this section, installation method of each library is explained.

While using package installation on Linux, it is better to use this package tool that manages distribution.(apt, rmp etc)
Install using source code, only when package management is not done.



Install SDL on Linux

  • Install SDL using package management tool
    • In ubuntu 「libsdl1.2-dev」is installed.

  • Install SDL from source.
    • Download and compile the file SDL-1.2.XX.tar.gz from SDL site
      % tar zxvf SDL-1.2.XX.tar.gz
      % cd SDL-1.2.XX
      % ./configure && make
      % sudo make install


Install Boost on Linux

  • Install Boost using package management tool
    • In ubuntu 「libboost-dev」and「libboost-regex-dev」is installed.

  • Install Boost from source
    • Download and compile the file boost-1.37.X from Boost site
      % tar zxvf boost_1_37_X.tar.gz
      % cd boost_1_37_X
      % ./configure && make
      % sudo make install

      % cd /usr/local/include
      % sudo ln -s boost_1_37_X/boost boost



URG library API


Method to use URG library

URG library for Windows.

URG library can be create as lib file and include/ folder.Those created can be used in Windows.
  • Build method
  • Start Visual Studio 2005 from urg-X.X.X/vc8/c/c_urg.vcproj (as well as urg-X.X.X/vc8/cpp/urg.vcproj), then press F7 to Build.
  • Build can be considered as success if Debug/c_urg.lib file and include folder are created.

  • How to use library
    • 生成された Debug/c_urg.lib を "追加の依存ファイル" に追記し、include フォルダを "追加のインクルードディレクトリ" に追記することで利用できます。


Using URG library in Linux

  • Compiling method
    • Compilation can be done with configure && make
      • C++ version library cannot be compiled without boost, SDL and SDL_net.

    • Each script in c_urg-config, urg-config can be used after installation using "make install".

      % tar zxvf urg-X.X.X.tar.gz
      % cd urg-X.X.X
      % ./configure && make
      # make install

  • How to use library
    • The option necessary for the compilation can be described by using c_urg-config (Or urg-config).