def toggle(self):
     if (self._platform_state_message is not None):
         reconnect = rospy.ServiceProxy("/reconnect", Empty)
         try:
             reconnect()
         except rospy.ServiceException, e:
             util.dasherr("Failed to reconnect the driver: service call failed with error: %s" % (e))
    def disable_base(self):
        # if any of the breakers is not enabled ask if they'd like to enable them
        if (self._platform_state_message is not None):
            if (self._platform_state_message.circuit_state[0] == PowerBoardState.STATE_ENABLED):
                switch_off_base = rospy.ServiceProxy("/base/switchOffMotors", Empty)

                try:
                    switch_off_base()
                except rospy.ServiceException, e:
                    util.dasherr("Failed to switch OFF base motors: service call failed with error: %s" % (e), self)

            elif (self._platform_state_message.circuit_state[0] == PowerBoardState.STATE_STANDBY):
                util.dasherr("Base motors are already switched OFF", self)
            elif (self._platform_state_message.circuit_state[0] == PowerBoardState.STATE_DISABLED):
                util.dasherr("Base is not connected", self)
    def disable_arm(self):
        # if any of the breakers is not enabled ask if they'd like to enable them
        if (self._platform_state_message is not None):
            if (self._platform_state_message.circuit_state[1] == PowerBoardState.STATE_ENABLED):
                switch_off_arm = rospy.ServiceProxy("/arm_1/switchOffMotors", Empty)

                try:
                    switch_off_arm()
                except rospy.ServiceException, e:
                    util.dasherr("Failed to switch OFF arm motors: service call failed with error: %s" % (e), self)

            elif (self._platform_state_message.circuit_state[1] == PowerBoardState.STATE_STANDBY):
                util.dasherr("Arm motors are already switched OFF", self)
            elif (self._platform_state_message.circuit_state[1] == PowerBoardState.STATE_DISABLED):
                util.dasherr("Arm is not connected", self)
    def enable_arm(self):
        # if any of the breakers is not enabled ask if they'd like to enable them
        if (self._platform_state_message is not None):
            if (self._platform_state_message.circuit_state[1] == PowerBoardState.STATE_STANDBY):
                switch_on_arm = rospy.ServiceProxy("/arm_1/switchOnMotors", Empty)

                try:
                    switch_on_arm()
                except rospy.ServiceException, e:
                    util.dasherr("Failed to switch ON arm motors: service call failed with error: %s" % (e), self)

            elif (self._platform_state_message.circuit_state[1] == PowerBoardState.STATE_ENABLED):
                util.dasherr("Arm motors are already switched ON", self)
            elif (self._platform_state_message.circuit_state[1] == PowerBoardState.STATE_DISABLED):
                util.dasherr("Arm is not connected", self)
    def enable_base(self):
        # if any of the breakers is not enabled ask if they'd like to enable them
        if (self._platform_state_message is not None):
            if (self._platform_state_message.circuit_state[0] ==
                    PowerBoardState.STATE_STANDBY):
                switch_on_base = rospy.ServiceProxy("/base/switchOnMotors",
                                                    Empty)

                try:
                    switch_on_base()
                except rospy.ServiceException, e:
                    util.dasherr(
                        "Failed to switch ON base motors: service call failed with error: %s"
                        % (e), self)

            elif (self._platform_state_message.circuit_state[0] ==
                  PowerBoardState.STATE_ENABLED):
                util.dasherr("Base motors are already switched ON", self)
            elif (self._platform_state_message.circuit_state[0] ==
                  PowerBoardState.STATE_DISABLED):
                util.dasherr("Base is not connected", self)