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

Add code style checks #331

Merged
merged 6 commits into from
Nov 23, 2023
Merged
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
4 changes: 4 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 120
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Add pre-commit auto formatting
31956156a6cab20c1f54f976dac745d95a1254c0
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Code style checks

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: Install cppcheck
run: sudo apt install cppcheck -y
- uses: pre-commit/[email protected]
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args:
- "--fix"
- "--exit-non-zero-on-fix"
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-format
args:
- "-i"
- id: cppcheck
args:
- "--suppress=missingInclude"
- "--suppress=unmatchedSuppression"
- "--suppress=unusedFunction"
11 changes: 6 additions & 5 deletions bitbots_blackboard/bitbots_blackboard/blackboard.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import tf2_ros as tf2
from bitbots_utils.utils import get_parameter_dict
from rclpy.node import Node

from bitbots_blackboard.capsules.animation_capsule import AnimationCapsule
from bitbots_blackboard.capsules.misc_capsule import MiscCapsule
from bitbots_blackboard.capsules.costmap_capsule import CostmapCapsule
from bitbots_blackboard.capsules.game_status_capsule import GameStatusCapsule
from bitbots_blackboard.capsules.kick_capsule import KickCapsule
from bitbots_blackboard.capsules.misc_capsule import MiscCapsule
from bitbots_blackboard.capsules.pathfinding_capsule import PathfindingCapsule
from bitbots_blackboard.capsules.team_data_capsule import TeamDataCapsule
from bitbots_blackboard.capsules.world_model_capsule import WorldModelCapsule
from bitbots_blackboard.capsules.costmap_capsule import CostmapCapsule
from bitbots_utils.utils import get_parameter_dict
from rclpy.node import Node
import tf2_ros as tf2


class BodyBlackboard:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

Communicates with the animation action server and plays predefined animations.
"""
from bitbots_msgs.action import Dynup, LookAt, PlayAnimation
from rclpy.action import ActionClient
from rclpy.callback_groups import ReentrantCallbackGroup
from rclpy.duration import Duration
from rclpy.node import Node

from bitbots_msgs.action import Dynup, LookAt, PlayAnimation


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

self.animation_client = ActionClient(
node,
PlayAnimation,
'animation',
callback_group=ReentrantCallbackGroup())
self.animation_client = ActionClient(node, PlayAnimation, "animation", callback_group=ReentrantCallbackGroup())

self.dynup_action_client = ActionClient(
node,
Dynup,
"dynup",
callback_group=ReentrantCallbackGroup())
self.dynup_action_client = ActionClient(node, Dynup, "dynup", callback_group=ReentrantCallbackGroup())

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

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

if not self.animation_client.wait_for_server(Duration(seconds=10)):
self.node.get_logger().error(
"Animation Action Server not running! Motion can not work without animation action server.")
"Animation Action Server not running! Motion can not work without animation action server."
)
return False

goal = PlayAnimation.Goal()
goal.animation = animation
goal.hcm = from_hcm # the animation is from the hcm
self.animation_client.send_goal_async(goal).add_done_callback(
lambda future: future.result().get_result_async().add_done_callback(
lambda _: self.__done_cb()))
lambda future: future.result().get_result_async().add_done_callback(lambda _: self.__done_cb())
)

self.active = True

Expand Down
Loading
Loading