Skip to content

Commit

Permalink
Merge branch 'master' into rqt-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrxyz authored Sep 4, 2023
2 parents ca59e5a + 1562ae9 commit 6fbbb20
Show file tree
Hide file tree
Showing 48 changed files with 394 additions and 201 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ jobs:
submodules: recursive
path: catkin_ws/src/mil
- name: Setup ROS Noetic
uses: ros-tooling/setup-ros@v0.3
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: noetic
- name: Install pip dependencies
run: |
cd $GITHUB_WORKSPACE/catkin_ws/src/mil
pip install -r requirements.txt
pip3 install -r requirements.txt
# We want to run a full test suite in CI - this includes the BlueView
# tests!
- name: Install BlueView Sonar SDK
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ repos:
hooks:
- id: yamllint
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.4
rev: v16.0.6
hooks:
- id: clang-format
- repo: https://github.com/PyCQA/autoflake
rev: v2.1.1
rev: v2.2.0
hooks:
- id: autoflake
args: [--remove-all-unused-imports, --ignore-init-module-imports]
Expand All @@ -34,18 +34,18 @@ repos:
exclude: ^docker|deprecated|NaviGator/simulation/VRX
args: [--severity=warning, --exclude=SC1090]
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.6.0-2
rev: v3.7.0-1
hooks:
- id: shfmt
exclude: ^docker|deprecated|NaviGator/simulation/VRX
- repo: https://github.com/charliermarsh/ruff-pre-commit
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.270'
rev: 'v0.0.282'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.2.5
hooks:
- id: codespell
args:
Expand Down
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
Loading

0 comments on commit 6fbbb20

Please sign in to comment.