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

How are nodes run?

asked 2019-09-22 08:46:17 -0500

mun gravatar image

updated 2019-09-22 08:51:09 -0500

gvdhoorn gravatar image

Hi

I'm looking at some ROS code from here which is part of a SLAM package. I wonder how the functions in this file are called when there's no mention of RGBDNode anywhere outside that file. Anyone know how int main() in that file is run?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-09-22 08:48:33 -0500

gvdhoorn gravatar image

updated 2019-09-22 11:23:51 -0500

How are nodes run?

A node is "just" a regular program that happens to use the ROS middleware for most of its input, output and control flow / coordination (ie: callbacks, timers, etc).

So nodes are run as any other program: by starting them from a shell (manually) or from another program (ie: roslaunch).

I wonder how the functions in this file are called when there's no mention of RGBDNode anywhere outside that file.

RGBDNode appears to be a class defined in appliedAI-Initiative/orb_slam_2_ros/ros/include/RGBDNode.h.

Anyone know how int main() in that file is run?

I'm not sure I follow: can you explain what exactly is unclear?


Edit:

The node is meant to be run using, e.g.,

roslaunch orb_slam2_ros orb_slam2_r200_rgbd.launch

but orb_slam2_r200_rgbd.launch calls ths node using

<node name="orb_slam2_rgbd" pkg="orb_slam2_ros" type="orb_slam2_ros_rgbd" output="screen">

If my understanding is correct, it references to a node called orb_slam2_rgbd in a file called orb_slam2_ros_rgbd.

No, the node line looks for a binary called orb_slam2_ros_rgbd and gives the ROS node (ie: the running instance of that binary) the name orb_slam2_rgbd. See also the roslaunch/XML/node - Attributes page.

Binaries (ie: programs, nodes, librarie) can be made up of many source files. In the case of orb_slam2_ros_rgbd, the node comprises two source files which in the end get combined into a single binary. See here for the add_executable(..) call in the project's CMakeLists.txt which configures all of this:

add_executable (${PROJECT_NAME}_rgbd
  ros/src/RGBDNode.cc
  ros/src/Node.cc
)

But there isn't a file called orb_slam2_ros_rgbd or a class called orb_slam2_rgbd.

I hope it is now clear that there doesn't need to be any source file with that name: as long as there is a binary with that name that roslaunch can find (and there is, as it gets created as a result of the build).

There is no one-to-one correspondence necessarily between classes/files and binaries.

edit flag offensive delete link more

Comments

The node is meant to be run using, e.g.,

roslaunch orb_slam2_ros orb_slam2_r200_rgbd.launch

but orb_slam2_r200_rgbd.launch calls ths node using

<node name="orb_slam2_rgbd" pkg="orb_slam2_ros" type="orb_slam2_ros_rgbd" output="screen">

If my understanding is correct, it references to a node called orb_slam2_rgbd in a file called orb_slam2_ros_rgbd. But there isn't a file called orb_slam2_ros_rgbd or a class called orb_slam2_rgbd.

mun gravatar image mun  ( 2019-09-22 09:22:52 -0500 )edit

Please note that this is not necessarily a question about ROS: any binary can be made up of many different source files and libraries. And there is almost never a requirement for a 1-to-1 correspondence between source files and eventual name of the binary.

gvdhoorn gravatar image gvdhoorn  ( 2019-09-22 10:33:03 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-09-22 08:46:17 -0500

Seen: 250 times

Last updated: Sep 22 '19