[ros-users] Help integrating ros with gpusurf

Sean Anderson sanderson at clearpathrobotics.com
Tue Aug 17 15:06:55 UTC 2010


I've decided I want to integrate some of my previous ros work with a vision
program I've written that uses OpenCV and gpusurf (
http://homes.esat.kuleuven.be/~ncorneli/gpusurf/)

Until a few months ago I've been purely a windows programmer and therefore
the problem I've run into (due my inexperience with cmake and the like) is
that I'm not entirely sure how to integrate the build process. gpusurf has
quite an extensive makefile, which uses nvidia's cuda, and I'm not sure if
it's easier to try and rewrite it using cmake, or add the ros dependencies
to the regular make file included in gpusurf.

Appended at the end is the 3 files used to build gpusurf.

Thanks for any help/suggestions!

- Sean

*Makefile*
---
include ../settings.mk

USE_NCGL    := 1

verbose     := 1

CCFILES        := main.cpp

INCLUDES    := -I../libsurf/inc

EXECUTABLE  := gpusurf

ifeq ($(emu), 1)
    LIB         := -L../libsurf/lib/emuRelease -lsurf
else
    LIB         := -L../libsurf/lib/Release -lsurf
endif

include ../common.mk



*settings.mk*
---
USE_CUDA    := 1
USE_VXL        := 0

CUDA_INSTALL_PATH           := /usr/local/cuda
CUDA_SDK_INSTALL_PATH       := /home/nico/NVIDIA_CUDA_SDK
NCGL_INSTALL_PATH           := ../libncgl

GLUT_INC_PATH                := /usr/include
GLUT_LIB_PATH                := /usr/lib
GLEW_INC_PATH                := /usr/include
GLEW_LIB_PATH                := /usr/lib
CG_INC_PATH                    := /usr/include
CG_LIB_PATH                    := /usr/lib
IMAGEMAGICK_INC_PATH        := /usr/include/ImageMagick
IMAGEMAGICK_LIB_PATH        := /usr/lib
VXL_INC_PATH                := /usr/local/vxl/vxl-1.10.0
VXL_LIB_PATH                := /usr/local/vxl/bin/lib



*common.mk*
---
.SUFFIXES : .cu .cu_dbg_o .c_dbg_o .cpp_dbg_o .cu_rel_o .c_rel_o .cpp_rel_o
.cubin

SRCDIR          ?= src
ROOTBINDIR      ?= bin
ROOTLIBDIR      ?= lib
ROOTOBJDIR      ?= obj
BINDIR          ?= $(ROOTBINDIR)
LIBDIR          ?= $(ROOTLIBDIR)

# Includes
INCLUDES        += -I./inc

# Compilers
CXX             := g++
CC              := gcc
LINK            := g++ -fPIC

ifeq ($(USE_CUDA), 1)
    LIBDIR_CUDA     := $(CUDA_SDK_INSTALL_PATH)/lib
    COMMONDIR       := $(CUDA_SDK_INSTALL_PATH)/common
    NVCC            := $(CUDA_INSTALL_PATH)/bin/nvcc
    NVCCFLAGS       :=
    INCLUDES        += -I$(CUDA_INSTALL_PATH)/include -I$(COMMONDIR)/inc
    LIB             += -L$(CUDA_INSTALL_PATH)/lib -L$(LIBDIR_CUDA)
-L$(COMMONDIR)/lib -lcuda -lcudart -lcutil
    ifeq ($(emu),1)
        LIB         += -lcublasemu
    else
        LIB         += -lcublas
    endif
endif

ifeq ($(USE_NCGL), 1)
#    INCLUDES    += -I$(NCGL_INSTALL_PATH)/inc -I/usr/include/freetype2

    INCLUDES    += -I$(NCGL_INSTALL_PATH)/inc -I$(GLUT_INC_PATH)
-I$(GLEW_INC_PATH) -I$(CG_INC_PATH) -I$(IMAGEMAGICK_INC_PATH)
    ifeq ($(emu),1)
        LIB         += -L$(NCGL_INSTALL_PATH)/lib/emuRelease -lncgl
    else
        LIB         += -L$(NCGL_INSTALL_PATH)/lib/Release -lncgl
    endif
        LIB         += -L$(GLUT_LIB_PATH) -lglut -L$(GLEW_LIB_PATH) -lGLEW
-L$(CG_LIB_PATH) -lCg -lCgGL -L$(IMAGEMAGICK_LIB_PATH) -lGL -lpthread
-lMagick++
endif

