1. Introduction:

The Robot Operating System (ROS) is a flexible framework for writing robot software. It is a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms. ROS does not include programming editor.  It will be ideal and convenient if there is IDE environment for ROS package development. This guide introduces NetBeans IDE as development and build platform on top of ROS catkin building system for developing ROS package in C++ language.  Hopefully, with a friendly IDE developers can program ROS packages more efficiency.

To follow the instructions you need to install NetBeans 8.2 with C++ plugin. Since Netbeans is Java based IDE you need to install Java SE 8 (JDK 9 is not compatible) as well If you don't have it. The ROS version in this article is Kinetic Kame which is primarily targeted at the Ubuntu 16.04. This implicates we exploit Netbeans to develop catkin-based packages. To try this tutorial ROS indigo must be setup completely. Details of ROS installation can be found here.the

ROS, Netbeans and Java SDK installation and setup could be quite a burden and time consuming.  We compile a VirtualBox virtual machine contains everything.  So before you decide to apply this solution to your own computer. You can use it to practice ROS and materials described here.  As it is for learning purpose, you should use it strictly in private network and without given access from the Internet.  The virtual machine can be downloaded here.  After download, runs VirtualBox and selects the File menu and choose Import Appliance to integrate it to your VirtualBox run-time.

2 Writing ROS Package:

We describe how to create a NetBeans C++ project for writing ROS package in this section.

2.1. Creating Catkin Working Space 

A catkin workspace is a folder in any name where you modify, build, and install catkin ROS packages. To create a catkin working space is easy, do

$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make

Then, edits "~/.bashrc"  and appends  "source ~/catkin_ws/devel/setup.bash"  

Details about creating catkin working space can be found here.

2.2 New a C++ Project

Runs NetBeans IDE by clicking the NetBeans icon in GNOME desktop application menu.  

 Clicks File->New Project, selects C++ in categories dialog box and Project with Existing Sources in Projects dialog box.
 Selects the catkin working space folder in step 2




Stating the project clean command as [devel/env.sh catkin_make clean],  and project build command as [devel/env.sh catkin_make].





 Selects the folder where you want to put Netbeans project files as shown in step 3. It is different to the catkin working space folder.


2.3 Writing Your Code

Before you start to write the code, it is highly recommend if you have NetBeans code assistant for ROS setup properly, to do so see section 3 C/C++ Code Assistance at the bottom of the page.

Now, create catkin package in src folder under catkin_ws  using "catkin_create_pkg" command.

$ catkin_create_pkg beginner_tutorials std_msgs roscpp

If the newly created package does not appear in project source tree, just close the project and re-open it again.  

Here is a beginner tutorial for writing ROS nodes.  You can use the source codes to do the exercise. Part 1 of the tutorial describes writing publisher node which is the talker. Part 2 describes writing the subscriber node which is listener. Part 3 describes to modify the CMakeList.txt in order to get the talker and listener nodes being built/compiled properly. So that they can be found and run by using rosrun command.  

To open a new C++ source file navigates to the project source tree, right click the src tree node under the beginner_tutorials package tree node then New and select C++ Source File with given name. For this exercise, you will name it talker.cpp and listen.cpp.

To build the nodes in the package (the CMakeList.txt must be modified properly), select Run menu on the top menu bar and then Build Project. This step will call catkin building scripts. If success , failure or errors will be shown inside Output window tab. 


2.4. Run ROS Nodes of the beginner_tutorials Package

To demo how to run a ROS node, we use the Writing a Simple Publisher and Subscriber exercise(you did it in section 2.3) which writes two simple ROS nodes - talker and listener. 

 To run talker and listener ROS nodes. , firstly to start the "roscore".


3. C/C++ Code Assistance:

NetBeans code assistance is a set of IDE features that help you navigate and edit source code. Before you write your ROS package, it will be helpful and convenience if you have code assistance to look after  the C/C++ header files of the ROS distribution. It allows you easily look up ROS API definitions from the C/C++ header files via  #include directives. Following figures are steps to set it up.

Clicks Tools->Options