ERROR: cannot launch node of type

Issue: cannot launch node of type, Cannot locate node of type



What I’ve done:

  • create a pkg
  • and the following:
cd catkin
catkin_make
source devel/setup.bash
chmod +x thecpp.cpp
rm -rf /home/user/catkin_ws/src/
rm -rf /home/user/catkin_ws/build/
rm -rf /home/user/catkin_ws/devel/
mkdir -p /home/user/catkin_ws/src/
cd /home/user/catkin_ws/
catkin_make
roslaunch thepkg thelaunch

I’ve tried to create the catkin_ws again, the issue remains unsolved.



Launch file:

<launch>
    <node pkg="odom_final" type="odom_cp" name="odom_node" output="screen"></node>
</launch>



cpp:

#include <ros/ros.h>
#include <std_msgs/Int32.h>

void callback(const std_msgs::Int32::ConstPtr &msg) {
    ROS_INFO("%d", msg->data);
}

int main (int argc, char **argv) {
    ros::init(argc, argv, "odom_node");
    ros::NodeHandle nh;
    ros::Subscriber sub = nh.subscribe("counter",1000,callback);
    ros::spin();
    return 0;
}



CMakeLists.txt:

cmake_minimum_required(VERSION 3.0.2)
project(odom_final)

find_package(catkin REQUIRED COMPONENTS
  #nav_msgs
  roscpp
  std_msgs
)

include_directories(
  ${catkin_INCLUDE_DIRS}
)

## Build ##
add_executable(odom_cp src/odom_cp.cpp)
add_dependencies(odom_cp ${odom_cp_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(odom_cp
   ${catkin_LIBRARIES}
)

Hi @RC1 ,

Your file contents seems to be fine.
I also see that you have created the catkin_ws folder again from scratch.

Looking at your commands, you missed the line to source your workspace after 2nd catkin_make.

Try this again by sourcing after catkin_make. Hopefully that should work.

Regards,
Girish

Thanks for the reply. Yes, I’ve also source after the 2nd catkin_make. Not just one file, all files return the same error.


This topic could be closed


I’ve solved the issue:
Step 1: rosrun pkgname nodename to verify the node
Step 2: Confirm that catkin_package(...) & include_directories(...) are placed before any executables
Step 3: catkin_make and source


Thanks for the help, Girish. I’d suggest to add a reminder for 4.2 CMakeLists.txt in the course notebook.

Hi @RC1 ,

Glad that you have solved this issue yourself !

On a side note, I would advise you to not delete the commented lines in the contents of CMakeLists.txt file.
I am assuming that you removed all the commented lines from CMakeLists.txt file and only retained the lines that are necessary - which made you jumble up the positions of the commands in the file.
So, just append or modify the existing contents in the future. DO NOT REMOVE / DELETE ANY LINES. Comment them out if you don’t require those lines.

Regards,
Girish

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.