Back to Tutorials Index... ## Hello World Extension VisualScene Maker allows programmers to extend its functionality by creating new extensions. These extensions can range from simply printing a text in the console, to adding behavior to a robot. To add a new extension in VSM, firstly, we need to add a new package to the *de.dfki.vsm.xtension*. Usually the name of the package is related to the name of the plugin we want to create, for example, if we are creating a new extension for the Baxter robot, our package path would look something similar to this: *de.dfki.vsm.xtension.baxter*. The next step is to create a new Java class. This class must extend *ActivityExecutor* class. This would be the entry point to our extension. The class *ActivityExecutor* is an abstract class, which means that our newly created Java class needs to fulfill the contract establish by *ActivityExecutor*. This contract compel/forces us to define four functionalities: 1. An identifier to our extension. (`public String marker(long id)`). Every time a new action is dispatched to our plugin, a new identifier is assigned to the action. This identifier is usually implemented as a concatenation of the custom string (usually '$') and the parameter id: `return "$"+id;` 2. How to launch an external application (`public void launch()`). Usually, our extension will communicate with extenal applications (eg., virtual characters, robots, a remote server, http server). These applications are usually not running all the time, and instead of executing them manually (starting the server, double click an GUI application, etc.), VSM execute them automatically for us. Before using our extension, VSM calls the *launch* function. In this function we define how we can start the external application. Have in mind that we have to explictely wait in the launch method until the external application is fully running before VSM executes any action. 3. How to stop the external application (`public void unload()`). Once VSM stops the execution, we should close the external application that was started by the launch method. In this function we specify how to kill it. 4. What to do once an action (activity) arrives (`public void execute(AbstractActivity activity)`). Every time an action to our extension is referenced, it goes throw the *execute* method. Therefore, inside this method, we implement what to do with received action. Note: If your extension does not rely on any external application, the methods *launch* and *unload* are not necessary to implement. You can just leave them with an empty body. For a working example see: <a href="createFirstExtension.html">Creating our first extension (Hello world)</a> and <a href="createClientExtension.html">Creating a client extension</a>
Back to Tutorials Index...