Skip to content

Commit 98e6ae6

Browse files
authored
Integrate Parameter Configuration, Add Initial Mission Command Support, Increase Performance (#25)
* Fixed issue with readme * Integrate HRL Support (#8) * Added missing type hints * Refactored to cleanup message sending and added support to send msg until ack * Added support for new HRL messages * Updated devices to use tuple key and ensure msg target in network * Added requirement to clone repo in readme * Resolved grammatical error * Updated readme to reflect require_ack change * Updated python requirement in readme and updated setup version * Resolved errors in structuring named value int message * Cleaned up readme formatting * Created dependencies section in readme * Update Message Commands and Handlers (#15) * Add HRL Support (#10) * Fixed issue with readme * Integrate HRL Support (#8) * Added missing type hints * Refactored to cleanup message sending and added support to send msg until ack * Added support for new HRL messages * Updated devices to use tuple key and ensure msg target in network * Added requirement to clone repo in readme * Resolved grammatical error * Updated readme to reflect require_ack change * Updated python requirement in readme and updated setup version * Resolved errors in structuring named value int message * Cleaned up readme formatting * Created dependencies section in readme * Removed ros commands, fixed gps, renamed outgoingmsg to agentmsg, fixed ack issue * fixed setup version * Cleaned up debug messages and fixed readme example * Add Param Setting and Reading (#19) * Resolved typo in readme * Re-update send command methods to use timeout instead of infinite loop * Refactored various send message functions into single function * Implemented starter waypoint and mission support * Added mission to agent object * Updated agent to have name field * Rename timeout period in agent * Modified agentmsg to be parent class and updated send method to used full msg * Refactored send message to be more usable and added new commands * Added waypoint and takeoff messages * Added simple takeoff and takeoff command support * Add catches to prevent invalid altitude settings * Code cleanup * Added missing method type hints * Fixed mission init and msgmap init * Updated common messages to use msg timeout * Fixed variable naming in msgs * Updated senders to check ack instead of in retry function * Add support to set parameters * Added support to set parameters and started process of enabling reading parameters * Cleaned up agent and modified parameters stored to be circular buffer * Added interface to read parameters * Removed unused files * Added assertions to message construction to ensure proper msg type is provided * Added debug statements to parameter read method * Resolved bugs in message sending and message map * Wrapped up implementation of initial parameter setting and reading feature * Removed unused comments * Refactored send message implementation to create new thread on call * Refactored parameter implementation to use independent threads * Removed log option and made just debug * Cleaned up parameter read implementation
1 parent 199c4fe commit 98e6ae6

33 files changed

+1621
-289
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pip3 install .
2222
`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.
2323

2424
```python
25-
from pymavswarm import MavSwarm, OutgoingMsg, MsgMap
25+
from pymavswarm import MavSwarm, AgentMsg, MsgMap
2626

2727
# Create a new pymavswarm interface
2828
mavswarm = MavSwarm()
@@ -34,10 +34,10 @@ mavswarm.connect('/dev/ttyUSB0', 115200, 255, 0)
3434
msgs = []
3535

3636
# Send an arming message to Agent (2, 1)
37-
msgs.append(OutgoingMsg(MsgMap().system_commands.arm, 2, 1))
37+
msgs.append(AgentMsg(MsgMap.system_commands.arm, 2, 1, True))
3838

3939
# Send the desired messages and require that the messages be acknowledged
40-
mavswarm.send_msg(msgs, require_ack=True)
40+
mavswarm.send_msg(msgs)
4141

4242
# Read the current state of the swarm agents
4343
for agent in mavswarm.get_agents():

pymavswarm/Agent.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
import monotonic
22
from .state import *
3+
from .mission import Mission
4+
from .param import Parameter
5+
from typing import Optional
6+
from collections import deque
7+
38

49

510
class Agent:
611
"""
712
Agent represents and stores the state of an agent in the network. The
813
agent's state is updated as new MAVLink messages are received from the
914
associated message
15+
Params:
16+
- sys_id : int : The system ID of the agent
17+
- comp_id : int : The componenet ID of the agent
18+
- name : str : The name assigned to the agent
19+
- timeout_period : float : The timeout period of the agent
20+
- max_params_stored : int : The maximum number of parameters that should be stored by an agent at once (implemented using a circular buffer)
1021
"""
11-
def __init__(self, sys_id, comp_id, timeout_period=30) -> None:
22+
def __init__(self, sys_id: int,
23+
comp_id: int,
24+
name: Optional[str]=None,
25+
timeout_period: float=30.0,
26+
max_params_stored: int=5) -> None:
1227
self.sys_id: int = sys_id
1328
self.comp_id: int = comp_id
29+
self.name: Optional[str] = name
1430
self.attitude: Attitude = Attitude()
1531
self.battery: Battery = Battery()
1632
self.docker_info: DockerInfo = DockerInfo()
@@ -24,5 +40,10 @@ def __init__(self, sys_id, comp_id, timeout_period=30) -> None:
2440
self.system_status = 'None'
2541
self.vehicle_type = 'None'
2642
self.last_heartbeat: int = monotonic.monotonic()
27-
self.timeout_period: int = timeout_period
28-
self.timeout: bool = False
43+
self.timeout_period: float = timeout_period
44+
self.timeout: bool = False
45+
self.current_waypoint: int = 0
46+
self.mission: Mission = Mission()
47+
self.last_params_read = deque(maxlen=max_params_stored)
48+
49+
return

0 commit comments

Comments
 (0)