@@ -11,20 +11,39 @@ class Node:
1111 """A node class for A* pathfinding"""
1212
1313 def __init__ (self , parent = None , position = None ):
14+ """Initialize the Node class.
15+
16+ Args:
17+ parent (Node, optional): Parent Node. Defaults to None.
18+ position (ob.State, optional): Position of the Node (x, y). Defaults to None.
19+ """
1420 self .parent = parent
1521 self .position = position
1622 self .g = 0
1723 self .h = 0
1824 self .f = 0
1925
20- def __eq__ (self , other ):
26+ def __eq__ (self , other ) -> bool :
27+ """Check if two nodes are equal.
28+
29+ Args:
30+ other (Node): Node to compare to.
31+
32+ Returns:
33+ bool: True if equal, False otherwise.
34+ """
2135 return (
2236 self .position .getX () == other .position .getX ()
2337 and self .position .getY () == other .position .getY ()
2438 )
2539 # return self.position[0] == other.position[0] and self.position[1] == other.position[1]
2640
27- def __str__ (self ):
41+ def __str__ (self ) -> str :
42+ """Return a string representation of the Node.
43+
44+ Returns:
45+ str: String representation of the Node.
46+ """
2847 return (
2948 str (self .position .getX ())
3049 + ", "
@@ -33,20 +52,49 @@ def __str__(self):
3352 + str (self .position .getYaw () * 180 / math .pi )
3453 )
3554
36- def __lt__ (self , other ):
55+ def __lt__ (self , other ) -> bool :
56+ """Check if the current node is less than another node.
57+
58+ Args:
59+ other (Node): Node to compare to.
60+
61+ Returns:
62+ bool: True if less than, False otherwise.
63+ """
3764 return self .f < other .f
3865
39- def __gt__ (self , other ):
66+ def __gt__ (self , other ) -> bool :
67+ """Check if the current node is greater than another node.
68+
69+ Args:
70+ other (Node): Node to compare to.
71+
72+ Returns:
73+ bool: True if greater than, False otherwise.
74+ """
4075 return self .f > other .f
4176
4277
4378class Astar (ob .Planner ):
4479 def __init__ (self , si : ob .SpaceInformation ):
80+ """Initialize the Astar class.
81+
82+ Args:
83+ si (ob.SpaceInformation): Space information.
84+ """
4585 super (Astar , self ).__init__ (si , "Astar" )
4686 self .states_ = []
4787 self .sampler_ = si .allocStateSampler ()
4888
49- def solve (self , ptc : ob .PlannerTerminationCondition ):
89+ def solve (self , ptc : ob .PlannerTerminationCondition ) -> ob .PlannerStatus :
90+ """Solve the Astar problem.
91+
92+ Args:
93+ ptc (ob.PlannerTerminationCondition): Planner termination condition.
94+
95+ Returns:
96+ ob.PlannerStatus: Planner status.
97+ """
5098 pdef = self .getProblemDefinition () # type: ob.ProblemDefinition
5199 goal = pdef .getGoal () # type: ob.GoalState
52100 si = self .getSpaceInformation () # type: ob.SpaceInformation
@@ -138,5 +186,6 @@ def solve(self, ptc: ob.PlannerTerminationCondition):
138186 return ob .PlannerStatus (solved , approximate )
139187
140188 def clear (self ):
189+ """Clear the Astar problem."""
141190 super (Astar , self ).clear ()
142191 self .states_ = []
0 commit comments