示例#1
0
 def reset_arm_rnd(self, arm, mode, data):
     """
     Issues a position command to an arm.
     Args:
         arm: Either TRIAL_ARM or AUXILIARY_ARM.
         mode: An integer code (defined in gps_pb2).
         data: An array of floats.
     """
     reset_command = PositionCommand()
     reset_command.mode = mode
     # Reset to uniform random state
     # Joints 1, 4, 5 and 6 have a range of -10,000 to +10,000 degrees. Joint 2 has a range of +42 to +318 degrees. Joint 3 has a range of +17 to +343 degrees. (see http://wiki.ros.org/jaco)
     reset_command.data = [
         (random() * 2 - 1) * pi,
         pi + (random() * 2 - 1) * pi / 2,
         # Limit elbow joints to 180 +/-90 degrees to prevent getting stuck in the ground
         pi + (random() * 2 - 1) * pi / 2,
         (random() * 2 - 1) * pi,
         (random() * 2 - 1) * pi,
         (random() * 2 - 1) * pi
     ]
     reset_command.pd_gains = self._hyperparams['pid_params']
     reset_command.arm = arm
     timeout = self._hyperparams['trial_timeout']
     reset_command.id = self._get_next_seq_id()
     try:
         self._reset_service.publish_and_wait(reset_command,
                                              timeout=timeout)
     except TimeoutException:
         self.relax_arm(arm)
         wait = raw_input(
             'The robot arm seems to be stuck. Unstuck it and press <ENTER> to continue.'
         )
         self.reset_arm(arm, mode, data)
示例#2
0
 def reset_arm(self, arm, mode, data):
     """
     Issues a position command to an arm.
     Args:
         arm: Either TRIAL_ARM or AUXILIARY_ARM.
         mode: An integer code (defined in gps_pb2).
         data: An array of floats.
     """
     reset_command = PositionCommand()
     reset_command.mode = mode
     reset_command.data = data
     reset_command.pd_gains = self._hyperparams['pid_params']
     reset_command.arm = arm
     timeout = self._hyperparams['trial_timeout']
     reset_command.id = self._get_next_seq_id()
     self._reset_service.publish_and_wait(reset_command, timeout=timeout)
示例#3
0
 def reset_arm(self, arm, mode, data):
     """
     Issues a position command to an arm.
     Args:
         arm: Either TRIAL_ARM or AUXILIARY_ARM.
         mode: An integer code (defined in gps_pb2).
         data: An array of floats.
     """
     reset_command = PositionCommand()
     reset_command.mode = mode
     reset_command.data = data
     reset_command.pd_gains = self._hyperparams['pid_params']
     reset_command.arm = arm
     timeout = self._hyperparams['trial_timeout']
     reset_command.id = self._get_next_seq_id()
     self._reset_service.publish_and_wait(reset_command, timeout=timeout)
def main():
    rospy.init_node('issue_com')
    pub = rospy.Publisher(POS_COM_TOPIC, PositionCommand, queue_size=10)
    test_pub = rospy.Publisher(TEST_TOPIC, Empty, queue_size=10)
    sub = rospy.Subscriber(POS_COM_TOPIC, PositionCommand, listen)
    #sub = rospy.Subscriber('/joint_states', JointState, listen)

    pc = PositionCommand()
    pc.mode = JOINT_SPACE
    #pc.arm = PositionCommand.LEFT_ARM
    pc.arm = 1#PositionCommand.RIGHT_ARM
    pc.data = np.zeros(7)

    r = rospy.Rate(1)
    #while not rospy.is_shutdown():
    #    pub.publish(pc)
    #    r.sleep()
    #    print 'published!'
    r.sleep()
    test_pub.publish(Empty())
    pub.publish(pc)
示例#5
0
 def reset_arm(self, arm, mode, data):
     """
     Issues a position command to an arm.
     Args:
         arm: Either TRIAL_ARM or AUXILIARY_ARM.
         mode: An integer code (defined in gps_pb2).
         data: An array of floats.
     """
     reset_command = PositionCommand()
     reset_command.mode = mode
     reset_command.data = data
     reset_command.pd_gains = self._hyperparams['pid_params']
     reset_command.arm = arm
     timeout = self._hyperparams['trial_timeout']
     reset_command.id = self._get_next_seq_id()
     try:
         self._reset_service.publish_and_wait(reset_command,
                                              timeout=timeout)
     except TimeoutException:
         self.relax_arm(arm)
         wait = raw_input(
             'The robot arm seems to be stuck. Unstuck it and press <ENTER> to continue.'
         )
         self.reset_arm(arm, mode, data)