CLI Command: genesys make
The genesys make command is a powerful scaffolding tool used to create and modify ROS 2 packages, nodes, and components. It automates the tedious process of creating files and editing build configurations.
This guide provides a detailed breakdown of what each make command does behind the scenes.
genesys make pkg
Creates a new ROS 2 package in the src/ directory.
Usage
genesys make pkg <package_name> [options]
<package_name>: The name of the package to create.
Options
--dependencies <dep1> <dep2>...: A list of ROS 2 package dependencies.--with-node: Automatically create an initial node inside the new package.
How It Works
- Language Choice: The command interactively prompts you to choose a language (
PythonorC++). - Package Creation: It runs
ros2 pkg createwith the correct build type (ament_pythonorament_cmake). - Dependencies: If dependencies are provided, they are passed to the
ros2 pkg createcommand, which adds them topackage.xml. - C++ Template: For C++ packages, it overwrites the default
CMakeLists.txtwith a custom Genesys template that includes helper comments and insertion points for future scaffolding commands.
genesys make node
Creates a new ROS 2 node file and registers it in an existing package.
Usage
genesys make node <node_name> --pkg <package_name> [options]
<node_name>: The name for the new node (e.g.,image_processor).--pkg <package_name>: The existing package to add the node to.--component: A flag to create a component instead. This is a shortcut forgenesys make component.
How It Works (Python)
- Node Type: Prompts you to select a node type (Publisher, Subscriber, etc.).
- File Creation: Creates a Python file (e.g.,
src/my_pkg/my_pkg/my_node.py) based on a template for the selected node type. setup.pyModification: Automatically adds the node's entry point tosrc/my_pkg/setup.py. This makes the node an executable that ROS 2 can find.# In setup.py 'console_scripts': [ 'my_node = my_pkg.my_node:main', # This line is added ],- Launch File:
- Creates a
src/my_pkg/launch/my_pkg_launch.pyfile if one doesn't exist. - Adds the new node to this launch file.
- Adds an install rule to
setup.pyto ensure the launch directory is installed.# In setup.py data_files (os.path.join('share', package_name, 'launch'), glob(os.path.join('launch', '*launch.py')))
- Creates a
How It Works (C++)
- Node Type: Prompts you to select a node type.
- File Creation: Creates a header (
.hpp) and source (.cpp) file insrc/my_pkg/include/my_pkg/andsrc/my_pkg/src/respectively, based on templates. The C++ macros are also available as a seperate package in the src of your general workspace, the templates generated for the publisher and subscriber nodes, make use of the macros, however, they can be altered to suit your coding choices!. CMakeLists.txtModification: Adds a new executable target as well as the genesys macros dependencies.# In CMakeLists.txt add_executable(my_node src/my_node.cpp) ament_target_dependencies(my_node rclcpp std_msgs) # Dependencies added here install(TARGETS my_node DESTINATION lib/${PROJECT_NAME})package.xmlModification: Adds any necessary<depend>tags for the node's dependencies as well as the macros.- Launch File: The same launch file generation and installation logic as the Python version is applied, but the install rule is added to
CMakeLists.txt.# In CMakeLists.txt install( DIRECTORY launch DESTINATION share/${PROJECT_NAME} )
genesys make component
Creates a new ROS 2 component (a composable node) and registers it.
Usage
genesys make component <component_name> --pkg <package_name>
<component_name>: The name for the new component.--pkg <package_name>: The existing package to add the component to.
How It Works (C++)
This is the most complex scaffolding operation.
- File Creation: Creates
.hppand.cppfiles for the component class. - Component Registration: Creates or updates a
src/register_components.cppfile. This file uses theRCLCPP_COMPONENTS_REGISTER_NODEmacro to register your component withpluginlib, which is the underlying mechanism for C++ components.// In src/register_components.cpp #include "my_pkg/my_component.hpp" RCLCPP_COMPONENTS_REGISTER_NODE(my_pkg::MyComponent) // This line is added CMakeLists.txtModification:- If this is the first component in the package, it adds a large block to create a shared library named
${PROJECT_NAME}_components. All subsequent components in the package are added to this same library. - It links the component source files and
register_components.cppto this library. - It uses
rclcpp_components_register_nodesto export the component plugins.
- If this is the first component in the package, it adds a large block to create a shared library named
- Plugin XML: Creates or updates
resource/pkg_name_plugin.xml. This XML file is whatpluginlibuses at runtime to find and load your component.<!-- In resource/pkg_name_plugin.xml --> <class type="my_pkg::MyComponent" base_class_type="rclcpp::Node"> <description>...</description> </class> package.xmlModification:- Adds dependencies like
rclcpp_componentsandpluginlib. - Adds an
<export>tag to point to the plugin XML file.
- Adds dependencies like
genesys make launch
Creates a new launch file.
Usage
genesys make launch --pkg <package_name> --name <launch_name>
--pkg <package_name>: The package to create the launch file in.--name <launch_name>: The name of the launch file (defaults tomixed_launch).
Description
By default, this creates a mixed_launch.py file. A mixed launch file is pre-configured with a ComposableNodeContainer, which allows you to efficiently run multiple components in a single process. It also has a section for regular, standalone nodes. This is the preferred launch file type when working with components.
genesys make interface
This command is a placeholder and is not yet implemented. It will print manual instructions for how to create custom message, service, or action files.