Skip to content

Commit

Permalink
Update with pre-commit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrxyz committed Aug 8, 2023
1 parent 1304cda commit 238bdd9
Show file tree
Hide file tree
Showing 36 changed files with 57 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,7 @@ def publish(self, timer_event):
)
print(e)
fprint(
"w: {}, h: {}".format(
global_ogrid.info.width,
global_ogrid.info.height,
),
f"w: {global_ogrid.info.width}, h: {global_ogrid.info.height}",
msg_color="red",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,11 @@ def from_urdf(
if find != -1 and find + len(transmission_suffix) == len(transmission.name):
if len(transmission.joints) != 1:
raise Exception(
"Transmission {} does not have 1 joint".format(
transmission.name,
),
f"Transmission {transmission.name} does not have 1 joint",
)
if len(transmission.actuators) != 1:
raise Exception(
"Transmission {} does not have 1 actuator".format(
transmission.name,
),
f"Transmission {transmission.name} does not have 1 actuator",
)

t_ratio = transmission.actuators[0].mechanicalReduction
Expand All @@ -195,9 +191,7 @@ def from_urdf(
joint = t_joint
if joint is None:
rospy.logerr(
"Transmission joint {} not found".format(
transmission.joints[0].name,
),
f"Transmission joint {transmission.joints[0].name} not found",
)
try:
trans = buff.lookup_transform(
Expand All @@ -217,9 +211,7 @@ def from_urdf(
joints.append(joint.name)
if limit != -1 and joint.limit.effort != limit:
raise Exception(
"Thruster {} had a different limit, cannot proceed".format(
joint.name,
),
f"Thruster {joint.name} had a different limit, cannot proceed",
)
limit = joint.limit.effort
limit_tuple = (limit, -limit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,15 @@ def _online_bagger_cb(self, status, result):
rospy.loginfo(f"KILL BAG WRITTEN TO {result.filename}")
else:
rospy.logwarn(
"KILL BAG {}, status: {}".format(
TerminalState.to_string(status),
result.status,
),
f"KILL BAG {TerminalState.to_string(status)}, status: {result.status}",
)

def _kill_task_cb(self, status, result):
if status == 3:
rospy.loginfo("Killed task success!")
return
rospy.logwarn(
"Killed task failed ({}): {}".format(
TerminalState.to_string(status),
result.result,
),
f"Killed task failed ({TerminalState.to_string(status)}): {result.result}",
)

def raised(self, alarm):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ def _check_faults(self, msg, topic):
return
self.broadcaster.raise_alarm(
severity=5,
problem_description="{} thrusters have faults".format(
len(self._raised_alarms),
),
problem_description=f"{len(self._raised_alarms)} thrusters have faults",
parameters={
t: self._get_fault_codes(k) for t, k in self._raised_alarms.items()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,7 @@ async def search_sides(self, moves):
self.shape_pose = found_pose
return
fprint(
"Saw (Shape={}, Color={}) on this side".format(
shape_color[0],
shape_color[1],
),
f"Saw (Shape={shape_color[0]}, Color={shape_color[1]}) on this side",
title="DETECT DELIVER",
msg_color="green",
)
Expand Down Expand Up @@ -287,10 +284,7 @@ def select_backup_shape(self):
self.shape_pose = point_normal
if self.Shape == shape or self.Color == color:
fprint(
"Correct shape not found, resorting to shape={} color={}".format(
shape,
color,
),
f"Correct shape not found, resorting to shape={shape} color={color}",
title="DETECT DELIVER",
msg_color="yellow",
)
Expand Down Expand Up @@ -430,9 +424,7 @@ async def shoot_and_align_forest(self):
move = await self.align_to_target()
if move.failure_reason != "":
fprint(
"Error Aligning with target = {}. Ending mission :(".format(
move.failure_reason,
),
f"Error Aligning with target = {move.failure_reason}. Ending mission :(",
title="DETECT DELIVER",
msg_color="red",
)
Expand Down Expand Up @@ -479,9 +471,7 @@ async def shoot_and_align(self):
move = await self.align_to_target()
if move.failure_reason != "":
fprint(
"Error Aligning with target = {}. Ending mission :(".format(
move.failure_reason,
),
f"Error Aligning with target = {move.failure_reason}. Ending mission :(",
title="DETECT DELIVER",
msg_color="red",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,7 @@ async def check_bays(self):

def update_shape(self, shape_res, normal_res, tf):
print_good(
"Found (Shape={}, Color={} in a bay".format(
shape_res.Shape,
shape_res.Color,
),
f"Found (Shape={shape_res.Shape}, Color={shape_res.Color} in a bay",
)
self.identified_shapes[(shape_res.Shape, shape_res.Color)] = self.get_shape_pos(
normal_res,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ async def run(self, args):
"yl": "yaw_left",
"yr": "yaw_right",
}
command = (
command if command not in shorthand.keys() else shorthand[command]
)
command = command if command not in shorthand else shorthand[command]
movement = getattr(self.move, command)

trans_move = command[:3] != "yaw"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ async def explore_closest_until(self, is_done, filter_and_sort):
)
if classification_index != -1:
self.send_feedback(
"{} identified. Canceling investigation".format(
move_id_tuple[1],
),
f"{move_id_tuple[1]} identified. Canceling investigation",
)
move_task.cancel()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ async def explore_closest_until(self, is_done, filter_and_sort):
)
if classification_index != -1:
self.send_feedback(
"{} identified. Canceling investigation".format(
move_id_tuple[1],
),
f"{move_id_tuple[1]} identified. Canceling investigation",
)
move_id_tuple[0].cancel()
await self.nh.sleep(1.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ async def run(self, parameters):
)
elif objects[key] != new_objects[key]:
self.send_feedback(
"{} changed from {} to {}".format(
key,
objects[key],
new_objects[key],
),
f"{key} changed from {objects[key]} to {new_objects[key]}",
)
await self.announce_object(
key,
Expand Down
39 changes: 6 additions & 33 deletions NaviGator/simulation/navigator_gazebo/test/test_sim_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ def test_odom(self):
rospy.sleep(0.1)
self.assertTrue(
len(self.odom_pos_msg) == 3 and len(self.odom_ori_msg) == 4,
msg="POS, ORI: {}, {}".format(
len(self.odom_pos_msg),
len(self.odom_ori_msg),
),
msg=f"POS, ORI: {len(self.odom_pos_msg)}, {len(self.odom_ori_msg)}",
)
initial_pos = [-1.2319, 0.0, 0.0]
initial_ori = [0.0, 0.0, 0.0, 1.0]
Expand All @@ -100,10 +97,7 @@ def test_absodom(self):
rospy.sleep(0.1)
self.assertTrue(
len(self.absodom_pos_msg) == 3 and len(self.absodom_ori_msg) == 4,
msg="POS, ORI: {}, {}".format(
len(self.absodom_pos_msg),
len(self.absodom_ori_msg),
),
msg=f"POS, ORI: {len(self.absodom_pos_msg)}, {len(self.absodom_ori_msg)}",
)
initial_pos = [743789.637462, -5503821.36715, 3125622.10477]
initial_ori = [0.0, 0.0, 0.0, 1.0]
Expand All @@ -122,25 +116,13 @@ def verify_pos_ori(self, pos, initial_pos, ori, initial_ori, topic):
actual,
initial,
places=0,
msg=(
"Error: {} position is: {} should be {}".format(
topic,
actual,
initial,
)
),
msg=(f"Error: {topic} position is: {actual} should be {initial}"),
)
for actual, initial in zip(ori, initial_ori):
self.assertEqual(
actual,
initial,
msg=(
"Error: {} orientation is: {} should be {}".format(
topic,
actual,
initial,
)
),
msg=(f"Error: {topic} orientation is: {actual} should be {initial}"),
)

def cam_info_right_cb(self, msg):
Expand Down Expand Up @@ -229,10 +211,7 @@ def verify_not_empty(self, data_lists, num_topics):
self.assertEqual(
len(data_lists),
num_topics,
msg="Number of topics is {}, should be {}".format(
len(data_lists),
num_topics,
),
msg=f"Number of topics is {len(data_lists)}, should be {num_topics}",
)
for data_list in data_lists:
self.assertNotEqual(len(data_list), 0, msg="data is empty")
Expand All @@ -243,13 +222,7 @@ def verify_info(self, res_info, initial_info, topic):
self.assertNotEqual(
actual_dim,
initial_dim,
msg=(
"Error: {} is: {} shouldn't be {}".format(
topic,
actual_dim,
initial_dim,
)
),
msg=(f"Error: {topic} is: {actual_dim} shouldn't be {initial_dim}"),
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,7 @@ def connect(self) -> None:
"""
if not self.connected:
rospy.loginfo(
"Attempting Connection to TD Server at {}:{}".format(
self.tcp_ip,
self.tcp_port,
),
f"Attempting Connection to TD Server at {self.tcp_ip}:{self.tcp_port}",
)
while not self.connected and not rospy.is_shutdown():
# recreate socket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def get_object_by_id(self, my_id):
req = ObjectDBQueryRequest()
req.name = "all"
resp = await self._database(req)
ans = [obj for obj in resp.objects if obj.id == my_id][0]
ans = next(obj for obj in resp.objects if obj.id == my_id)
return ans

async def begin_observing(self, cb):
Expand Down
5 changes: 1 addition & 4 deletions SubjuGator/command/subjugator_alarm/alarm_handlers/kill.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ def _bag_done_cb(self, status, result):
rospy.loginfo(f"KILL BAG WRITTEN TO {result.filename}")
else:
rospy.logwarn(
"KILL BAG {}, status: {}".format(
TerminalState.to_string(status),
result.status,
),
f"KILL BAG {TerminalState.to_string(status)}, status: {result.status}",
)

def bagger_dump(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ def check_continuity(self, new_odom_msg: Odometry): # True if 'continuous'
if jump > self.MAX_JUMP:
rospy.logerr("ODOM DISCONTINUITY DETECTED")
self.ab.raise_alarm(
problem_description="ODOM DISCONTINUITY DETECTED JUMPED {} METERS".format(
jump,
),
problem_description=f"ODOM DISCONTINUITY DETECTED JUMPED {jump} METERS",
severity=5,
)
self.odom_discontinuity = True
Expand All @@ -120,9 +118,7 @@ def need_kill(self):
if odom_loss:
rospy.logerr_throttle(
1,
"LOST ODOM FOR {} SECONDS".format(
(rospy.Time.now() - self.last_time).to_sec(),
),
f"LOST ODOM FOR {(rospy.Time.now() - self.last_time).to_sec()} SECONDS",
)
self.ab.raise_alarm(
problem_description="LOST ODOM FOR {} SECONDS".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ def wait_for_subscribers(self):
while not rospy.is_shutdown() and self.publisher.get_num_connections() == 0:
if i == 4:
print(
"Waiting for subscriber to connect to {}".format(
self.publisher.name,
),
f"Waiting for subscriber to connect to {self.publisher.name}",
)
rospy.sleep(0.5)
i += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ async def fire(self, target: str):
)

self.print_good(
"{} locked. Firing torpedoes. Hit confirmed, good job Commander.".format(
target,
),
f"{target} locked. Firing torpedoes. Hit confirmed, good job Commander.",
)
sub_pos = await self.tx_pose()
print("Current Sub Position: ", sub_pos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ def find_gate(
p2 = rosmsg_to_numpy(o2.pose.position)
if distance.euclidean(p, p2) > max_distance_away:
fprint(
"Poles too far away. Distance {}".format(
distance.euclidean(p, p2),
),
f"Poles too far away. Distance {distance.euclidean(p, p2)}",
)
continue
if distance.euclidean(p, p2) < min_distance_away:
Expand All @@ -180,10 +178,7 @@ def find_gate(
continue
if abs(line[0]) < 1 and abs(line[1]) < 1:
fprint(
"Objects on top of one another. x {}, y {}".format(
line[0],
line[1],
),
f"Objects on top of one another. x {line[0]}, y {line[1]}",
)
continue
return (p, p2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ async def start_search_in_cone(
distance_tol: float = 10,
speed: float = 0.5,
clear: bool = False,
c_func: Callable = None,
c_func: Callable | None = None,
):
if clear:
print("SONAR_OBJECTS: clearing pointcloud")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ def test():
assert numpy.allclose(
shift2,
shift,
), "Magnetic Hardsoft Compenstion self-test failed, shifts: {}".format(
(shift2, shift),
)
), f"Magnetic Hardsoft Compenstion self-test failed, shifts: {(shift2, shift)}"
assert (
error < 1e-5
), f"Magnetic Hardsoft Compenstion self-test failed, error: {error}"
Expand Down
Loading

0 comments on commit 238bdd9

Please sign in to comment.