Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit 593ad95

Browse files
authored
Add code style checks (#331)
2 parents 71b7975 + a72d507 commit 593ad95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+912
-745
lines changed

.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
ColumnLimit: 120

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Add pre-commit auto formatting
2+
31956156a6cab20c1f54f976dac745d95a1254c0

.github/workflows/pre-commit.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Code style checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v4
14+
- name: Install cppcheck
15+
run: sudo apt install cppcheck -y
16+
- uses: pre-commit/action@v3.0.0

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.1.6
4+
hooks:
5+
- id: ruff
6+
args:
7+
- "--fix"
8+
- "--exit-non-zero-on-fix"
9+
- repo: https://github.com/psf/black
10+
rev: 23.11.0
11+
hooks:
12+
- id: black
13+
- repo: https://github.com/pocc/pre-commit-hooks
14+
rev: v1.3.5
15+
hooks:
16+
- id: clang-format
17+
args:
18+
- "-i"
19+
- id: cppcheck
20+
args:
21+
- "--suppress=missingInclude"
22+
- "--suppress=unmatchedSuppression"
23+
- "--suppress=unusedFunction"

bitbots_blackboard/bitbots_blackboard/blackboard.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
import tf2_ros as tf2
2+
from bitbots_utils.utils import get_parameter_dict
3+
from rclpy.node import Node
4+
15
from bitbots_blackboard.capsules.animation_capsule import AnimationCapsule
2-
from bitbots_blackboard.capsules.misc_capsule import MiscCapsule
6+
from bitbots_blackboard.capsules.costmap_capsule import CostmapCapsule
37
from bitbots_blackboard.capsules.game_status_capsule import GameStatusCapsule
48
from bitbots_blackboard.capsules.kick_capsule import KickCapsule
9+
from bitbots_blackboard.capsules.misc_capsule import MiscCapsule
510
from bitbots_blackboard.capsules.pathfinding_capsule import PathfindingCapsule
611
from bitbots_blackboard.capsules.team_data_capsule import TeamDataCapsule
712
from bitbots_blackboard.capsules.world_model_capsule import WorldModelCapsule
8-
from bitbots_blackboard.capsules.costmap_capsule import CostmapCapsule
9-
from bitbots_utils.utils import get_parameter_dict
10-
from rclpy.node import Node
11-
import tf2_ros as tf2
1213

1314

1415
class BodyBlackboard:

bitbots_blackboard/bitbots_blackboard/capsules/animation_capsule.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
55
Communicates with the animation action server and plays predefined animations.
66
"""
7+
from bitbots_msgs.action import Dynup, LookAt, PlayAnimation
78
from rclpy.action import ActionClient
89
from rclpy.callback_groups import ReentrantCallbackGroup
910
from rclpy.duration import Duration
1011
from rclpy.node import Node
1112

12-
from bitbots_msgs.action import Dynup, LookAt, PlayAnimation
13-
1413

1514
class AnimationCapsule:
1615
def __init__(self, node: Node):
@@ -25,17 +24,9 @@ def __init__(self, node: Node):
2524
self.cheering_animation: str = self.node.get_parameter("Animations.Misc.cheering").value
2625
self.init_animation: str = self.node.get_parameter("Animations.Misc.init").value
2726

28-
self.animation_client = ActionClient(
29-
node,
30-
PlayAnimation,
31-
'animation',
32-
callback_group=ReentrantCallbackGroup())
27+
self.animation_client = ActionClient(node, PlayAnimation, "animation", callback_group=ReentrantCallbackGroup())
3328

34-
self.dynup_action_client = ActionClient(
35-
node,
36-
Dynup,
37-
"dynup",
38-
callback_group=ReentrantCallbackGroup())
29+
self.dynup_action_client = ActionClient(node, Dynup, "dynup", callback_group=ReentrantCallbackGroup())
3930

4031
self.lookat_action_client = ActionClient(node, LookAt, "look_at_goal")
4132

@@ -56,15 +47,16 @@ def play_animation(self, animation: str, from_hcm: bool) -> bool:
5647

5748
if not self.animation_client.wait_for_server(Duration(seconds=10)):
5849
self.node.get_logger().error(
59-
"Animation Action Server not running! Motion can not work without animation action server.")
50+
"Animation Action Server not running! Motion can not work without animation action server."
51+
)
6052
return False
6153

6254
goal = PlayAnimation.Goal()
6355
goal.animation = animation
6456
goal.hcm = from_hcm # the animation is from the hcm
6557
self.animation_client.send_goal_async(goal).add_done_callback(
66-
lambda future: future.result().get_result_async().add_done_callback(
67-
lambda _: self.__done_cb()))
58+
lambda future: future.result().get_result_async().add_done_callback(lambda _: self.__done_cb())
59+
)
6860

6961
self.active = True
7062

0 commit comments

Comments
 (0)