Generate ROS or ROS 2 Packages for Model Reference Hierarchy in Simulink
Model references in Simulink® enable modular development and code reuse in large components. In robotics and autonomous systems applications, using a model reference hierarchy facilitates seamless integration during parallel development efforts for perception, motion-planning, and control algorithms. During code generation and deployment of Simulink model reference hierarchies as ROS or ROS 2 packages, you can package the code in one of these ways:
Standalone top-level packages
Subdirectories under the same top level package
This table illustrates the generated source code, and library hierarchy along with the code artifacts, for the two package options on a Linux® device:
Model Reference Package Option | Generated Source Code Hierarchy | Generated Library Hierarchy | Generated Code Artifacts |
---|---|---|---|
Standalone top-level package |
|
| Multiple TAR archives
|
Subdirectory under same top-level package |
|
| Single TAR archive
|
To configure generated ROS or ROS 2 packages for a model reference hierarchy, follow these steps:
In the top-level model containing the model reference hierarchy, select the Apps tab of the Simulink Toolstrip and, in the Apps gallery, select Robot Operating System (ROS).
In the dialog box, select a value for ROS Network to configure the model for ROS or ROS 2 node generation. Then, in the ROS tab of the Simulink Toolstrip, specify your network parameters.
In the Prepare section, select Hardware Settings. This opens the Hardware Implementation section of the model configuration parameters.
Under Hardware board settings, select Target hardware resources > Build options.
Set Generate model reference code as to
Standalone package
orSub-directory in same package
to specify whether to generate the model reference code as a standalone package or as a subdirectory in the same top-level package.
For more information about using model references in Simulink, see Model Reference Behavior and Capabilities (Simulink).