Question about how Ros2 builds packages [closed]
I am re-writing a ros1 package for ros2 and had a question about how ros2 builds/compiles. I know that in c++ when you compile your code is combined into one file based upon your codes links, dependencies, etc. Does ROS2 work the same? The reason I ask is that I have about 2k lines of code broken up into six .cpp (servo driver, ik, ik algorithm, gait, control all under a node in the controller cpp). So I guess what I'm trying to ask is do I write the code as if it's one big file as far as pubs/subs are concerned and then the build/compile phase will put it all where it needs to go?
There's no magic here. "ROS2" doesn't do anything special. What happens is that Colcon essentially just runs CMake, which will run
make
, which will call GCC to compile and link your binary.This is the same process with or without Colcon. But without it, it would be you, manually running CMake, which then runs
make
, etc, etc.So if you know how this works with plain CMake. You know how it works "in ROS2" (which is not really something you can say, as there's nothing there which is different).