Skip to content

Commit 81969ef

Browse files
author
随风而散
committed
throw error
1 parent 445386f commit 81969ef

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

nav2_dwb_controller/dwb_plugins/include/dwb_plugins/kinematic_parameters.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
#include <memory>
3939
#include <string>
40-
40+
#include <stdexcept>
4141
#include "rclcpp/rclcpp.hpp"
4242
#include "nav2_util/lifecycle_node.hpp"
4343

@@ -110,10 +110,11 @@ class KinematicsHandler
110110
inline KinematicParameters getKinematics() {
111111
KinematicParameters* ptr = kinematics_.load();
112112
// Check for nullptr before dereferencing
113-
if (ptr != nullptr) {
114-
return *ptr;
113+
if (ptr == nullptr) {
114+
throw std::runtime_error(
115+
"KinematicsHandler::getKinematics() called before kinematics_ is initialized");
115116
}
116-
return KinematicParameters();
117+
return *ptr;
117118
}
118119

119120
using Ptr = std::shared_ptr<KinematicsHandler>;

0 commit comments

Comments
 (0)