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 Indigo lgloo which is primarily targeted at the Ubuntu 14.04 LTS (Trusty) release. 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.

Writing Your ROS Package:

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

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. 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/ catkin_make clean],  and project build command as [devel/ 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.


3. Writing Your Code

Now, create catkin package in src folder under catkin_ws  using "catkin_create_pkg" command, and start to write your code in the src folder of the package. 

$ 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 node having simple publisher and subscriber. You can use the codes as the exercise.

To build the package, 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. 


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 which writes two simple ROS nodes - talker and listener.  You can simply take the source code there and put them in src folder of beginner_tutorials package folder and build the project.  

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


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