-
Notifications
You must be signed in to change notification settings - Fork 9
Installing and Configuring CLion
For working with this project, CLion is our recommended IDE and the one used by the developers. The free community edition has all the tools needed to contribute to this project.
You are welcome to use any IDE you want, but we won't be available for troubleshooting if you have any problems with it. If you are convinced another IDE is superior in any way, feel free to write an installation guide for that IDE.
- Download CLion and install.
- Install compiler, this option is only needed with Windows
- Open CLion.
-
ctrl + alt + s
(open settings). - Search for:
toolchains
. - Select "MinGW" as environment.
- This is probably not installed, download and install this, restart CLion after the installation.
- If the path is not correct set this path to MinGW (this probably looks like
C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32
)
If there are no errors and the run is successful, everything is set-up correctly!
Launch CLion, and create a new project by clicking on VCS--> Check out from Version Control
, and select Git
.
If you want to create a Pull Request, please fork the repository at https://github.com/project-march/march-iv
and clone your own fork. Run in the march_ws
directory of the project the following command in your terminal
catkin_make
First make sure that you source catkin correctly, with the following command
source /opt/ros/kinetic/setup.bash
In order for catkin to know where your files are located, you have to provide a source. You do this with source ~/path/to/the/repo/march-iv/march_ws/devel/setup.bash
.
This needs to be done for every new terminal you start, so it is advised to add this command to your ~/.bashrc
, which is ran every time a new terminal is started.
Unfortunately, this is also needed before you launch CLion. We provide a quick launchscript so you don't have to do it manually:
source ~/path/to/the/repo/march-iv/march_ws/devel/setup.bash
~/path/to/clion/clion-2018.2.4/bin/clion.sh
Put this in a CLion.bash
file and make it executable with sudo chmod +x CLion.bash
. After this you can make it double-clickable.
In CLion open run configurations
. Create 2 run configurations, one to run ROS and the other one to run tests.
- Click the
+
and create anapplication
. Set target and executable toExoskeleton
- Click the
+
and create aGoogle Test
. Set target tomarch_main-test
It is advised to install the Hatchery Plugin as it has ROS support.
You can install Hatchery directly through the IDE, via File | Settings | Plugins | Search for "hatchery"
.
Setting up a shortcut for auto-formatting code will save time when developing the exoskeleton. The styleguide check is mandatory for passing the build process.
- Install clang-format with
sudo apt-get install -y clang-format-3.8
. - Go to
File->Settings->Preferences->Plugins
and search forClangFormatIJ
. Install this plugin. It installs the context menu to invoke locally installed clang-format for a file or for a selection. - Go to
Tools->clang-format
and change theclang-format-binary
toclang-format-3.8
. - The path can stay empty.
- Go to
Keymap->Plugins->ClangFormatIJ->Reformat Code with clang-format
and setup a keyboard shortcut.
Your code is now properly formatted when you trigger your shortcut!
A copyright header in each file is mandatory to pass the build process.
Settings -> Editor -> File and Code Templates
- Select Scheme:
Project
- Select
C++ Class Header`` under the
files` tab - Replace the content with the following code:
#parse("C File Header.h")
#[[#ifndef]]# ${INCLUDE_GUARD}
#[[#define]]# ${INCLUDE_GUARD}
${NAMESPACES_OPEN}
class ${NAME} {
};
${NAMESPACES_CLOSE}
#[[#endif]]# // ${INCLUDE_GUARD}
- Click
Apply
- Go to the
Includes
tab and select theC File Header
- Replace content with the following code:
#if ($HEADER_COMMENTS)
// Copyright $YEAR Project March.
#end
-
Apply
and clickOK
- Make sure the CMake is loaded (open the top level CMake and click the warning if it's there).
- Mark the
march_state_machine/src
asProject Sources and Headers
. The issue should be resolved now and CLion should find its imports correctly.
change your cmake_build location to the build location used by ROS with the following steps:
- Go to
File --> Settings --> Build, Execution, Deployment --> CMake
- Set the generation Path to
~/<link/to/the/repo>/march-iv/march_ws/devel
and apply - Add the CMake option
-DCATKIN_DEVEL_PREFIX:PATH=~/<link/to/the/repo>/march-iv/march_ws/devel
- Finally you should right-click on your top level CMakeList.txt file in CLion and select "Reload CMake Project"
Source: https://answers.ros.org/question/284786/setup-clion-with-ros/