Skip to content

Commit af72761

Browse files
fix majority of python linting errors introduced in python costmap API additions to get CI turning over again (#3223)
* fix majority of python linting errors * finish linting
1 parent 80909a1 commit af72761

File tree

2 files changed

+64
-40
lines changed

2 files changed

+64
-40
lines changed

nav2_simple_commander/nav2_simple_commander/costmap_2d.py

Lines changed: 63 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -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

nav2_simple_commander/nav2_simple_commander/robot_navigator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ def waitUntilNav2Active(self, navigator='bt_navigator', localizer='amcl'):
299299
def _getPathImpl(self, start, goal, planner_id='', use_start=False):
300300
"""
301301
Send a `ComputePathToPose` action request.
302+
302303
Internal implementation to get the full result, not just the path.
303304
"""
304305
self.debug("Waiting for 'ComputePathToPose' action server")

0 commit comments

Comments
 (0)