How to debug SceneLib with Eclipse

posted 24 Jul 2014, 13:36 by Hanme Kim

For the last preparation before starting to study about the SceneLib library and Visual SLAM, here is a post describes how to debug SceneLib with Eclipse. Regarding how to install SceneLib 1.0 on Ubuntu 10.04, please refer to the previous post.

1. Have SceneLib and other components in a folder
All you need are glow_104, MonoSLAMGlow, SceneLib, VW34 and TestSeqMonoSLAM folders.

2. Clean and configure
If you have ever compiled and/or configured any component, please clean and/or re-configure them as below.

// GLOW Toolkit
$ cd glow_104
$ cd glow_src
$ sudo make clean
$ sudo make
$ sudo ln -s libglow.a.1.0.2 libglow.a

// VW34 Library
$ cd VW34
$ sudo make clean
$ sudo rm configure
$ ./bootstrap
$ ./configure
$ sudo make
$ sudo make install

// SceneLib
$ cd SceneLib
$ sudo make clean
$ ./configure
$ sudo make
$ sudo make install

// MonoSLAMGlow
$ cd MonoSLAMGlow
$ sudo make clean
$ sudo make

3. Modify ‘MonoSLAMGlow/Makefile’
Add ‘all: ${EXECUTABLE)’ before ‘$(EXECUTABLE):$(OFILES) to make a target correctly as below.

# Executable
all: $(EXECUTABLE)

$(EXECUTABLE): $(OFILES) 

4. Run Eclipse and select the folder as a workspace
I installed Eclipse IDE for C/C++ Linux Developers - Indigo Service Release 1 Version on Ubuntu 10.04. In the Eclipse IDE, choose ‘File->Switch Workspace->Other...’, and select the folder as a workspace.

5. Add SceneLib and all other components as projects to Eclipse
In the Eclipse IDE, choose ‘File->New->Makefile Project with Existing Code’, select a folder using the ‘Browse...’ button, and click the ‘Finish’ button after selecting ‘Linux GCC’ for ‘Toolchain for indexer Settings’. Do the same things for all components (i.e., glow_104, MonoSLAMGlow, SceneLib and VW34). You should see all added projects in the ‘Project Explorer’ window as below.


6. Change ‘Build location’ of the ‘glow_104’ project
In the Eclipse IDE, right click on the ‘glow_104’ project’, choose ‘Properties’, click ‘C/C++ Build’. On the ‘Builder Settings’ tab, select ‘glow_104->glow_src’ using the ‘Workspace...’ button as its make file is located in the ‘glow_src’ folder.

7. Modify ‘glow_104/glow_src/Makefile’
To build GLOW Toolkit in the debug mode, change ‘CFLAGS_Linux’ and ‘CFLAGS_IRIX’ as below.

CFLAGS_Linux=-Wall \
 -DGLOW_PLATFORM_LINUX \
 -DGLOW_PLATFORM_LITTLEENDIAN -g
#NODEBUGCFLAGS_Linux=-O2 -DNODEBUG

CFLAGS_IRIX=-fullwarn -no_auto_include \
 -LANG:std \
 -woff 1209,3201,1424,1375 \
 -OPT:Olimit=0 \
 -I../Compat-SGI \
 -DGLOW_COMPAT_CLIBNOSTDNAMESPACE \
 -DGLOW_PLATFORM_IRIX \
 -DGLOW_PLATFORM_BIGENDIAN -g
#NODEBUGCFLAGS_IRIX=-O2 -DNODEBUG

8. Rebuild all component in the Eclipse IDE
Right click on each project, select ‘Clean Project’ and ‘Build Project’ sequentially.

9. Debug MonoSLAMGlow
You can debug MonoSLAMGlow by selecting ‘1 monoslam’ from the Debug icon.


10. Run MonoSLAMGlow
Right click on the ‘MonoSLAMGlow’ project, choose ‘Run As->Local C/C++ Application’, and click ‘OK’ button after selecting ‘gdb/mi’ as a configuration to run.


Now is the time to start reading Andrew Davison’s papers and delving the SceneLib’s source code! :)

[Update on 18/06/2012]
If you cannot use "Open Declaration (F3)" on a function when you are debugging, and if you get a warning or error message something like "... unresolved inclusion ..." or "... could not be resolved ..." on the function, please add its source folder following below.

1) Right click on the project, and select "Properties".
2) Select "C/C++ General - Paths and Symbols".
3) Select "Includes" tab and "GNU C++".
4) Add its source folder using "Add..." button.

How to install SceneLib 1.0 on Ubuntu 10.04

posted 23 Jul 2014, 17:51 by Hanme Kim   [ updated 23 Jul 2014, 18:12 ]

SceneLib?

SceneLib is an open-source C++ library for SLAM designed and implemented by Andrew Davison with additional work by Paul Smith. SceneLib 1.0 is released with full source code under the GNU Lesser Public License (LGPL). SceneLib is a generic SLAM library in principle, with a modular approach to specification of the details of robot and sensor types. However it also has specialised components to permit real-time vision-based SLAM with a single camera (MonoSLAM) and the design is optimised towards this type of application. Available alongside the SceneLib library is source code which compiles to the executable program MonoSLAMGlow. This is an example application of MonoSLAM which can take images in real-time from an IEEE1394 camera or off-line from a disk sequence and perform sparse monocular SLAM. Some of the more advanced techniques we have published such as patch warping are not implemented in this release.

