Problems with executables

hi everybody,

I´m working on rosbot 2.0 for my final work degree in industrial engineering, everything was ok following the tutorials on the web but recently I´ve found a problem that I can´t solve.

When I create executables (.cpp) and I add them in the package previously created in the folder of src, like on the node example, and I execute the order catkin make everything seems ok, it compiles and it seems that the new node is recognized, the problem is that when I try to execute the new node the system told me that he can´t find anything executable with this name.

I ´ve followed all the steps explained on the tutorial of creating nodes, I´ve modified the Cmakelist.txt also but I don´t know how it works, maybe the problem is here but I don´t even know. Does anyone knows something about it?

My question is, when in the tutorial they ask about creating a new node for something like the SLAM navigation system, do I have to create a new package also? or I can work with the previous package and add nodes in the src folder? and then, what do I have to modify exactly on the Cmakelist to make a .cpp executable for the system? (libraries, uncomment lines, commands…)

I hope you can help me!

thank you so much!

JUAN MANUEL LEÓN MUÑOZ

HI Juan,
I also saw your mail, but to make it more clear i will only answer here, if you want to communicate thru mails let me know :slight_smile: . Can I ask you to send me your compressed /src folder and also CMakeLists.txt it would help me to find the problem.

Best regards,
Karol Konkol
Husarion team

1 Like

yes karol, where could I send you? by mail or I post it here or what?

drive_controller.cpp (927 Bytes)
action_controller.cpp (1.8 KB)

sorry but I send you the complete folder by mail because the system don´t let me upload it here.

1 Like

Hi,
I’ve managed to fix it. There was a problem with paths to package. And also I commented part of your code (there are some errors) as it’s not the problem we are trying to solve I hope you don’t mind :slight_smile: .
CMakeLists.txt:

cmake_minimum_required(VERSION 3.0.2)
project(drive_controller)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
  roscpp
)

catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES drive_controller
#  CATKIN_DEPENDS roscpp
#  DEPENDS system_lib
)

include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)

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

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

drive_controller_node.cpp

#include <ros/ros.h>
#include <geometry_msgs/PoseStamped.h>

void pose_callback(const geometry_msgs::PoseStampedPtr &pose){
   std::cout<<"working"<<std::endl;
   return;
}

int main(int argc, char **argv)
{
   ros::init(argc, argv, "drive_controller");
   ros::NodeHandle n("~");
   ros::Subscriber pose_sub = n.subscribe("/pose", 1, pose_callback);
   ros::Rate loop_rate(100);
   while (ros::ok())
   {
      ros::spinOnce();
      loop_rate.sleep();
   }
}

thank you so much, your attention has been really helpful, for any other problem I will contact you again,
have a good day! :slight_smile:

Hi Mss Karol another time, the node code that you just send me is different that the one on the slam navigation tutorial from the web.

It has differences in the transformation function and similar things and when I try to see the transformation in rviz it doesn´t work, it sais that it´s unable to transform any position, so I´ve tried to fix it adding the same code as it appears on the tutorial but when I try to compile it the system detects an error and give the next message:

“CMakeFiles/drive_controller_node.dir/src/drive_controller_node.cpp.o: In function pose_callback(boost::shared_ptr<geometry_msgs::PoseStamped_<std::allocator<void> > > const&)':drive_controller_node.cpp:(.text+0x58): undefined reference to tf::TransformBroadcaster::TransformBroadcaster()'drive_controller_node.cpp:(.text+0x1ae): undefined reference to `tf::TransformBroadcaster::sendTransform(tf::StampedTransform const&)'collect2: error: ld returned 1 exit statusdrive_controller/CMakeFiles/drive_controller_node.dir/build.make:112: recipe for target ‘/home/husarion/ros_workspace/devel/lib/drive_controller/drive_controller_node’ failedmake[2]: *** [/home/husarion/ros_workspace/devel/lib/drive_controller/drive_controller_node] Error 1CMakeFiles/Makefile2:669: recipe for target ‘drive_controller/CMakeFiles/drive_controller_node.dir/all’ failedmake[1]: *** [drive_controller/CMakeFiles/drive_controller_node.dir/all] Error 2Makefile:140: recipe for target ‘all’ failedmake: *** [all] Error 2Invoking “make -j4 -l4” failed”

I hope you can help me.

thank you again!

Hi,
I will deal with this error in a moment. I know it is not your fault, it makes me laugh actually ;), but in my country Karol is a male name. So i would stick to the Mr instead of Miss if I may.

Best regards
Karol Konkol

Hi,
Could you send me the code that produced this error and CMakeLists like last time ? Or is it the same code as last time ?
Best regards
Karol Konkol

1 Like

hi,
First of all I’m so sorry, I don’t really want to offend you Karol. I hope you can forgive me.

actually I´ve already solve the problem we have been talking about, but I’ve adavnced and I’ ve found a new one, I’m trying to learn how to explore unknown spaces automatically, actually I have followed all the steps from the tutorial on the web I include the configuration file and I create the launch file also, the problem is that when I try to run the launch file the explore_lite node can´t run and I don´t know why.

the message that appears is this one:

“ERROR: cannot launch node of type [explore_lite/explore]: explore_lite
ROS path [0]=/opt/ros/melodic/share/ros
ROS path [1]=/home/husarion/ros_workspace/src
ROS path [2]=/home/husarion/husarion_ws/src
ROS path [3]=/opt/ros/melodic/share”

I will send you by mail the launch and the configuration file, I don´t know what could happen.

I hope you can help me.

Sorry again for my mistake.

Hope you have a great day!!

Hi,
We are sorry for that one because as it turned out in melodic image explore_lite package is not installed. We will change it in the future image. What you can do right now is install it manually. It looks like this:

sudo apt-get install ros-melodic-<package> #you can use tab when typing package it will help by showing all available packages

in this case you should type

sudo apt-get install ros-melodic-explore-lite

If you want to check if you have particular package you have to look to ROS path[0] from error. I did like that:

ls -R /opt/ros/melodic/share | grep explore

I’m not sure if it’s correct way to do this but it works for me

Best regards,
Karol Konkol
Husarion Team

hi Karol,
I hope everything goes right, I write you because I’am interested in working with rviz using the Lidar sensor and the rgbd camera of my ROSBot2.0, I’ve been searching some examples but I can´t achieve my target, do you the way to do it?

than you so much.

Juanma

Hi Jaunma,
I’m sorry for so late response. If you still need support could you tell me what is your target?

Best regards,
Karol Konkol
Husarion Team