ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

As far as I know rosservice.call_service doesn't work for this usage. I attached the code that I used below.

#!/usr/bin/env python

import rospy
import time

from std_msgs.msg import Bool from std_msgs.msg import Int32 from dynamixel_controllers.srv import TorqueEnable import sys

def callback_receive(msg): rospy.wait_for_service('joint2_controller/torque_enable') rospy.wait_for_service('joint1_controller/torque_enable') if msg.data == 1: joint2 = rospy.ServiceProxy('joint2_controller/torque_enable', TorqueEnable) joint1 = rospy.ServiceProxy('joint1_controller/torque_enable', TorqueEnable) joint_2=joint2(True) joint_1=joint1(True) #print(msg.data) #rosservice.call_service('/joint2_controller/torque_enable',True) #rosservice.call_service('/joint1_controller/torque_enable',True) elif msg.data == 0: joint2 = rospy.ServiceProxy('joint2_controller/torque_enable', TorqueEnable) joint1 = rospy.ServiceProxy('joint1_controller/torque_enable', TorqueEnable) joint_2=joint2(False) joint_1=joint1(False) #rosservice.call_service('/joint2_controller/torque_enable',False) #rosservice.call_service('/joint1_controller/torque_enable',False) #print("6")

if __name__ == '__main__': rospy.init_node('subscriber_node') rospy.Subscriber("/X",Int32,callback_receive)

rospy.spin()

As far as I know rosservice.call_service doesn't work for this usage. I attached the code that I used below.used.

#!/usr/bin/env python

import rospy
import time

from std_msgs.msg import Bool from std_msgs.msg import Int32 from dynamixel_controllers.srv import TorqueEnable import sys

sys

def callback_receive(msg): rospy.wait_for_service('joint2_controller/torque_enable') rospy.wait_for_service('joint1_controller/torque_enable') if msg.data == 1: joint2 = rospy.ServiceProxy('joint2_controller/torque_enable', TorqueEnable) joint1 = rospy.ServiceProxy('joint1_controller/torque_enable', TorqueEnable) joint_2=joint2(True) joint_1=joint1(True) elif msg.data == 0: joint2 = rospy.ServiceProxy('joint2_controller/torque_enable', TorqueEnable) joint1 = rospy.ServiceProxy('joint1_controller/torque_enable', TorqueEnable) joint_2=joint2(True) joint_1=joint1(True) #print(msg.data) #rosservice.call_service('/joint2_controller/torque_enable',True) #rosservice.call_service('/joint1_controller/torque_enable',True) elif msg.data == 0: joint2 = rospy.ServiceProxy('joint2_controller/torque_enable', TorqueEnable) joint1 = rospy.ServiceProxy('joint1_controller/torque_enable', TorqueEnable) joint_2=joint2(False) joint_1=joint1(False) #rosservice.call_service('/joint2_controller/torque_enable',False) #rosservice.call_service('/joint1_controller/torque_enable',False) #print("6")

if __name__ == '__main__': rospy.init_node('subscriber_node') rospy.Subscriber("/X",Int32,callback_receive)

rospy.Subscriber("/X",Int32,callback_receive)
 rospy.spin()