Skip to content

Commit 33fc789

Browse files
committed
fixed robustness wrt to NaNs
1 parent 00ac620 commit 33fc789

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

hector_ros_controllers/src/collision_checker.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ bool CollisionChecker::checkCollision( const std::unordered_map<std::string, dou
135135
RCLCPP_ERROR( node_->get_logger(), "Model not initialized." );
136136
return true;
137137
}
138+
// return true if any position is Nan or Inf
139+
for ( const auto &[name, position] : joint_positions ) {
140+
if ( std::isnan( position ) || std::isinf( position ) ) {
141+
RCLCPP_ERROR(
142+
node_->get_logger(),
143+
"Joint position for joint '%s' is NaN or Inf (%.3f). Assuming the robot is in collision.",
144+
name.c_str(), position );
145+
return true;
146+
}
147+
}
138148
// transforms the joint positions into the pinocchio format
139149
Eigen::VectorXd q = q_default_;
140150
for ( const auto &[name, position] : joint_positions ) {

0 commit comments

Comments
 (0)