-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from tue-robotics/feature/check_ebutton
Feature/check ebutton
- Loading branch information
Showing
4 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
from startup import * | ||
from utility import * | ||
from world_model import * | ||
from check_ebutton import * |
36 changes: 36 additions & 0 deletions
36
robot_smach_states/src/robot_smach_states/check_ebutton.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#! /usr/bin/env python | ||
import rospy | ||
import smach | ||
|
||
from human_interaction import Say | ||
|
||
class CheckEButton(smach.State): | ||
"""Check if the robot's Emergency button is pressed""" | ||
def __init__(self, robot=None): | ||
smach.State.__init__(self, outcomes=["pressed", | ||
"released"]) | ||
self.robot = robot | ||
|
||
def execute(self, userdata=None): | ||
if self.robot.ebutton.read_ebutton(): | ||
return "pressed" | ||
else: | ||
return "released" | ||
|
||
class NotifyEButton(smach.StateMachine): | ||
"""Alert the operator that the robot's Emergency button is still pressed""" | ||
|
||
def __init__(self, robot): | ||
smach.StateMachine.__init__(self, outcomes=["succeeded"]) | ||
assert hasattr(robot, "ebutton") | ||
assert hasattr(robot, "speech") | ||
|
||
with self: | ||
smach.StateMachine.add( "CHECK_EBUTTON", | ||
CheckEButton(robot), | ||
transitions={ "pressed" :"SAY_PRESSED", | ||
"released" :"succeeded"}) | ||
|
||
smach.StateMachine.add("SAY_PRESSED", | ||
Say(robot, ["My Emergency button is still pressed", "E-Button still pressed"], block=False), | ||
transitions={ "spoken":"succeeded"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters