Skip to content
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

Ci/add cpp check #40

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8b8de24
ci: add cppcheck
kminoda Jun 4, 2024
bf154e8
add more suppression
kminoda Jun 4, 2024
e57410b
update cppcheck version
kminoda Jun 4, 2024
2e2cb23
update suppressions list
kminoda Jun 4, 2024
e7064d5
add two workflows
kminoda Jun 4, 2024
bd4b78e
change name
kminoda Jun 4, 2024
01739e2
change timing of all ci
kminoda Jun 4, 2024
d50d05d
update
kminoda Jun 4, 2024
de6f3e8
update
kminoda Jun 4, 2024
a89e8b6
update
kminoda Jun 4, 2024
85c5036
fix
kminoda Jun 4, 2024
4eb1d9c
update name
kminoda Jun 4, 2024
e715115
fix mistake
kminoda Jun 4, 2024
ed14e35
add echo in diff
kminoda Jun 4, 2024
9231644
update regex
kminoda Jun 4, 2024
4f10212
add statistics for cppcheck-all
kminoda Jun 4, 2024
2d3bbb3
avoid checking cppcheck dir
kminoda Jun 4, 2024
ba13741
error-exit
kminoda Jun 4, 2024
e32bc67
dummy test
kminoda Jun 4, 2024
f2e9789
upload file even if it fails
kminoda Jun 4, 2024
f64238b
fix bug
kminoda Jun 4, 2024
c8f59cb
revert unnecessary commit
kminoda Jun 4, 2024
7923ce9
minor fix
kminoda Jun 4, 2024
7a02961
dummy test
kminoda Jun 4, 2024
8c7d41c
dummy test
kminoda Jun 4, 2024
330ceb8
modify to show cppcheck result even when failure
kminoda Jun 4, 2024
b8829a4
finalize PR
kminoda Jun 4, 2024
2332541
feat!: replace autoware_auto_msgs with autoware_msgs for map modules …
mitsudome-r Jun 4, 2024
b7f18a1
feat!: replace autoware_auto_msgs with autoware_msgs for simulator mo…
mitsudome-r Jun 4, 2024
3384a55
Merge branch 'main' into ci/add_cpp_check
kminoda Jun 4, 2024
ac26f55
fix pre-commit
kminoda Jun 5, 2024
6948f0b
fix pre-commit
kminoda Jun 5, 2024
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
59 changes: 59 additions & 0 deletions .cppcheck_suppressions
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
arrayIndexThenCheck
assignBoolToFloat
checkersReport
constParameterPointer
constParameterReference
constStatement
constVariable
constVariablePointer
constVariableReference
containerOutOfBounds
cstyleCast
ctuOneDefinitionRuleViolation
current_deleted_index
duplicateAssignExpression
duplicateBranch
duplicateBreak
duplicateCondition
duplicateExpression
funcArgNamesDifferent
functionConst
functionStatic
invalidPointerCast
knownConditionTrueFalse
missingInclude
missingIncludeSystem
multiCondition
noConstructor
noExplicitConstructor
noValidConfiguration
obstacle_cruise_planner
passedByValue
preprocessorErrorDirective
redundantAssignment
redundantContinue
redundantIfRemove
redundantInitialization
returnByReference
selfAssignment
shadowArgument
shadowFunction
shadowVariable
stlFindInsert
syntaxError
uninitMemberVar
unknownMacro
unmatchedSuppression
unpreciseMathCall
unreadVariable
unsignedLessThanZero
unusedFunction
unusedScopedObject
unusedStructMember
unusedVariable
useInitializationList
useStlAlgorithm
uselessCallsSubstr
uselessOverride
variableScope
virtualCallInConstructor
60 changes: 60 additions & 0 deletions .github/workflows/cppcheck-all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: cppcheck-all

on:
pull_request:
schedule:
- cron: 0 0 * * *
workflow_dispatch:

jobs:
cppcheck-all:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake git libpcre3-dev

# cppcheck from apt does not yet support --check-level args, and thus install from source
- name: Install Cppcheck from source
run: |
mkdir /tmp/cppcheck
git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck
cd /tmp/cppcheck
git checkout 2.14.1
mkdir build
cd build
cmake ..
make -j $(nproc)
sudo make install

- name: Run Cppcheck on all files
continue-on-error: true
id: cppcheck
run: |
cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --xml . 2> cppcheck-report.xml
shell: bash

- name: Count errors by error ID and severity
run: |
#!/bin/bash
temp_file=$(mktemp)
grep -oP '(?<=id=")[^"]+" severity="[^"]+' cppcheck-report.xml | sed 's/" severity="/,/g' > "$temp_file"
echo "Error counts by error ID and severity:"
sort "$temp_file" | uniq -c
rm "$temp_file"
shell: bash

- name: Upload Cppcheck report
uses: actions/upload-artifact@v2
with:
name: cppcheck-report
path: cppcheck-report.xml

- name: Fail the job if Cppcheck failed
if: steps.cppcheck.outcome == 'failure'
run: exit 1
65 changes: 65 additions & 0 deletions .github/workflows/cppcheck-differential.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: cppcheck-differential

on:
pull_request:

jobs:
cppcheck-differential:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake git libpcre3-dev

# cppcheck from apt does not yet support --check-level args, and thus install from source
- name: Install Cppcheck from source
run: |
mkdir /tmp/cppcheck
git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck
cd /tmp/cppcheck
git checkout 2.14.1
mkdir build
cd build
cmake ..
make -j $(nproc)
sudo make install

- name: Get changed files
id: changed-files
run: |
git fetch origin ${{ github.base_ref }} --depth=1
git diff --name-only FETCH_HEAD ${{ github.sha }} > changed_files.txt
cat changed_files.txt

- name: Run Cppcheck on changed files
continue-on-error: true
id: cppcheck
run: |
files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true)
if [ -n "$files" ]; then
echo "Running Cppcheck on changed files: $files"
cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt
else
echo "No C++ files changed."
touch cppcheck-report.txt
fi
shell: bash

- name: Show cppcheck-report result
run: |
cat cppcheck-report.txt

- name: Upload Cppcheck report
uses: actions/upload-artifact@v2
with:
name: cppcheck-report
path: cppcheck-report.txt

- name: Fail the job if Cppcheck failed
if: steps.cppcheck.outcome == 'failure'
run: exit 1
1 change: 0 additions & 1 deletion map/map_height_fitter/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>autoware_auto_mapping_msgs</depend>
<depend>autoware_map_msgs</depend>
<depend>geometry_msgs</depend>
<depend>lanelet2_extension</depend>
Expand Down
10 changes: 5 additions & 5 deletions map/map_height_fitter/src/map_height_fitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <lanelet2_extension/utility/message_conversion.hpp>
#include <lanelet2_extension/utility/query.hpp>

#include <autoware_auto_mapping_msgs/msg/had_map_bin.hpp>
#include <autoware_map_msgs/msg/lanelet_map_bin.hpp>
#include <autoware_map_msgs/srv/get_partial_point_cloud_map.hpp>
#include <sensor_msgs/msg/point_cloud2.hpp>
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
Expand All @@ -38,7 +38,7 @@ struct MapHeightFitter::Impl

explicit Impl(rclcpp::Node * node);
void on_pcd_map(const sensor_msgs::msg::PointCloud2::ConstSharedPtr msg);
void on_vector_map(const autoware_auto_mapping_msgs::msg::HADMapBin::ConstSharedPtr msg);
void on_vector_map(const autoware_map_msgs::msg::LaneletMapBin::ConstSharedPtr msg);
bool get_partial_point_cloud_map(const Point & point);
double get_ground_height(const Point & point) const;
std::optional<Point> fit(const Point & position, const std::string & frame);
Expand All @@ -59,7 +59,7 @@ struct MapHeightFitter::Impl

// for fitting by vector_map_loader
lanelet::LaneletMapPtr vector_map_;
rclcpp::Subscription<autoware_auto_mapping_msgs::msg::HADMapBin>::SharedPtr sub_vector_map_;
rclcpp::Subscription<autoware_map_msgs::msg::LaneletMapBin>::SharedPtr sub_vector_map_;
};

MapHeightFitter::Impl::Impl(rclcpp::Node * node) : tf2_listener_(tf2_buffer_), node_(node)
Expand Down Expand Up @@ -95,7 +95,7 @@ MapHeightFitter::Impl::Impl(rclcpp::Node * node) : tf2_listener_(tf2_buffer_), n

} else if (fit_target_ == "vector_map") {
const auto durable_qos = rclcpp::QoS(1).transient_local();
sub_vector_map_ = node_->create_subscription<autoware_auto_mapping_msgs::msg::HADMapBin>(
sub_vector_map_ = node_->create_subscription<autoware_map_msgs::msg::LaneletMapBin>(
"~/vector_map", durable_qos,
std::bind(&MapHeightFitter::Impl::on_vector_map, this, std::placeholders::_1));

Expand Down Expand Up @@ -163,7 +163,7 @@ bool MapHeightFitter::Impl::get_partial_point_cloud_map(const Point & point)
}

void MapHeightFitter::Impl::on_vector_map(
const autoware_auto_mapping_msgs::msg::HADMapBin::ConstSharedPtr msg)
const autoware_map_msgs::msg::LaneletMapBin::ConstSharedPtr msg)
{
vector_map_ = std::make_shared<lanelet::LaneletMap>();
lanelet::utils::conversion::fromBinMsg(*msg, vector_map_);
Expand Down
8 changes: 4 additions & 4 deletions map/map_loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Please see [the description of `GetSelectedPointCloudMap.srv`](https://github.co

### Feature

lanelet2_map_loader loads Lanelet2 file and publishes the map data as autoware_auto_mapping_msgs/HADMapBin message.
lanelet2_map_loader loads Lanelet2 file and publishes the map data as autoware_map_msgs/LaneletMapBin message.
The node projects lan/lon coordinates into arbitrary coordinates defined in `/map/map_projector_info` from `map_projection_loader`.
Please see [tier4_autoware_msgs/msg/MapProjectorInfo.msg](https://github.com/tier4/tier4_autoware_msgs/blob/tier4/universe/tier4_map_msgs/msg/MapProjectorInfo.msg) for supported projector types.

Expand All @@ -144,7 +144,7 @@ Please see [tier4_autoware_msgs/msg/MapProjectorInfo.msg](https://github.com/tie

### Published Topics

- ~output/lanelet2_map (autoware_auto_mapping_msgs/HADMapBin) : Binary data of loaded Lanelet2 Map
- ~output/lanelet2_map (autoware_map_msgs/LaneletMapBin) : Binary data of loaded Lanelet2 Map

### Parameters

Expand All @@ -156,15 +156,15 @@ Please see [tier4_autoware_msgs/msg/MapProjectorInfo.msg](https://github.com/tie

### Feature

lanelet2_map_visualization visualizes autoware_auto_mapping_msgs/HADMapBin messages into visualization_msgs/MarkerArray.
lanelet2_map_visualization visualizes autoware_map_msgs/LaneletMapBin messages into visualization_msgs/MarkerArray.

### How to Run

`ros2 run map_loader lanelet2_map_visualization`

### Subscribed Topics

- ~input/lanelet2_map (autoware_auto_mapping_msgs/HADMapBin) : binary data of Lanelet2 Map
- ~input/lanelet2_map (autoware_map_msgs/LaneletMapBin) : binary data of Lanelet2 Map

### Published Topics

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
#include <component_interface_utils/rclcpp.hpp>
#include <rclcpp/rclcpp.hpp>

#include <autoware_auto_mapping_msgs/msg/had_map_bin.hpp>
#include <autoware_map_msgs/msg/lanelet_map_bin.hpp>
#include <tier4_map_msgs/msg/map_projector_info.hpp>

#include <lanelet2_projection/UTM.h>

#include <memory>
#include <string>

using autoware_auto_mapping_msgs::msg::HADMapBin;
using autoware_map_msgs::msg::LaneletMapBin;
using tier4_map_msgs::msg::MapProjectorInfo;

class Lanelet2MapLoaderNode : public rclcpp::Node
Expand All @@ -38,7 +38,7 @@ class Lanelet2MapLoaderNode : public rclcpp::Node
static lanelet::LaneletMapPtr load_map(
const std::string & lanelet2_filename,
const tier4_map_msgs::msg::MapProjectorInfo & projector_info);
static HADMapBin create_map_bin_msg(
static LaneletMapBin create_map_bin_msg(
const lanelet::LaneletMapPtr map, const std::string & lanelet2_filename,
const rclcpp::Time & now);

Expand All @@ -48,7 +48,7 @@ class Lanelet2MapLoaderNode : public rclcpp::Node
void on_map_projector_info(const MapProjectorInfo::Message::ConstSharedPtr msg);

component_interface_utils::Subscription<MapProjectorInfo>::SharedPtr sub_map_projector_info_;
rclcpp::Publisher<HADMapBin>::SharedPtr pub_map_bin_;
rclcpp::Publisher<LaneletMapBin>::SharedPtr pub_map_bin_;
};

#endif // MAP_LOADER__LANELET2_MAP_LOADER_NODE_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <rclcpp/rclcpp.hpp>

#include <autoware_auto_mapping_msgs/msg/had_map_bin.hpp>
#include <autoware_map_msgs/msg/lanelet_map_bin.hpp>
#include <visualization_msgs/msg/marker_array.hpp>

#include <string>
Expand All @@ -29,12 +29,12 @@ class Lanelet2MapVisualizationNode : public rclcpp::Node
explicit Lanelet2MapVisualizationNode(const rclcpp::NodeOptions & options);

private:
rclcpp::Subscription<autoware_auto_mapping_msgs::msg::HADMapBin>::SharedPtr sub_map_bin_;
rclcpp::Subscription<autoware_map_msgs::msg::LaneletMapBin>::SharedPtr sub_map_bin_;
rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr pub_marker_;

bool viz_lanelets_centerline_;

void onMapBin(const autoware_auto_mapping_msgs::msg::HADMapBin::ConstSharedPtr msg);
void onMapBin(const autoware_map_msgs::msg::LaneletMapBin::ConstSharedPtr msg);
};

#endif // MAP_LOADER__LANELET2_MAP_VISUALIZATION_NODE_HPP_
1 change: 0 additions & 1 deletion map/map_loader/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>autoware_auto_mapping_msgs</depend>
<depend>autoware_map_msgs</depend>
<depend>component_interface_specs</depend>
<depend>component_interface_utils</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void Lanelet2MapLoaderNode::on_map_projector_info(

// create publisher and publish
pub_map_bin_ =
create_publisher<HADMapBin>("output/lanelet2_map", rclcpp::QoS{1}.transient_local());
create_publisher<LaneletMapBin>("output/lanelet2_map", rclcpp::QoS{1}.transient_local());
pub_map_bin_->publish(map_bin_msg);
RCLCPP_INFO(get_logger(), "Succeeded to load lanelet2_map. Map is published.");
}
Expand Down Expand Up @@ -141,18 +141,18 @@ lanelet::LaneletMapPtr Lanelet2MapLoaderNode::load_map(
return nullptr;
}

HADMapBin Lanelet2MapLoaderNode::create_map_bin_msg(
LaneletMapBin Lanelet2MapLoaderNode::create_map_bin_msg(
const lanelet::LaneletMapPtr map, const std::string & lanelet2_filename, const rclcpp::Time & now)
{
std::string format_version{}, map_version{};
lanelet::io_handlers::AutowareOsmParser::parseVersions(
lanelet2_filename, &format_version, &map_version);

HADMapBin map_bin_msg;
LaneletMapBin map_bin_msg;
map_bin_msg.header.stamp = now;
map_bin_msg.header.frame_id = "map";
map_bin_msg.format_version = format_version;
map_bin_msg.map_version = map_version;
map_bin_msg.version_map_format = format_version;
map_bin_msg.version_map = map_version;
lanelet::utils::conversion::toBinMsg(map, &map_bin_msg);

return map_bin_msg;
Expand Down
Loading
Loading