-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Here is the documentation for installation of Indigo and Jade.
Here is the documentation for catkin_tools.
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.
I got the C++ code of the first example (Hello World) from this elegant tutorial by Jonathan Bohren.
I borrowed the idea of the second example (Turtlesim) from ROS official tutorial.
The hauppauge ROS package in the third example (Video Pipeline) is created by Simon Leonard