Saturday, April 7, 2012

Eclipse with ROS

If you want to write scripts for ROS using Eclipse editor and project settings, you can do so by following some ordered steps.
  1. Create a ROS package  # Create a ros package in your ros-workspace
  2. roscd package_name     # Goto the directory where you created your package 
  3. make eclipse-project      # This is an important step to tell eclipse that we will be using our package in eclipse as a project
  4. Goto Import ->package_directory->apply
  5. Add the executable name to CMakelists.txt file
  6. rosmake package_name
  7. Goto Run Configurations {give path to your binary} -> Apply
  8. Run
If you get an error while doing step 3, try the following

For roscpp, your project needs to follow the standard package template, where the Makefile looks like:
 include $(shell rospack find mk)/cmake.mk
And nothing more (i.e. the rest of your bulid is configured via CMake). The above cmake.mk file declares the eclipse-project target.
If you don't wish to use the cmake.mk file, then you can grab the necessary Makefile rule from mk/cmake.mk and adapt it to your needs.

Enjoy your project in eclipse now :)

Creating new python project
Make sure you first create a source folder in the project by right clicking on your project name and then New-> Source folder.
The source folder created by the rospkg does not work.
Then go on to add the new file {pydev module}.
By default the project name will be weird like containing '@' symbols so make sure to renaming your project to something nice before you try running it.

Passing Runtime arguments in Eclipse-Python
import sys
sys.argv = raw_input('Enter command line arguments: ').split()
 

No comments:

Post a Comment