From a937047fee5371d0b074cba65cb78e495f7090f5 Mon Sep 17 00:00:00 2001 From: yy389 Date: Tue, 10 Oct 2023 22:14:25 -0400 Subject: [PATCH] clean if-else --- hello_helpers/src/hello_helpers/hello_misc.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hello_helpers/src/hello_helpers/hello_misc.py b/hello_helpers/src/hello_helpers/hello_misc.py index 5d0d944..b3fb0dd 100644 --- a/hello_helpers/src/hello_helpers/hello_misc.py +++ b/hello_helpers/src/hello_helpers/hello_misc.py @@ -240,19 +240,16 @@ class HelloNode: if not server_reached: rospy.signal_shutdown('Unable to connect to arm action server. Timeout exceeded.') sys.exit() - - if self.robot_name == None: - self._joint_states_subscriber = rospy.Subscriber('/stretch/joint_states', JointState, self._joint_states_callback) - else: - self._joint_states_subscriber = rospy.Subscriber('/'+self.robot_name+'/joint_states', JointState, self._joint_states_callback) - + self.tf2_buffer = tf2_ros.Buffer() self.tf2_listener = tf2_ros.TransformListener(self.tf2_buffer) if self.robot_name == None: + self._joint_states_subscriber = rospy.Subscriber('/stretch/joint_states', JointState, self._joint_states_callback) self._tool_subscriber = rospy.Subscriber('/tool', String, self._tool_callback) self._mode_subscriber = rospy.Subscriber('/mode', String, self._mode_callback) self.point_cloud_subscriber = rospy.Subscriber('/camera/depth/color/points', PointCloud2, self._point_cloud_callback) else: + self._joint_states_subscriber = rospy.Subscriber('/'+self.robot_name+'/joint_states', JointState, self._joint_states_callback) self._tool_subscriber = rospy.Subscriber('/'+self.robot_name+'/tool', String, self._tool_callback) self._mode_subscriber = rospy.Subscriber('/'+self.robot_name+'/mode', String, self._mode_callback) self.point_cloud_subscriber = rospy.Subscriber('/'+self.robot_name+'/camera/depth/color/points', PointCloud2, self._point_cloud_callback)