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

feat(accel_brake_map_calibrator): replace polling takeData function with the callback function #7282

Closed
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
2ac6e68
get steer msg by take instead of callback
N-Eiki Jun 5, 2024
e004617
use take function for get actuation_status
N-Eiki Jun 5, 2024
cc08670
use take function for get actuation cmd from subscriber
N-Eiki Jun 5, 2024
4461684
delete comment out \n add debug values of steer
N-Eiki Jun 5, 2024
0ea237d
use take function for get velocity from subscriber
N-Eiki Jun 5, 2024
899cfa0
clean code : delete temporary comment out. add comments what code exp…
N-Eiki Jun 5, 2024
493caa2
style(pre-commit): autofix
pre-commit-ci[bot] Jun 5, 2024
fedba85
undo copyright change.\n move to new autoware msg from old autoware_a…
N-Eiki Jun 6, 2024
46d34ae
undo copyright year.\n delete if nest for CodeScene Cloud Delta Analy…
N-Eiki Jun 6, 2024
fae4cfd
style(pre-commit): autofix
pre-commit-ci[bot] Jun 6, 2024
e832a83
add fetchData to decrease timerCallback func's cyclomatic complexity\…
N-Eiki Jun 6, 2024
f029367
solve conflict
N-Eiki Jun 6, 2024
62946c6
style(pre-commit): autofix
pre-commit-ci[bot] Jun 6, 2024
beb026d
fortmat by clang and camelCase function name to snake_case
N-Eiki Jun 6, 2024
671ef8a
solve conflict
N-Eiki Jun 6, 2024
6069593
fix: treat CI warning eg: add static_cast, to snake_case, delete redu…
N-Eiki Jun 6, 2024
49b65a5
style(pre-commit): autofix
pre-commit-ci[bot] Jun 6, 2024
ad843d6
Merge branch 'autowarefoundation:main' into feat/use_takeData_in_abc_…
N-Eiki Jun 6, 2024
865c2a4
Merge branch 'main' into feat/use_takeData_in_abc_module
N-Eiki Jun 6, 2024
3cd3286
Merge branch 'main' into feat/use_takeData_in_abc_module
N-Eiki Jun 6, 2024
2022fc9
refactor(autoware_velocity_walkway_module): prefix package with autow…
esteve Jun 6, 2024
a749eda
ci(openai-pr-reviewer): remove the action (#7332)
xmfcx Jun 6, 2024
4c434d0
ci(pr-agent): update configuration (#7334)
xmfcx Jun 6, 2024
ce1a86a
ci(build-and-test): run on self hosted (#7336)
xmfcx Jun 6, 2024
321e1c7
chore(steer_offset_estimator): add prefix autoware_ to steer_offset_e…
go-sakayori Jun 7, 2024
e800d54
refactor(pose2twist): apply static analysis (#7307)
a-maumau Jun 7, 2024
28cb715
fix : use not used variable
N-Eiki Jun 7, 2024
118e4bb
feat(pointcloud_preprocessor): add z filter in vector map inside (#7…
YoshiRi Jun 7, 2024
f1f7fcb
style(pre-commit): autofix
pre-commit-ci[bot] Jun 7, 2024
b24507f
fix(map_based_prediction): fix generatePathForOnLaneVehicle (#7238)
kosuke55 Jun 7, 2024
675edab
Remove unused statement causing build error
N-Eiki Jun 7, 2024
cb225d7
Merge branch 'feat/use_takeData_in_abc_module' of github.com:N-Eiki/a…
N-Eiki Jun 7, 2024
64f82a8
style(pre-commit): autofix
pre-commit-ci[bot] Jun 7, 2024
cac7eb3
refactor(surround_obstacle_checker)!: prefix package and namespace wi…
satoshi-ota Jun 7, 2024
17aad93
refactor(behavior_path_side_shift_module)!: prefix package and namesp…
kyoichi-sugahara Jun 7, 2024
cc9512b
fix(yabloc): suppress no viable conversion error (#7299)
KYabuuchi Jun 7, 2024
d54e1ff
feat(obstacle_curise): revert lateral stop margin for unknown objects…
yuki-takagi-66 Jun 7, 2024
9202dab
chore(mrm_comfortable_stop_operator): remove unused main file (#7191)
isamu-takagi Jun 7, 2024
c672f86
refactor(sampling_based_planner): add autoware prefix (#7348)
maxime-clem Jun 7, 2024
e24f48d
chore: update CODEOWNERS (#7165)
awf-autoware-bot[bot] Jun 7, 2024
e752cad
refactor(behavior velocity intersection)!: prefix package and namespa…
soblin Jun 7, 2024
9cb51d0
feat(emergency_handler, mrm_handler): change to read topic by polling…
Autumn60 Jun 7, 2024
c85b83d
fix(pose2twist): compute angular velocity through quaternion (#7322)
KYabuuchi Jun 7, 2024
722e822
chore(smart_mpc): add maitainers (#7346)
kosuke55 Jun 7, 2024
9c961a9
refactor(behavior_path_start_planner_module)!: prefix package and nam…
danielsanchezaran Jun 7, 2024
ce0fcf5
refactor(mpc_lateral_controller, trajectory_follower_node)!: prefix p…
HansOersted Jun 7, 2024
a3955e9
fix(static_obstacle_avoidance): return shift validation (#7229)
satoshi-ota Jun 7, 2024
6013a78
refactor(sampling_planner_module): use std::make_shared (#7226)
maxime-clem Jun 7, 2024
6669213
refactor(behavior_velocity_planner_common)!: prefix package and names…
rej55 Jun 7, 2024
7d6c2fd
refactor(planning_validator)!: prefix package and namespace with auto…
kyoichi-sugahara Jun 7, 2024
2b7c0db
feat(pose_instability_detector): change validation algorithm (#7042)
TaikiYamada4 Jun 7, 2024
4aeb69f
ci(clang-tidy-differential): split it out of build-and-test-different…
xmfcx Jun 7, 2024
e6b56a4
feat(imu_corrector): componentize ImuCorrector and GyroBiasEstimator …
a-maumau Jun 7, 2024
1f6c264
refactor(path_optimizer, velocity_smoother)!: prefix package and name…
satoshi-ota Jun 7, 2024
fbe57b1
refactor(costmap_generator)!: add autoware prefix (#7329)
kosuke55 Jun 7, 2024
2b0de17
refactor(gyro_odometer): apply static analysis (#7360)
a-maumau Jun 7, 2024
565589c
feat(obstacle_cruise)!: type specified stop deccel limit and enabling…
yuki-takagi-66 Jun 7, 2024
4577719
fix(perception_online_evaluator): add metric_value not only stat (#7…
kosuke55 Jun 7, 2024
2f6cd2b
chore(lane_departure_checker): add maintainer (#7366)
zulfaqar-azmi-t4 Jun 7, 2024
f03323f
refactor(lane_departure_checker)!: prefix package and namespace with …
kyoichi-sugahara Jun 7, 2024
dfa31a6
fix(mrm_handler): fix stop judgement (#7362)
Autumn60 Jun 7, 2024
ed038d8
chore(smart_mpc_trajectory_follower): add prefix autoware_ to smart_m…
go-sakayori Jun 7, 2024
b1749af
feat(autonomous_emergency_braking): prefix package and namespace with…
danielsanchezaran Jun 7, 2024
f93e5b3
refactor(rtc_interface)!: prefix package and namespace with autoware …
rej55 Jun 7, 2024
d891ef7
feat(lidar_transfusion): add lidar_transfusion 3D detection package (…
amadeuszsz Jun 7, 2024
f328a15
fix(autoware_planning_validator): revert node name change (#7371)
kyoichi-sugahara Jun 7, 2024
57786a7
refactor(behavior_path_avoidance_by_lane_change_module)!: prefix pack…
esteve Jun 7, 2024
7d12dcf
fix(tier4_planning_launch): unexpected modules were registered (#7377)
takayuki5168 Jun 8, 2024
3b036b1
feat(autoware_velocity_smoother): use polling subscriber (#7216)
takayuki5168 Jun 8, 2024
14c75e6
feat(joy_controller): use polling subscriber (#7286)
takayuki5168 Jun 8, 2024
af9db8c
refactor(joy_controller)!: prefix package and namespace with autoware…
takayuki5168 Jun 8, 2024
a6ef8bb
feat(tier4_autoware_utils): suppress too many warning of TF transform…
takayuki5168 Jun 8, 2024
a082e64
refactor(pid_longitudinal_controller)!: prefix package and namespace …
takayuki5168 Jun 8, 2024
240c976
refactor(path_smoother)!: prefix package and namespace with autoware …
takayuki5168 Jun 8, 2024
ac483b9
refactor(out_of_lane): remove from behavior_velocity (#7359)
maxime-clem Jun 9, 2024
09f7676
fix(multi_object_tracker): fix segmentation fault bug of the debug ob…
technolojin Jun 10, 2024
a8b7620
delete blank sentence
N-Eiki Jun 10, 2024
a137560
chore(vehicle_cmd_gate): add prefix autoware_ to vehicle_cmd_gate (#7…
go-sakayori Jun 10, 2024
2235e20
feat(autoware_lane_departure_checker): use polling subscriber (#7358)
kyoichi-sugahara Jun 10, 2024
af9194e
chore(control): add maintainer for several control modules (#7389)
zulfaqar-azmi-t4 Jun 10, 2024
b9c66fc
fix : handle to review, eliminate redundant cast
N-Eiki Jun 10, 2024
3eccd71
fix: undo miss delete
N-Eiki Jun 11, 2024
ff3ef6a
Merge branch 'feat/use_takeData_in_abc_module' of github.com:N-Eiki/a…
N-Eiki Jun 11, 2024
54de65a
Merge branch 'N-Eiki-feat/use_takeData_in_abc_module'
N-Eiki Jun 11, 2024
1a7288a
solve conflict
N-Eiki Jun 11, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2020 Tier IV, Inc. All rights reserved.
// Copyright 2024 Tier IV, Inc. All rights reserved.
shmpwk marked this conversation as resolved.
Show resolved Hide resolved
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -23,12 +23,13 @@
#include "rclcpp/rclcpp.hpp"
#include "tf2/utils.h"
#include "tier4_autoware_utils/ros/logger_level_configure.hpp"
#include "tier4_autoware_utils/ros/polling_subscriber.hpp"
#include "tier4_autoware_utils/ros/transform_listener.hpp"

#include <Eigen/Dense>

#include "autoware_vehicle_msgs/msg/steering_report.hpp"
#include "autoware_vehicle_msgs/msg/velocity_report.hpp"
#include "autoware_auto_vehicle_msgs/msg/steering_report.hpp"
#include "autoware_auto_vehicle_msgs/msg/velocity_report.hpp"
tkimura4 marked this conversation as resolved.
Show resolved Hide resolved
#include "geometry_msgs/msg/twist_stamped.hpp"
#include "nav_msgs/msg/occupancy_grid.hpp"
#include "std_msgs/msg/bool.hpp"
Expand Down Expand Up @@ -56,8 +57,8 @@
namespace accel_brake_map_calibrator
{

using autoware_vehicle_msgs::msg::SteeringReport;
using autoware_vehicle_msgs::msg::VelocityReport;
using autoware_auto_vehicle_msgs::msg::SteeringReport;
using autoware_auto_vehicle_msgs::msg::VelocityReport;
tkimura4 marked this conversation as resolved.
Show resolved Hide resolved
using geometry_msgs::msg::TwistStamped;
using nav_msgs::msg::OccupancyGrid;
using raw_vehicle_cmd_converter::AccelMap;
Expand Down Expand Up @@ -107,10 +108,14 @@ class AccelBrakeMapCalibrator : public rclcpp::Node
rclcpp::Publisher<Float32Stamped>::SharedPtr map_error_ratio_pub_;
rclcpp::Publisher<CalibrationStatus>::SharedPtr calibration_status_pub_;

rclcpp::Subscription<VelocityReport>::SharedPtr velocity_sub_;
rclcpp::Subscription<SteeringReport>::SharedPtr steer_sub_;
rclcpp::Subscription<ActuationStatusStamped>::SharedPtr actuation_status_sub_;
rclcpp::Subscription<ActuationCommandStamped>::SharedPtr actuation_cmd_sub_;
tier4_autoware_utils::InterProcessPollingSubscriber<SteeringReport> steer_sub_{
this, "~/input/steer"};
tier4_autoware_utils::InterProcessPollingSubscriber<ActuationStatusStamped> actuation_status_sub_{
this, "~/input/actuation_status"};
tier4_autoware_utils::InterProcessPollingSubscriber<ActuationCommandStamped> actuation_cmd_sub_{
this, "~/input/actuation_cmd"};
tier4_autoware_utils::InterProcessPollingSubscriber<VelocityReport> velocity_sub_{
this, "~/input/velocity"};

// Service
rclcpp::Service<UpdateAccelBrakeMap>::SharedPtr update_map_dir_server_;
Expand Down Expand Up @@ -244,12 +249,12 @@ class AccelBrakeMapCalibrator : public rclcpp::Node
const int brake_pedal_index, const int brake_vel_index, const double measured_acc,
const double map_acc);
void updateTotalMapOffset(const double measured_acc, const double map_acc);
void callbackActuation(
const std_msgs::msg::Header header, const double accel, const double brake);
void callbackActuationCommand(const ActuationCommandStamped::ConstSharedPtr msg);
void callbackActuationStatus(const ActuationStatusStamped::ConstSharedPtr msg);
void callbackVelocity(const VelocityReport::ConstSharedPtr msg);
void callbackSteer(const SteeringReport::ConstSharedPtr msg);

void takeActuation(const std_msgs::msg::Header header, const double accel, const double brake);
void takeActuationCommand(const ActuationCommandStamped::ConstSharedPtr msg);
void takeActuationStatus(const ActuationStatusStamped::ConstSharedPtr msg);
void takeVelocity(const VelocityReport::ConstSharedPtr msg);

bool callbackUpdateMapService(
const std::shared_ptr<rmw_request_id_t> request_header,
UpdateAccelBrakeMap::Request::SharedPtr req, UpdateAccelBrakeMap::Response::SharedPtr res);
Expand Down
1 change: 1 addition & 0 deletions vehicle/accel_brake_map_calibrator/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<maintainer email="[email protected]">Tomoya Kimura</maintainer>
<maintainer email="[email protected]">Taiki Tanaka</maintainer>
<maintainer email="[email protected]">Takeshi Miura</maintainer>
<maintainer email="[email protected]">Eiki Nagata</maintainer>
tkimura4 marked this conversation as resolved.
Show resolved Hide resolved

<license>Apache License 2.0</license>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//

Check notice on line 1 in vehicle/accel_brake_map_calibrator/src/accel_brake_map_calibrator_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Lines of Code in a Single File

The lines of code decreases from 1362 to 1356, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.

Check notice on line 1 in vehicle/accel_brake_map_calibrator/src/accel_brake_map_calibrator_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 4.06 to 4.17, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.

Check notice on line 1 in vehicle/accel_brake_map_calibrator/src/accel_brake_map_calibrator_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Primitive Obsession

The ratio of primitive types in function arguments increases from 59.48% to 60.00%, threshold = 30.0%. The functions in this file have too many primitive types (e.g. int, double, float) in their function argument lists. Using many primitive types lead to the code smell Primitive Obsession. Avoid adding more primitive arguments.
// Copyright 2020 Tier IV, Inc. All rights reserved.
// Copyright 2024 Tier IV, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -207,23 +207,7 @@
using std::placeholders::_1;
using std::placeholders::_2;
using std::placeholders::_3;

Check notice on line 210 in vehicle/accel_brake_map_calibrator/src/accel_brake_map_calibrator_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Complex Method

AccelBrakeMapCalibrator::AccelBrakeMapCalibrator decreases in cyclomatic complexity from 19 to 17, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
velocity_sub_ = create_subscription<VelocityReport>(
"~/input/velocity", queue_size,
std::bind(&AccelBrakeMapCalibrator::callbackVelocity, this, _1));
steer_sub_ = create_subscription<SteeringReport>(
"~/input/steer", queue_size, std::bind(&AccelBrakeMapCalibrator::callbackSteer, this, _1));
if (accel_brake_value_source_ == ACCEL_BRAKE_SOURCE::STATUS) {
actuation_status_sub_ = create_subscription<ActuationStatusStamped>(
"~/input/actuation_status", queue_size,
std::bind(&AccelBrakeMapCalibrator::callbackActuationStatus, this, _1));
}
if (accel_brake_value_source_ == ACCEL_BRAKE_SOURCE::COMMAND) {
actuation_cmd_sub_ = create_subscription<ActuationCommandStamped>(
"~/input/actuation_cmd", queue_size,
std::bind(&AccelBrakeMapCalibrator::callbackActuationCommand, this, _1));
}

// Service
update_map_dir_server_ = create_service<UpdateAccelBrakeMap>(
"~/input/update_map_dir",
Expand Down Expand Up @@ -296,19 +280,42 @@
<< "\n\t"
<< "update_fail_count_: " << update_fail_count_ << "\n");

/* valid check */
// take data from subscribers

shmpwk marked this conversation as resolved.
Show resolved Hide resolved
// take actuation data
if (accel_brake_value_source_ == ACCEL_BRAKE_SOURCE::STATUS) {
ActuationStatusStamped::ConstSharedPtr actuation_status_ptr = actuation_status_sub_.takeData();
if (!actuation_status_ptr) return;
takeActuationStatus(actuation_status_ptr);
}
if (accel_brake_value_source_ == ACCEL_BRAKE_SOURCE::COMMAND) {
ActuationCommandStamped::ConstSharedPtr actuation_cmd_ptr = actuation_cmd_sub_.takeData();
if (!actuation_cmd_ptr) return;
takeActuationCommand(actuation_cmd_ptr);
}

// take velocity data
VelocityReport::ConstSharedPtr velocity_ptr = velocity_sub_.takeData();
if (!velocity_ptr) return;
takeVelocity(velocity_ptr);

// take steer data
steer_ptr_ = steer_sub_.takeData();

/* valid check */
// data check
if (
!twist_ptr_ || !steer_ptr_ || !accel_pedal_ptr_ || !brake_pedal_ptr_ ||
!delayed_accel_pedal_ptr_ || !delayed_brake_pedal_ptr_) {
// lack of data
RCLCPP_WARN_STREAM_THROTTLE(
get_logger(), *get_clock(), 5000, "lack of topics (twist, steer, accel, brake)");
lack_of_data_count_++;
return;
}

debug_values_.data.at(CURRENT_STEER) = steer_ptr_->steering_tire_angle;

Check notice on line 318 in vehicle/accel_brake_map_calibrator/src/accel_brake_map_calibrator_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Complex Method

AccelBrakeMapCalibrator::timerCallback increases in cyclomatic complexity from 23 to 28, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check warning on line 318 in vehicle/accel_brake_map_calibrator/src/accel_brake_map_calibrator_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Bumpy Road Ahead

AccelBrakeMapCalibrator::timerCallback has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
// data check 2
if (
isTimeout(twist_ptr_->header.stamp, timeout_sec_) ||
Expand Down Expand Up @@ -458,7 +465,7 @@
}
}

void AccelBrakeMapCalibrator::callbackVelocity(const VelocityReport::ConstSharedPtr msg)
void AccelBrakeMapCalibrator::takeVelocity(const VelocityReport::ConstSharedPtr msg)
{
// convert velocity-report to twist-stamped
auto twist_msg = std::make_shared<TwistStamped>();
Expand Down Expand Up @@ -496,13 +503,7 @@
pushDataToVec(twist_msg, twist_vec_max_size_, &twist_vec_);
}

void AccelBrakeMapCalibrator::callbackSteer(const SteeringReport::ConstSharedPtr msg)
{
debug_values_.data.at(CURRENT_STEER) = msg->steering_tire_angle;
steer_ptr_ = msg;
}

void AccelBrakeMapCalibrator::callbackActuation(
void AccelBrakeMapCalibrator::takeActuation(
const std_msgs::msg::Header header, const double accel, const double brake)
{
// get accel data
Expand Down Expand Up @@ -538,22 +539,21 @@
getNearestTimeDataFromVec(brake_pedal_ptr_, pedal_to_accel_delay_, brake_pedal_vec_);
}

void AccelBrakeMapCalibrator::callbackActuationCommand(
void AccelBrakeMapCalibrator::takeActuationCommand(
const ActuationCommandStamped::ConstSharedPtr msg)
{
const auto header = msg->header;
const auto accel = msg->actuation.accel_cmd;
const auto brake = msg->actuation.brake_cmd;
callbackActuation(header, accel, brake);
takeActuation(header, accel, brake);
}

void AccelBrakeMapCalibrator::callbackActuationStatus(
const ActuationStatusStamped::ConstSharedPtr msg)
void AccelBrakeMapCalibrator::takeActuationStatus(const ActuationStatusStamped::ConstSharedPtr msg)
{
const auto header = msg->header;
const auto accel = msg->status.accel_status;
const auto brake = msg->status.brake_status;
callbackActuation(header, accel, brake);
takeActuation(header, accel, brake);
}

bool AccelBrakeMapCalibrator::callbackUpdateMapService(
Expand Down
Loading