SRRC Wiki

Service Robotics Research Center
at Ulm University of Applied Sciences

User Tools

Site Tools


tutorials:laser-obstacle-avoid-scenario:start

Simple System: Laser Obstacle Avoid

This tutorial will explore and run a simple obstacle avoidance system with a robot that moves collision-free with a laser ranger. It illustrates a simple—but realistic—example to get hands-on experience with the SmartMDSD Toolchain.

Basic Information

Level Beginner
Role System builder, but also other roles while browsing through the system's building blocks
Assumptions none
System Requirements Virtual Machine Image Installed, see ready-to-go virtual machine
You will learn How to work with software components in the SmartMDSD Toolchain
About the file structure of software components in the toolchain
How the laser obstacle avoid algorithm works
How to modify and rebuild a component at the source code level

Introduction

This tutorial will guide you in understading simple application for laser-based obstacle avoidance in simulation. We will explore the software component and implemented algorithm in the SmartMDSD Toolchain to get hands-on experience. You will learn:

  • How to find your way in a software component
  • How to implement a software component
  • How to start/deploy a readily available set of components using the simulator

We will use an already existing software component project “ComponentLaserObstacleAvoid” as well as the system project “SystemLaserObstacleAvoidP3dxPlayerStageSimulator”.

  • SystemLaserObstacleAvoidP3dxPlayerStageSimulator: Software component which provides the Player/Stage simulator. It simulates a laser ranger and Pioneer P3dx robot.
  • ComponentLaserObstacleAvoid: Software component which implements a simple reactive obstacle avoidance algorithm. It periodically receives laser range scans, calculates steering commands and provides these to the P3DX platform (simulator) for execution.

Please see one of the next tutorials to learn how to create a component and system on your own.

System Component Architecture

Before we start the system, we will take a look at the architecture.

First, open the project if necessary: Right-click on “SystemLaserObstacleAvoidP3dxPlayerStageSimulator” in the “Project Explorer” and select “Open Project”.

Open the Component Architecture to explore the system. It is named SystemLaserObstacleAvoidP3dxPlayerStageSimulatorComponentArchitecture. There are two ways to open the Component Architecture. Double click one of the highligted entries as indicated in the below figure:

As you can see in the below picture, the system contains the two components: one to represent the simulator and one for obstacle avoidance. Both components provide or require services. Two pairs of component ports are connected. The obstacle avoidance component will receive laser scans from the simulated robot, calculate commands, and provide/send them as navigation velocity commands to the simulated robot.

We will later explore and modify the obstacle avoidance algorithm.

Executing the System

Deploying and Starting the System

To run the system, we need to deploy it and run the components.

Deploying copies/transfers the system and all necessary parts to the target machine. In this case it is the local computer or virtual machine guest system. Right-click on the system project and select SmartMDSD Build ToolsDeploy

The system is now ready to start and you will be asked to execute it. Note that there are other ways to execute a deployed system, e.g. on a remote robot.

Choose yes in the popup dialogue to start the system. A terminal window will open and show the scenario control menu:

Choose menu-start to start the scenario. Further terminals open automatically. One per component and one additional window for the naming service. Note that they may not be visibile initally in case they overlap.

You have to select a environment for the simulated robot. In the window with red font, choose a world number, e.g. 0 (Hospital world) and press enter.

Now, all software components and the simulator start running. You will see the GUI of the simulator showing the robot moving around in the hospital world:

Hints to use the Simulator

  • you can move the robot by dragging it (left mouse button)
  • you can rotate the robot by the mouse clicking the right button
  • you can zoom in / zoom out by ctrl + right mouse button
  • you can move the map by dragging it (left mouse button)

Shutting Down the System

To stop the simulation and all components, select the following options in the scenario control window/menu :

  • Choose menu-stop to stop the scenario and all the software components
  • Choose quit to quit the scenario (quit includes menu-stop)

All components and the simulator will shut down managed by the components shutdown procedure. Only one window will stay open. Do not close any window manually, except the last one that remains open and will ask you to close it manually.

Exploring the Component for Obstacle Avoidance

To better understand the components in this scenario, we will explore the software component ComponentLaserObstacleAvoid. We will inspect it at the model and source code level. We will run the build process from model transformation, code generation, and compilation and test it in our system.

Open the software component model by double clicking one of the entries highlighted in the below image:

The model of the obstacle avoidance component looks as follows:

The component has one activity named as RobotTask which is connected to two component ports. One port is an input port for the laser service LaserServiceIn. The other port is output port for NavigationVelocityServiceOut. Click on a port and open the properties view to see its details as shown in the below figure. This port realizes the service definition ForkingServiceDefinition LaserService.

The algorithm calculates movements based on the laser scan and provides these movements as navigation velocities to command the robot. Open the output port properties, and you can see it realizes JoiningServiceDefinition NavigationVelocityService.

Modifying the Algorithm

This algorithm is implemented in an activity. Its model representative is the RobotTask. To Open the source code of the RobotTask, open the file /ComponentLaserObstacleAvoid/smartsoft/src/RobotTask.cc. The method RobotTask::on_execute() holds the implementation of the algorithm. It first receives laser scans,then calculates new navigation commands and finally sends them to the robot base.

Now read through the source code to understand the algorithm. Not how the algorithm received scans from the component port and provides the result to the component port.

You may now modify the source code and enhance the algorithm or you may remove the implementation and use this component to work on the exercises.

The following figure describes the relation of the ports and activity of the component model to the source code that implements the algorithm in the RobotTask.

After modifying the source code, you need to compile the component:

  • Right click on project ComponentLaserObstacleAvoid → SmartMDSD build tools → CMake
  • Right click on project ComponentLaserObstacleAvoid → SmartMDSD build tools → make all

To test your improved component you need to deploy and run the system project where this component is included. You have learned how to do this in the first part of the tutorial.

Further Information

What do do next?

Please proceed with next tutorial (A More Complex System using the Flexible Navigation Stack) to have a look on a more complex system. You can also then check further tutorials for learning “how to develop your own Component and System”.

Acknowledgements

tutorials/laser-obstacle-avoid-scenario/start.txt · Last modified: 2019/02/07 09:42 by Dennis Stampfer