How are nodes run?
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?
Asked by mun on 2019-09-22 08:46:17 UTC
Answers
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 calledorb_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 calledorb_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.
Asked by gvdhoorn on 2019-09-22 08:48:33 UTC
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
.
Asked by mun on 2019-09-22 09:22:52 UTC
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.
Asked by gvdhoorn on 2019-09-22 10:33:03 UTC
Comments