Skip to content

Commit d3deee2

Browse files
随风而散suifengersan123
authored andcommitted
fix linting problems Signed-off-by: suifengersan123 <[email protected]>
Signed-off-by: suifengersan123 <[email protected]>
1 parent 71ea8fe commit d3deee2

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

nav2_dwb_controller/dwb_plugins/include/dwb_plugins/kinematic_parameters.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,8 @@ class KinematicsHandler
147147

148148
inline KinematicParameters getKinematics() {
149149
KinematicParameters* ptr = kinematics_.load();
150-
// Check for nullptr before dereferencing
151150
if (ptr == nullptr) {
152-
throw std::runtime_error(
153-
"KinematicsHandler::getKinematics() called before kinematics_ is initialized");
151+
throw std::runtime_error("KinematicsHandler::getKinematics() called before kinematics_ is initialized");
154152
}
155153
return *ptr;
156154
}

nav2_dwb_controller/dwb_plugins/src/kinematic_parameters.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ KinematicsHandler::KinematicsHandler()
5656
KinematicsHandler::~KinematicsHandler()
5757
{
5858
KinematicParameters* ptr = kinematics_.load();
59-
if (ptr != nullptr) {
60-
delete ptr;
61-
}
59+
if (ptr != nullptr) {
60+
delete ptr;
61+
}
6262
}
6363

6464
void KinematicsHandler::initialize(
@@ -154,11 +154,11 @@ void KinematicsHandler::deactivate()
154154
void KinematicsHandler::setSpeedLimit(
155155
const double & speed_limit, const bool & percentage)
156156
{
157-
KinematicParameters* ptr = kinematics_.load();
158-
if (ptr == nullptr) {
159-
return; // Nothing to update
160-
}
161-
KinematicParameters kinematics(*ptr);
157+
KinematicParameters* ptr = kinematics_.load();
158+
if (ptr == nullptr) {
159+
return; // Nothing to update
160+
}
161+
KinematicParameters kinematics(*ptr);
162162

163163
if (speed_limit == nav2_costmap_2d::NO_SPEED_LIMIT) {
164164
// Restore default value
@@ -239,11 +239,11 @@ void
239239
KinematicsHandler::updateParametersCallback(std::vector<rclcpp::Parameter> parameters)
240240
{
241241
rcl_interfaces::msg::SetParametersResult result;
242-
KinematicParameters* ptr = kinematics_.load();
243-
if (ptr == nullptr) {
244-
return; // Nothing to update
245-
}
246-
KinematicParameters kinematics(*ptr);
242+
KinematicParameters* ptr = kinematics_.load();
243+
if (ptr == nullptr) {
244+
return; // Nothing to update
245+
}
246+
KinematicParameters kinematics(*ptr);
247247

248248
for (auto parameter : parameters) {
249249
const auto & param_type = parameter.get_type();
@@ -296,7 +296,6 @@ KinematicsHandler::updateParametersCallback(std::vector<rclcpp::Parameter> param
296296
void KinematicsHandler::update_kinematics(KinematicParameters kinematics) {
297297
KinematicParameters* new_kinematics = new KinematicParameters(kinematics);
298298
KinematicParameters* old_kinematics = kinematics_.exchange(new_kinematics);
299-
300299
if (old_kinematics != nullptr) {
301300
delete old_kinematics;
302301
}

0 commit comments

Comments
 (0)