Configure MDK

The default configuration performed by the MDK install script can be modified, if required. Instructions for doing so are on this page.

In most cases, no configuration changes will be required at all—read Install MDK carefully, and determine if you need to make changes before continuing with the instructions on this page.
Where a change is required, almost always it will only be to ensure that the network address is determined correctly—we recommend you change nothing else, at least until you have confirmed correct operation and familiarised yourself with the MDK.
At the bottom of this page, some debugging information is provided for the MDK installation.

Configuration files

Some of the settings below are stored in ~/.miro2/config/user_setup.bash. This file is also used on-board the robot, and contains various settings relevant only to that environment—you can safely ignore comments and settings that are not described on this page.

Add symbolic link

During install, a link is placed at ~/mdk pointing to the MDK directory (in our example installation, to ~/mdk-190211). You may safely delete—or move—this link if you prefer.

If you do so, you must ensure that the correct path to the MDK is used whenever ~/mdk is used. You should check the remaining items on this page, and also replace ~/mdk wherever it is used in the documentation with the correct path to your MDK installation.

It is strongly recommended that you use the MDK through a symbolic link; this will avoid version control problems if you update your MDK at a later date.
It is recommended that you leave the link at ~/mdk—at least to begin with—since you can then copy-and-paste code directly from the documentation into your terminal.

Initialise automatically

A command is placed at the bottom of your ~/.bashrc to initialise the MDK (by sourcing setup.bash).

~/.bashrc
# MDK source ~/mdk/setup.bash

Some users will prefer to remove this automatic initialisation command from their ~/.bashrc. In that case, source setup.bash manually in your terminal before each use of the MDK.

If you have deleted or moved the link at ~/mdk, as described in the previous step, you must update the command in ~/.bashrc accordingly.

Network address

The value listed beside "Network address" when setup.bash runs should be the network address of your system. A correct network address is required if the MDK is to be able to communicate with the robot or with the simulator.

If the indicated network address is not correct, or if you wish to change how that address is determined, this section describes the procedure.

The most common reason for failure to determine the correct network address is if your system has more than one IPv4 network listed by ifconfig—to handle this situation, read on.

Default configuration

Most machines have only one network address—aka "IP address"—and it is this that the MDK must determine. Usually, then, this will be performed correctly by the default scripts.

Three approaches can be used to determine the network address: "dynamic", "static", and "loopback". Which technique is used is controlled by the value of MIRO_NETWORK_MODE. This value is set in user_setup.bash, which is stored at ~/.miro2/config/user_setup.bash, and you can change it if required.

The network address determination is performed by the function miro_resolve_network_address() in setup.bash. setup.bash should not be changed, but you can follow it through if you need to debug network address determination.

The default configuration is to use "dynamic" determination mode, which is described below.

Dynamic address

If MIRO_NETWORK_MODE is set to "dynamic" (the default setting), the network address is determined dynamically when setup.bash is run using the function miro_get_dynamic_address().

In the default implementation of the function (in setup.bash), the first qualifying IPv4 address listed by ifconfig is taken. If your system has more than one IPv4 address, and the first is not the one you intend to use, either provide your own implementation of miro_get_dynamic_address() (in user_setup.bash) or use one of the static address determination modes

Custom implementation

To customize miro_get_dynamic_address(), uncomment the version in user_setup.bash and modify it to correctly recover the network address dynamically. Note that an uncommented function in user_setup.bash automatically overrides the one defined in setup.bash.

The custom function should set the network address into MIRO_DYNAMIC_IP and then exit.

Here is an example function that returns the address of the network adapter with a specified name wlan0:

