Skip to content

Commit 87b2062

Browse files
authored
Merge pull request #1 from unl-nimbus-lab/develop
Release 0.0.1
2 parents 4e92cc4 + 4d64b19 commit 87b2062

18 files changed

+1199
-1
lines changed

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,48 @@
11
# 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

pymavswarm/Agent.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import monotonic
2+
from .state import *
3+
4+
5+
class Agent:
6+
"""
7+
Agent represents and stores the state of an agent in the network. The
8+
agent's state is updated as new MAVLink messages are received from the
9+
associated message
10+
"""
11+
def __init__(self, sys_id, comp_id, timeout_period=30) -> None:
12+
self.sys_id: int = sys_id
13+
self.comp_id: int = comp_id
14+
self.attitude: Attitude = Attitude()
15+
self.battery: Battery = Battery()
16+
self.docker_info: DockerInfo = DockerInfo()
17+
self.gps_info: GPSInfo = GPSInfo()
18+
self.location: Location = Location()
19+
self.ekf: EKFStatus = EKFStatus()
20+
self.telemetry: Telemetry = Telemetry()
21+
self.velocity: Velocity = Velocity()
22+
self.armed: bool = False
23+
self.flight_mode: str = 'None'
24+
self.system_status = 'None'
25+
self.vehicle_type = 'None'
26+
self.last_heartbeat: int = monotonic.monotonic()
27+
self.timeout_period: int = timeout_period
28+
self.timeout: bool = False

0 commit comments

Comments
 (0)