Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

Commit f2cf686

Browse files
Add pre-commit and CI-format (#206)
* Add pre-commit and ci-format
1 parent 6639e53 commit f2cf686

File tree

7 files changed

+166
-7
lines changed

7 files changed

+166
-7
lines changed

.github/workflows/ci-format.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This is a format job. Pre-commit has a first-party GitHub action, so we use
2+
# that: https://github.com/pre-commit/action
3+
4+
name: Format
5+
6+
on:
7+
workflow_dispatch:
8+
pull_request:
9+
10+
jobs:
11+
pre-commit:
12+
name: Format
13+
runs-on: ubuntu-22.04
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-python@v4
17+
with:
18+
python-version: 3.10.6
19+
- name: Install system hooks
20+
run: sudo apt install -qq cppcheck ament-cmake-uncrustify ament-cmake-pep257
21+
- uses: pre-commit/[email protected]
22+
with:
23+
extra_args: --all-files --hook-stage manual

.pre-commit-config.yaml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# To use:
2+
#
3+
# pre-commit run -a
4+
#
5+
# Or:
6+
#
7+
# pre-commit install # (runs every time you commit in git)
8+
#
9+
# To update this file:
10+
#
11+
# pre-commit autoupdate
12+
#
13+
# See https://github.com/pre-commit/pre-commit
14+
15+
repos:
16+
# Standard hooks
17+
- repo: https://github.com/pre-commit/pre-commit-hooks
18+
rev: v4.1.0
19+
hooks:
20+
- id: check-added-large-files
21+
- id: check-ast
22+
- id: check-case-conflict
23+
- id: check-docstring-first
24+
- id: check-merge-conflict
25+
- id: check-symlinks
26+
- id: check-xml
27+
- id: check-yaml
28+
- id: debug-statements
29+
- id: end-of-file-fixer
30+
- id: mixed-line-ending
31+
- id: trailing-whitespace
32+
exclude_types: [rst]
33+
- id: fix-byte-order-marker
34+
35+
36+
# Python hooks
37+
- repo: https://github.com/asottile/pyupgrade
38+
rev: v2.31.1
39+
hooks:
40+
- id: pyupgrade
41+
args: [--py36-plus]
42+
43+
# # PEP 257
44+
- repo: local
45+
hooks:
46+
- id: ament_pep257
47+
name: ament_pep257
48+
description: Format files with pep257.
49+
entry: ament_pep257
50+
language: system
51+
args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"]
52+
53+
- repo: https://github.com/pycqa/flake8
54+
rev: 4.0.1
55+
hooks:
56+
- id: flake8
57+
args: ["--extend-ignore=E501"]
58+
59+
# CPP hooks
60+
- repo: local
61+
hooks:
62+
- id: ament_uncrustify
63+
name: ament_uncrustify
64+
description: Format files with uncrustify.
65+
entry: ament_uncrustify
66+
language: system
67+
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
68+
args: ["--reformat"]
69+
70+
- repo: local
71+
hooks:
72+
- id: ament_cppcheck
73+
name: ament_cppcheck
74+
description: Static code analysis of C/C++ files.
75+
stages: [commit]
76+
entry: ament_cppcheck
77+
language: system
78+
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
79+
80+
# Maybe use https://github.com/cpplint/cpplint instead
81+
- repo: local
82+
hooks:
83+
- id: ament_cpplint
84+
name: ament_cpplint
85+
description: Static code analysis of C/C++ files.
86+
stages: [commit]
87+
entry: ament_cpplint
88+
language: system
89+
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
90+
args: ["--linelength=100", "--filter=-whitespace/newline"]
91+
92+
# Cmake hooks
93+
- repo: local
94+
hooks:
95+
- id: ament_lint_cmake
96+
name: ament_lint_cmake
97+
description: Check format of CMakeLists.txt files.
98+
stages: [commit]
99+
entry: ament_lint_cmake
100+
language: system
101+
files: CMakeLists\.txt$
102+
103+
# Copyright
104+
- repo: local
105+
hooks:
106+
- id: ament_copyright
107+
name: ament_copyright
108+
description: Check if copyright notice is available in all files.
109+
stages: [commit]
110+
entry: ament_copyright
111+
language: system
112+
113+
# Docs - RestructuredText hooks
114+
- repo: https://github.com/PyCQA/doc8
115+
rev: 0.10.1
116+
hooks:
117+
- id: doc8
118+
args: ['--max-line-length=100', '--ignore=D001']
119+
exclude: CHANGELOG\.rst$
120+
121+
- repo: https://github.com/pre-commit/pygrep-hooks
122+
rev: v1.9.0
123+
hooks:
124+
- id: rst-backticks
125+
exclude: CHANGELOG\.rst$
126+
- id: rst-directive-colons
127+
- id: rst-inline-touching-normal
128+
129+
# Spellcheck in comments and docs
130+
# skipping of *.svg files is not working...
131+
- repo: https://github.com/codespell-project/codespell
132+
rev: v2.1.0
133+
hooks:
134+
- id: codespell
135+
args: ['--write-changes']
136+
exclude: CHANGELOG\.rst|\.(svg|pyc)$

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ robot hardware interfaces between `ros2_control` and Gazebo.
142142
The `gazebo_ros2_control` `<plugin>` tag also has the following optional child elements:
143143

144144
- `<robot_param>`: The location of the `robot_description` (URDF) on the parameter server, defaults to `robot_description`
145-
- `<robot_param_node>`: Name of the node where the `robot_param` is located, defauls to `robot_state_publisher`
145+
- `<robot_param_node>`: Name of the node where the `robot_param` is located, defaults to `robot_state_publisher`
146146
- `<parameters>`: YAML file with the configuration of the controllers
147147

148148
#### Default gazebo_ros2_control Behavior
@@ -229,7 +229,7 @@ ros2 launch gazebo_ros2_control_demos tricycle_drive.launch.py
229229

230230
Send example commands:
231231

232-
When the Gazebo world is launched you can run some of the following commads to move the cart.
232+
When the Gazebo world is launched you can run some of the following commands to move the cart.
233233

234234
```bash
235235
ros2 run gazebo_ros2_control_demos example_position

gazebo_ros2_control/include/gazebo_ros2_control/gazebo_system_interface.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class GazeboSystemInterface
6161
: public hardware_interface::SystemInterface
6262
{
6363
public:
64-
/// \brief Initilize the system interface
64+
/// \brief Initialize the system interface
6565
/// param[in] model_nh pointer to the ros2 node
6666
/// param[in] parent_model pointer to the model
6767
/// param[in] control_hardware vector filled with information about robot's control resources

gazebo_ros2_control/src/gazebo_ros2_control_plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ std::string GazeboRosControlPrivate::getURDF(std::string param_name) const
444444
usleep(100000);
445445
}
446446
RCLCPP_INFO(
447-
model_nh_->get_logger(), "Recieved urdf from param server, parsing...");
447+
model_nh_->get_logger(), "Received urdf from param server, parsing...");
448448

449449
return urdf_string;
450450
}

gazebo_ros2_control/src/gazebo_system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void GazeboSystem::registerJoints(
207207
}
208208
RCLCPP_INFO_STREAM(
209209
this->nh_->get_logger(),
210-
"Joint '" << joint_name << "'is mimicing joint '" << mimicked_joint <<
210+
"Joint '" << joint_name << "'is mimicking joint '" << mimicked_joint <<
211211
"' with mutiplier: " << mimic_joint.multiplier);
212212
this->dataPtr->mimic_joints_.push_back(mimic_joint);
213213
suffix = "_mimic";

gazebo_ros2_control_demos/config/tricycle_drive_controller.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ joint_state_broadcaster:
1313
ros__parameters:
1414
extra_joints: ["right_wheel_joint", "left_wheel_joint"]
1515

16-
tricycle_controller:
16+
tricycle_controller:
1717
ros__parameters:
1818
# Model
1919
traction_joint_name: traction_joint # Name of traction joint in URDF
@@ -30,7 +30,7 @@ tricycle_controller:
3030
pose_covariance_diagonal: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # Need to be set if fusing odom with other localization source
3131
twist_covariance_diagonal: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # Need to be set if fusing odom with other localization source
3232
velocity_rolling_window_size: 10 # Rolling window size of rcppmath::RollingMeanAccumulator applied on linear and angular speeds published on odom
33-
33+
3434
# Rate Limiting
3535
traction: # All values should be positive
3636
# min_velocity: 0.0

0 commit comments

Comments
 (0)