From 0f6009098c55449656703dc474199277237f81ee Mon Sep 17 00:00:00 2001 From: Bluefairy-ljy <3099568863@qq.com> Date: Sat, 3 Oct 2026 20:41:25 +0800 Subject: [PATCH] Move getParam calls out of ROS_ASSERT so they run in release builds. --- .../rm_common/decision/command_sender.h | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/rm_common/include/rm_common/decision/command_sender.h b/rm_common/include/rm_common/decision/command_sender.h index 77419309..35c17230 100644 --- a/rm_common/include/rm_common/decision/command_sender.h +++ b/rm_common/include/rm_common/decision/command_sender.h @@ -805,7 +805,10 @@ class JointPositionBinaryCommandSender : public CommandSenderBase(nh) { - ROS_ASSERT(nh.getParam("on_pos", on_pos_) && nh.getParam("off_pos", off_pos_)); + if (!nh.getParam("on_pos", on_pos_)) + ROS_ERROR("on_pos no defined (namespace: %s)", nh.getNamespace().c_str()); + if (!nh.getParam("off_pos", off_pos_)) + ROS_ERROR("off_pos no defined (namespace: %s)", nh.getNamespace().c_str()); } void on() { @@ -843,8 +846,12 @@ class CardCommandSender : public CommandSenderBase public: explicit CardCommandSender(ros::NodeHandle& nh) : CommandSenderBase(nh) { - ROS_ASSERT(nh.getParam("long_pos", long_pos_) && nh.getParam("short_pos", short_pos_) && - nh.getParam("off_pos", off_pos_)); + if (!nh.getParam("long_pos", long_pos_)) + ROS_ERROR("long_pos no defined (namespace: %s)", nh.getNamespace().c_str()); + if (!nh.getParam("short_pos", short_pos_)) + ROS_ERROR("short_pos no defined (namespace: %s)", nh.getNamespace().c_str()); + if (!nh.getParam("off_pos", off_pos_)) + ROS_ERROR("off_pos no defined (namespace: %s)", nh.getNamespace().c_str()); } void long_on() { @@ -882,8 +889,10 @@ class JointJogCommandSender : public CommandSenderBase explicit JointJogCommandSender(ros::NodeHandle& nh, const sensor_msgs::JointState& joint_state) : CommandSenderBase(nh), joint_state_(joint_state) { - ROS_ASSERT(nh.getParam("joint", joint_)); - ROS_ASSERT(nh.getParam("step", step_)); + if (!nh.getParam("joint", joint_)) + ROS_ERROR("joint no defined (namespace: %s)", nh.getNamespace().c_str()); + if (!nh.getParam("step", step_)) + ROS_ERROR("step no defined (namespace: %s)", nh.getNamespace().c_str()); } void reset() { @@ -927,10 +936,7 @@ class JointPointCommandSender : public CommandSenderBase : CommandSenderBase(nh), joint_state_(joint_state) { if (!nh.getParam("joint", joint_)) - { ROS_ERROR("JointPointCommandSender failed to get 'joint' param under namespace: %s", nh.getNamespace().c_str()); - } - ROS_ASSERT(nh.getParam("joint", joint_)); } void setPoint(double point) { @@ -963,7 +969,10 @@ class CameraSwitchCommandSender : public CommandSenderBase public: explicit CameraSwitchCommandSender(ros::NodeHandle& nh) : CommandSenderBase(nh) { - ROS_ASSERT(nh.getParam("camera_left_name", camera1_name_) && nh.getParam("camera_right_name", camera2_name_)); + if (!nh.getParam("camera_left_name", camera1_name_)) + ROS_ERROR("camera_left_name no defined (namespace: %s)", nh.getNamespace().c_str()); + if (!nh.getParam("camera_right_name", camera2_name_)) + ROS_ERROR("camera_right_name no defined (namespace: %s)", nh.getNamespace().c_str()); msg_.data = camera2_name_; } void switchCameraLeft()