ifeq ($(USE_VXL), 1)
    INCLUDES    += -I$(VXL_INC_PATH) -I$(VXL_INC_PATH)/../bin/core
-I$(VXL_INC_PATH)/core -I$(VXL_INC_PATH)/../bin/vcl -I$(VXL_INC_PATH)/vcl
-I$(VXL_INC_PATH)/contrib/oxl
    LIB         += -L$(VXL_LIB_PATH) -lmvl -lvgl_algo -lvgl -lvnl_algo -lvnl
-lvul -lvbl -lv3p_netlib
endif

# append optional arch/SM version flags (such as -arch sm_11)
NVCCFLAGS += $(SMVERSIONFLAGS)

# architecture flag for cubin build
CUBIN_ARCH_FLAG := -m32

# Warning flags
CXXWARN_FLAGS := \
    -W -Wall \
    -Wimplicit \
    -Wswitch \
    -Wformat \
    -Wchar-subscripts \
    -Wparentheses \
    -Wmultichar \
    -Wtrigraphs \
    -Wpointer-arith \
    -Wcast-align \
    -Wreturn-type \
    -Wno-unused-function \
    $(SPACE)

CWARN_FLAGS := $(CXXWARN_FLAGS) \
    -Wstrict-prototypes \
    -Wmissing-prototypes \
    -Wmissing-declarations \
    -Wnested-externs \
    -Wmain \

# Compiler-specific flags
CXXFLAGS  := $(CXXWARN_FLAGS)
CFLAGS    := $(CWARN_FLAGS)

# Common flags
COMMONFLAGS = $(INCLUDES) -DUNIX
ifeq ($(USE_CUDA),1)
    COMMONFLAGS += -DUSE_CUDA
endif
ifeq ($(USE_VXL),1)
    COMMONFLAGS += -DUSE_VXL
endif

# Debug/release configuration
ifeq ($(dbg),1)
    COMMONFLAGS += -g
    NVCCFLAGS   += -D_DEBUG
    BINSUBDIR   := Debug
    LIBSUFFIX   := D
else
    COMMONFLAGS += -O3
    BINSUBDIR   := Release
    LIBSUFFIX   :=
    NVCCFLAGS   += --compiler-options -fno-strict-aliasing
    CXXFLAGS    += -fno-strict-aliasing -fno-stack-protector
    CFLAGS      += -fno-strict-aliasing -fno-stack-protector
endif

# Device emulation configuration
ifeq ($(emu), 1)
    NVCCFLAGS   += -deviceemu
    CUDACCFLAGS +=
    BINSUBDIR   := emu$(BINSUBDIR)
    # consistency, makes developing easier
    CXXFLAGS                += -D__DEVICE_EMULATION__
    CFLAGS                  += -D__DEVICE_EMULATION__
endif

ifneq ($(DYNAMIC_LIB),)
    TARGETDIR_DYNAMIC := $(LIBDIR)/$(BINSUBDIR)
    TARGET_DYNAMIC    := $(TARGETDIR_DYNAMIC)/$(DYNAMIC_LIB)
    LINKLINE_DYNAMIC  = $(LINK) -shared -Wl,-soname,$(DYNAMIC_LIB) -o
$(TARGET_DYNAMIC) $(OBJS)
endif

ifneq ($(STATIC_LIB),)
    TARGETDIR_STATIC := $(LIBDIR)/$(BINSUBDIR)
    TARGET_STATIC    := $(TARGETDIR_STATIC)/$(STATIC_LIB)
    LINKLINE_STATIC  = ar qv $(TARGET_STATIC) $(OBJS)
endif

ifneq ($(EXECUTABLE),)
    TARGETDIR := $(BINDIR)/$(BINSUBDIR)
    TARGET    := $(TARGETDIR)/$(EXECUTABLE)
    LINKLINE  = $(LINK) -o $(TARGET) $(OBJS) $(LIB)
endif

# check if verbose
ifeq ($(verbose), 1)
    VERBOSE :=
else
    VERBOSE := @
endif

################################################################################
# Check for input flags and set compiler flags appropriately
################################################################################
ifeq ($(fastmath), 1)
    NVCCFLAGS += -use_fast_math
endif

ifeq ($(keep), 1)
    NVCCFLAGS += -keep
    NVCC_KEEP_CLEAN := *.i* *.cubin *.cu.c *.cudafe* *.fatbin.c *.ptx
