ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ERROR: cannot launch node of type [...]: can't locate node [...] in package [...]

asked 2020-01-19 12:47:34 -0600

updated 2020-01-19 12:48:26 -0600

This system is running Ubuntu 16.04 64bit with Kinetic. The project builds properly with catkin_make; and right after source devel/setup.bash is run in the same terminal. As soon as the project is launched via roslaunch jimmy_lidar_motor_control lidar_motor_control.launch the following error appears:

ERROR: cannot launch node of type [jimmy_lidar_motor_control/lidar_motor_control]: can't locate node [lidar_motor_control] in package [jimmy_lidar_motor_control]

The project structure is pretty standard:

└── src
    ├── jimmycpp
    │   ├── //unrelated files (I think)
    │   ├── //unrelated files (I think)
    │   └── //unrelated files (I think)
    └── jimmy_lidar_motor_control
        ├── CMakeLists.txt
        ├── include
        │   └── jimmy_lidar_motor_control
        │       └── lidar_motor_control.h
        ├── launch
        │   └── lidar_motor_control.launch
        ├── msg
        │   └── motion_command_to_execute.msg
        ├── package.xml
        └── src
            └── lidar_motor_control.cpp

the launch file is very simple:

<?xml version="1.0" encoding="UTF-8"?>
    <node name="jimmy_lidar_motor_control_mynode" 

To figure out what files ROS can "see" i ran rosrun command and pressed TAB-TAB, and all the files in the directory are visible:

mo@Home-W530:~/Desktop/workspace$ rosrun jimmy_lidar_motor_control 
CMakeLists.txt                  lidar_motor_control.launch
jimmy_lidar_motor_control_node  motion_command_to_execute.msg
lidar_motor_control.cpp         package.xml

Everything is in C++ so I don't think it's related to file permissions (output of ls -la):

-rwxrwxrwx 1 mo mo 7287 Jan 19 12:32 lidar_motor_control.cpp

All the questions I looked through did not solve my issue:

Here is the CMakeLists.txt in case the issue is there:

# What version of CMake is needed?
cmake_minimum_required(VERSION 2.8.3)


## Compile as C++11, supported in ROS Kinetic and newer

find_package(catkin REQUIRED COMPONENTS

#declare any custom files that I have created

#the custom message I am declaring relies on data types found here
generate_messages(DEPENDENCIES std_msgs )

  INCLUDE_DIRS include
#  LIBRARIES my_robot_base
  CATKIN_DEPENDS roscpp message_runtime
#  DEPENDS system_lib

# Specify locations of header files.
include_directories(include ${catkin_INCLUDE_DIRS})

#  NOTE: executable name and source file name should be the same!!!!
add_executable(${PROJECT_NAME}_node src/lidar_motor_control.cpp)

target_link_libraries(${PROJECT_NAME}_node serial ${catkin_LIBRARIES})

# this line is to be used anytime I am using custom messages. It prevents build 
# errors when I run `catkin_make`. The first argument is the same name as the 
# name of the source file. The second argument is the name of the package plus 
# add “_generate_messages_cpp”. This solution to my problem is described on 
# in section

in case the entire output of roslaunch jimmy_lidar_motor_control lidar_motor_control.launch which causes this problem is useful, here it is:

mo@Home-W530:~/Desktop/workspace$ roslaunch jimmy_lidar_motor_control lidar_motor_control.launch 
... logging to /home/mo/.ros/log/749beb5c-3ae5-11ea-9996-e09d3128cfa4/roslaunch-Home-W530-6823.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://Home-W530:37099/


 * /rosdistro: kinetic
 * /rosversion: 1.12.14

    jimmy_lidar_motor_control_mynode (jimmy_lidar_motor_control/lidar_motor_control)

auto-starting new ...
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-01-19 15:35:12 -0600

updated 2020-01-19 15:46:45 -0600

In your CMakeLists.txt:

add_executable(${PROJECT_NAME}_node src/lidar_motor_control.cpp)

Since your project name is "jimmy_lidar_motor_control", from:


The node is going to be named "jimmy_lidar_motor_control_node", not "lidar_motor_control", which is why it's not found.

Also, not sure where this comes from:

#  NOTE: executable name and source file name should be the same!!!!

But that's totally false and wrong.

edit flag offensive delete link more


@christophebedard Thanks! I reworked the add_executable... line (and everything that followed) and voila, everything worked! About the incorrect comment, thanks for pointing it out. I have a lot to learn, and I appreciate you pointing out a hole in my know-how... Thanks again!

BuilderMike gravatar image BuilderMike  ( 2020-01-19 18:52:02 -0600 )edit

It can be a good practice to give them the same name, but you don't have to. My pleasure!

christophebedard gravatar image christophebedard  ( 2020-01-20 08:59:03 -0600 )edit

"reworked the add_executable... line (and everything that followed)"

what's the rework? please share.

kalkimann gravatar image kalkimann  ( 2021-07-24 10:38:18 -0600 )edit

@kalkimann I'm guessing they changed "lidar_motor_control" to "jimmy_lidar_motor_control_node", or "lidar_motor_control" to "${PROJET_NAME}_node". Just ask another question if these instructions don't apply well to your own situation/issue.

christophebedard gravatar image christophebedard  ( 2021-07-26 09:40:57 -0600 )edit

Question Tools

1 follower


Asked: 2020-01-19 12:47:34 -0600

Seen: 8,686 times

Last updated: Jan 19 '20