stance_phase.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 from jsk_footstep_controller.msg import GroundContactState
5 from jsk_rviz_plugins.msg import OverlayText
6 
7 def callback(msg):
8  text = OverlayText()
9  if msg.contact_state == GroundContactState.CONTACT_BOTH_GROUND:
10  text.text = "Double Stance Phase"
11  text.fg_color.a = 1.0
12  text.fg_color.r = 25 / 255.0
13  text.fg_color.g = 1
14  text.fg_color.b = 1
15  elif msg.contact_state == GroundContactState.CONTACT_LLEG_GROUND or msg.contact_state == GroundContactState.CONTACT_RLEG_GROUND:
16  text.text = "Single Stance Phase"
17  text.fg_color.a = 1.0
18  text.fg_color.r = 1
19  text.fg_color.g = 0
20  text.fg_color.b = 0
21  elif msg.contact_state == GroundContactState.CONTACT_UNSTABLE:
22  text.text = "Unstable"
23  text.fg_color.a = 1.0
24  text.fg_color.r = 1
25  text.fg_color.g = 0
26  text.fg_color.b = 0
27  elif msg.contact_state == GroundContactState.CONTACT_AIR:
28  text.text = "Air"
29  text.fg_color.a = 1.0
30  text.fg_color.r = 1
31  text.fg_color.g = 0
32  text.fg_color.b = 0
33  pub.publish(text)
34 
35 def main():
36  global pub
37  pub = rospy.Publisher("stance_phase_text", OverlayText)
38  sub = rospy.Subscriber("/footcoords/contact_state", GroundContactState, callback)
39  rospy.spin()
40 
41 
42 if __name__ == "__main__":
43  rospy.init_node("stance_phase_text")
44  main()
def callback(msg)
Definition: stance_phase.py:7


jsk_footstep_controller
Author(s):
autogenerated on Fri May 14 2021 02:52:04