~/.miro2/config/user_setup.bash
miro_get_dynamic_address() { # recover address of named adapter ADAPTER_NAME=wlan0 MIRO_DYNAMIC_IP=`/sbin/ifconfig | grep $ADAPTER_NAME -A 2 | grep "inet " | sed s/addr:// | sed s/.*inet\ // | sed s/\ .*//` }

Constraining accepted dynamic address

In some conditions, your network interface may self-assign a bogus IP address (often of the form 169.x.x.x) for a moment before it is assigned a valid IP address by DHCP. At boot, the system waits for a valid IP address and then uses it to start the network services (including the ROS master), and by default any address is allowed. If network services are started with a bogus address, they will not work correctly (ROS master will be unreachable) after DHCP has assigned a real address. See the related FAQ: Why can I not reach the on-board ROS master?

There are two ways to solve this problem. The first, if appropriate, is to switch to "static" for Network address mode, and specify the address in advance. If you can't do this (because you want to use DHCP), you can alternatively restrict the set of valid IP addresses that the robot will accept at boot time by modifying the setting MIRO_DYNAMIC_IP_MATCH in user_setup.bash. For example, to allow only addresses that take the form 192.x.x.x, use the setting below.

export MIRO_DYNAMIC_IP_MATCH='^192\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'
The setting MIRO_DYNAMIC_IP_MATCH was introduced at R190407—if the variable is not present in your user_setup.bash, add it manually using the template at ~/mdk/share/config/user_setup.bash.

Static address

If your network address is fixed, you can set MIRO_NETWORK_MODE to "static" and MIRO_STATIC_IP to the network address. For example:

~/.miro2/config/user_setup.bash
MIRO_NETWORK_MODE=static MIRO_STATIC_IP=192.168.1.100

Loopback address

If you do not need the network—for instance, you intend to use only the simulator—you can also use the "loopback" mode, which is equivalent to "static" mode with the network address set to 127.0.0.1.

~/.miro2/config/user_setup.bash
MIRO_NETWORK_MODE=loopback

Debugging information

If you are having configuration problems with the MDK, run miro_info and check over the environment variables to see if anything is awry. A typical output is shown below.

mitch@leviathan ~ $ miro_info [ MIRO ] MIRO_DIR_BIN=~/mdk/bin/deb64 MIRO_DIR_CONFIG=~/.miro2/config MIRO_DIR_DUMP=/tmp/miro2/dump MIRO_DIR_LOG=/tmp/miro2/log MIRO_DIR_MDK=~/mdk MIRO_DIR_ONBOARD=~/mdk/bin/onboard MIRO_DIR_SHARE=~/mdk/share MIRO_DIR_STATE=/run/user/1000/miro2/state MIRO_DIR_TMP=/tmp/miro2 MIRO_DIR_TRASH=~/.miro2/trash MIRO_DIR_USER=~/.miro2 MIRO_DYNAMIC_IP_WAIT=60 MIRO_EDITION=2 MIRO_MDK_RELEASE=R190211 MIRO_MULTITOOL=~/mdk/bin/onboard/multitool.sh MIRO_NETWORK_MODE=dynamic MIRO_ROBOT_NAME=miro MIRO_ROS_RELEASE=kinetic MIRO_STATIC_IP= MIRO_SYSTEM=deb64 MIRO_TOKEN=miro2 MIRO_USER_SETUP=~/.miro2/config/user_setup.bash [ ROS ] ROS_ROOT=/opt/ros/kinetic/share/ros ROS_PACKAGE_PATH=~/mdk/catkin_ws/install/share:/opt/ros/kinetic/share ROS_MASTER_URI=http://localhost:11311 ROS_VERSION=1 MIRO_ROS_RELEASE=kinetic ROS_MASTER_IP=localhost ROSLISP_PACKAGE_DIRECTORIES= ROS_DISTRO=kinetic ROS_IP=192.168.1.100 ROS_ETC_DIR=/opt/ros/kinetic/etc/ros GAZEBO_MODEL_PATH=~/mdk/sim/models:/usr/share/gazebo-7/models GAZEBO_RESOURCE_PATH=~/mdk/sim:/usr/share/gazebo-7 GAZEBO_MASTER_URI=http://localhost:11345 GAZEBO_PLUGIN_PATH=~/mdk/bin/deb64:/usr/lib/x86_64-linux-gnu/gazebo-7/plugins GAZEBO_MODEL_DATABASE_URI=http://models.gazebosim.org PYTHONPATH=~/mdk/share/python:~/mdk/catkin_ws/install/lib/python2.7/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages