Skip to content

Commit

Permalink
Handle missing effort limit in URDF (ros-visualization#1084) (ros-vis…
Browse files Browse the repository at this point in the history
…ualization#1085)

* Handle missing effort limit in URDF

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com>
(cherry picked from commit a83d8195a16cdcdbd417938cb8d3a30b4c826b12)

Co-authored-by: Patrick Roncagliolo <ronca.pat@gmail.com>
  • Loading branch information
mergify[bot] and roncapat authored Nov 9, 2023
1 parent 6ecfcec commit 30a4772
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <rviz_common/properties/property.hpp>
#include <rviz_rendering/objects/effort_visual.hpp>
#include <sensor_msgs/msg/joint_state.hpp>
#include <rclcpp/logging.hpp>

using namespace std::chrono_literals;

Expand Down Expand Up @@ -196,8 +197,16 @@ void EffortDisplay::topic_callback(const std_msgs::msg::String & msg)
if (joint->type == urdf::Joint::REVOLUTE || joint->type == 2) {
std::string joint_name = it->first;
urdf::JointLimitsSharedPtr limit = joint->limits;
joints_[joint_name] = std::make_shared<JointInfo>(joint_name, joints_category_);
joints_[joint_name]->setMaxEffort(limit->effort);
if (limit) {
joints_[joint_name] = std::make_shared<JointInfo>(joint_name, joints_category_);
joints_[joint_name]->setMaxEffort(limit->effort);
} else {
RCLCPP_WARN(
context_->getRosNodeAbstraction().lock()->get_raw_node()->get_logger(),
"Joint '%s' has no <limit> tag in URDF. Effort plugin needs to know the effort "
"limit to determine the size of the corresponding visual marker. "
"Effort display for this joint will be inhibited.", joint_name.c_str());
}
}
}
}
Expand Down

0 comments on commit 30a4772

Please sign in to comment.