-
Notifications
You must be signed in to change notification settings - Fork 1
bagel_robot
This tutorial shows how to control a robot in MARS via a Bagel graph.
- If Bagel is installed from source:
cd bob-magic-dev
source env.sh
cd bagel/bagel_magic
python gui.py
-
If Bagel is installed from binary release link start the software depending on your operating system:
- macOS: Start the
BagelMagic.app
- Windows: Start the
run.bat
in the downloaded folder - Ubuntu: Start
BagelMagic
in the downloaded folder Note: You don't have to use the install option.
- macOS: Start the
If the wizard is running you should see the following GUI:
To test the selection you can start MARS with button 6
in the wizard.
You should see a simple Kephera like robot in a squared environment:
For the example setup a Python script is installed which controls the robot. This script will produce a conflict if we want to control the robot with a Bagel graph. Additionally, the distance sensors, depicted as red lines, are not visible in the DataBroker modle which is used to connect inputs and outputs of the Bagel graph with the simulation. So we first have to adapt the Python script to 1. not write motor values for the robot and 2. provide the distance sensors to DataBroker.
For the following instruction we consider "$BAGEL_ROOT" as local installation folder. The local installation folder depends on how and where you have installed BagelMagic:
- macOS Binaraies: /Application/BagelMagic.app/Contents/MacOS/
- Windows Binaries: The folder that you extracted form the zip archieve
- Ubuntu Binaries: The folder that you extracted from the tgz archieve
- Intallation from source: If you used the
bootstrap_magic.sh
script the root folder should bebob-magic-dev
from where you started the script. Note: You cannot move the installed folder. If you want to change the installation folder you have to run the bootstrap script from the new folder.
The MARS configuration file for a selected robot is defined by the selected
BagelGraph to control the robot. In our example the graph name is robo2
and
the version is 1.0.0
. The configuration can then be found in
$BAGEL_ROOT/install/configuration/mars/graph_name/graph_version
so in our
case:
$BAGEL_ROOT/install/configuration/mars/robo2/1.0.0/
Within that folder the Python script that is executed is
python/mars_plugin.py
. To prevent the script from writing robot commands
we comment the setMotor function calls as shown in:
To add the distance sensors to DataBroker we can add two lines as shown in:
If we open the BagelGUI with button 5
in the wizard the selected control
graph is automatically loaded into the GUI. By default we have to nodes, one
for each motor of the robot, where the outputs of the nodes are also outputs
of the graph (marked orange) that can be accessed via DataBroker.
Whether a port is transferred to DataBroker or not can be toggled by right clicking on the port and selecting toggle interface:
Three modes are available:
- White: the port is invisible for DataBroker
- Orange: the port is exported to DataBroker
- Yellow: the port is exported to DataBroker through the whole control hierarchy. Note: This mode is not fully implemented yet.
To test the graph we can toggle to two intput ports and save the model Database->Store Model
or the button save model
on the lower right corner of the
GUI.
After changing a graph we have to compile it with the button in are 3
of the
wizard. Note: If you forget to compile the graph an old version is loaded
into MARS which is currently a typical pitfall.
To generate connections in DataBroker we can use the data_broker_graph_view
module. First we have to start the simulation (button 6
in the wizard). To
open the module click DataBrokerGraphView->show window
. On the
right hand side of the window we can enter filter options. For our example we
can add the filters *Bagel*
, *Motors*
, and *Sensors*
. With the right
mouse button we can move the view. To show up the data nodes we might have to
hold down the right mouse button and move the pointer to the upper right
corner of the view.
We can sort the nodes as shown in the image. However, the eight BagelMARS:distance_00* nodes are not yet generated in this tutorial. By creating edges from
the BagelMARS:outputs
nodes to the mars_sim:cmd/Motors*
nodes the graph
will generate the motor commands for our robot.
Now we can open the DataBroker GUI, if not already open, with
data/DataBroker
. In that GUI we should have a tab BagelMARS
where we can
set the motor commands for the robot.
Now we can open BagelGUI and add eight PIPE
nodes to the graph. We can change
the name of the nodes in the NodeData
widget that can be opened with the D
symbol in the toolbar. By rebuilding the graph shown in the following image
we generate a behavior where the robot turns to the left whenever is senses an
obstacle.
Some hints:
- To set a bias value (a value that is constantly added to an input) you can
right click on the input port and select
configure interface
. - Negative motor values move the test robot forward.
- Edge properties light weights that are multiplied with the connected node output values can be changed in the NodeData widget if the edge is selected.
- Don't forget to compile the graph. ;-)
To have more structure in the main graph we can create a graph as shown in:
and change the model name (upper right corner) to merge_sensors
. When we
save the model (after renaming it) a new graph is stored in the database.
Note: The database is a local file-based database in the folder structure
of the software. If you delete the software (folder) you also loose the graphs
stored in the database.
If we now close the BagelGUI and open it again with the robo2 graph we can add
the new node with Database->Add Component
and select merge_sensor
.