-
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 #932 from tue-robotics/feature/examples_smach_states
Feature/examples smach states
- Loading branch information
Showing
24 changed files
with
414 additions
and
54 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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,41 @@ | ||
# ROS | ||
import rospy | ||
import argparse | ||
|
||
# TU/e Robotics | ||
from robot_skills.get_robot import get_robot | ||
|
||
# Robot Smach States | ||
from robot_smach_states.util import designators as ds | ||
from robot_smach_states import SegmentObjects | ||
|
||
from robot_skills.classification_result import ClassificationResult | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
parser = argparse.ArgumentParser(description="Test if it can segment objects") | ||
parser.add_argument("--robot", default="hero", help="Robot name (amigo, hero, sergio)") | ||
parser.add_argument("entity", default="dinner_table", help="Name of the entity on which to segment objects") | ||
args = parser.parse_args() | ||
|
||
rospy.init_node("example_segment_objects") | ||
|
||
robot = get_robot(args.robot) | ||
location_name = args.entity | ||
|
||
rospy.loginfo("Creating location designator") | ||
location_designator = ds.EntityByIdDesignator(robot, location_name) | ||
|
||
rospy.loginfo("Creating found entity designator") | ||
segmented_entities_designator = ds.VariableDesignator([], resolve_type=[ClassificationResult]) | ||
|
||
rospy.loginfo("Creating segment objects state") | ||
sm = SegmentObjects(robot, segmented_entities_designator.writeable, location_designator, "on_top_of") | ||
|
||
rospy.loginfo("Executing segment objects state") | ||
sm.execute() | ||
|
||
rospy.loginfo("Resulting classification result: \n {}".format(segmented_entities_designator.resolve())) | ||
|
||
rospy.loginfo("Done") |
22 changes: 22 additions & 0 deletions
22
robot_smach_states/examples/human_interaction/example_detect_faces.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,22 @@ | ||
#!/usr/bin/python | ||
|
||
# ROS | ||
import rospy | ||
import argparse | ||
|
||
# Detect face | ||
from robot_skills import get_robot | ||
from robot_smach_states import DetectFace | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Test if the robot can detect the face of the person standing in front" | ||
"of it") | ||
parser.add_argument("--robot", default="hero", help="Robot name (amigo, hero, sergio)") | ||
args = parser.parse_args() | ||
|
||
rospy.init_node('test_detect_faces') | ||
robot = get_robot(args.robot) | ||
|
||
detect_state = DetectFace(robot=robot) | ||
detect_state.execute(None) |
26 changes: 26 additions & 0 deletions
26
robot_smach_states/examples/human_interaction/example_give_directions.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,26 @@ | ||
import rospy | ||
import argparse | ||
|
||
# TU/e Robotics | ||
from robot_smach_states.human_interaction import give_directions | ||
import robot_smach_states.util.designators as ds | ||
from robot_skills.get_robot import get_robot | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
parser = argparse.ArgumentParser(description="Starting from the current robot position and orientation give " | ||
"directions to the desired target object") | ||
parser.add_argument("--robot", default="hero", help="Robot name (amigo, hero, sergio)") | ||
parser.add_argument("target_entity_id", type=str, help="Entity id of the target object") | ||
args = parser.parse_args() | ||
|
||
# Create node | ||
rospy.init_node("test_give_directions") | ||
robot = get_robot(args.robot) | ||
e_id = args.target_entity_id | ||
|
||
# Instantiate GuideToSymbolic machine | ||
state = give_directions.GiveDirections(r, ds.EntityByIdDesignator(r, id=e_id)) | ||
# Execute the state | ||
state.execute() |
21 changes: 21 additions & 0 deletions
21
robot_smach_states/examples/human_interaction/example_hear_options.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,21 @@ | ||
# ROS | ||
import rospy | ||
import argparse | ||
|
||
# TU/e Robotics | ||
from robot_skills.get_robot import get_robot | ||
|
||
# Robot Smach States | ||
from robot_smach_states.human_interaction import HearOptions | ||
|
||
if __name__ == "__main__": | ||
|
||
parser = argparse.ArgumentParser(description="Test if the robot hears the things from the options available") | ||
parser.add_argument("--robot", default="hero", help="Robot name (amigo, hero, sergio)") | ||
args = parser.parse_args() | ||
|
||
rospy.init_node('test_hear_options') | ||
robot = get_robot(args.robot) | ||
|
||
hear_option_state = HearOptions(robot, ['no', 'yes']) | ||
hear_option_state.execute() |
22 changes: 22 additions & 0 deletions
22
robot_smach_states/examples/human_interaction/example_say.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,22 @@ | ||
#ROS | ||
import rospy | ||
import argparse | ||
|
||
# TU/e Robotics | ||
from robot_skills.get_robot import get_robot | ||
|
||
# Robot Smach States | ||
from robot_smach_states.human_interaction import Say | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Test the say state with a sentence") | ||
parser.add_argument("--robot", default="hero", help="Robot name (amigo, hero, sergio)") | ||
args = parser.parse_args() | ||
|
||
rospy.init_node('test_say') | ||
robot = get_robot(args.robot) | ||
sentence = 'I have said something useful' | ||
|
||
say_state = Say(robot, sentence) | ||
say_state.execute() |
30 changes: 30 additions & 0 deletions
30
robot_smach_states/examples/human_interaction/example_show_image.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,30 @@ | ||
import argparse | ||
|
||
#ROS | ||
import rospy | ||
|
||
# TU/e Robotics | ||
from robot_skills.get_robot import get_robot | ||
|
||
# Robot Smach States | ||
from robot_smach_states.human_interaction import ShowImageState | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
parser = argparse.ArgumentParser(description="Show an image on the robot display.") | ||
parser.add_argument( | ||
"file_path", | ||
type=str, | ||
help="String describing the path to the image (absolute path incl. file extension)" | ||
) | ||
parser.add_argument("--robot", default="hero", help="Robot name (amigo, hero, sergio)") | ||
args = parser.parse_args() | ||
|
||
rospy.init_node('example_show_image') | ||
|
||
robot = get_robot(args.robot) | ||
file_path = args.file_path | ||
|
||
show_image_state = ShowImageState(robot, file_path) | ||
show_image_state.execute() |
31 changes: 31 additions & 0 deletions
31
robot_smach_states/examples/human_interaction/example_wait_for_person_in_front.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,31 @@ | ||
# ROS | ||
import rospy | ||
import argparse | ||
|
||
# TU/e Robotics | ||
from robot_skills.get_robot import get_robot | ||
|
||
# Robot Smach States | ||
from robot_smach_states.human_interaction import WaitForPersonInFront | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Test to see if the robot detects a person in front of him") | ||
parser.add_argument("--robot", default="hero", help="Robot name (amigo, hero, sergio)") | ||
args = parser.parse_args() | ||
|
||
rospy.init_node("example_wait_for_person_in_front") | ||
|
||
robot = get_robot(args.robot) | ||
|
||
rospy.loginfo("Creating wait for person in front state") | ||
attempts = 10 | ||
sleep_interval = 0.2 | ||
sm = WaitForPersonInFront(robot, attempts, sleep_interval) | ||
outcome = sm.execute() | ||
|
||
rospy.loginfo("Executing wait for person in front state") | ||
if outcome == "success": | ||
rospy.loginfo("Detected person") | ||
else: | ||
rospy.loginfo("No person detected") |
File renamed without changes.
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
28 changes: 28 additions & 0 deletions
28
robot_smach_states/examples/manipulation/example_set_gripper.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,28 @@ | ||
#ROS | ||
import rospy | ||
import argparse | ||
|
||
# TU/e Robotics | ||
from robot_skills.get_robot import get_robot | ||
from robot_skills.arms import GripperState | ||
|
||
# Robot Smach States | ||
from robot_smach_states.manipulation import SetGripper | ||
import robot_smach_states.util.designators as ds | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
parser = argparse.ArgumentParser(description="Test the gripper state whether it can open and close") | ||
parser.add_argument("--robot", default="hero", help="Robot name (amigo, hero, sergio)") | ||
args = parser.parse_args() | ||
|
||
rospy.init_node("Set_gripper_state") | ||
robot = get_robot(args.robot) | ||
arm = ds.UnoccupiedArmDesignator(robot, {}) | ||
|
||
for gripper_state in [GripperState.CLOSE, GripperState.OPEN]: | ||
set_gripper_state = SetGripper(robot, arm, gripperstate=gripper_state) | ||
outcome = set_gripper_state.execute() | ||
rospy.loginfo("Set gripper state to {}, outcome: {}".format(gripper_state, outcome)) | ||
rospy.sleep(2.5) |
40 changes: 40 additions & 0 deletions
40
robot_smach_states/examples/navigation/example_force_drive.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,40 @@ | ||
# ROS | ||
import rospy | ||
import argparse | ||
|
||
# TU/e Robotics | ||
from robot_skills.get_robot import get_robot | ||
|
||
# Robot Smach States | ||
from robot_smach_states import ForceDrive | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Test the force drive of the robot") | ||
parser.add_argument("--robot", default="hero", help="Robot name (amigo, hero, sergio)") | ||
args = parser.parse_args() | ||
|
||
rospy.init_node("example_force_drive") | ||
robot = get_robot(args.robot) | ||
|
||
sentence = "I am going to execute a force drive, press enter if the area around me is clear" | ||
robot.speech.speak(sentence) | ||
confirm = raw_input(sentence) | ||
|
||
rospy.loginfo("Creating forward force drive state") | ||
vx = 0.3 | ||
t = 1.0 | ||
sm = ForceDrive(robot, vx, 0, 0, t) | ||
|
||
rospy.loginfo("Executing forward force drive state") | ||
sm.execute() | ||
|
||
rospy.loginfo("Creating rotating force drive state") | ||
vtheta = 1.57 | ||
t = 2.0 | ||
sm = ForceDrive(robot, 0, 0, vtheta, t) | ||
|
||
rospy.loginfo("Executing forward force drive state") | ||
sm.execute() | ||
|
||
rospy.loginfo("Done") |
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
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
robot_smach_states/examples/navigation/example_tour_guide.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,33 @@ | ||
import rospy | ||
import argparse | ||
|
||
# TU/e Robotics | ||
from robot_smach_states.navigation import guidance | ||
from robot_skills.get_robot import get_robot | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
parser = argparse.ArgumentParser(description="While the robot is driving to a nav goal, this state tells the rooms" | ||
"and furniture objects the robot encounters") | ||
parser.add_argument("--robot", default="hero", help="Robot name (amigo, hero, sergio)") | ||
parser.add_argument("--x_threshold", type=float, default=0.75, help="threshold determining when a piece of " | ||
"furniture is close enough to be described [m]") | ||
parser.add_argument("--y_threshold", type=float, default=1.5, help="threshold determining when a piece of furniture" | ||
" is close enough to be described [m]") | ||
args = parser.parse_args() | ||
|
||
# Create node, robot and tour_guide instance | ||
rospy.init_node("example_tour_guide") | ||
robot = get_robot(args.robot) | ||
state = guidance.TourGuide(robot, args.x_threshold, args.y_threshold) | ||
|
||
# Initialize | ||
state.initialize() | ||
|
||
rate = rospy.Rate(1) | ||
# Keep explaining the robot movement | ||
while not rospy.is_shutdown(): | ||
rospy.loginfo(state.describe_near_objects()) | ||
rate.sleep() | ||
|
Oops, something went wrong.