SRRC Wiki

Service Robotics Research Center
at Ulm University of Applied Sciences

User Tools

Site Tools


tutorials:ros:mixed-port-component-ros

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
tutorials:ros:mixed-port-component-ros [2019/02/05 09:43]
Dennis Stampfer [Introduction]
tutorials:ros:mixed-port-component-ros [2019/04/30 15:09]
Alex Lotz [Add a plain ROS port]
Line 29: Line 29:
 ===== Add a plain ROS port ===== ===== Add a plain ROS port =====
  
-The current implementation of the plain ROS ports in a SmartMDSD component is an experimental feature that is only realized as a textual Domain Specific Language (DSL). Graphical modeling of plain ROS ports is on the development roadmap. +For activating ​the ROS feature and for modeling the ROS MixedPortnew model with the file extension ​**.rosinterfacespool** ​needs to be created within a component project. For our example, we will create the following model file:
- +
-For activating ROS feature and for modeling the plain ROS porttwo new model files with the respective ​file extensions ​**.rosinterfacespool** ​and **.componentRosPorts** need to be created within a component project. For our example, we will create the following ​two model files:+
  
   - **joy.rosinterfacespool**:​ this file provides an abstract representation of the available ROS interfaces that can be used in our component (we will select a subset of these interfaces for our component in the next model). This model can be shared between several components.   - **joy.rosinterfacespool**:​ this file provides an abstract representation of the available ROS interfaces that can be used in our component (we will select a subset of these interfaces for our component in the next model). This model can be shared between several components.
-  - **ComponentRosJoystick.componentRosPorts**:​ This is a mapping model where a subset of the available ROS interfaces can be selected and assigned to a specific component. This model is specific to a definite component. 
  
 The content of the **joy.rosinterfacespool** for our example looks as follows: The content of the **joy.rosinterfacespool** for our example looks as follows:
Line 40: Line 37:
 {{ :​tutorials:​ros:​joy.rosinterfacespool.png |}} {{ :​tutorials:​ros:​joy.rosinterfacespool.png |}}
  
-As can be seen, this model specifies two **ROS (topic) subscriber** interfaces, one named **_diagnostics** and the other named **_joy**. We therefore select it as a port of our mixed-port component ​(.componentRosPorts). For our example, we are interested in the **_joy** subscriber interface (that we will select in the followup model). Moreover, the model specifies a **topicName** that is the ROS topic address the subscriber will connect to, and the **type** which specifies the related ROS message type. Both informations are used by the SmartMDSD ROS generator to generate C++ code that integrates the ROS infrastructure with the component'​s internal infrastructure.+As can be seen, this model specifies two **ROS (topic) subscriber** interfaces, one named **_diagnostics** and the other named **_joy**. We therefore select it as a port of our mixed-port component. For our example, we are interested in the **_joy** subscriber interface (that we will select in the followup model). Moreover, the model specifies a **topicName** that is the ROS topic address the subscriber will connect to, and the **type** which specifies the related ROS message type. Both informations are used by the SmartMDSD ROS generator to generate C++ code that integrates the ROS infrastructure with the component'​s internal infrastructure. 
 + 
 +The ROS port can be selected in the component graphical model as follows: 
 + 
 +{{ :​tutorials:​ros:​createrosport.gif |}}
  
-The ROS port-selection ​model then reads as follows:+After saving the model, we can trigger the ROS C++ code generation ​as follows:
  
-{{ :​tutorials:​ros:​componentrosjoystick.componentrosports.png ​|}}+{{ :​tutorials:​ros:​runcodegen.gif |}}
  
-Please note, that this model is used as source for generating the component-internal ROS infrastrucure C++ code. The generated ROS C++ code can be found in a new subfolder named **ROS** within the component project (see on the left of the above screenshot). Here you can see that several helper classes are generated that implement the initialization of the ROS infrastructure (such as the calling of the methods **ros::​init(...)**,​ **ros::​spin()**,​ and **ros::​shutdown**),​ as well as the instantiation of the selected ROS subscriber, in our case the **ros::​Subscriber** named **_joy**. ​+The generated ROS C++ code can be found in a new subfolder named **ROS** within the component project (see on the left of the above screenshot). Here you can see that several helper classes are generated that implement the initialization of the ROS infrastructure (such as the calling of the methods **ros::​init(...)**,​ **ros::​spin()**,​ and **ros::​shutdown**),​ as well as the instantiation of the selected ROS subscriber, in our case the **ros::​Subscriber** named **_joy**. ​
  
 Moreover, a **CMakeLists.txt** file is generated that uses the **ROS catkin** build infrastructure for compiling the ROS related code parts. Please note, that the generated cmake file deviates from the typical ROS cmake files in the sense that the actual creation of the executable is deactivated and is performed instead by the component'​s top-level cmake file (which simply includes the ROS cmake file). Moreover, a **CMakeLists.txt** file is generated that uses the **ROS catkin** build infrastructure for compiling the ROS related code parts. Please note, that the generated cmake file deviates from the typical ROS cmake files in the sense that the actual creation of the executable is deactivated and is performed instead by the component'​s top-level cmake file (which simply includes the ROS cmake file).
tutorials/ros/mixed-port-component-ros.txt · Last modified: 2019/04/30 15:11 by Alex Lotz