From c024624672bb65961aa4ff3f4fb4353f0504db04 Mon Sep 17 00:00:00 2001 From: Kotaro Yoshimoto Date: Wed, 25 Dec 2024 08:45:50 +0900 Subject: [PATCH] =?UTF-8?q?Python=E5=90=91=E3=81=91=E3=81=AElinter/formatt?= =?UTF-8?q?er=E3=82=92ruff=E3=81=A7=E7=B5=B1=E4=B8=80=E3=81=99=E3=82=8B=20?= =?UTF-8?q?(#662)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 9 ++- consai_ros2/consai_visualizer/package.xml | 2 +- .../src/consai_visualizer/field_widget.py | 79 ++++++++++++------ .../src/consai_visualizer/visualizer.py | 81 +++++++++++-------- .../robocup_ssl_comm/launch/comm.launch.py | 4 +- crane_bringup/launch/crane.launch.py | 21 +++-- crane_bringup/launch/data.launch.py | 12 ++- crane_bringup/package.xml | 1 + crane_description/CMakeLists.txt | 6 -- .../crane_description/__init__.py | 4 +- .../crane_description/parameter.py | 4 +- crane_gui/package.xml | 2 +- crane_msgs/CMakeLists.txt | 5 ++ crane_msgs/package.xml | 4 +- crane_robot_skills/package.xml | 1 + crane_visualization_interfaces/CMakeLists.txt | 5 ++ crane_visualization_interfaces/package.xml | 3 + crane_world_model_publisher/package.xml | 1 + scenario_test/STOP_AVOID_BALL.py | 4 +- scenario_test/STOP_ROBOT_SPEED.py | 4 +- scenario_test/emit_from_penalty_01.py | 6 +- scripts/measure_laytency.py | 6 +- utility/crane_lint_common/package.xml | 3 + 23 files changed, 172 insertions(+), 95 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 028843d61..054bec646 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -59,11 +59,12 @@ repos: # hooks: # - id: isort - - repo: https://github.com/psf/black - rev: 24.10.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.4 hooks: - - id: black - args: [--line-length=99, --skip-string-normalization] + - id: ruff + args: [--fix] + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-clang-format rev: v17.0.6 diff --git a/consai_ros2/consai_visualizer/package.xml b/consai_ros2/consai_visualizer/package.xml index 628dcda37..d4f803a34 100644 --- a/consai_ros2/consai_visualizer/package.xml +++ b/consai_ros2/consai_visualizer/package.xml @@ -18,7 +18,7 @@ rqt_py_common ament_lint_auto - ament_lint_common + crane_lint_common diff --git a/consai_ros2/consai_visualizer/src/consai_visualizer/field_widget.py b/consai_ros2/consai_visualizer/src/consai_visualizer/field_widget.py index 36057482f..d01b1fe20 100644 --- a/consai_ros2/consai_visualizer/src/consai_visualizer/field_widget.py +++ b/consai_ros2/consai_visualizer/src/consai_visualizer/field_widget.py @@ -38,7 +38,6 @@ class FieldWidget(QWidget): - def __init__(self, parent=None): super(FieldWidget, self).__init__(parent) @@ -62,7 +61,9 @@ def __init__(self, parent=None): self._draw_area_size = QSizeF(self.rect().size()) # 描画領域サイズ self._scale_field_to_draw = 1.0 # フィールド領域から描画領域に縮小するスケール self._do_rotate_draw_area = False # 描画領域を90度回転するフラグ - self._mouse_clicked_point = QPointF(0.0, 0.0) # マウスでクリックした描画領域の座標 + self._mouse_clicked_point = QPointF( + 0.0, 0.0 + ) # マウスでクリックした描画領域の座標 self._mouse_current_point = QPointF(0.0, 0.0) # マウスカーソルの現在座標 self._mouse_drag_offset = QPointF(0.0, 0.0) # マウスでドラッグした距離 self._previous_update_time = datetime.datetime.now() # 前回の描画時刻 @@ -77,7 +78,9 @@ def set_invert(self, param): self._invert = param def set_visualizer_objects(self, msg): - self._visualizer_objects.setdefault(msg.z_order, {})[(msg.layer, msg.sub_layer)] = msg + self._visualizer_objects.setdefault(msg.z_order, {})[ + (msg.layer, msg.sub_layer) + ] = msg def set_active_layers(self, layers: list[tuple[str, str]]): self._active_layers = layers @@ -167,7 +170,7 @@ def paintEvent(self, event): painter = QPainter(self) # 背景色をセット - painter.setBrush(QColor('darkgreen')) + painter.setBrush(QColor("darkgreen")) painter.drawRect(self.rect()) painter.save() @@ -184,7 +187,7 @@ def paintEvent(self, event): if self._do_rotate_draw_area is True: painter.rotate(-90) - draw_caption = ('caption', 'caption') in self._active_layers + draw_caption = ("caption", "caption") in self._active_layers self._draw_objects_on_transformed_area(painter, draw_caption) self._draw_visualizer_info_on_transformed_area(painter) @@ -228,13 +231,19 @@ def _resize_draw_area(self): else: # 描画回転にヒステリシスをもたせる if self._do_rotate_draw_area is True: - self._draw_area_size = QSizeF(widget_height, widget_height * field_h_per_w) + self._draw_area_size = QSizeF( + widget_height, widget_height * field_h_per_w + ) else: - self._draw_area_size = QSizeF(widget_width, widget_width * field_h_per_w) + self._draw_area_size = QSizeF( + widget_width, widget_width * field_h_per_w + ) self._scale_field_to_draw = self._draw_area_size.width() / field_full_width - def _draw_text(self, painter: QPainter, pos: QPointF, text: str, font_size: int = 10): + def _draw_text( + self, painter: QPainter, pos: QPointF, text: str, font_size: int = 10 + ): # 回転を考慮したテキスト描画関数 painter.save() font = painter.font() @@ -261,7 +270,9 @@ def _to_qcolor(self, color: VisColor): output.setAlphaF(color.alpha) return output - def _draw_objects_on_transformed_area(self, painter: QPainter, draw_caption: bool = False): + def _draw_objects_on_transformed_area( + self, painter: QPainter, draw_caption: bool = False + ): # 描画領域の移動や拡大を考慮した座標系でオブジェクトを描画する for z_order in sorted(self._visualizer_objects): for active_layer in self._active_layers: @@ -312,13 +323,15 @@ def _draw_visualizer_info_on_transformed_area(self, painter: QPainter): drag_line.p2.x = current_point.x() drag_line.p2.y = current_point.y() drag_line.size = 4 - drag_line.color.name = 'lightsalmon' - drag_line.caption = 'dist: {:.1f} : {:.1f}, theta: {:.1f}'.format( + drag_line.color.name = "lightsalmon" + drag_line.caption = "dist: {:.1f} : {:.1f}, theta: {:.1f}".format( distance.x(), distance.y(), theta_deg ) self._draw_shape_line(painter, drag_line, True) - def _draw_objects_on_window_area(self, painter: QPainter, draw_caption: bool = False): + def _draw_objects_on_window_area( + self, painter: QPainter, draw_caption: bool = False + ): # ウィンドウ領域にオブジェクトを描画する for z_order in sorted(self._visualizer_objects): for active_layer in self._active_layers: @@ -335,25 +348,27 @@ def _draw_visualizer_info_on_window_area(self, painter: QPainter): # フレームレートを描画 time_diff = datetime.datetime.now() - self._previous_update_time self._frame_rate_buffer.append(1.0 / time_diff.total_seconds()) - average_frame_rate = sum(self._frame_rate_buffer) / self._frame_rate_buffer.maxlen + average_frame_rate = ( + sum(self._frame_rate_buffer) / self._frame_rate_buffer.maxlen + ) self._previous_update_time = datetime.datetime.now() annotation = ShapeAnnotation() - annotation.text = 'FPS: {:.1f}'.format(average_frame_rate) + annotation.text = "FPS: {:.1f}".format(average_frame_rate) annotation.normalized_x = 0.0 annotation.normalized_y = 0.95 annotation.normalized_width = 0.1 annotation.normalized_height = 0.05 - annotation.color.name = 'white' + annotation.color.name = "white" self._draw_shape_annotation(painter, annotation) # カーソル位置を描画 cursor_pos = self._convert_draw_to_field_pos(self._mouse_current_point) if self._invert: - annotation.text = 'inv' - annotation.color.name = 'lightcoral' + annotation.text = "inv" + annotation.color.name = "lightcoral" else: - annotation.text = 'pos' - annotation.text += ' {:.2f} : {:.2f}'.format(cursor_pos.x(), cursor_pos.y()) + annotation.text = "pos" + annotation.text += " {:.2f} : {:.2f}".format(cursor_pos.x(), cursor_pos.y()) annotation.normalized_x = 0.1 self._draw_shape_annotation(painter, annotation) @@ -365,7 +380,7 @@ def _draw_shape_annotation( TARGET_WIDTH = shape.normalized_width * self.width() TARGET_HEIGHT = shape.normalized_height * self.height() - if shape.text == '': + if shape.text == "": return painter.save() @@ -373,7 +388,9 @@ def _draw_shape_annotation( # TARGET_HEIGHTに合わせてフォントサイズを変更する font = painter.font() font_metrics = QFontMetrics(font) - height_fit_point_size = font.pointSizeF() * TARGET_HEIGHT / font_metrics.height() + height_fit_point_size = ( + font.pointSizeF() * TARGET_HEIGHT / font_metrics.height() + ) font.setPointSizeF(height_fit_point_size) font_metrics = QFontMetrics(font) @@ -396,7 +413,9 @@ def _draw_shape_annotation( painter.restore() - def _draw_shape_point(self, painter: QPainter, shape: ShapePoint, draw_caption: bool = False): + def _draw_shape_point( + self, painter: QPainter, shape: ShapePoint, draw_caption: bool = False + ): painter.setPen(QPen(self._to_qcolor(shape.color), shape.size)) point = self._convert_field_to_draw_point(shape.x, shape.y) painter.drawPoint(point) @@ -404,7 +423,9 @@ def _draw_shape_point(self, painter: QPainter, shape: ShapePoint, draw_caption: if draw_caption: self._draw_text(painter, point, shape.caption) - def _draw_shape_line(self, painter: QPainter, shape: ShapeLine, draw_caption: bool = False): + def _draw_shape_line( + self, painter: QPainter, shape: ShapeLine, draw_caption: bool = False + ): painter.setPen(QPen(self._to_qcolor(shape.color), shape.size)) p1 = self._convert_field_to_draw_point(shape.p1.x, shape.p1.y) p2 = self._convert_field_to_draw_point(shape.p2.x, shape.p2.y) @@ -417,7 +438,9 @@ def _draw_shape_line(self, painter: QPainter, shape: ShapeLine, draw_caption: bo ) self._draw_text(painter, p_mid, shape.caption) - def _draw_shape_arc(self, painter: QPainter, shape: ShapeArc, draw_caption: bool = False): + def _draw_shape_arc( + self, painter: QPainter, shape: ShapeArc, draw_caption: bool = False + ): painter.setPen(QPen(self._to_qcolor(shape.color), shape.size)) top_left = self._convert_field_to_draw_point( @@ -476,7 +499,9 @@ def _draw_shape_circle( ) self._draw_text(painter, bottom, shape.caption) - def _draw_shape_tube(self, painter: QPainter, shape: ShapeTube, draw_caption: bool = False): + def _draw_shape_tube( + self, painter: QPainter, shape: ShapeTube, draw_caption: bool = False + ): painter.setPen(QPen(self._to_qcolor(shape.line_color), shape.line_size)) painter.setBrush(self._to_qcolor(shape.fill_color)) @@ -524,7 +549,9 @@ def _draw_shape_tube(self, painter: QPainter, shape: ShapeTube, draw_caption: bo if draw_caption: self._draw_text(painter, bottom_left, shape.caption) - def _draw_shape_robot(self, painter: QPainter, shape: ShapeRobot, draw_caption: bool = False): + def _draw_shape_robot( + self, painter: QPainter, shape: ShapeRobot, draw_caption: bool = False + ): painter.setPen(QPen(self._to_qcolor(shape.line_color), shape.line_size)) painter.setBrush(self._to_qcolor(shape.fill_color)) diff --git a/consai_ros2/consai_visualizer/src/consai_visualizer/visualizer.py b/consai_ros2/consai_visualizer/src/consai_visualizer/visualizer.py index be957cbf1..54647caf1 100644 --- a/consai_ros2/consai_visualizer/src/consai_visualizer/visualizer.py +++ b/consai_ros2/consai_visualizer/src/consai_visualizer/visualizer.py @@ -36,11 +36,10 @@ class Visualizer(Plugin): - def __init__(self, context): super(Visualizer, self).__init__(context) - self.setObjectName('Visualizer') + self.setObjectName("Visualizer") self._node = context.node self._logger = self._node.get_logger() @@ -49,32 +48,34 @@ def __init__(self, context): # widgetを読み込む # FieldWidgetはカスタムウィジェットとしてuiファイルに設定済み - pkg_name = 'consai_visualizer' - _, package_path = get_resource('packages', pkg_name) - ui_file = os.path.join(package_path, 'share', pkg_name, 'resource', 'visualizer.ui') - loadUi(ui_file, self._widget, {'FieldWidget': FieldWidget}) + pkg_name = "consai_visualizer" + _, package_path = get_resource("packages", pkg_name) + ui_file = os.path.join( + package_path, "share", pkg_name, "resource", "visualizer.ui" + ) + loadUi(ui_file, self._widget, {"FieldWidget": FieldWidget}) # rqtのUIにwidgetを追加する if context.serial_number() > 1: self._widget.setWindowTitle( - self._widget.windowTitle() + (' (%d)' % context.serial_number()) + self._widget.windowTitle() + (" (%d)" % context.serial_number()) ) context.add_widget(self._widget) # loggerをセット self._widget.field_widget.set_logger(self._logger) - self._add_visualizer_layer('caption', 'caption') + self._add_visualizer_layer("caption", "caption") self._sub_visualize_objects_array = self._node.create_subscription( ObjectsArray, - 'visualizer_objects', + "visualizer_objects", self._callback_visualizer_objects, rclpy.qos.qos_profile_sensor_data, ) self.sub_feedback = self._node.create_subscription( RobotFeedbackArray, - '/robot_feedback', + "/robot_feedback", self._callback_feedback, rclpy.qos.qos_profile_sensor_data, ) @@ -82,22 +83,28 @@ def __init__(self, context): self.ping = PingStatusArray() self.sub_ping = self._node.create_subscription( - PingStatusArray, '/ping', self._callback_ping, 10 + PingStatusArray, "/ping", self._callback_ping, 10 ) - self._pub_replacement = self._node.create_publisher(Replacement, 'replacement', 10) + self._pub_replacement = self._node.create_publisher( + Replacement, "replacement", 10 + ) # Parameterを設定する - self._widget.field_widget.set_invert(self._node.declare_parameter('invert', False).value) + self._widget.field_widget.set_invert( + self._node.declare_parameter("invert", False).value + ) - for team in ['blue', 'yellow']: - for turnon in ['on', 'off']: - method = 'self._widget.btn_all_' + turnon + '_' + team + '.clicked.connect' + for team in ["blue", "yellow"]: + for turnon in ["on", "off"]: + method = ( + "self._widget.btn_all_" + turnon + "_" + team + ".clicked.connect" + ) eval(method)( partial( self._publish_all_robot_turnon_replacement, - team == 'yellow', - turnon == 'on', + team == "yellow", + turnon == "on", ) ) @@ -137,15 +144,15 @@ def save_settings(self, plugin_settings, instance_settings): # layerとsub layerをカンマで結合して保存 active_layers = self._extract_active_layers() - combined_layers = [x[0] + ',' + x[1] for x in active_layers] - instance_settings.set_value('active_layers', pack(combined_layers)) + combined_layers = [x[0] + "," + x[1] for x in active_layers] + instance_settings.set_value("active_layers", pack(combined_layers)) def restore_settings(self, plugin_settings, instance_settings): # UIが起動したときに実行される関数 # カンマ結合されたlayerを復元してセット - combined_layers = unpack(instance_settings.value('active_layers', [])) - active_layers = [x.split(',') for x in combined_layers] + combined_layers = unpack(instance_settings.value("active_layers", [])) + active_layers = [x.split(",") for x in combined_layers] for layer, sub_layer in active_layers: self._add_visualizer_layer(layer, sub_layer, Qt.Checked) @@ -163,8 +170,10 @@ def _callback_visualizer_objects(self, msg): def _add_visualizer_layer(self, layer: str, sub_layer: str, state=Qt.Unchecked): # レイヤーに重複しないように項目を追加する - if layer == '' or sub_layer == '': - self._logger.warning('layer={} or sub_layer={} is empty'.format(layer, sub_layer)) + if layer == "" or sub_layer == "": + self._logger.warning( + "layer={} or sub_layer={} is empty".format(layer, sub_layer) + ) return parents = self._widget.layer_widget.findItems(layer, Qt.MatchExactly, 0) @@ -172,7 +181,9 @@ def _add_visualizer_layer(self, layer: str, sub_layer: str, state=Qt.Unchecked): if len(parents) == 0: new_parent = QTreeWidgetItem(self._widget.layer_widget) new_parent.setText(0, layer) - new_parent.setFlags(new_parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) + new_parent.setFlags( + new_parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable + ) new_child = QTreeWidgetItem(new_parent) else: @@ -210,14 +221,14 @@ def _publish_replacement(self) -> None: # チェックが入ったボタン情報を解析する button = self._widget.radio_buttons.checkedButton() - if button.text() == 'NONE': + if button.text() == "NONE": return - elif button.text() == 'Ball': + elif button.text() == "Ball": self._publish_ball_replacement(start, end) return else: is_yellow = False - if button.text()[0] == 'Y': + if button.text()[0] == "Y": is_yellow = True robot_id = int(button.text()[1:]) self._publish_robot_replacement(start, end, is_yellow, robot_id) @@ -272,12 +283,12 @@ def _update_robot_synthetics(self): for i in range(16): # 電圧 try: - getattr(self._widget, f'robot{i}_voltage').setText( - '{:.2f}'.format(self.latest_battery_voltage[i]) + getattr(self._widget, f"robot{i}_voltage").setText( + "{:.2f}".format(self.latest_battery_voltage[i]) ) except AttributeError: try: - getattr(self._widget, f'robot{i}_voltage').setText(str(0.0)) + getattr(self._widget, f"robot{i}_voltage").setText(str(0.0)) except AttributeError: pass pass @@ -286,14 +297,14 @@ def _update_robot_synthetics(self): try: # 一旦全て"-"で埋める for i in range(12): - getattr(self._widget, f'robot{i}_connection_status').setText('-') + getattr(self._widget, f"robot{i}_connection_status").setText("-") for ping_status in self.ping.ping: getattr( - self._widget, f'robot{ping_status.robot_id}_connection_status' - ).setText('{:.1f}ms'.format(ping_status.ping_ms)) + self._widget, f"robot{ping_status.robot_id}_connection_status" + ).setText("{:.1f}ms".format(ping_status.ping_ms)) except AttributeError: try: - getattr(self._widget, f'robot{i}_connection_status').setText('-') + getattr(self._widget, f"robot{i}_connection_status").setText("-") except AttributeError: pass pass diff --git a/consai_ros2/robocup_ssl_comm/launch/comm.launch.py b/consai_ros2/robocup_ssl_comm/launch/comm.launch.py index 54c482dbd..0b34d7b29 100644 --- a/consai_ros2/robocup_ssl_comm/launch/comm.launch.py +++ b/consai_ros2/robocup_ssl_comm/launch/comm.launch.py @@ -73,7 +73,9 @@ def generate_launch_description(): ], ), ComposableNode( - package="robocup_ssl_comm", plugin="robocup_ssl_comm::GrSim", name="grsim" + package="robocup_ssl_comm", + plugin="robocup_ssl_comm::GrSim", + name="grsim", ), ], output="screen", diff --git a/crane_bringup/launch/crane.launch.py b/crane_bringup/launch/crane.launch.py index c4bec0cfb..3e4a32a75 100644 --- a/crane_bringup/launch/crane.launch.py +++ b/crane_bringup/launch/crane.launch.py @@ -44,7 +44,9 @@ def generate_launch_description(): # DeclareLaunchArgument('referee_port', default_value='10003'), DeclareLaunchArgument("referee_port", default_value="11111"), DeclareLaunchArgument("team", default_value="ibis", description="チーム名"), - DeclareLaunchArgument("sim", default_value="true", description="シミュレータフラグ"), + DeclareLaunchArgument( + "sim", default_value="true", description="シミュレータフラグ" + ), DeclareLaunchArgument( "original_grsim", default_value="false", @@ -67,7 +69,9 @@ def generate_launch_description(): default_value="true", description="ロボットの退場する方向", ), - DeclareLaunchArgument("record", default_value="false", description="rosbag記録フラグ"), + DeclareLaunchArgument( + "record", default_value="false", description="rosbag記録フラグ" + ), Node( condition=UnlessCondition(LaunchConfiguration("simple_ai")), package="crane_session_controller", @@ -184,7 +188,9 @@ def generate_launch_description(): on_exit=default_exit_behavior, ), Node( - package="robocup_ssl_comm", executable="grsim_node", on_exit=default_exit_behavior + package="robocup_ssl_comm", + executable="grsim_node", + on_exit=default_exit_behavior, ), Node( package="crane_robot_receiver", @@ -220,7 +226,11 @@ def generate_launch_description(): {"vision_port": LaunchConfiguration("vision_port")}, {"tracker_address": "224.5.23.2"}, {"tracker_port": 11010}, - {"is_emplace_positive_side": LaunchConfiguration("is_emplace_positive_side")}, + { + "is_emplace_positive_side": LaunchConfiguration( + "is_emplace_positive_side" + ) + }, ], output="screen", on_exit=default_exit_behavior, @@ -265,7 +275,8 @@ def generate_launch_description(): condition=IfCondition(LaunchConfiguration("record")), actions=[ ExecuteProcess( - cmd=["ros2", "bag", "record", "-a", "-s", "mcap"], output="screen" + cmd=["ros2", "bag", "record", "-a", "-s", "mcap"], + output="screen", ), ], ), diff --git a/crane_bringup/launch/data.launch.py b/crane_bringup/launch/data.launch.py index 696ad737e..da951315b 100644 --- a/crane_bringup/launch/data.launch.py +++ b/crane_bringup/launch/data.launch.py @@ -13,10 +13,10 @@ # limitations under the License. from launch import LaunchDescription -from launch.actions import DeclareLaunchArgument, GroupAction, Shutdown +from launch.actions import DeclareLaunchArgument, Shutdown from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node -from launch.conditions import IfCondition, UnlessCondition +from launch.conditions import IfCondition default_exit_behavior = Shutdown() @@ -42,9 +42,13 @@ def generate_launch_description(): ), DeclareLaunchArgument("referee_port", default_value="10003"), # DeclareLaunchArgument("referee_port", default_value="11111"), - DeclareLaunchArgument("team", default_value="Test Team", description="team name"), DeclareLaunchArgument( - "gui", default_value="true", description="Set true if you want to use GUI." + "team", default_value="Test Team", description="team name" + ), + DeclareLaunchArgument( + "gui", + default_value="true", + description="Set true if you want to use GUI.", ), Node( package="robocup_ssl_comm", diff --git a/crane_bringup/package.xml b/crane_bringup/package.xml index 478d4cc7c..2c8f271e2 100755 --- a/crane_bringup/package.xml +++ b/crane_bringup/package.xml @@ -11,6 +11,7 @@ ament_index_python joy launch_ros + ament_lint_auto crane_lint_common diff --git a/crane_description/CMakeLists.txt b/crane_description/CMakeLists.txt index 0175647b0..cb5c9d1a5 100755 --- a/crane_description/CMakeLists.txt +++ b/crane_description/CMakeLists.txt @@ -57,12 +57,6 @@ ament_export_dependencies(python_cmake_module) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # uncomment the line when a copyright and license is not present in all source files - #set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # uncomment the line when this package is not in a git repo - #set(ament_cmake_cpplint_FOUND TRUE) ament_lint_auto_find_test_dependencies() endif() diff --git a/crane_description/crane_description/__init__.py b/crane_description/crane_description/__init__.py index a279ecab3..d106f7aeb 100755 --- a/crane_description/crane_description/__init__.py +++ b/crane_description/crane_description/__init__.py @@ -24,6 +24,8 @@ class crane_parameters: def __init__(self, node, timeout_sec=10.0): param_names = crane_description.parameter.list_parameters(node, timeout_sec) - params = crane_description.parameter.get_parameters(node, param_names, timeout_sec) + params = crane_description.parameter.get_parameters( + node, param_names, timeout_sec + ) for param_name, param_value in params.items(): setattr(self, param_name, param_value) diff --git a/crane_description/crane_description/parameter.py b/crane_description/crane_description/parameter.py index 3dcd5ae92..adef40d3e 100755 --- a/crane_description/crane_description/parameter.py +++ b/crane_description/crane_description/parameter.py @@ -86,7 +86,9 @@ def get_parameters(node, parameter_names, timeout_sec=10.0): elif pvalue.type == ParameterType.PARAMETER_NOT_SET: value = None else: - raise RuntimeError("Unknown parameter type {pvalue.type}".format_map(locals())) + raise RuntimeError( + "Unknown parameter type {pvalue.type}".format_map(locals()) + ) return_values[parameter_names[i]] = value return return_values diff --git a/crane_gui/package.xml b/crane_gui/package.xml index 6398aba88..2b1bfd97e 100644 --- a/crane_gui/package.xml +++ b/crane_gui/package.xml @@ -16,7 +16,7 @@ std_msgs ament_lint_auto - ament_lint_common + crane_lint_common ament_cmake diff --git a/crane_msgs/CMakeLists.txt b/crane_msgs/CMakeLists.txt index 80bdf2115..1c1739e64 100755 --- a/crane_msgs/CMakeLists.txt +++ b/crane_msgs/CMakeLists.txt @@ -63,4 +63,9 @@ rosidl_generate_interfaces(${PROJECT_NAME} DEPENDENCIES builtin_interfaces std_msgs geometry_msgs ) +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + ament_auto_package() diff --git a/crane_msgs/package.xml b/crane_msgs/package.xml index d02aa27ce..11be1569e 100755 --- a/crane_msgs/package.xml +++ b/crane_msgs/package.xml @@ -16,11 +16,11 @@ geometry_msgs std_msgs - rosidl_interface_packages - ament_lint_auto crane_lint_common + rosidl_interface_packages + ament_cmake diff --git a/crane_robot_skills/package.xml b/crane_robot_skills/package.xml index e9a2fa328..357e79641 100755 --- a/crane_robot_skills/package.xml +++ b/crane_robot_skills/package.xml @@ -24,6 +24,7 @@ ament_index_python launch_ros + ament_lint_auto crane_lint_common diff --git a/crane_visualization_interfaces/CMakeLists.txt b/crane_visualization_interfaces/CMakeLists.txt index e53f00bf8..607eba88d 100644 --- a/crane_visualization_interfaces/CMakeLists.txt +++ b/crane_visualization_interfaces/CMakeLists.txt @@ -65,4 +65,9 @@ install( DESTINATION include/${PROJECT_NAME}/${PROJECT_NAME}/ ) +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + ament_auto_package() diff --git a/crane_visualization_interfaces/package.xml b/crane_visualization_interfaces/package.xml index d0642a9e2..c90d1ec28 100644 --- a/crane_visualization_interfaces/package.xml +++ b/crane_visualization_interfaces/package.xml @@ -21,6 +21,9 @@ python3-protobuf rosidl_default_runtime + ament_lint_auto + crane_lint_common + rosidl_interface_packages diff --git a/crane_world_model_publisher/package.xml b/crane_world_model_publisher/package.xml index d44321a45..ba6368eea 100755 --- a/crane_world_model_publisher/package.xml +++ b/crane_world_model_publisher/package.xml @@ -22,6 +22,7 @@ ament_index_python launch_ros + ament_lint_auto crane_lint_common diff --git a/scenario_test/STOP_AVOID_BALL.py b/scenario_test/STOP_AVOID_BALL.py index 9f2c88b0b..e28607b5b 100644 --- a/scenario_test/STOP_AVOID_BALL.py +++ b/scenario_test/STOP_AVOID_BALL.py @@ -32,7 +32,9 @@ def check(x: float, y: float, vx: float = 0.0, vy: float = 0.0): success = True for _ in range(5): - if rcst_comm.observer.customized().get_result("yellow_robot_did_not_avoid_ball"): + if rcst_comm.observer.customized().get_result( + "yellow_robot_did_not_avoid_ball" + ): success = False break time.sleep(1) diff --git a/scenario_test/STOP_ROBOT_SPEED.py b/scenario_test/STOP_ROBOT_SPEED.py index 6f3a6ec9b..836efa102 100644 --- a/scenario_test/STOP_ROBOT_SPEED.py +++ b/scenario_test/STOP_ROBOT_SPEED.py @@ -41,7 +41,9 @@ def yellow_robot_did_not_move( time.sleep(1) assert success is True - assert rcst_comm.observer.customized().get_result("yellow_robot_did_not_move") is False + assert ( + rcst_comm.observer.customized().get_result("yellow_robot_did_not_move") is False + ) if __name__ == "__main__": diff --git a/scenario_test/emit_from_penalty_01.py b/scenario_test/emit_from_penalty_01.py index 04f74d966..0525cc266 100644 --- a/scenario_test/emit_from_penalty_01.py +++ b/scenario_test/emit_from_penalty_01.py @@ -1,9 +1,6 @@ import math import time from rcst.communication import Communication -from rcst import calc -from rcst.ball import Ball -from rcst.robot import RobotDict def is_in_penalty_area(x: float, y: float) -> bool: @@ -19,7 +16,8 @@ def test_emit_from_penalty_01(rcst_comm: Communication): rcst_comm.observer.reset() time.sleep(5) success = not is_in_penalty_area( - rcst_comm.observer.get_world().get_ball().x, rcst_comm.observer.get_world().get_ball().y + rcst_comm.observer.get_world().get_ball().x, + rcst_comm.observer.get_world().get_ball().y, ) assert success is True diff --git a/scripts/measure_laytency.py b/scripts/measure_laytency.py index b93e80ca5..ee59e44f9 100644 --- a/scripts/measure_laytency.py +++ b/scripts/measure_laytency.py @@ -26,9 +26,11 @@ def __init__(self): def detection_callback(self, msg: TrackedFrame): # print("detection_callback") if self.move_start_time is not None: - robot = None for r in msg.robots: - if r.robot_id.id == self.robot_id and r.robot_id.team == RobotId.TEAM_COLOR_BLUE: + if ( + r.robot_id.id == self.robot_id + and r.robot_id.team == RobotId.TEAM_COLOR_BLUE + ): if len(r.vel) > 0: vel_2d = r.vel[0] vel = math.sqrt(vel_2d.x**2 + vel_2d.y**2) diff --git a/utility/crane_lint_common/package.xml b/utility/crane_lint_common/package.xml index 3e7c632d0..dac07f559 100644 --- a/utility/crane_lint_common/package.xml +++ b/utility/crane_lint_common/package.xml @@ -16,6 +16,9 @@ + + + ament_cmake