Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.48.0
rev: v0.49.1
hooks:
- id: markdownlint
args: [-c, .markdownlint.yaml, --fix]
Expand All @@ -32,13 +32,13 @@ repos:
- id: yamllint

- repo: https://github.com/tier4/pre-commit-hooks-ros
rev: v0.10.2
rev: v0.10.3
hooks:
- id: ros-include-guard
- id: sort-package-xml

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.11.0.1
rev: v0.11.0.1-1
hooks:
- id: shellcheck

Expand All @@ -49,14 +49,14 @@ repos:
args: [-w, -s, -i=4]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.12
rev: v0.16.4
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v22.1.4
rev: v22.1.8
hooks:
- id: clang-format
types_or: [c++, c, cuda]
Expand Down
22 changes: 11 additions & 11 deletions crane_mcap_tools/crane_mcap_tools/bag_analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@
from .tracking import BallState, RobotState, track_ball, track_robot

__all__ = [
"BagReader",
"BagData",
"BagInfo",
"TimestampedMsg",
"run_survey",
"detect_events",
"BagReader",
"BallState",
"ControlSnapshot",
"Event",
"track_robot",
"track_ball",
"FactorTransition",
"RobotState",
"BallState",
"TimestampedMsg",
"analyze_control",
"angle_diff",
"ball_to_robot_dist",
"detect_events",
"detect_factor_transitions",
"ControlSnapshot",
"FactorTransition",
"distance_2d",
"run_survey",
"speed_2d",
"speed_3d",
"angle_diff",
"ball_to_robot_dist",
"track_ball",
"track_robot",
]
2 changes: 1 addition & 1 deletion crane_mcap_tools/crane_mcap_tools/bag_analysis/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def cmd_events(args: argparse.Namespace) -> None:

def cmd_control(args: argparse.Namespace) -> None:
"""control_target分析を実行する."""
from .control import detect_factor_transitions, analyze_control
from .control import analyze_control, detect_factor_transitions

time_range = _parse_time_range(getattr(args, "time", None))
changes_only = getattr(args, "changes_only", False)
Expand Down
14 changes: 7 additions & 7 deletions crane_mcap_tools/crane_mcap_tools/mcap_analysis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""MCAP annotation analysis tools for RoboCup SSL matches."""

from .extractor import MCAPAnnotationExtractor, AnnotationContext
from .gemini_client import GeminiAnalysisClient, AnalysisResult
from .extractor import AnnotationContext, MCAPAnnotationExtractor
from .gemini_client import AnalysisResult, GeminiAnalysisClient
from .mcap_tools import MCAP_TOOLS_SCHEMA, MCAPToolsHandler
from .report_generator import ReportGenerator
from .mcap_tools import MCAPToolsHandler, MCAP_TOOLS_SCHEMA

__all__ = [
"MCAPAnnotationExtractor",
"MCAP_TOOLS_SCHEMA",
"AnalysisResult",
"AnnotationContext",
"GeminiAnalysisClient",
"AnalysisResult",
"ReportGenerator",
"MCAPAnnotationExtractor",
"MCAPToolsHandler",
"MCAP_TOOLS_SCHEMA",
"ReportGenerator",
]
11 changes: 4 additions & 7 deletions crane_mcap_tools/crane_mcap_tools/mcap_analysis/gemini_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from dataclasses import dataclass

from .extractor import AnnotationContext
from .mcap_tools import MCAPToolsHandler, MCAP_TOOLS_SCHEMA
from .mcap_tools import MCAP_TOOLS_SCHEMA, MCAPToolsHandler

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -260,12 +260,9 @@ def analyze_annotation_with_tools(

# マークダウンのコードブロックを削除(```json ... ```)
json_text = raw_response.strip()
if json_text.startswith("```json"):
json_text = json_text[7:] # ```json を削除
if json_text.startswith("```"):
json_text = json_text[3:] # ``` を削除
if json_text.endswith("```"):
json_text = json_text[:-3] # ``` を削除
json_text = json_text.removeprefix("```json") # ```json を削除
json_text = json_text.removeprefix("```") # ``` を削除
json_text = json_text.removesuffix("```") # ``` を削除
json_text = json_text.strip()

# JSONをパース
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import logging
from typing import Any

from .extractor import AnnotationContext, WorldModelSnapshot
from ..bag_analysis.metrics import distance_2d, speed_2d, speed_3d
from .extractor import AnnotationContext, WorldModelSnapshot

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion crane_mcap_tools/crane_mcap_tools/svg_video/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from .video_generator import VideoGenerator

__all__ = [
"SvgExtractor",
"SvgAssembler",
"SvgExtractor",
"VideoGenerator",
"create_renderer",
"list_available_backends",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from .resvg_renderer import ResvgPyRenderer

__all__ = [
"SvgRendererBase",
"OutputFormat",
"CairoSvgRenderer",
"OutputFormat",
"ResvgPyRenderer",
"SvgRendererBase",
]
3 changes: 0 additions & 3 deletions crane_mcap_tools/crane_mcap_tools/svg_video/renderers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def render(self, svg_string: str) -> bytes:
Returns:
画像バイト列(フォーマットはoutput_formatに依存)
"""
pass

