-
Notifications
You must be signed in to change notification settings - Fork 11
MACE Living and Breathing Test
This test assumes that you have installed MACE and the supporting libraries. If you have yet to do so, install MACE by following the steps outlined in either of the following pages:
Before you run MACE, you need to make sure your configuration file is set up properly. By default, MACE loads the Default.xml
file, located in OpenMACE/MaceSetup_Configs/Default.xml
. For this test, we will edit this file to connect to a simulated vehicle and the MACE GUI. Open the Default.xml
configuration file in any text editor and change the "ListenAddress" in the VehicleComms
module to the IP of your machine. Similarly, change the "GUIHostAddress" in the GroundStation
module to the IP of your machine. An example XML file is shown below with "localhost" as the IP address:
<?xml version="1.0" encoding="utf-8"?>
<ModuleConfigurations MaceInstance="0">
<GlobalParams>
<Parameter Name="GlobalOrigin">
<Parameter Name="Latitude">35.6212140</Parameter>
<Parameter Name="Longitude">-78.7992165</Parameter>
<Parameter Name="Altitude">0.0</Parameter>
</Parameter>
<Parameter Name="EnvironmentBoundary">
<Parameter Name="Vertices">(-35.359349, 149.154646),
(-35.359421, 149.160719)
(-35.363713, 149.162548)
(-35.365700, 149.155107)
</Parameter>
<Parameter Name="Type">soft</Parameter>
<Parameter Name="Name">YOU SHALL NOT PASS</Parameter>
</Parameter>
<Parameter Name="maceID">1</Parameter>
</GlobalParams>
<Module Class="VehicleComms" Type="Arduplane">
<Parameter Name="ID">1</Parameter>
<Parameter Name="ProtocolParameters">
<Parameter Name="Name">Mavlink</Parameter>
<Parameter Name="Version">V2</Parameter>
</Parameter>
<Parameter Name="UDPParameters">
<Parameter Name="ListenAddress">127.0.0.1</Parameter>
<Parameter Name="ListenPortNumber">14551</Parameter>
</Parameter>
<Parameter Name="ModuleParameters">
<Parameter Name="AirborneInstance">false</Parameter>
</Parameter>
<Parameter Name="LocalPositionParameters">
<Parameter Name="TransformAltitude">true</Parameter>
</Parameter>
<Parameter Name="EKFOrigin">
<Parameter Name="SetEKFOrigin">true</Parameter>
<Parameter Name="DuplicateToHome">false</Parameter>
<Parameter Name="Latitude">35.6212140</Parameter>
<Parameter Name="Longitude">-78.7992165</Parameter>
<Parameter Name="Altitude">0.0</Parameter>
</Parameter>
</Module>
<Module Class="GroundStation" Type="NASAPhase2">
<Parameter Name="ID">1</Parameter>
<Parameter Name="MACEComms">
<Parameter Name="GUIHostAddress">127.0.0.1</Parameter>
<Parameter Name="ListenPort">8082</Parameter>
<Parameter Name="SendPort">8080</Parameter>
</Parameter>
</Module>
</ModuleConfigurations>
Note that you would want to change the ListenAddress
and GUIHostAddress
to the correct IP addresses. If you are running a simulated vehicle and the GUI both on your local machine, change both addresses to the IP address of your local machine.
With the configuration file setup, there are two ways to run the MACE application. For most users, the easiest way to run it is from the Qt Creator IDE. Follow the instructions in one of the following sections based on your preference:
Open the Qt Creator IDE and load the OpenMACE/src.pro
file to load the MACE project. Open the Projects
tab and select the Run
option. In the Command line arguments:
box, enter the relative path from the root MACE
directory (i.e. where your MACE_ROOT
environment variable points to) to where your desired XML configuration file is. If this box is left blank, MACE will load the configuration file OpenMACE/MaceSetup_Configs/Default.xml
. An example screenshot is shown below loading the Default.xml
file.
Once you have added the correct path to your desired configuration file, click the green "Play" button in the bottom left of the GUI to run the MACE application. You should see a command prompt open up and show text similar to that shown below:
Navigate to the OpenMACE/bin
directory and run the following command:
$ ./MACE MaceSetup_Configs/Default.xml
Note that on Windows, the ./
is not necessary
If the command executed correctly, you will see text similar to that shown below:
The GUI loads a separate JSON configuration file located in the config MACE_Frontend directory (MACE_Frontend/config/config.json
). Make sure that the map_port
value equals the SendPort
value of the MACE config file. An example configuration is shown below for a connection with the MACE instance we started above:
{ "map_port": 8080 }
With the configuration file in place, run the MACE GUI:
Open a terminal and navigate to the MACE_Frontend
directory to run:
$ cd MACE_Frontend/
$ yarn start:app
If successful, the MACE GUI will run, and you should see a blank map similar to the one below. Note that the command above may take a few moments to actually start the GUI while it waits for the watcher to start up, and you may see a white screen while the command finishes.
If MACE starts up correctly using the XML configuration file from above, MACE currently does not print anything new to the console as there is no vehicle started.
To run a simulated vehicle, open a terminal and navigate to wherever ardupilot
was cloned. NOTE: On Windows, you will have to do this in a Cygwin temrinal, NOT the regular Windows command prompt.
Change into the ArduCopter
directory and run the sim_vehicle.py
script with a few arguments:
-
--instance=
: denotes the vehicle instance ID for port setup -
--sysid=
: denotes the vehicle ID (i.e. sets theSYSID_THISMAV
parameter) -
--out=udp=
: specify an IP:PORT combination. The IP should be set to the "ListenAddress" IP in the MACE XML configuration file, and the PORT should be set to the "ListenPortNumber" in the same configuration file -
--custom-location
: specify a location to start the vehicle at. Format is:lat,lon,alt,heading
$ cd ardupilot/ArduCopter
$ sim_vehicle.py --instance=1 --sysid=1 --console --out=udp:127.0.0.1:14551 --custom-location=-35.3632621,149.1652374,0,240
If you run multiple vehicles, the ID's set with the --instance
and --sysid
flags must the same for each vehicle, and unique between vehicles. For example, the above command is launching vehicle 1 with the following flags: --instance=1 --sysid=1
. In order to run vehicle ID 2, run:
$ sim_vehicle.py --instance=2 --sysid=2 --console --out=udp:127.0.0.1:14552 --custom-location=-35.3632621,149.1652374,0,240
If successful, you should see a terminal window and "console" window appear that resemble the screenshot below:
If the configurations were set up correctly, you should see output similar to the following in the MACE terminal:
You should also see a connected vehicle in the MACE GUI, similar to the screenshot below.
If everything was set up correctly and you see a vehicle on the MACE GUI, try executing a simple command to ensure two-way communications are enabled. To start, we will execute a Takeoff command -- on the vehicle HUD on the right side of the screen, click the takeoff icon (circled in red in the below image) and then click the takeoff icon in the pop-up to takeoff to the altitude shown. The vehicle should arm its motors and takeoff to a default of 10 meters (you can change the altitude in the pop up if you wish to climb to a different altitude)
A common issue when running MACE with a vehicle and a GUI is not being able to see the vehicle on the GUI. There are a few common cases:
- If MACE has connection with the GUI, but NOT the vehicle, then MACE will only show its setup printouts.
- If MACE has connection with the Vehicle, but NOT the GUI, then MACE should be printing things like "Failed to write Vehicle Heartbeat" (among other things).
- Similar to #1, if MACE has connection with neither the GUI nor the Vehicle, then MACE will only show its setup printouts.
For Case #1, first check that your MACE configuration file (default is OpenMACE/MaceSetup_Configs/Default.xml
) is pointing to the correct vehicle. For simulated vehicles, check the UDPParameters
for the correct IP and port combination. This IP and port combination should match the IP and port that is being output from the ArduPilot simulation. For example, if the simulated vehicle was run via the following command:
$ sim_vehicle.py --console -m --out=udp:127.0.0.1:14552 --instance=2 --sysid=2
then the VehicleComms
portion of the MACE configuration file would look like:
<Module Class="VehicleComms" Type="Arducopter">
<Parameter Name="ID">2</Parameter>
<Parameter Name="ProtocolParameters">
<Parameter Name="Name">Mavlink</Parameter>
<Parameter Name="Version">V2</Parameter>
</Parameter>
<Parameter Name="UDPParameters">
<Parameter Name="ListenAddress">127.0.0.1</Parameter>
<Parameter Name="ListenPortNumber">14552</Parameter>
</Parameter>
<Parameter Name="ModuleParameters">
<Parameter Name="AirborneInstance">false</Parameter>
</Parameter>
<Parameter Name="LocalPositionParameters">
<Parameter Name="TransformAltitude">true</Parameter>
</Parameter>
<Parameter Name="EKFOrigin">
<Parameter Name="SetEKFOrigin">true</Parameter>
<Parameter Name="DuplicateToHome">false</Parameter>
<Parameter Name="Latitude">35.6212140</Parameter>
<Parameter Name="Longitude">-78.7992165</Parameter>
<Parameter Name="Altitude">0.0</Parameter>
</Parameter>
</Module>
If this does not resolve the issue, check that you are outputting the correct IP and port combination on the simulator. Run the command output
in the ardupilot terminal and make sure your IP:Port combination is present. If it is not present, you can add it manually by running output add <IP>:<PORT>
.
For Case #2, this typically means the IP and port combinations are incorrect for the MACE configuration file and/or the GUI configuration file. For a GUI on the same machine as the MACE instance, the GroundStation
module portion of the MACE configuration file should look like:
<Module Class="GroundStation" Type="NASAPhase2">
<Parameter Name="ID">1</Parameter>
<Parameter Name="MACEComms">
<Parameter Name="GUIHostAddress">127.0.0.1</Parameter>
<Parameter Name="ListenPort">8082</Parameter>
<Parameter Name="SendPort">8080</Parameter>
</Parameter>
</Module>
Then on the GUI side, open the config.json
file in the OpenMACE/MACE_Frontend/config
directory. This configuration should mimic the ports in the MACE XML file, and in the case of a local setup matching the above MACE Ground station setup, the file should look like:
{ "map_port": 8080 }
Note that the map_port
corresponds to where MACE is "sending" data to (i.e. the SendPort
in the MACE XML file)
For Case #3, you will have to check the fixes for both Case #1 and Case #2 as the issue is likely some combination of both.