Service Robotics Research Center
at Ulm University of Applied Sciences

User Tools

Site Tools


Developing Your First Software Component

This Tutorial will guide you Model, Develop and Compile your first Component. It will guide you to develop ComponentLaserObstacleAvoidNew Component by using readily available Domain Models.

This tutorial is also available as video tutorial.

Basic Information

Level Beginner
Role System builder, but also other roles while browsing through the system's building blocks
Assumptions Having completed the tutorial A More Complex System using the Flexible Navigation Stack
System Requirements Virtual Machine Image Installed, see ready-to-go virtual machine
You will learn How to model a Component
How to choose input/output ports and services used/provided by Component
How to implement a Component


This tutorial explains how a component supplier models and implements a software component for simple obstacle avoidance of a wheeled robot. It shows all the necessary steps to reproduce this task using the SmartMDSD Toolchain (v3), an Integrated Development Environment for system composition in a robotics software ecosystem. The video first models the component by composing already existing domain models (service definitions) to define the component hull (input/output ports). It then implements a simple algorithm for obstacle avoidance.

The service definitions have been previously developed by domain experts for navigation (Ecosystem Tier 2 models, see RobMoSys Wiki: Ecosystem Organization). The domain models define the interfaces of the obstacle avoidance component at a service level (service for laser sensor data, service for motion commands). The result is a RobMoSys-conformant component. The SmartMDSD Toolchain generates executable code from the model and the video shows how to implement a simple algorithm for obstacle avoidance.

The obstacle avoidance component is part of the flexible navigation stack as illustrated in the figure below.

Outlook: The next tutorial in this series of tutorials will show how to use this software component and others to compose a system.

The component that is being developed in this tutorial can also be found in the code repository.

Modeling the component

To test it continue with the next tutorial which cover the Composition of this Component in to a system. We first create a new component project for our component named “ComponentLaserObstacleAvoidNew”.

Step 1: Select the New Project → Component Project (Tier 3)

Step 2: Give a name and location to your project. Use $SMART_ROOT_ACE/repos/ComponentRepository/ as default path. Name it ComponentLaserObstacleAvoidNew.

Step 3: You will be able to see the project is created with empty Component

Step 4: Drag ImportDomainModels on the screen which will pop up a window for Domain Object Import. In the list, select CommBasicObjects and CommNavigationObjects which we will use in your component.

Step 5: Drag InputPort on the Component, which will list the available services, then select the ForkingServiceDefinitite LaserService

Step 6: You will be able to see Input Port: LaserServiceIn on the component. Now, Drag Activity on the component and name it RobotTask. You can implement business logic within an activity. It can uses data from input port or provide data to the output port.

Step 7: Drag OutputPort on the component. This will suggest the services which component may be providing to the other components. Here it is important to know the correct service which our component will be providing. Select JoiningServiceDefinition NavigationVelocityService.

Step 8: Automatically it will ask to select the Activity which will be responsible for providing the data to the output port under the name of NavigationVelocityService. Basically, we want the RobotTask to provide the Navigation Velocity to the other components. So, select the RobotTask to link the service with the activity.

Step 9: You can see, there is a link between the RobotTask and Output port.

Step 10: As you can observe, the LaserServiceIn is not connected to any task. As it is the decision of Component Designer (You) if and how you want to use the incomming service data. We need the LaserData as input to calculate new navigation velocities for obstacle avoidance. So, let's create a link between LaserServiceIn and RobotTask. Using MandetoryInputLink draw the link from LaserServiceIn to RobotTask. RobotTask now can use the LaserData and using that can provide Navigation Velocity.

Step 11: Let's nicely arrange our component model. You are now done with Modeling your first Component.

Step 12: The component task should run with some frequency again and again, So we will add a periodic timer which will trigger the task to get executed with the frequency which we set in the properties. So, let's add a periodic time and keep the default frequency of 1.0.

Implement the Business Logic

Now, let's implement the business logic of LaserObstacleAvoid that actually takes laser scans and calculates navigation commands. We need to have one .hh files as a supportive files for this components which should be created in Smartsoft/src folder. Create the file SimpleAvoid.hh. You may copy-paste it from the repository or develop it on your own as an exercise.

To use the algorithm for obstacle avoidance, we need to implement the RobotTask::on_execute() method. This function is called during execution of our activity. Modify your according to:

#include "SimpleAvoid.hh"
int RobotTask::on_execute()
	Smart::StatusCode status;
		    CommBasicObjects::CommMobileLaserScan laserServiceInObject;
		    status = this->laserServiceInGetUpdate(laserServiceInObject);
		    if(status != Smart::SMART_OK)
		        std::cerr << "Getting laser scan failed: " << status << std::endl;
		        return 0;
		    std::cout << "Done with Receiving the Laser,  Now Sending Velocity !" << std::endl;
		    CommBasicObjects::CommNavigationVelocity comNavVel;
		    Smart::StatusCode status_nav;
		    double velocity =0;//= RandDouble::fRand(0.0,0.02);
		    double turnrate =0;//= RandDouble::fRand(0.0,0.02);
		    comNavVel.set_vX(velocity*0.5, 0.001);
		    comNavVel.set_omega(turnrate * 0.0575);
		    std::cout << "Velocity : " << velocity	<< std::endl;
		    std::cout << "turnrate :" << turnrate	<< std::endl;
		    if (velocity > 500)
		    status_nav = this->navigationVelocityServiceOutPut(comNavVel);
		    if(status_nav != Smart::SMART_OK)
		        std::cerr << status << std::endl;
		        std::cout << "Some Error in the Conection as status is not ok " << std::endl;
		    	std::cout << "Updating Velocity " << comNavVel << std::endl;
		    return 0;

Compile the Component

Now you are done with implementing a component. You need to compile it before you can use it.

  • Right-click on your component project → Smartsoft Build Tools → CMake
  • Right-click on your component project → Smartsoft Build Tools → makeall

You have now successfully completed the Development of ComponentLaserObstacleAvoid.

What do do next?

You can proceed with next tutorial Developing Your First System: Composing Software Components to see how to compose your component to a system and running it.


tutorials/develop-your-first-component/start.txt · Last modified: 2019/02/05 17:17 by Dennis Stampfer