Skip to content

Commit 902f8ad

Browse files
authored
add pre-commit to repo (#7)
add pre-commit
1 parent f674476 commit 902f8ad

File tree

8 files changed

+581
-394
lines changed

8 files changed

+581
-394
lines changed

.clang-format

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
5+
ColumnLimit: 100
6+
AccessModifierOffset: -2
7+
AlignAfterOpenBracket: AlwaysBreak
8+
BreakBeforeBraces: Allman
9+
ConstructorInitializerIndentWidth: 0
10+
ContinuationIndentWidth: 2
11+
DerivePointerAlignment: false
12+
PointerAlignment: Middle
13+
ReflowComments: false
14+
IncludeBlocks: Preserve
15+
...

.pre-commit-config.yaml

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

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# kinematics_interface
2-
This is a ROS 2 package for using C++ kinematics frameworks in the context of ROS 2 control. A kinematics interface is designed to allow ROS 2 controllers to control robots in Cartesian space. This package also contains a basic implementation of the interface using KDL.
2+
This is a ROS 2 package for using C++ kinematics frameworks in the context of ROS 2 control. A kinematics interface is designed to allow ROS 2 controllers to control robots in Cartesian space. This package also contains a basic implementation of the interface using KDL.

kinematics_interface/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ ament_export_include_directories(
4747
include
4848
)
4949

50-
ament_package()
50+
ament_package()

kinematics_interface/include/kinematics_interface/kinematics_interface_base.hpp

+29-31
Original file line numberDiff line numberDiff line change
@@ -20,68 +20,66 @@
2020

2121
#include <rclcpp_lifecycle/lifecycle_node.hpp>
2222

23-
namespace kinematics_interface {
24-
class KinematicsBaseClass {
25-
public:
26-
KinematicsBaseClass() = default;
23+
namespace kinematics_interface
24+
{
25+
class KinematicsBaseClass
26+
{
27+
public:
28+
KinematicsBaseClass() = default;
2729

28-
virtual ~KinematicsBaseClass() = default;
30+
virtual ~KinematicsBaseClass() = default;
2931

30-
/**
32+
/**
3133
* \brief Create an interface object which takes calculate forward and inverse kinematics
3234
*/
33-
virtual bool
34-
initialize(std::shared_ptr<rclcpp_lifecycle::LifecycleNode> node, const std::string &end_effector_name) = 0;
35+
virtual bool initialize(
36+
std::shared_ptr<rclcpp_lifecycle::LifecycleNode> node,
37+
const std::string & end_effector_name) = 0;
3538

36-
/**
39+
/**
3740
* \brief Convert Cartesian delta-x to joint delta-theta, using the Jacobian.
3841
* \param[in] joint_pos joint positions of the robot in radians
3942
* \param[in] delta_x_vec input Cartesian deltas (x, y, z, wx, wy, wz)
4043
* \param[out] delta_theta_vec output vector with joint states
4144
* \return true if successful
4245
*/
43-
virtual bool
44-
convert_cartesian_deltas_to_joint_deltas(const std::vector<double> &joint_pos,
45-
const std::vector<double> &delta_x_vec,
46-
const std::string &link_name,
47-
std::vector<double> &delta_theta_vec) = 0;
46+
virtual bool convert_cartesian_deltas_to_joint_deltas(
47+
const std::vector<double> & joint_pos, const std::vector<double> & delta_x_vec,
48+
const std::string & link_name, std::vector<double> & delta_theta_vec) = 0;
4849

49-
/**
50+
/**
5051
* \brief Convert joint delta-theta to Cartesian delta-x.
51-
* \param joint_pos joint positions of the robot in radians
52+
* \param joint_pos joint positions of the robot in radiansgit checkout
5253
* \param[in] delta_theta_vec vector with joint states
5354
* \param[out] delta_x_vec Cartesian deltas (x, y, z, wx, wy, wz)
5455
* \return true if successful
5556
*/
56-
virtual bool
57-
convert_joint_deltas_to_cartesian_deltas(const std::vector<double> &joint_pos,
58-
const std::vector<double> &delta_theta_vec,
59-
const std::string &link_name,
60-
std::vector<double> &delta_x_vec) = 0;
57+
virtual bool convert_joint_deltas_to_cartesian_deltas(
58+
const std::vector<double> & joint_pos, const std::vector<double> & delta_theta_vec,
59+
const std::string & link_name, std::vector<double> & delta_x_vec) = 0;
6160

62-
/**
61+
/**
6362
* \brief Calculates the joint transform for a specified link using provided joint positions.
6463
* \param[in] joint_pos joint positions of the robot in radians
6564
* \param[in] link_name the name of the link to find the transform for
6665
* \param[out] transform_vec transformation matrix of the specified link in column major format.
6766
* \return true if successful
6867
*/
69-
virtual bool
70-
calculate_link_transform(const std::vector<double> &joint_pos, const std::string &link_name,
71-
std::vector<double> &transform_vec) = 0;
68+
virtual bool calculate_link_transform(
69+
const std::vector<double> & joint_pos, const std::string & link_name,
70+
std::vector<double> & transform_vec) = 0;
7271

73-
/**
72+
/**
7473
* \brief Calculates the joint transform for a specified link using provided joint positions.
7574
* \param[in] joint_pos joint positions of the robot in radians
7675
* \param[in] link_name the name of the link to find the transform for
7776
* \param[out] jacobian Jacobian matrix of the specified link in column major format.
7877
* \return true if successful
7978
*/
80-
virtual bool
81-
calculate_jacobian(const std::vector<double> &joint_pos, const std::string &link_name,
82-
std::vector<double> &jacobian) = 0;
83-
84-
};
79+
virtual bool calculate_jacobian(
80+
const std::vector<double> & joint_pos, const std::string & link_name,
81+
std::vector<double> & jacobian) = 0;
82+
};
8583

8684
} // namespace kinematics_interface
8785

0 commit comments

Comments
 (0)