Skip to content

Feature/pre commit #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
65 changes: 65 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
BasedOnStyle: Google
AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 2
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: true
BinPackParameters: true
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: true
DerivePointerBinding: false
PointerBindsToType: true
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 60
PenaltyBreakString: 1
PenaltyBreakFirstLessLess: 1000
PenaltyExcessCharacter: 1000
PenaltyReturnTypeOnItsOwnLine: 90
SpacesBeforeTrailingComments: 2
Cpp11BracedListStyle: false
Standard: Auto
IndentWidth: 2
TabWidth: 2
UseTab: Never
IndentFunctionDeclarationAfterType: false
SpacesInParentheses: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
SortIncludes: false
SpaceAfterCStyleCast: false

# Configure each individual brace in BraceWrapping
BreakBeforeBraces: Custom

# Control of individual brace wrapping cases
BraceWrapping:
AfterCaseLabel: 'true'
AfterClass: 'true'
AfterControlStatement: Never
AfterEnum : 'true'
AfterFunction : 'true'
AfterNamespace : 'true'
AfterStruct : 'true'
AfterUnion : 'true'
BeforeCatch : 'false'
BeforeElse : 'false'
IndentBraces : 'false'
...
128 changes: 128 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# To use:
#
# pre-commit run -a
#
# Or:
#
# pre-commit install # (runs every time you commit in git)
#
# To update this file:
#
# pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit

repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-symlinks
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- id: check-byte-order-marker # Forbid UTF-8 byte-order markers

# Python hooks
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py36-plus]

- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
args: ["--line-length=100"]

- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D401,D404"]

- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
args: ["--ignore=E501,W503"]

# CPP hooks
- repo: local
hooks:
- id: ament_cppcheck
name: ament_cppcheck
description: Static code analysis of C/C++ files.
stages: [pre-commit]
entry: env AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS=1 ament_cppcheck
language: system
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$


- repo: local
hooks:
- id: clang-format
name: clang-format
description: Format files with ClangFormat.
entry: clang-format-14
language: system
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
args: ['-fallback-style=none', '-i']
- repo: local
hooks:
- id: ament_cpplint
name: ament_cpplint
description: Static code analysis of C/C++ files.
stages: [pre-commit]
entry: ament_cpplint
language: system
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
args: ["--linelength=120"]

# Cmake hooks
- repo: local
hooks:
- id: ament_lint_cmake
name: ament_lint_cmake
description: Check format of CMakeLists.txt files.
stages: [pre-commit]
entry: ament_lint_cmake
language: system
files: CMakeLists.txt$

# Copyright - ament_copyright is somewhat broken for some licenses. We therefore disable it
#- repo: local
# hooks:
# - id: ament_copyright
# name: ament_copyright
# description: Check if copyright notice is available in all files.
# stages: [pre-commit]
# entry: ament_copyright
# language: system


# Docs - RestructuredText hooks
- repo: https://github.com/PyCQA/doc8
rev: v1.1.2
hooks:
- id: doc8
args: ['--max-line-length=100', '--ignore=D001']


# Spellcheck in comments and docs
# skipping of *.svg files is not working...
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: ['--write-changes', '-L bootup,assertIn']
exclude: \.(svg|pyc|drawio)$
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)

ament_target_dependencies(${PROJECT_NAME}
ethercat_sdk_master

)

target_link_libraries(${PROJECT_NAME}
yaml-cpp
yaml-cpp
)


Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# rsl_drive_sdk
# rsl_drive_sdk

Software Development Kit for all RSL drives.\
The source code is released under [BSD 3](LICENSE).
Expand All @@ -9,7 +9,7 @@ The source code is released under [BSD 3](LICENSE).
| ---| --- |
| Dynadrive | Fully supported, including calibration |
| Halodi drives | Fully supported, including calibration |
| Other | There are additional, but not officially supported drives |
| Other | There are additional, but not officially supported drives |