endif

# Add cudacc flags
NVCCFLAGS += $(CUDACCFLAGS)

# Add common flags
NVCCFLAGS += $(COMMONFLAGS)
CXXFLAGS  += $(COMMONFLAGS)
CFLAGS    += $(COMMONFLAGS)

ifeq ($(nvcc_warn_verbose),1)
    NVCCFLAGS += $(addprefix --compiler-options ,$(CXXWARN_FLAGS))
    NVCCFLAGS += --compiler-options -fno-strict-aliasing
endif

################################################################################
# Set up object files
################################################################################
OBJDIR := $(ROOTOBJDIR)/$(BINSUBDIR)/$(SRCDIR)
OBJS :=  $(patsubst %.cpp,$(OBJDIR)/%.cpp.o,$(notdir $(CCFILES)))
OBJS +=  $(patsubst %.c,$(OBJDIR)/%.c.o,$(notdir $(CFILES)))
ifeq ($(USE_CUDA), 1)
    OBJS +=  $(patsubst %.cu,$(OBJDIR)/%.cu.o,$(notdir $(CUFILES)))
endif
################################################################################
# Set up cubin files
################################################################################
CUBINDIR := $(SRCDIR)/data
CUBINS +=  $(patsubst %.cu,$(CUBINDIR)/%.cubin,$(notdir $(CUBINFILES)))

################################################################################
# Rules
################################################################################
$(OBJDIR)/%.c.o : $(SRCDIR)/%.c $(C_DEPS)
    $(VERBOSE)$(CC) $(CFLAGS) -o $@ -c $<

$(OBJDIR)/%.cpp.o : $(SRCDIR)/%.cpp $(C_DEPS)
    $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $<

$(OBJDIR)/%.cu.o : $(SRCDIR)/%.cu $(CU_DEPS)
    $(VERBOSE)$(NVCC) -o $@ -c $< $(NVCCFLAGS)

$(CUBINDIR)/%.cubin : $(SRCDIR)/%.cu cubindirectory
    $(VERBOSE)$(NVCC) $(CUBIN_ARCH_FLAG) -o $@ -cubin $< $(NVCCFLAGS)


TARGETLIST := makeobjdir $(OBJS) $(CUBINS) Makefile

ifneq ($(DYNAMIC_LIB),)
    TARGETLIST := makedirdynamic $(TARGETLIST)
    TARGETLIST += $(TARGET_DYNAMIC)
endif
ifneq ($(STATIC_LIB),)
    TARGETLIST := makedirstatic $(TARGETLIST)
    TARGETLIST += $(TARGET_STATIC)
endif
ifneq ($(EXECUTABLE),)
    TARGETLIST := makedirexec $(TARGETLIST)
    TARGETLIST += $(TARGET)
endif


all : $(TARGETLIST)

$(TARGET):
    $(VERBOSE)$(LINKLINE)

$(TARGET_DYNAMIC):
    $(VERBOSE)$(LINKLINE_DYNAMIC)

$(TARGET_STATIC):
    $(VERBOSE)$(LINKLINE_STATIC)

cubindirectory:
    @mkdir -p $(CUBINDIR)

makeobjdir:
    @mkdir -p $(OBJDIR)

makedirexec:
    @mkdir -p $(TARGETDIR)

makedirdynamic:
    @mkdir -p $(TARGETDIR_DYNAMIC)

makedirstatic:
    @mkdir -p $(TARGETDIR_STATIC)

tidy :
    @find | egrep "#" | xargs rm -f
    @find | egrep "\~" | xargs rm -f

cleanall : clean

clean : tidy
    $(VERBOSE)rm -f $(OBJS)
    $(VERBOSE)rm -f $(CUBINS)
    $(VERBOSE)rm -f $(TARGET_DYNAMIC)
    $(VERBOSE)rm -f $(TARGET_STATIC)
    $(VERBOSE)rm -f $(TARGET)
    $(VERBOSE)rm -f $(NVCC_KEEP_CLEAN)

clobber : clean
    rm -rf $(ROOTOBJDIR)
    rm -rf $(ROOTLIBDIR)
    rm -rf $(ROOTBINDIR)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/ros-users/attachments/20100817/475a09a9/attachment-0002.html>
-------------- next part --------------
------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
-------------- next part --------------
_______________________________________________
ros-users mailing list
ros-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ros-users


More information about the ros-users mailing list