Skip to content

Commit

Permalink
more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
PRANETALLU committed Nov 25, 2023
1 parent a9bfb1c commit a54d219
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@


class MissionPlannerTest(TestUnit):
"""A definition of the MissionPlannerTest
Args:
TestUnit (object): TestUnit is passed within the class
"""
def __init__(self, nh):
self.nh = nh

def create_spoofs(self):
"""Creates a Spoof Generator object
"""
sg = SpoofGenerator()
empty = PerceptionObjectArray()
stc = PerceptionObjectArray()
Expand Down Expand Up @@ -64,6 +71,8 @@ def create_spoofs(self):
)

async def run_tests(self):
"""Several mission cases are being run.
"""
base_file = (
"/".join(__file__.split("/")[0:-1]) + "/mission_planner_no_markers_yamls"
)
Expand Down Expand Up @@ -110,6 +119,14 @@ async def run_tests(self):
await self.pub_missing_objects

async def _run_mission(self, yaml_file, spoof_pub, spoof_service, desc):
"""Opens up a yaml file and executes actions embedded within objects.
Args:
yaml_file (yaml): a yaml file is passed in
spoof_pub (object): a spoof_pub object is passed in
spoof_service (object): a poof_service executes the action
desc (object): executes the first test
"""
with open(yaml_file) as stream:
try:
spoof_pub.start(self.nh)
Expand Down
40 changes: 40 additions & 0 deletions NaviGator/test/navigator_test/nodes/circle_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ def __init__(
rospy.Timer(rospy.Duration(1), self.publish_ogrid)

def _make_ogrid_transform(self):
"""
Transforms points from ENU to ogrid frame coordinates
Returns:
lambda point: performs a dot operation for ogrid frame coordinates
"""
self.grid = np.zeros(
(self.height / self.resolution, self.width / self.resolution)
)
Expand All @@ -116,6 +122,12 @@ def _make_ogrid_transform(self):
return lambda point: self.t.dot(np.append(point[:2], 1))[:2]

def reseed(self, req: Optional[TriggerRequest]) -> None:
"""
Generates buoys and totems and also checks for proximity
Args:
req (Optional[TriggerRequest]): the reseed operation is being performed on the request.
"""
# Generate some buoys and totems
buoy_positions = np.random.uniform(self.bf_size, size=(self.num_of_buoys, 2))
self.ids = np.array([1, 45, 32, 55])
Expand Down Expand Up @@ -149,6 +161,17 @@ def reseed(self, req: Optional[TriggerRequest]) -> None:
def position_to_object(
self, position: np.ndarray, color: Sequence[int], id, name: str = "totem"
) -> PerceptionObject:
"""_summary_
Args:
position (np.ndarray): position of the object
color (Sequence[int]): color of the sequence is passed in
id (int): id of the object is passed in
name (str, optional): name of the object is passed in. Defaults to "totem".
Returns:
PerceptionObject: "PerceptionObject" instance is created with all the parameters being assigned.
"""
obj = PerceptionObject()
obj.id = int(id)
obj.header = mil_tools.make_header(frame="enu")
Expand All @@ -162,6 +185,14 @@ def position_to_object(
return obj

def got_request(self, req: ObjectDBQueryRequest) -> ObjectDBQueryResponse:
"""Gets a request based on the name of the object
Args:
req (ObjectDBQueryRequest): object that is passed in for comparison purposes
Returns:
ObjectDBQueryResponse: response is submitted based on the request type
"""
fprint(f"Request received {req.name}")
if req.name in self.ids:
index = np.argwhere(self.ids == req.name)
Expand All @@ -187,6 +218,11 @@ def got_request(self, req: ObjectDBQueryRequest) -> ObjectDBQueryResponse:
return ObjectDBQueryResponse(objects=objects, found=True)

def get_message(self) -> OccupancyGrid:
"""An ogrid component is being set with the assigned values.
Returns:
OccupancyGrid: this type of grid is sent with all the passed-in data
"""
if self.grid is None:
fprint(
"Ogrid was requested but no ogrid was found. Using blank.",
Expand All @@ -207,13 +243,17 @@ def get_message(self) -> OccupancyGrid:
return ogrid

def draw_buoys(self) -> None:
"""A buoys is being drawn out, especially with a circle.
"""
for b in self.buoy_positions:
center = tuple(self.transform(b).astype(np.int32).tolist())
cv2.circle(
self.grid, center, int(self.buoy_size / self.resolution), 255, -1
)

def draw_totems(self) -> None:
"""A totem is being drawn with two separate circles.
"""
for b in self.totem_positions:
center = tuple(self.transform(b).astype(np.int32).tolist())
cv2.circle(
Expand Down

0 comments on commit a54d219

Please sign in to comment.