mirror of
https://github.com/AdaCore/OpenUxAS.git
synced 2026-02-12 13:07:16 -08:00
Python AMASE Example
The purpose of this example is twofold:
- To show how to use Python with AMASE directly rather than through UxAS.
- To provide some standard configuration options for air vehicles and their payloads.
This example includes a Python program that connects to AMASE and sends the LMCP messages necessary to configure, initialize, and command a set of air vehicles. It then saves these messages as a scenario file Scenario_Output.xml that can be used to re-run the scenario in AMASE by itself. Finally, it receives information about the air vehicles from AMASE through LMCP messages and prints this information.
Note: this example is currently untested on Windows.
Files:
RunPythonWithAmase.py- Python program that sends and receives LMCP messages to/from AMASE.Scenario_Empty.xml- An AMASE scenario file that zooms in on the map but is otherwise empty.runAMASE_PythonWithAmase.sh- bash script to startup AMASE with the empty scenario.runAMASE_PythonWithAmase.bat- Windows script to startup AMASE with an empty scenario.MessageLibrary/- A collection of representativeAirVehicleConfiguration,AirVehicleState,GimbalConfiguration,GimbalState,CameraConfiguration,CameraState, andFlightProfilemessages that can be used to configure air vehicles and their payloads.
Running the Example:
- Open a terminal window in the directory:
examples/07_PythonWithAmase/ - Enter the command:
./runAMASE_PythonWithAmase.sh - Start the AMASE simulation (i.e. push the play button)
- Open another terminal window in the directory:
examples/07_PythonWithAmase/ - Enter the command:
python RunPythonWithAmase.py
What Happens?
- When the AMASE simulation starts, it is configured to set up a TCP/IP server on port 5555.
- When the Python program starts, it connects to the AMASE TCP/IP server using ZeroMQ.
- The Python program creates the LMCP messages necessary to configure and initialize three air vehicles in AMASE, some entirely from "stratch" and others by loading and modifying messages from the
MessageLibrary/directory, and sends them to AMASE. - The Python program then creates and sends some example
MissionCommandandVehicleActionCommandLMCP messages to control the vehicles. - Then Python program then reads through queued LMCP messages until it reaches an
AirVehicleStatemessage that has a timestamp of at least 7000 ms into the scenario. It then prints out certainAirVehicleStateinformation (ID, Time, Latitude, Longitude, Altitude, and EnergyAvailable) for each vehicle.
Things to Try:
- Running
RunPythonWithAmase.pygenerates the fileScenario_Output.xml, which saves the messages it sends to AMASE in a 'scenario file.' Restart AMASE by following steps 1 and 2 above, then load this scenario file in AMASE by going to AMASE'sFile > Open Scenariomenu and selectingScenario_Output.xml. Then press the Play button in AMASE. AMASE should configure and command the air vehicles just asRunPythonWithAmase.pydid. - Try to add a fourth air vehicle to the scenario in
RunPythonWithAmase.pywith different configuration and state information than the other three. Send it at least oneMissionCommandand/orVehicleActionCommand.