16 from __future__
import print_function
22 from osrf_gear.msg
import Goal
23 from sensor_msgs.msg
import JointState
24 from std_srvs.srv
import Trigger
25 from trajectory_msgs.msg
import JointTrajectory
26 from trajectory_msgs.msg
import JointTrajectoryPoint
30 rospy.loginfo(
"Waiting for competition to be ready...")
31 rospy.wait_for_service(
'/ariac/start_competition')
32 rospy.loginfo(
"Competition is now ready.")
33 rospy.loginfo(
"Requesting competition start...")
36 start = rospy.ServiceProxy(
'/ariac/start_competition', Trigger)
38 except rospy.ServiceException
as exc:
39 rospy.logerr(
"Failed to start the competition: %s" % exc)
41 if not response.success:
42 rospy.logerr(
"Failed to start the competition: %s" % response)
44 rospy.loginfo(
"Competition started!")
50 rospy.Publisher(
"/ariac/arm/command", JointTrajectory, queue_size=10)
57 rospy.loginfo(
"Received goal:\n" + str(msg))
61 rospy.loginfo(
"Current Joint States (throttled to 0.1 Hz):\n" + str(msg))
66 rospy.loginfo(
"Sending arm to zero joint positions...")
70 msg = JointTrajectory()
71 msg.joint_names = self.current_joint_state.name
72 point = JointTrajectoryPoint()
73 point.positions = [0] * len(msg.joint_names)
74 point.time_from_start = rospy.Duration(1.0)
76 rospy.loginfo(
"Sending command:\n" + str(msg))
77 self.joint_trajectory_publisher.publish(msg)
81 rospy.init_node(
"gear_example_node")
84 goal_sub = rospy.Subscriber(
"/ariac/orders", Goal, comp_class.goal_callback)
85 joint_state_sub = rospy.Subscriber(
"/joint_states", JointState, comp_class.joint_state_callback)
87 rospy.loginfo(
"Setup complete.")
91 if __name__ ==
'__main__':
def goal_callback(self, msg)
def send_arm_to_zero_state(self)
joint_trajectory_publisher
def joint_state_callback(self, msg)