Overview
This section describes network configuration in more detail.
There are three network addresses to be determined. For each of these there is a section, below, which shows the priority of sources from which they are set in a table, and goes on to describe the different approaches to determining them.
Local network address
This is the address of the local machine where you are installing the MDK, and is stored in the environment variable MIRO_LOCAL_IP
.
MIRO_LOCAL_IP | If this value is set when setup.bash runs, no further determination is performed. |
MIRO_STATIC_IP | If MIRO_NETWORK_MODE is set to static , this value is used. |
miro_get_dynamic_address() | If MIRO_NETWORK_MODE is set to dynamic , the value returned by this function is used. |
MIRO_ADAPTER_NAME | If MIRO_ADAPTER_NAME is set and not empty, miro_get_dynamic_address() will find only addresses for the specified adapter. |
127.0.0.1 | If MIRO_NETWORK_MODE is set to loopback , this value is used. |
127.0.0.1 | If none of the above sets a non-empty value into MIRO_LOCAL_IP , this value is used. |
Most machines have only one network address—aka "IP address"—and it is this that must be determined and stored in MIRO_LOCAL_IP
. Usually, MIRO_LOCAL_IP
will be recovered correctly by the default configuration which relies on miro_get_dynamic_address()
.
Dynamic mode
The default value of MIRO_NETWORK_MODE
is "dynamic". In this mode the network address is determined dynamically when setup.bash
is run using the function miro_get_dynamic_address()
.
In the default implementation of this 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, you have the following options.
- Most easily, set
MIRO_ADAPTER_NAME
to the name (e.g.wlan0
), or some part of the name (e.g.wlan
) of the network adapter you intend to use. It will then be selected correctly. - Provide your own implementation of
miro_get_dynamic_address()
(starting with the template inuser_setup.bash
). - Use one of the other address determination modes ("static" or "loopback").
To provide your own implementation of miro_get_dynamic_address()
, uncomment the version in user_setup.bash
and modify it to correctly recover your local 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.
Static mode
If your network address is fixed, you can set MIRO_NETWORK_MODE
to "static" and MIRO_STATIC_IP
to the fixed address. For example:
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
.
Robot network address
This is the address of the robot with which you are working, and is stored in the environment variable MIRO_ROBOT_IP
.
MIRO_ROBOT_IP | If this value is set when setup.bash runs, no further determination is performed. |
<empty> | MIRO_ROBOT_IP cannot be recovered automatically and is left empty if not specified. |
Set this explicitly before you source ~/mdk/setup.bash
if you want to work with a robot. See Off-board for more details.
ROS_MASTER_IP
may be set incorrectly.ROS master address
This is the address where the ROS master is running, and is stored in the environment variable ROS_MASTER_IP
.
ROS_MASTER_IP | If this value is set when setup.bash runs, no further determination is performed. |
MIRO_ROBOT_IP | If this value is not empty, it is used also as ROS_MASTER_IP . |
localhost | If none of the above sets a non-empty value into ROS_MASTER_IP , this value is used. |
Usually, you can leave setup.bash
to configure this. If the above two values are set correctly, ROS_MASTER_IP
will be set automatically to the local address (if using the simulator) or to the robot's address (if working with a robot).
If you want to use a specific ROS master, in either case, you can set this value explicitly before sourcing setup.bash
.