4 Display the difference between reference and actual swing/support time according to hrpsys_ros_bridge/ContactState using
5 jsk_rviz_plugins/PictogramArray
10 from geometry_msgs.msg
import Quaternion
11 from hrpsys_ros_bridge.msg
import ContactState, ContactStateStamped, ContactStatesStamped
12 from std_msgs.msg
import ColorRGBA
13 import message_filters
16 "msgs = ContactStatesStamped"
17 if len(ref_contact_states_queue) > buffer_size - 1:
18 arr = PictogramArray()
19 arr.header.frame_id =
"/odom"
20 arr.header.stamp = rospy.Time.now()
21 for i, (ref_st, act_st)
in enumerate(zip(ref.states, act.states)):
23 if ref_st.state.state == act_st.state.state:
26 if [ref_st.state.state, act_st.state.state] == [ContactState.OFF, ContactState.ON]:
27 if [x.states[i].state.state
for x
in ref_contact_states_queue] == [ContactState.OFF] * buffer_size
and [x.states[i].state.state
for x
in act_contact_states_queue] == [ContactState.OFF] * buffer_size:
28 picto.character =
"fa-long-arrow-down"
30 picto.pose.orientation = Quaternion(0, -1, 0, 1)
31 picto.action = Pictogram.ADD
32 picto.color = ColorRGBA(1.0, 0.0, 0.0, 0.8)
33 rospy.loginfo(
"%s early landing %s [s]", ref_st.header.frame_id, str(ref_st.state.remaining_time))
34 elif [x.states[i].state.state
for x
in ref_contact_states_queue] == [ContactState.ON] * buffer_size
and [x.states[i].state.state
for x
in act_contact_states_queue] == [ContactState.ON] * buffer_size:
35 picto.character =
"up-bold"
37 picto.pose.orientation = Quaternion(0, -1, 0, 1)
38 picto.action = Pictogram.ADD
39 picto.color = ColorRGBA(0.0, 1.0, 0.0, 0.8)
40 rospy.loginfo(
"%s late taking off", ref_st.header.frame_id)
44 elif [ref_st.state.state, act_st.state.state] == [ContactState.ON, ContactState.OFF]:
45 if [x.states[i].state.state
for x
in ref_contact_states_queue] == [ContactState.OFF] * buffer_size
and [x.states[i].state.state
for x
in act_contact_states_queue] == [ContactState.OFF] * buffer_size:
46 picto.character =
"fa-long-arrow-down"
48 picto.pose.orientation = Quaternion(0, -1, 0, 1)
49 picto.action = Pictogram.ADD
50 picto.color = ColorRGBA(0.0, 1.0, 0.0, 0.8)
51 rospy.loginfo(
"%s late landing", ref_st.header.frame_id)
52 elif [x.states[i].state.state
for x
in ref_contact_states_queue] == [ContactState.ON] * buffer_size
and [x.states[i].state.state
for x
in act_contact_states_queue] == [ContactState.ON] * buffer_size:
53 picto.character =
"up-bold"
55 picto.pose.orientation = Quaternion(0, -1, 0, 1)
56 picto.action = Pictogram.ADD
57 picto.color = ColorRGBA(1.0, 0.0, 0.0, 0.8)
58 rospy.loginfo(
"%s early taking off %s [s]", ref_st.header.frame_id, str(ref_st.state.remaining_time))
61 picto.header.frame_id = ref_st.header.frame_id
62 picto.header.stamp = ref_st.header.stamp
63 arr.pictograms.append(picto)
64 if len(arr.pictograms) > 0:
66 ref_contact_states_queue.pop(0)
67 act_contact_states_queue.pop(0)
68 ref_contact_states_queue.append(ref)
69 act_contact_states_queue.append(act)
71 if __name__ ==
"__main__":
72 rospy.init_node(
"landing_time_detector")
74 pub = rospy.Publisher(
"~pictogram_array", PictogramArray)
79 ref_contact_states_queue = []
80 act_contact_states_queue = []
83 ts.registerCallback(callback)