File tree Expand file tree Collapse file tree
docs/10-prerequisities/25-ros2/50-ros1-ros2-patterns Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ title : ROS2 CmakeLists
3+ pagination_label : ROS2 CmakeLists
4+ description : ROS2 CmakeLists
5+ ---
6+
7+ # ROS2 CmakeLists
8+
9+ ## ` include_directories() `
10+
11+ In ROS2 you have to explicitly list all the packages you are including from:
12+ ```
13+ ...
14+ include_directories(
15+ ...
16+ ${mrs_lib_INCLUDE_DIRS}
17+ ${<some_other_package>_INCLUDE_DIRS}
18+ }
19+ ```
20+
21+ ## exporting nodeletes (components)
22+
23+ Components are declared in CmakeLists, instead of package.xml (like it was in ROS1):
24+ ```
25+ rclcpp_components_register_nodes(MrsMultirotorSimulator_Simulator PLUGIN "mrs_multirotor_simulator::MultirotorSimulator" EXECUTABLE MrsMultirotorSimulator_Simulator)
26+ ```
27+
28+ ## exporting pluginlib plugins
29+
30+ You need to provide path to the ` .xml ` file with plugin description in CmakeLists, instaed of in ` package.xml ` like it was in ROS1:
31+ ```
32+ # <package of the base class>, <relative path to the xml>
33+ pluginlib_export_plugin_description_file(mrs_uav_hw_api plugins.xml)
34+ ```
Original file line number Diff line number Diff line change 11---
2- title : C++ componentts
3- pagination_label : C++ componentes
4- description : C++ components
2+ title : C++ components (nodelets)
3+ pagination_label : C++ componentes (nodelets)
4+ description : C++ components (nodelets)
55---
6+
7+ # ` onInit() `
8+
9+ There is no onInit() method like in ROS1.
10+ Now, you need to implement the constructor of ` rclcpp::Node() ` .
11+
12+ However, you cannot obtain a pointer to the node in the constructor (while it is still running).
13+ Therefore, we create our own ` initialize() ` method as a one-shot timer that contain most of the init routines.
14+ We can use the constructor solely for starting the timer.
You can’t perform that action at this time.
0 commit comments