One of my favorite editors for coding is Atom, which has recently received support to work as a full-fledged IDE by utilizing the language server protocol. This is a short guide on how to setup the Atom IDE for ROS developers.
First, get Atom and Cquery up and running
- Build and install cquery according to the instructions on its Github Wiki.
- Install the Atom packages atom-ide-ui and ide-cquery
- In the ide-cquery settings of Atom, make sure the correct Cquery path is set (according to your installation)
Now in your own code base, do the following:
- Compile your catkin packages with
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON. This will create a
compile_commands.jsonfile for each package in its respective build folder.
- Then collect all
compile_commands.jsonfiles into a single file by executing in the catkin workspace
cat ./build/**/compile_commands.json > compile_commands.json && sed -i -e ':a;N;$!ba;s/\]\n*\[/,/g' compile_commands.json
compile_commands.jsonfile must be delimited by a pair of square brackets, the second part of this command is supposed to remove pairs of brackets that we no longer need after concatenating multiple files.
- So far so good, but this does not work for header-only libraries, because no compile commands were generated for them, since there is nothing to compile.
To include also the headers into the json file, run
compdb -p . list > compile_commands.json.extended
- Finally, create a symlink in your project root of the Atom workspace
ln -s /path/to/compile_commands.json.extended compile_commands.json
After restarting Atom, Cquery should now be able to find this file and start building the database.
On startup, cquery will take some time to load the index into memory. Expect high CPU usage during this time. Afterwards, you should be able to hover over variables and functions and jump around in your code.
Hope it helps, happy coding!