Go to the documentation of this file.00001
00002
00003 import rospy
00004 from hrpsys_ros_bridge.msg import ContactState, ContactStateStamped, ContactStatesStamped
00005 from random import random
00006 if __name__ == "__main__":
00007 rospy.init_node("contact_state_sample")
00008 pub = rospy.Publisher("~output", ContactStatesStamped)
00009 link_names = rospy.get_param("~links", ["r_shoulder_pan_link"])
00010 rate = rospy.Rate(1)
00011 while not rospy.is_shutdown():
00012 states = ContactStatesStamped()
00013 states.header.stamp = rospy.Time.now()
00014 for link_name in link_names:
00015 state = ContactStateStamped()
00016 state.header.frame_id = link_name
00017 state.header.stamp = rospy.Time.now()
00018 if random() < 0.5:
00019 state.state.state = ContactState.ON
00020 else:
00021 state.state.state = ContactState.OFF
00022 states.states.append(state)
00023 pub.publish(states)
00024 rate.sleep()