@@ -34,13 +34,12 @@ class PyCostmap2D:
3434
3535 def __init__ (self , occupancy_map ):
3636 """
37- Initializer for costmap2D.
37+ Initialize costmap2D.
38+
39+ Args:
40+ ----
41+ occupancy_map (OccupancyGrid): 2D OccupancyGrid Map
3842
39- Initialize instance variables with parameter occupancy_map.
40- Args:
41- occupancy_map (OccupancyGrid): 2D OccupancyGrid Map
42- Returns:
43- None
4443 """
4544 self .size_x = occupancy_map .info .width
4645 self .size_y = occupancy_map .info .height
@@ -92,49 +91,65 @@ def getCostXY(self, mx: int, my: int) -> np.uint8:
9291 """
9392 Get the cost of a cell in the costmap using map coordinate XY.
9493
95- Args:
96- mx (int): map coordinate X to get cost
97- my (int): map coordinate Y to get cost
98- Returns:
99- np.uint8: cost of a cell
94+ Args
95+ ----
96+ mx (int): map coordinate X to get cost
97+ my (int): map coordinate Y to get cost
98+
99+ Returns
100+ -------
101+ np.uint8: cost of a cell
102+
100103 """
101104 return self .costmap [self .getIndex (mx , my )]
102105
103106 def getCostIdx (self , index : int ) -> np .uint8 :
104107 """
105108 Get the cost of a cell in the costmap using Index.
106109
107- Args:
108- index (int): index of cell to get cost
109- Returns:
110- np.uint8: cost of a cell
110+ Args
111+ ----
112+ index (int): index of cell to get cost
113+
114+ Returns
115+ -------
116+ np.uint8: cost of a cell
117+
111118 """
112119 return self .costmap [index ]
113120
114121 def setCost (self , mx : int , my : int , cost : np .uint8 ) -> None :
115122 """
116123 Set the cost of a cell in the costmap using map coordinate XY.
117124
118- Args:
119- mx (int): map coordinate X to get cost
120- my (int): map coordinate Y to get cost
121- cost (np.uint8): The cost to set the cell
122- Returns:
123- None
125+ Args
126+ ----
127+ mx (int): map coordinate X to get cost
128+ my (int): map coordinate Y to get cost
129+ cost (np.uint8): The cost to set the cell
130+
131+ Returns
132+ -------
133+ None
134+
124135 """
125136 self .costmap [self .getIndex (mx , my )] = cost
126137
127138 def mapToWorld (self , mx : int , my : int ) -> tuple [float , float ]:
128139 """
129140 Get the world coordinate XY using map coordinate XY.
130141
131- Args:
132- mx (int): map coordinate X to get world coordinate
133- my (int): map coordinate Y to get world coordinate
134- Returns:
135- tuple of float: wx, wy
136- wx (float) [m]: world coordinate X
137- wy (float) [m]: world coordinate Y
142+ Args
143+ ----
144+ mx (int): map coordinate X to get world coordinate
145+ my (int): map coordinate Y to get world coordinate
146+
147+ Returns
148+ -------
149+ tuple of float: wx, wy
150+ wx (float) [m]: world coordinate X
151+ wy (float) [m]: world coordinate Y
152+
138153 """
139154 wx = self .origin_x + (mx + 0.5 ) * self .resolution
140155 wy = self .origin_y + (my + 0.5 ) * self .resolution
@@ -144,13 +159,17 @@ def worldToMap(self, wx: float, wy: float) -> tuple[int, int]:
144159 """
145160 Get the map coordinate XY using world coordinate XY.
146161
147- Args:
148- wx (float) [m]: world coordinate X to get map coordinate
149- wy (float) [m]: world coordinate Y to get map coordinate
150- Returns:
151- tuple of int: mx, my
152- mx (int): map coordinate X
153- my (int): map coordinate Y
162+ Args
163+ ----
164+ wx (float) [m]: world coordinate X to get map coordinate
165+ wy (float) [m]: world coordinate Y to get map coordinate
166+
167+ Returns
168+ -------
169+ tuple of int: mx, my
170+ mx (int): map coordinate X
171+ my (int): map coordinate Y
172+
154173 """
155174 mx = int ((wx - self .origin_x ) // self .resolution )
156175 my = int ((wy - self .origin_y ) // self .resolution )
@@ -160,10 +179,14 @@ def getIndex(self, mx: int, my: int) -> int:
160179 """
161180 Get the index of the cell using map coordinate XY.
162181
163- Args:
164- mx (int): map coordinate X to get Index
165- my (int): map coordinate Y to get Index
166- Returns:
167- int: The index of the cell
182+ Args
183+ ----
184+ mx (int): map coordinate X to get Index
185+ my (int): map coordinate Y to get Index
186+
187+ Returns
188+ -------
189+ int: The index of the cell
190+
168191 """
169192 return my * self .size_x + mx
0 commit comments