|
1 | 1 | # pymavswarm
|
2 |
| -Python library used to communicate with robotic swarms over MAVLink |
| 2 | + |
| 3 | +## Introduction |
| 4 | +`pymavswarm` is a Python library implemented to enable interaction with robotic swarms using the MAVLink protocol. This library supports reading MAVLink messages sent from multiple agents in a swarm and sending MAVLink messages to agents within the swarm. Such functionality ultimately enables development of new swarm applications such as ground control stations. |
| 5 | + |
| 6 | + |
| 7 | +## Installation |
| 8 | +`pymavswarm` must currently be installed manually. To do so, refer to the steps below: |
| 9 | +1. Navigate to the `pymavswarm/` repository directory |
| 10 | +```bash |
| 11 | +cd path/to/pymavswarm/ |
| 12 | +``` |
| 13 | +2. Install the `pymavswarm` Python package |
| 14 | +```bash |
| 15 | +pip3 install . |
| 16 | +``` |
| 17 | + |
| 18 | +## Getting Started |
| 19 | +`pymavswarm` has been implemented to enable easy interfacing with robotic swarms. Refer to the following code snippet for a simple example to get started with the library. For more comprehensive documentation and examples, checkout the project Wiki. |
| 20 | + |
| 21 | +```python |
| 22 | +from pymavswarm import MavSwarm, OutgoingMsg, MsgMap |
| 23 | + |
| 24 | +# Create a new pymavswarm interface |
| 25 | +mavswarm = MavSwarm() |
| 26 | + |
| 27 | +# Establish a connection with a USB telemetry device |
| 28 | +mavswarm.connect('/dev/ttyUSB0', 115200, 255, 0) |
| 29 | + |
| 30 | +# Create a list of messages to send to the respective agents |
| 31 | +msgs = [] |
| 32 | + |
| 33 | +# Send an arming message to Agent (2, 1) |
| 34 | +msgs.append(OutgoingMsg(MsgMap().system_commands.arm, 2, 1)) |
| 35 | + |
| 36 | +# Send the desired messages and check for message acknowledgement |
| 37 | +mavswarm.send_msg(msgs, ack=True) |
| 38 | + |
| 39 | +# Read the current state of the swarm agents |
| 40 | +for agent in mavswarm.get_agents(): |
| 41 | + print(f'Latitude: {agent.location.latitude} Longitude: {agent.location.longitude}') |
| 42 | + |
| 43 | +# Close the pymavswarm connection |
| 44 | +mavswarm.disconnect() |
| 45 | +``` |
| 46 | + |
| 47 | +## License |
| 48 | +SwarmPlanner is released under the GNU General Public License v3 or later |
0 commit comments