As SceneLib is a good starting point to study about Visual SLAM that I am really interested in, I have decided to delve into the code level details. But, when I tried to compile it following the instructions described in its website and readme files, I have got some errors and issues, and it seems like that many things have been changed regarding to the Linux distribution, script and compiler since SceneLib was released long time ago. So, I needed to spend time and effort mostly googling for solving them, and, as I managed to compile and run it now, I am writing this to share my experience with you all.

1. Install the basic development tools on Ubuntu 10.04
As I need a modern Linux distribution with standard programming tools installed, I chose Ubuntu 10.04 and installed the basic development tools using the below command.

$ sudo apt-get install build-essential

2. Install OpenGL and GLUT
Before you install OpenGL and GLUT, please make sure you have the gcc compiler installed first.

$ sudo apt-get install g++
$ sudo apt-get install freeglut3 freeglut3-dev libglut3 libglut3-dev libglew1.5 libglew1.5-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev mesa-common-dev

3. Install Pthread library
You can install the Pthread library using the below command.

$ sudo apt-get install libpthread-stubs0 libpthread-stubs0-dev

4. Install libraw1394, libraw1394-dev, libdc1394 and libdc1394-dev
Although there is a comment that the new version 2.* of libdc1394 will not work with VW and other software so need to get the older version 1.*, I just installed the latest version of it as I couldn't find the older one, and disabled the IEEE1394 functionality to use the offline mode only.

$ sudo apt-get install libraw1394-11 libraw1394-dev libraw1394-doc
$ sudo apt-get install libdc1394-22-dbg libdc1394-utils libdc1394-22 libdc1394-22-dev libdc1394-22-doc

5. Install Xforms Toolkit
To do this, please follow the instruction described in http://xforms-toolkit.org/installation.html.

[Update on 13/06/2012]
Or.. download the XForms source package called xforms.latest_stable.tar.gz, install libjpeg62-dev using the Synaptic Package Manager, and follow the below instructions.

$ sudo apt-get install libxpm-dev
$ sudo apt-get install libopenjpeg-dev

$ cd xforms-1.0.93sp1
$ ./configure
$ make
$ sudo make install

6. Download SceneLib
You can download SceneLib and all necessary components from the SceneLib’s download page.

7. Unpack SceneLib
Unpack the downloaded files to create the following directories which by default should be at the same level (they will look for each other): glow_104, MonoSLAMGlow, TestSeqMonoSLAM, SceneLib and VW34.

$ sudo tar xvfz vw34.tar.gz
$ sudo tar xvfz scenelib.tar.gz
$ sudo tar xvfz glow_104.tar.gz
$ sudo tar xvfz monoslamglow.tar.gz
$ sudo tar xvfz testseqmonoslam.tar.gz

8. Compile GLOW Toolkit
If you have followed the instructions so far correctly, you shouldn't have a problem to compile the GLOW Toolkit using the below commands.

$ cd glow_104
$ cd glow_src
$ sudo make
$ sudo ln -s libglow.a.1.0.2 libglow.a

9. Modify 'VW34/configure.ac'
Comment out 'X', 'XFORMS' and 'Firewire' components.

# X
#AC_CHECK_HEADERS(X11/Xlib.h X11/Xutil.h,
#         [libx=yes],
#                [libx=no; AC_MSG_WARN(**** x libraries not found **** libVWX.a will not be compiled)])
AM_CONDITIONAL(X, test x$libx = xyes)

# XFORMS
#AC_CHECK_HEADERS(forms.h,
#         [xforms=yes],
#                [xforms=no; AC_MSG_WARN(**** xforms not found **** libVWXForms.a will not be compiled)])
AM_CONDITIONAL(XFORMS, test x$xforms = xyes)

# Firewire
#AC_CHECK_LIB(dc1394_control, dc1394_dma_setup_capture,
#            [firewire=yes],
#     [firewire=no; AC_MSG_WARN(**** libdc1394 not found **** libVWFirewire.a will not be compiled)], 
#     [-lraw1394])
AM_CONDITIONAL(FIREWIRE, test x$firewire = xyes) 

Correct the GTK path.

