ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
![]() | 1 | initial version |
I ran your code and found no issues... (ubuntu 16.04 with ROS kinetic), however you are not publishing your CMakeLists.txt neither your package.xml files. Here are mine for reference:
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(hello_world)
## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
find_package(catkin REQUIRED
COMPONENTS
roscpp
)
catkin_package(
CATKIN_DEPENDS
)
add_executable(hello_world ros/src/hello_world.cpp)
target_link_libraries(hello_world ${catkin_LIBRARIES})
package.xml
<?xml version="1.0"?>
<package>
<name>hello_world</name>
<version>1.0.0</version>
<description>
hello world tutorial
</description>
<license>GPLv3</license>
<author email="olima@isr.tecnico.ulisboa.pt">Oscar Lima</author>
<maintainer email="olima@isr.tecnico.ulisboa.pt">Oscar Lima</maintainer>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
</package>
Compile your code
catkin build --this
Very important: source your workspace again after having compiled
source ~/my_catkin_ws/devel/setup.bash
Run the code
roscore
rosrun hello_world hello_world
You should now be able to see the desired output
[ INFO] [/hello_ros]: HELLO_ROS