Skip to content
Jerry edited this page Oct 4, 2016 · 22 revisions

A Very Brief ROS Tutorial

Installing ROS

Here is the documentation for installation of Indigo and Jade.

Installing Catkin Command Line Tools

Here is the documentation for catkin_tools.

Hellow World

Open a terminal window (ctrl+alt+t). Copy and paste the following codes to your terminal.

# create catkin workspace
cd ~
mkdir -p catkin_ws/src
# initialize catkin workspace
cd ~/catkin_ws
catkin init --workspace .
# create ros package (hello_world)
cd src
catkin create pkg --rosdistro indigo -c roscpp rospy -l BSD -m maintainer_name maintainer_email -a author_name author_email hello_world

Open your favorite editor (eg. Emacs) to edit the package.xml and CMakeLists.txt files if you did something wrong when you created the package or you want to add more information.

Create hello_world_node.cpp file with following contents.

// Include the ROS C++ APIs
#include <ros/ros.h>

// Standard C++ entry point
int main(int argc, char** argv) {
  // Announce this program to the ROS master as a "node" called "hello_world_node"
  ros::init(argc, argv, "hello_world_node");
  // Start the node resource managers (communication, time, etc)
  ros::start();
  // Broadcast a simple log message
  ROS_INFO_STREAM("Hello, world!");
  // Process ROS callbacks until receiving a SIGINT (ctrl-c)
  ros::spin();
  // Stop the node's resources
  ros::shutdown();
  // Exit tranquilly
  return 0;
}

You should have a similar architecture tree as follows.

my_catkin_ws/
└── src
    └── hello_world
        ├── CMakeLists.txt
        ├── include
        │   └── hello_world
        ├── package.xml
        └── src
            └── hello_world_node.cpp

Now you are ready to compile the ROS package by catkin tools using the following command.

catkin build

After compiling the the package, you can launch the ROS node. Please do remember to launch the roscore before executing the node.

rosrun hello_world hello_world_node

By running the node, you should be able to observe the following results in you terminal.

Turtlesim

Video Pipeline

Clone this wiki locally