forked from MissouriMRR/SUAS-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
"""Defines the state classes.""" | ||
|
||
from state_machine.states.impl import Airdrop, Land, ODLC, Start, Takeoff, Waypoint | ||
from state_machine.states.impl import ( | ||
Airdrop, | ||
Land, | ||
Mapping, | ||
ODLC, | ||
Start, | ||
Takeoff, | ||
Waypoint, | ||
) | ||
from state_machine.states.state import State |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Implements the behavior of the Mapping state.""" | ||
|
||
import asyncio | ||
import logging | ||
|
||
import dronekit | ||
|
||
from state_machine.state_tracker import ( | ||
update_state, | ||
update_drone, | ||
update_flight_settings, | ||
) | ||
from state_machine.states.mapping import Mapping | ||
|
||
|
||
async def run(self: Mapping) -> None: | ||
""" | ||
Implements the run method for the Mapping state. | ||
This method captures photos of the mapping area and then transitions to the ODLC state. | ||
Returns | ||
------- | ||
ODLC : State | ||
The next state after the drone has successfully landed. | ||
""" | ||
try: | ||
update_state("Mapping") | ||
update_drone(self.drone) | ||
update_flight_settings(self.flight_settings) | ||
|
||
logging.info("Mapping") | ||
|
||
# TODO: Implement the mapping state | ||
raise NotImplementedError("Mapping state not implemented yet") | ||
|
||
logging.info("Mapping state complete.") | ||
except asyncio.CancelledError as ex: | ||
logging.error("Mapping state canceled") | ||
raise ex | ||
|
||
|
||
# Setting the run_callable attribute of the Mapping class to the run function | ||
Mapping.run_callable = run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Declares the Mapping state class.""" | ||
|
||
from typing import Awaitable, Callable, ClassVar | ||
|
||
from state_machine.states.state import State | ||
|
||
|
||
class Mapping(State): | ||
""" | ||
The Mapping state of the state machine. | ||
This state represents the phase in which the drone is capturing photos of the mapping area. | ||
Attributes | ||
---------- | ||
run_callable : ClassVar[Callable[["Mapping"], Awaitable[State]]] | ||
The callable object to call when this state is run. This object is | ||
shared between all instances of this class. | ||
Methods | ||
------- | ||
run(self) -> Awaitable[State]: | ||
Execute the logic associated with this state and return the next state | ||
to transition to. | ||
""" | ||
|
||
run_callable: ClassVar[Callable[["Mapping"], Awaitable[State]]] | ||
|
||
def run(self) -> Awaitable[State]: | ||
return self.run_callable() |