@classmethod
@abstractmethod
Expand All @@ -64,7 +63,6 @@ def is_available(cls) -> bool:
Returns:
使用可能な場合True
"""
pass

@classmethod
@abstractmethod
Expand All @@ -75,7 +73,6 @@ def get_name(cls) -> str:
Returns:
レンダラー名(例: "cairosvg", "resvg")
"""
pass

@classmethod
def get_description(cls) -> str:
Expand Down
3 changes: 2 additions & 1 deletion crane_mcap_tools/crane_mcap_tools/svg_video/svg_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"""

import logging
from collections.abc import Iterator
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Iterator
from typing import Any

from rclpy.serialization import deserialize_message

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import logging
import subprocess
from collections.abc import Iterator
from enum import Enum
from pathlib import Path
from typing import Iterator

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion crane_mcap_tools/scripts/mcap_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from pathlib import Path

from crane_mcap_tools.mcap_analysis import (
MCAPAnnotationExtractor,
GeminiAnalysisClient,
MCAPAnnotationExtractor,
ReportGenerator,
)
from crane_mcap_tools.mcap_analysis.prompts import (
Expand Down
2 changes: 1 addition & 1 deletion crane_web_debugger/web/download_fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import argparse
import os
import re
import urllib.request
import sys
import urllib.request

UA = (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import os
from pathlib import Path

import launch
from launch.actions import DeclareLaunchArgument, LogInfo
from launch.substitutions import LaunchConfiguration
Expand Down
3 changes: 2 additions & 1 deletion crane_world_model_publisher/scripts/plot_kick_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

import argparse
import json
import sys
import os
import sys
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np

Expand Down
1 change: 0 additions & 1 deletion docker/dev/ball-calibration/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import Literal

import numpy as np

from models import RobustAggregateStats
from robust_fit import FitResult

Expand Down
1 change: 0 additions & 1 deletion docker/dev/ball-calibration/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import math

import numpy as np

from models import (
OptimizationConfig,
OptimizationResult,
Expand Down
5 changes: 2 additions & 3 deletions docker/dev/ball-calibration/robust_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import logging
import math
from collections.abc import Callable
from dataclasses import dataclass, field
from typing import Callable

import numpy as np
from scipy.optimize import least_squares
Expand Down Expand Up @@ -101,8 +101,7 @@ def fit_linear_ransac(
min_samples: int = 5,
) -> FitResult:
"""RANSACRegressor による線形フィット v(t) = v0 - a*t."""
from sklearn.linear_model import RANSACRegressor
from sklearn.linear_model import LinearRegression
from sklearn.linear_model import LinearRegression, RANSACRegressor

result = FitResult(method="ransac")
n = len(time_points)
Expand Down
5 changes: 2 additions & 3 deletions docker/dev/ball-calibration/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
from fastapi import FastAPI, HTTPException, UploadFile
from fastapi.responses import FileResponse, StreamingResponse
from fastapi.staticfiles import StaticFiles

from ssl_log_extractor import extract_ball_timeline_and_trajectories
from models import (
AddTrajectoryRequest,
LoadPathRequest,
Expand All @@ -28,6 +26,7 @@
TrajectoryInfo,
)
from optimizer import compute_predicted_trajectories, run_optimization
from ssl_log_extractor import extract_ball_timeline_and_trajectories
from yaml_exporter import build_yaml_preview, build_yaml_string

logging.basicConfig(level=logging.INFO)
Expand Down Expand Up @@ -342,8 +341,8 @@ async def delete_trajectory(event_id: int) -> dict:
@app.get("/api/bootstrap/{event_id}")
async def get_bootstrap(event_id: int, n_boot: int = 300) -> dict:
"""指定軌道のブートストラップ分布を返す (UI ヒストグラム用)."""
from robust_fit import bootstrap_ci, pick_fit_fn
import numpy as np
from robust_fit import bootstrap_ci, pick_fit_fn

result: OptimizationResult | None = _state["optimization_result"]
if result is None:
Expand Down
2 changes: 1 addition & 1 deletion docker/dev/ball-calibration/ssl_log_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ def extract_ball_timeline_and_trajectories(
logger.info("SSL ログ抽出開始: %s", path)

try:
from ssl_vision_wrapper_tracked_pb2 import TrackerWrapperPacket
from ssl_vision_wrapper_pb2 import SSL_WrapperPacket
from ssl_vision_wrapper_tracked_pb2 import TrackerWrapperPacket
except ImportError as e:
raise RuntimeError(
f"protobuf モジュールが見つかりません。sync_proto.sh を実行してから Docker を"
Expand Down
4 changes: 2 additions & 2 deletions docker/dev/ball-calibration/tests/test_robust_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from __future__ import annotations

import numpy as np

from tests.conftest import make_synthetic_trajectory
from robust_fit import (
FitResult,
bootstrap_ci,
Expand All @@ -15,6 +13,8 @@
pick_fit_fn,
)

from tests.conftest import make_synthetic_trajectory

TRUE_V0 = 4.0
TRUE_DECEL = 0.7
TOL = 0.15 # 許容誤差(m/s または m/s²)
Expand Down
1 change: 0 additions & 1 deletion docker/dev/ball-calibration/yaml_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import time

import yaml

from models import OptimizationResult

logger = logging.getLogger(__name__)
Expand Down
Loading
Loading