-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added clang-format and pre-commit config * Reformatting * Added CI * Fixed Cppcheck arguments --------- Co-authored-by: Aljoscha Schmidt <[email protected]>
- Loading branch information
Showing
9 changed files
with
618 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
BasedOnStyle: LLVM | ||
AllowShortBlocksOnASingleLine: Always | ||
AllowShortLoopsOnASingleLine: true | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BreakBeforeBraces: Linux | ||
ColumnLimit: 100 | ||
IndentPPDirectives: BeforeHash | ||
PenaltyBreakComment: 1000 | ||
PenaltyExcessCharacter: 10 | ||
SpaceAfterTemplateKeyword: false | ||
SpaceInEmptyBlock: true | ||
SpacesInConditionalStatement: true | ||
SpacesInParentheses: true | ||
UseTab: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: CI Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- ros2 | ||
pull_request: | ||
branches: | ||
- ros2 | ||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
Linting: | ||
name: Lint Code Base | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup | ||
run: | | ||
sudo apt-get update && sudo apt-get install -y clang-format cppcheck libxml2-utils | ||
- name: Lint C++ code | ||
run: | | ||
echo "Linting C++ code..." | ||
clang-format -Werror -n -style=file $(find . -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.c' -o -name '*.cc') | ||
- name: Run cppcheck on C++ code | ||
run: | | ||
echo "Running cppcheck on C++ code..." | ||
cppcheck --force --quiet --error-exitcode=1 --language=c++ $(find . -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.c' -o -name '*.cc') | ||
- name: Lint package.xml | ||
run: | | ||
xmllint --noout --schema http://download.ros.org/schema/package_format3.xsd $(find . -name 'package.xml') | ||
build-and-test: | ||
needs: Linting | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ros:jazzy-ros-base | ||
steps: | ||
- name: install build tools | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y ros-dev-tools | ||
- uses: actions/checkout@v4 | ||
with: | ||
path: src/e_stop_manager | ||
- name: rosdep | ||
run: | | ||
rosdep update --rosdistro jazzy --include-eol-distros | ||
rosdep install -y --from-paths src --ignore-src --rosdistro jazzy | ||
- name: build | ||
run: | | ||
source /opt/ros/jazzy/setup.bash | ||
colcon build | ||
- name: test | ||
run: | | ||
source /opt/ros/jazzy/setup.bash | ||
colcon test --packages-select e_stop_manager | ||
colcon test-result --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: v14.0.6 | ||
hooks: | ||
- id: clang-format | ||
name: Clang Format | ||
args: [--style=file] | ||
files: \.(cpp|hpp|h|c|cc)$ | ||
|
||
- repo: local | ||
hooks: | ||
- id: cppcheck | ||
name: Cppcheck | ||
entry: cppcheck --force --quiet --language=c++ | ||
language: system | ||
types: [c, c++] | ||
files: \.(cpp|hpp|h|c|cc)$ | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 23.1.0 | ||
hooks: | ||
- id: black | ||
name: Black | ||
args: [--diff] | ||
language_version: python3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
#include "rclcpp/rclcpp.hpp" | ||
#include "rclcpp/publisher.hpp" | ||
#include <e_stop_manager_msgs/srv/set_e_stop.hpp> | ||
#include <e_stop_manager_msgs/msg/e_stop_list.hpp> | ||
#include "rclcpp/rclcpp.hpp" | ||
#include "std_msgs/msg/bool.hpp" | ||
#include <e_stop_manager_msgs/msg/e_stop_list.hpp> | ||
#include <e_stop_manager_msgs/srv/set_e_stop.hpp> | ||
|
||
namespace e_stop_manager | ||
{ | ||
|
||
class EStopManager | ||
{ | ||
public: | ||
explicit EStopManager(const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); | ||
|
||
// required if not subclassing Node, see https://github.com/ros2/demos/blob/humble/composition/src/node_like_listener_component.cpp | ||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface() const { | ||
return this->node_->get_node_base_interface(); | ||
} | ||
private: | ||
void publishEStops( bool force_e_stop = false ); | ||
class EStopManager | ||
{ | ||
public: | ||
explicit EStopManager( const rclcpp::NodeOptions &options = rclcpp::NodeOptions() ); | ||
|
||
bool setEStopServiceCB(const std::shared_ptr<e_stop_manager_msgs::srv::SetEStop::Request> request, | ||
std::shared_ptr<e_stop_manager_msgs::srv::SetEStop::Response> response ); | ||
// required if not subclassing Node, see https://github.com/ros2/demos/blob/humble/composition/src/node_like_listener_component.cpp | ||
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface() const | ||
{ | ||
return this->node_->get_node_base_interface(); | ||
} | ||
|
||
private: | ||
void publishEStops( bool force_e_stop = false ); | ||
|
||
bool setEStopServiceCB( const std::shared_ptr<e_stop_manager_msgs::srv::SetEStop::Request> request, | ||
std::shared_ptr<e_stop_manager_msgs::srv::SetEStop::Response> response ); | ||
|
||
rclcpp::Service<e_stop_manager_msgs::srv::SetEStop>::SharedPtr set_e_stop_service_; | ||
rclcpp::Service<e_stop_manager_msgs::srv::SetEStop>::SharedPtr set_e_stop_service_; | ||
|
||
e_stop_manager_msgs::msg::EStopList e_stop_list_msg_; | ||
rclcpp::Publisher<e_stop_manager_msgs::msg::EStopList>::SharedPtr e_stop_list_pub_; | ||
std::map<std::shared_ptr<rclcpp::Publisher<std_msgs::msg::Bool>>, std::vector<std::string> > e_stop_pub_; | ||
rclcpp::Node::SharedPtr node_; | ||
}; | ||
} | ||
e_stop_manager_msgs::msg::EStopList e_stop_list_msg_; | ||
rclcpp::Publisher<e_stop_manager_msgs::msg::EStopList>::SharedPtr e_stop_list_pub_; | ||
std::map<std::shared_ptr<rclcpp::Publisher<std_msgs::msg::Bool>>, std::vector<std::string>> e_stop_pub_; | ||
rclcpp::Node::SharedPtr node_; | ||
}; | ||
} // namespace e_stop_manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<package format="2"> | ||
<package format="3"> | ||
<name>e_stop_manager</name> | ||
<version>1.0.0</version> | ||
<description>The e_stop_manager package</description> | ||
|
||
<maintainer email="katrin.becker.17@stud-tu-darmstadt.de">Katrin</maintainer> | ||
<maintainer email="aljoscha.schmidt@tu-darmstadt.de">Aljoscha Schmidt</maintainer> | ||
|
||
<!-- One license tag required, multiple allowed, one license per tag --> | ||
<!-- Commonly used license strings: --> | ||
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 --> | ||
<license>TODO</license> | ||
|
||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<depend>std_msgs</depend> | ||
<depend>e_stop_manager_msgs</depend> | ||
<depend>rclcpp_components</depend> | ||
<test_depend>ros_testing</test_depend> | ||
|
||
<!-- The export tag contains other, unspecified, tags --> | ||
<export> | ||
<!-- Other tools can request additional information be placed here --> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
Oops, something went wrong.