Skip to content

Commit 0d3a457

Browse files
authored
Merge pull request #3893 from JdeRobot/pass-formatter
Pass formatter
2 parents 0fd41a8 + bb2aa29 commit 0d3a457

5 files changed

Lines changed: 26 additions & 16 deletions

File tree

exercises/drone_cat_mouse/python_template/HAL.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,31 @@ def __auto_spin() -> None:
7474

7575
_mouse_position = [20.0, 5.0, 0.0]
7676

77+
7778
def _mouse_pose_callback(msg):
7879
_mouse_position[0] = msg.pose.position.x
7980
_mouse_position[1] = msg.pose.position.y
8081
_mouse_position[2] = msg.pose.position.z
8182

83+
8284
_mouse_pose_node = rclpy.create_node("cat_mouse_pose_tracker")
8385
# this topic is published as BEST_EFFORT. if you subscribe with the default
8486
# settings (which are RELIABLE) the two don't match and you receive nothing,
8587
# so get_mouse_position would just keep returning the default below. using
8688
# the sensor-data profile makes both sides BEST_EFFORT, so the messages flow.
8789
_mouse_pose_sub = _mouse_pose_node.create_subscription(
88-
PoseStamped, '/drone1/self_localization/pose', _mouse_pose_callback,
89-
qos_profile_sensor_data
90+
PoseStamped,
91+
"/drone1/self_localization/pose",
92+
_mouse_pose_callback,
93+
qos_profile_sensor_data,
9094
)
9195

9296
executor.add_node(_mouse_pose_node)
9397

9498

9599
### helpers ###
96100

101+
97102
def _call_state_event(event_value):
98103
"""send a state machine event without using asyncio.
99104
the normal DroneWrapper does this through asyncio.run(), which doesn't work

exercises/drone_cat_mouse/python_template/WebGUI.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ def update_gui(self):
9797
b64_right = None
9898
shape_right = 0
9999

100-
self.msg["image_left"] = json.dumps({"image_left": b64_left, "shape_left": shape_left})
101-
self.msg["image_right"] = json.dumps({"image_right": b64_right, "shape_right": shape_right})
100+
self.msg["image_left"] = json.dumps(
101+
{"image_left": b64_left, "shape_left": shape_left}
102+
)
103+
self.msg["image_right"] = json.dumps(
104+
{"image_right": b64_right, "shape_right": shape_right}
105+
)
102106
self.send_to_client(json.dumps(self.msg))
103107

104108
def setLeftImage(self, image):

exercises/drone_cat_mouse/python_template/academy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import math
44

55
TAKEOFF_HEIGHT = 3.0
6-
CHASE_SPEED = 2.0 # keep this above the mouse's 1.5 or the cat never catches up
7-
SLOW_RADIUS = 3.0 # once we're this close, ease off so we don't overshoot
6+
CHASE_SPEED = 2.0 # keep this above the mouse's 1.5 or the cat never catches up
7+
SLOW_RADIUS = 3.0 # once we're this close, ease off so we don't overshoot
88

99
# get off the ground first
1010
HAL.takeoff(TAKEOFF_HEIGHT)
@@ -16,7 +16,7 @@
1616

1717
dx = mouse[0] - cat[0]
1818
dy = mouse[1] - cat[1]
19-
dz = TAKEOFF_HEIGHT - cat[2] # hold our height
19+
dz = TAKEOFF_HEIGHT - cat[2] # hold our height
2020

2121
dist = math.sqrt(dx * dx + dy * dy)
2222

exercises/drone_cat_mouse/python_template/processB/HAL.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __auto_spin() -> None:
5858

5959
### helpers ###
6060

61+
6162
def _call_state_event(event_value):
6263
"""send a state machine event without using asyncio.
6364
the normal DroneWrapper does this through asyncio.run(), which doesn't work

exercises/drone_cat_mouse/python_template/processB/academy.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@
1010
ESCAPE_SPEED = 1.5
1111
# square around the mouse's spawn (x=20, y=5), 10m a side
1212
WAYPOINTS = [
13-
(25.0, 5.0, TAKEOFF_HEIGHT),
13+
(25.0, 5.0, TAKEOFF_HEIGHT),
1414
(25.0, 10.0, TAKEOFF_HEIGHT),
1515
(20.0, 10.0, TAKEOFF_HEIGHT),
1616
(15.0, 10.0, TAKEOFF_HEIGHT),
17-
(15.0, 5.0, TAKEOFF_HEIGHT),
18-
(15.0, 0.0, TAKEOFF_HEIGHT),
19-
(20.0, 0.0, TAKEOFF_HEIGHT),
20-
(25.0, 0.0, TAKEOFF_HEIGHT),
17+
(15.0, 5.0, TAKEOFF_HEIGHT),
18+
(15.0, 0.0, TAKEOFF_HEIGHT),
19+
(20.0, 0.0, TAKEOFF_HEIGHT),
20+
(25.0, 0.0, TAKEOFF_HEIGHT),
2121
]
22-
REACH_THRESHOLD = 1.2 # how close counts as "reached this corner"
22+
REACH_THRESHOLD = 1.2 # how close counts as "reached this corner"
2323

2424

2525
def distance(pos, target):
2626
return math.sqrt(
27-
(pos[0] - target[0]) ** 2 +
28-
(pos[1] - target[1]) ** 2 +
29-
(pos[2] - target[2]) ** 2
27+
(pos[0] - target[0]) ** 2
28+
+ (pos[1] - target[1]) ** 2
29+
+ (pos[2] - target[2]) ** 2
3030
)
3131

3232

0 commit comments

Comments
 (0)