## Dependencies
Expand All @@ -18,15 +18,15 @@ The source code is released under [BSD 3](LICENSE).

| Repository | URL | License | Content |
| --- | - | --- | --- |
| ethercat_sdk_master | https://github.com/leggedrobotics/ethercat_sdk_master/tree/master/ethercat_sdk_master | BSD 3-Clause | Ethercat master implementation |
| soem_interface | https://github.com/leggedrobotics/soem_interface | GPLv3 | Wrapper around [SOEM](https://github.com/OpenEtherCATsociety/soem) |
| ethercat_sdk_master | https://github.com/leggedrobotics/ethercat_sdk_master/tree/master/ethercat_sdk_master | BSD 3-Clause | Ethercat master implementation |
| soem_interface | https://github.com/leggedrobotics/soem_interface | GPLv3 | Wrapper around [SOME](https://github.com/OpenEtherCATsociety/some) |
| message_logger | https://github.com/leggedrobotics/message_logger.git | BSD 3-Clause | Simple logger |

#### Installable via rosdep:

| Repository | URL | License | Content |
| --- | - | --- | --- |
| yaml_cpp_vendor |https://github.com/ros2/yaml_cpp_vendor | Apache 2.0 / MIT | yaml library |
| yaml_cpp_vendor |https://github.com/ros2/yaml_cpp_vendor | Apache 2.0 / MIT | yaml library |

## Usage

Expand Down
49 changes: 24 additions & 25 deletions include/rsl_drive_sdk/Command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@
** Copyright 2024 Robotic Systems Lab - ETH Zurich:
** Remo Diethelm, Christian Gehring, Samuel Bachmann, Philipp Leeman, Lennart Nachtigall, Jonas Junger, Jan Preisig,
** Fabian Tischhauser, Johannes Pankert
** Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions
*are met:
** Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
*following conditions are met:
**
** 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
** 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
*disclaimer.
**
** 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
*documentation and/or other materials provided with the distribution.
** 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
*following disclaimer in the documentation and/or other materials provided with the distribution.
**
** 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from
*this software without specific prior written permission.
** 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
*products derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
*HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
*LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
*ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
*USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
*INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
*DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
*SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
*SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
*WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once


// std
#include <ostream>
#include <string>

// any measurements
#include <chrono>
// rsl_drive_sdk
#include "rsl_drive_sdk/mode/ModeEnum.hpp"
#include "rsl_drive_sdk/mode/PidGains.hpp"


namespace rsl_drive_sdk
{


//! Drive command.
class Command
{
Expand Down Expand Up @@ -68,8 +68,8 @@ class Command
Command();
virtual ~Command();

const std::chrono::high_resolution_clock::time_point & getStamp() const;
void setStamp(const std::chrono::high_resolution_clock::time_point & stamp);
const std::chrono::high_resolution_clock::time_point& getStamp() const;
void setStamp(const std::chrono::high_resolution_clock::time_point& stamp);

mode::ModeEnum getModeEnum() const;
void setModeEnum(const mode::ModeEnum modeEnum);
Expand Down Expand Up @@ -98,9 +98,9 @@ class Command
double getJointTorque() const;
void setJointTorque(const double jointTorque);

mode::PidGainsF & getPidGains();
const mode::PidGainsF & getPidGains() const;
void setPidGains(const mode::PidGainsF & pidGains);
mode::PidGainsF& getPidGains();
const mode::PidGainsF& getPidGains() const;
void setPidGains(const mode::PidGainsF& pidGains);

/*!
* Check if the command is valid:
Expand All @@ -111,10 +111,9 @@ class Command
*/
bool isValid() const;

virtual std::string asString(const std::string & prefix = "") const;
virtual std::string asString(const std::string& prefix = "") const;
};

std::ostream & operator<<(std::ostream & out, const Command & command);

std::ostream& operator<<(std::ostream& out, const Command& command);

} // rsl_drive_sdk
} // namespace rsl_drive_sdk
Loading