I was following this link: http://www.ros.org/wiki/IDEs to get my code completion working. On top of the plugin rosvim.vim installed, I also have OmniCppComplete. I don't get the code completion working under ROS, how should I do that? By the way, code completion for any other codes excluding ROS-related codes are just working out of the box.
Any ideas..
EDIT:
How should I tailor my ~/.vimrc file. Anyway. I've tried to add yours with the existing one like below:
syntax enable
se nu
set tabstop=4
set shiftwidth=4
set expandtab
filetype on
filetype plugin on
set nocp
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#CompleteCpp
set tags+=~/.vim/tags/ros
" OmniCppComplete settings to be tweaked
let OmniCpp_NamespaceSearch=1
let OmniCpp_GlobalScopeSearch=1
let OmniCpp_ShowAccess=1
let OmniCpp_MayCompleteDot=1
let OmniCpp_MayCompleteArrow=1
let OmniCpp_MayCompleteScope=1
let OmniCpp_DefaultNamespaces=["std","_GLIBCXX_STD"]
" Hotkey to generate tags for you current project
map <F5> :!/usr/bin/ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
*I've uninstalled and reinstalled the autocompletion with both methods below but still does not work
To use OmniCppComplete with ROS, you have to generate a set of tags for the ROS stacks. There are probably better ways of doing this, but I was successful with find and grep.
First, generate a list of files that you want to generate tags from:
find /opt/ros/diamondback/stacks | grep -E '*/include/*/.*\.(h|hpp)' > /tmp/ros.filelist
Then use ctags to generate a tags database from this list:
ctags --sort=foldcase --c++-kinds=+p --fields=+iaS --extra=+q -f /tmp/ros.tags -L /tmp/ros.filelist
Once you have done this, you can move your tags file into your ~/.vim directory
mv /tmp/ros.filelist ~/.vim/tags/ros
And edit your ~/.vimrc file accordingly
set tags+=~/.vim/tags/ros
" OmniCppComplete settings to be tweaked
let OmniCpp_NamespaceSearch=1
let OmniCpp_GlobalScopeSearch=1
let OmniCpp_ShowAccess=1
let OmniCpp_MayCompleteDot=1
let OmniCpp_MayCompleteArrow=1
let OmniCpp_MayCompleteScope=1
let OmniCpp_DefaultNamespaces=["std","_GLIBCXX_STD"]
" Hotkey to generate tags for you current project
map <F5> :!/usr/bin/ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
Hope this helps.
The following .vimrc snippet is mostly from here. Visit the link to see how to create stl, qt, sdl and qt4 tags (or deactivate the "set"-lines).
The only ros-specific part is `rospack cflags-only-I` in the third line, which lists all the include directories of the ros package in which you are editing files for the ctags command (this assumes the current working dir of vim is your projects directory, see below, which btw also allows you to use :mak). With this, hitting F11 will generate completion tags for your current file's project.
In contrast to the solution of mjcarroll this creates a tagfile in your project's directory, which is specific to the dependencies of your project. Therefore you need to create the tags (F11) for each of the packages in which you are editing files. On the other hand vim should be faster looking up its tag database.
map <f12> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q .<cr> "This is to tag the include for ros packages the current project depends on map <f11> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q . `rospack cflags-only-I`<cr> "map <f11> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ~/local/usr/include/<cr> " configure tags - add additional tags here or comment out not-used ones set tags+=~/.vim/tags/stdlibtags set tags+=~/.vim/tags/gltags "set tags+=~/.vim/tags/sdl set tags+=~/.vim/tags/qt4tags " OmniCppComplete let OmniCpp_NamespaceSearch = 1 let OmniCpp_GlobalScopeSearch = 1 let OmniCpp_ShowAccess = 1 let OmniCpp_MayCompleteDot = 1 let OmniCpp_MayCompleteArrow = 1 let OmniCpp_MayCompleteScope = 1 "let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] " automatically open and close the popup menu / preview window au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif set completeopt=menuone,menu,preview ",longest "END Omnicompletion
Vim's present working dir (:pwd) needs to be the root directory of your package (i.e., the output of rospack find <yourpackage>) because calling "rospack cflags-only-I" without package name argument will use the current dir as package name. This is the case if you start vim in that directory or use :cd to change there. Alternatively you could somehow (I do not know how, though) find out the package name of the project your file belongs to, to give it to the rospack call.
Mine is 64 bit... Anyway, I can't imagine this to be the problem.
Asked: 2011-03-24 13:59:13 -0500
Seen: 837 times
Last updated: Apr 07 '11
Do I need to know any specific computer language or framework to use ROS?
Problem with sensor_msgs::Image::ConstPtr conversion to IplImage
is ros client c++ code thread safe?
How to use Python setuptools to build a Python extension
How to run ROS commands from C++ application?
ROS Answers is licensed under Creative Commons Attribution 3.0 Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.