Skip to content

Commit

Permalink
added simple nan runtime check
Browse files Browse the repository at this point in the history
  • Loading branch information
mhubii committed Nov 20, 2023
1 parent 091aca5 commit 9add600
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef LBR_ROS2_CONTROL__LBR_STATE_BROADCASTER_HPP_
#define LBR_ROS2_CONTROL__LBR_STATE_BROADCASTER_HPP_

#include <cmath>
#include <limits>
#include <map>
#include <memory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef LBR_ROS2_CONTROL__LBR_VIRTUAL_FT_BROADCASTER_HPP_
#define LBR_ROS2_CONTROL__LBR_VIRTUAL_FT_BROADCASTER_HPP_

#include <cmath>
#include <functional>
#include <limits>
#include <memory>
Expand Down
4 changes: 4 additions & 0 deletions lbr_ros2_control/src/lbr_state_broadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ controller_interface::CallbackReturn LBRStateBroadcaster::on_init() {

controller_interface::return_type LBRStateBroadcaster::update(const rclcpp::Time & /*time*/,
const rclcpp::Duration & /*period*/) {
// check any for nan
if (std::isnan(state_interface_map_[joint_names_[0]][hardware_interface::HW_IF_POSITION])) {
return controller_interface::return_type::OK;
}
for (const auto &state_interface : state_interfaces_) {
state_interface_map_[state_interface.get_prefix_name()][state_interface.get_interface_name()] =
state_interface.get_value();
Expand Down
4 changes: 4 additions & 0 deletions lbr_ros2_control/src/lbr_virtual_ft_broadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ controller_interface::CallbackReturn LBRVirtualFTBroadcaster::on_init() {
controller_interface::return_type
LBRVirtualFTBroadcaster::update(const rclcpp::Time & /*time*/,
const rclcpp::Duration & /*period*/) {
// check any for nan
if (std::isnan(joint_position_interfaces_[0].get().get_value())) {
return controller_interface::return_type::OK;
}
for (std::size_t i = 0; i < joint_names_.size(); ++i) {
joint_positions_(i) = joint_position_interfaces_[i].get().get_value();
external_joint_torques_(i) = external_joint_torque_interfaces_[i].get().get_value();
Expand Down

0 comments on commit 9add600

Please sign in to comment.