AC_CHECK_FILES(/usr/include/gtkgl-2.0/gtkgl/gtkglarea.h,

Comment out the Qt component.

# Qt
#BNV_HAVE_QT
AM_CONDITIONAL(QT, test x$have_qt = xyes)

10. Add '#include <cstdlib>'
To prevent various error messages, please add '#include <cstdlib>' on the top of the listed files below.
  • VW34/VW/Image/imagebase.h
  • VW34/VW/IOBasics/miscioutils.cpp
  • VW34/VW/GeomObjects/rotationmatrix.cpp
  • VW34/VW/GeomObjects/calibrationtable.cpp
  • VW34/VW/GeomObjects/operations.cpp
  • VW34/VW/Sequencers/sequencerbase.cpp
  • VW34/VW/GeomCompute/delaunay.cpp
  • VW34/VW/GeomCompute/line2dcomputeguisac.cpp
  • VW34/VW/GeomCompute/fmplanarcomputenonlinear.cpp
  • VW34/VW/Improc/edgel.h
  • VW34/VWGL/Display/awfface.cpp
  • SceneLib/Scene/init_feature.cpp

11. Add '#include <cstring>'
To prevent various error messages, please add '#include <cstring>' on the top of the listed files below.
  • VW34/VW/Image/imageconversions.cpp
  • VW34/VW/Sequencers/sequencermovie.cpp
  • VW34/VWGL/Display/awfmaterial.cpp

12. Add '#include <cstdio>'
To prevent various error messages, please add '#include <cstdio>' on the top of the listed files below.
  • VW34/VWGL/Interface/slider.cpp

13. Add '#include <typeinfo>'
To prevent various error messages, please add '#include <typeinfo>' on the top of the listed files below.
  • SceneLib/Scene/scene_single.cpp

14. Modify 'VW34/VW/GeomObjects/point3d.h' file
Add Ln148 and Ln149 as below.

 };

 Point3D operator+(const Point3D &p1, const Point3D &p2);
 Point3D operator/(const Point3D &p1, const double a);

 typedef Point3D Vector3D;

}; // end namespace VW 

15. Modify ‘VW34/VW/GeomObjects/point2d.h’ file
Add Ln 134 and Ln 135 as below.

 };

 Point2D operator+(const Point2D &p1, const Point2D &p2);
 Point2D operator/(const Point2D &p1, const double a);

 typedef Point2D Vector2D;

}; // end namespace VW 

16. Modify ‘VW34/VW/GeomObjects/lineseg2d.h’ file
Add Ln 155 and Ln 156 as below.

 };

 std::ostream& operator<<(std::ostream& s, const LineSeg2D &ls);
 std::istream& operator>>(std::istream& s, LineSeg2D &ls);

}; // end namespace VW 

17. Modify ‘VW34/VW/GeomObjects/lineseg3d.h’ file
Add Ln 93, Ln 94, Ln 95 and Ln 96 as below.

 };

 double Norm2(const LineSeg3D &ls);
 double Norm(const LineSeg3D &ls);
 std::ostream& operator<<(std::ostream& s, const LineSeg3D &ls);
 std::istream& operator>>(std::istream& s, LineSeg3D &ls);

 // Other funcs
 VW::LineSeg3D operator+(const VW::LineSeg3D &line, const VW::Point3D &point);
 VW::LineSeg3D operator-(const VW::LineSeg3D &line, const VW::Point3D &point);

}; // end namespace VW 

18. Modify ‘VW34/VW/Sequencers/sequencerbase.h’ file
Change Ln 127 as below.

 void CopyImage(ImType& image, unsigned int which_channel=0) { }; 

19. Modify ‘VW34/VW/Improc/matchdata.h’ file
Add Ln 72 and Ln 73 as below.

 std::ostream & operator << (std::ostream & s, const MatchData & m);
 std::istream & operator >> (std::istream & s, MatchData & m);

 /** Sort into order of increasing match score. */
 void SortAscending(std::vector<MatchData>& list);
 /** Sort into order of decreasing match score. */
 void SortDescending(std::vector<MatchData>& list); 

20. Compile VW34
If you have followed the instructions so far correctly, you can compile VW34 without any error.

$ cd VW34
$ ./bootstrap
$ ./configure
$ sudo make
$ sudo make install

21. Compile SceneLib
If you have followed the instructions so far correctly, you can compile SceneLib without any error.

$ cd SceneLib
$ ./configure
$ sudo make
$ sudo make install

22. Modify 'MonoSLAMGlow/Makefile' file
Remove -lVWFirewire from the line defining VWLIBS as below.

VWLIBS = -L$(VWDIR)/lib -lVWGLOW -lVWGL -lVW -lVNL  

Remove -D$(OS) and -D$(ARCH) from the line defining CFLAGS as below.

CFLAGS = $(GLOWHEADERS) $(VWHEADERS) $(SCENEHEADERS) -Wall -D_REENTRANT -O3 -g #-D_REALTIME_

Remove $(FIREWIRELIBS) from the line defining LINKFLAGS as below.

LINKFLAGS = $(SCENELIBS) $(VWLIBS) $(GLOWLIBS) $(GLLIBS) -Wall -O2 $(PTHREADLIBS) $(MATHSLIBS) 

23. Compile MonoSLAMGlow
If you have followed the instructions so far correctly, you can compile MonoSLAMGlow without any problem.

$ cd MonoSLAMGlow
$ sudo make

24. Running MonoSLAMGlow in the offline mode
If you have followed the instructions so far correctly, you can run MonoSLAMGlow in the offline mode, and you should see its user interface as below.

$ ./monoslam


Now is the time to delve into the SceneLib in the code level details, good luck for all of us! :)

1-2 of 2