5 from hrpsys_ros_bridge.srv
import OpenHRP_StabilizerService_getParameter
as getParameter
7 from std_msgs.msg
import Empty
8 from sound_play.msg
import SoundRequest
9 from hrpsys_ros_bridge.msg
import ContactStatesStamped, ContactStateStamped, ContactState
10 from hrpsys_ros_bridge.msg
import MotorStates
13 g_previous_st_controller_mode =
None 17 is_lleg_contact =
None 18 is_rleg_contact =
None 19 for state
in msg.states:
20 if state.header.frame_id ==
"lfsensor":
21 if state.state.state == ContactState.ON:
22 is_lleg_contact =
True 24 is_lleg_contact =
False 25 if state.header.frame_id ==
"rfsensor":
26 if state.state.state == ContactState.ON:
27 is_rleg_contact =
True 29 is_rleg_contact =
False 30 if is_lleg_contact
or is_rleg_contact:
36 if (actual_from
in expected_from
and 37 actual_to == expected_to):
44 g_odom_init_trigger_pub.publish(Empty())
45 if is_servo_on
is False:
48 sound = SoundRequest()
49 sound.sound = SoundRequest.SAY
50 sound.command = SoundRequest.PLAY_ONCE
51 if hasattr(SoundRequest,
'volume'):
53 sound.arg =
"Robot stands on the ground." 54 g_robotsound_pub.publish(sound)
57 global g_previous_st_controller_mode
58 global g_odom_init_trigger_pub, g_robotsound_pub
60 if (controller_mode ==
"MODE_AIR" or 61 controller_mode ==
"MODE_IDLE" or 62 controller_mode ==
"MODE_ST"):
63 if g_previous_st_controller_mode ==
None:
64 g_previous_st_controller_mode = controller_mode
65 if controller_mode ==
"MODE_ST":
70 [
"MODE_AIR",
"MODE_IDLE"],
73 g_previous_st_controller_mode = controller_mode
77 is_servo_on = any(msg.servo_state)
79 if __name__ ==
"__main__":
80 rospy.init_node(
"stabilizer_watcher")
81 contact_states_sub = rospy.Subscriber(
"/act_contact_states", ContactStatesStamped, contactStatesCallback, queue_size=1)
82 motor_states_sub = rospy.Subscriber(
"/motor_states", MotorStates, motorStatesCallback, queue_size=1)
83 g_odom_init_trigger_pub = rospy.Publisher(
"/odom_init_trigger", Empty, queue_size=1)
84 g_robotsound_pub = rospy.Publisher(
"/robotsound", SoundRequest, queue_size=1)
def contactStatesCallback(msg)
def isChangedControllerMode(actual_from, actual_to, expected_from, expected_to)
def controllerModeToString(msg)
def motorStatesCallback(msg)