Documentation for the SWARM Firmware API.

Layout

The SWARM Firmware documentation has the following structure:

  1. Examples - "How do you use this thing?"
  2. SWARM Firmware Modules - "Our fancy software system (and no it's not ROS)"
  3. Built-In Algorithms - "The real power here!"

Examples

Most of the configuration of the SWARM system is completed through the `SimulationSettings.json` file that can be found in the `settings` folder in the root of the project. The examples shown below provide examples of how to use Python to spin up the system quickly. For detailed information on settings, please see Configurator Guide.


Running A Simulation

The following Python code can be found in the `examples` folder in the main directory.

from core.swarm import SWARM

API_KEY = "test"
SIMULATION_NAME = "example"


sim_manager = SWARM(access_key=API_KEY)

sim_manager.validate_environment_name(args.map_name)

sim_manager.setup_simulation(args.map_name)

new_simulation = sim_manager.build_simulation(SIMULATION_NAME)

sim_manager.run_simulation(args.map_name, SIMULATION_NAME)

# Go to your browser and type in "127.0.0.1" or the IP address provided if you are on the 
# cloud version!
                

Let's go through this line by line.

Line 1 - 3 Import the SWARM Module (DOCS LINK) and set your API Key.
Line 5 Create a new instance of the SWARM Module, giving it the API key you defined and a possible IP address if you are using the SWARM Developer Cloud version.
Line 7 Validate the name of the environment you chose. This is confirmed with the Server to make sure you have the right environment selected.
Line 9 Run the setup process, providing the name of the map.
Line 11 Build the simulation, setting up the needed files and perparing the Client.
Line 13 Run the simulation. This sends the Simulation package to the Core server

Extracting Data

In this example, we will extract data from the SWARM Core server once we have submitted a simulation.

Using the example above, we can now extract a data package in the form of a tar file.

from core.swarm import SWARM

API_KEY = "test"
SIMULATION_NAME = "example"


sim_manager = SWARM(access_key=API_KEY)

sim_manager.extract_data(SIMULATION_NAME)

                

A loading bar will pop up once you send this command, indicating how large the file is that will downloaded. The data will be stored in the `data` folder in a folder labeled the name of the simulation that is provided.

View A Level

You can now spin up an environment for a fixed period of time and fly through said environment to see the level layout, what is of interest, etc.

To do this, you only need to make a small change. You can also use the file view_level.py in the examples folder. You can use the Python code below.

from core.swarm import SWARM

API_KEY = "test"
SIMULATION_NAME = "example"


sim_manager = SWARM(access_key=API_KEY)

sim_manager.validate_environment_name(args.map_name)

sim_manager.setup_simulation(args.map_name)

new_simulation = sim_manager.build_simulation(SIMULATION_NAME)

sim_manager.run_view_only_simulation(args.map_name, SIMULATION_NAME)

# Go to your browser and type in "127.0.0.1" or the IP address provided if you are on the 
# cloud version!
                

Let's go through this line by line.

Line 1 - 3 Import the SWARM Module (DOCS LINK) and set your API Key.
Line 5 Create a new instance of the SWARM Module, giving it the API key you defined and a possible IP address if you are using the SWARM Developer Cloud version.
Line 7 Validate the name of the environment you chose. This is confirmed with the Server to make sure you have the right environment selected.
Line 9 Run the setup process, providing the name of the map.
Line 11 Build the simulation, setting up the needed files and perparing the Client.
Line 13 Run the simulation in "View Only". This sends the Simulation package to the Core server and runs the simulation, but will not move the agent.

SWARM Firmware Modules

Description

The SWARM Firmware consists of a set of flexible modules that can be quickly inserted into each agent, allowing maximum performance and usefulness. As Python allows for an easy process to go from one to many components, each module has a similar structure, such as receiving messages, operating in our "multi-level" paradigm and more.

Each module has it's own logging system and ability to run a collection of specifically designed algorithms, allowing for maximum plug and play as needed during development.

Now, we know what you may be thinking: "Python is slow!". You're right, especially when working on any embedded system. container p-3 shadow-sm my-3, we thought of that and we came up with a new way. The backbone of each module is written in C++, which is then managed by our Python manager. So, when you're ready for the real world, we make the process of going Python -> C++ that much easier. More on this later!

Available Modules

HighLevelBehavior
This module manages the high level behavior, such as following a path, communicating with other agents or deciding what action to take next.
Available Algorithms
LowLevelPathPlanning
This modules acts as the vehicle manager, managing the low-level controller, activating automated commands like taking off and also allows for fine-grained path planning via pre-built solutions.
Mapping
This module generates a set of Maps that can be utilized for planning, such an Occupancy Map. More map types coming soon, including SLAM!
Available Algorithms
HighLevelPathPlanning
This module records video or images in the provided format, at the same resolution as the camera that is provided. For now, only a single camera can be recorded but we are working on multi-camera setups as container p-3 shadow-sm my-3!
Available Algorithms

</div>

Built-In Algorithms

Description

Below are the provided algorithms, which can be referenced by the ClassName

Path Following

Description
An algorithm that follows a list of waypoints.
ClassName
PathFollowing
Parameters
completed_waypoint_distance
the distance in meters to say a waypoint is "completed"
0.5 - 3.0 meters

Pass Through Planner

Description
An algorithm that acts as a passthrough, taking the provided command and then giving said command to the low-level controller.
ClassName
PassThroughPlanner
Parameters

- None

Pass Through Trajectory Planner

Description
An algorithm that simply passes through a provided Trajectory. Choose this if you don't want to modify your trajectory in any way.
ClassName
PassThroughTrajectoryPlanner
Parameters

- None

Video Recorder

Description
An algorithm that records video or images using OpenCV at the prescribed resolution as set by the Sensors field of the agent.
ClassName
VideoRecorder
Parameters

- None

Tags: