Robotics StackExchange | Archived questions

How to run a cpp file in ROS?

I'm currently using the 'apriltagsros" package: http://wiki.ros.org/apriltags_ros

I'm trying to run the apriltagsdetectornode.cpp file to detect an april tag setup in the Gazebo environment. We're using the PX4 for running flights, and I'm having trouble actually runinnf the file. I keep getting errors of 'gcc: error: apriltagdetectornode: No such file or directory'. Any help would be appreciated.

Asked by vnovelo on 2019-04-23 12:57:39 UTC

Comments

I keep getting errors of 'gcc: error: april_tag_detector_node: No such file or directory'.

that's a compiler error, while your question title and part of the question text asks how to "run a cpp file". Those are two different things.

.cpp files are first compiled. The objects then linked. The resulting binary is then executed (or "run").

Could you please update your question to make it clear where the actual problems are?

Asked by gvdhoorn on 2019-04-23 14:07:50 UTC

Answers

@vnovelo, please provide more information. I will suggest some solutions, but none of them may work since you didn't give too much information.

WARNING! According to apriltags_ros package, it only supports ROS Indigo distribution. If you are trying to use this package with ROS Kinetic, it may not be possible and the error might be caused by this!

1-) After installing april_tags_ros package did you build it with catkin_make? All you need to is going catkin_ws directory and typing catkin_make.

2-) Did you source the setup.bash file? Try:

source catkin_ws/source/devel.setup.bash

You need to source in each terminal you call ros nodes. If you don't want to source everytime, add above command to .bashrc

3-) If you did previous two steps, and still couldn't get the node working, open CMakeLists.txt file inside of april_tags_ros package and check the lines: add_executable(apriltags_ros src/apriltags_ros/april_tag_detector_node.cpp ) If it doesn't exist, add this line. However, probably it exists and your problem is caused by the reason in WARNING! part.

I hope this helps. Don't forget to mark this comment as answer!

Asked by samialperen on 2019-04-25 05:51:47 UTC

Comments

After installing april_tags_ros package did you build it with catkin_make? All you need to is going catkin_ws directory and typing catkin_make.

No, you need a little more than that. See #q252478 for an example workflow.

Asked by gvdhoorn on 2019-04-25 06:04:34 UTC

@gvdhoorn, I assumed he is downloaded the package into catkin_ws/src directory. Yet, you are definitely right! In any case, we need more information to understand the situation better.

Asked by samialperen on 2019-04-25 06:19:04 UTC