forked from LASR-at-Home/Base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jared Swift <j.w.swift@outlook.com> Co-authored-by: m-barker <mattbarker322@gmail.com> Co-authored-by: Zoe <ezoe013@gmail.com> Co-authored-by: fireblonde <nicollehchevska@gmail.com>
- Loading branch information
1 parent
5a0c0cc
commit 7ae9edb
Showing
25 changed files
with
1,091 additions
and
138 deletions.
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
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
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,35 @@ | ||
import smach | ||
import rospy | ||
import os | ||
import rospkg | ||
|
||
DATASET_ROOT = os.path.join( | ||
rospkg.RosPack().get_path("lasr_vision_deepface"), "datasets" | ||
) | ||
|
||
|
||
class CheckKnownPeople(smach.State): | ||
def __init__(self): | ||
smach.State.__init__( | ||
self, | ||
outcomes=["succeeded", "failed"], | ||
input_keys=["task_name"], | ||
output_keys=["known_people"], | ||
) | ||
|
||
def execute(self, userdata): | ||
try: | ||
dataset_path = os.path.join(DATASET_ROOT, userdata.task_name) | ||
print(dataset_path) | ||
known_people_names = [ | ||
f | ||
for f in os.listdir(dataset_path) | ||
if os.path.isdir(os.path.join(dataset_path, f)) | ||
] | ||
rospy.set_param("/known_people", known_people_names) | ||
userdata.known_people = known_people_names | ||
return "succeeded" | ||
except Exception as e: | ||
print(f"Face detection using dataset {dataset_path}") | ||
rospy.logerr(f"Failed to get known people: {str(e)}") | ||
return "failed" |
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Look to a specific point passed in as a parameter | ||
Similar to look_to_point but the input key is replaced with a passed argument for the point to look at | ||
""" | ||
|
||
import smach_ros | ||
import smach | ||
import actionlib | ||
import rospy | ||
from control_msgs.msg import PointHeadGoal, PointHeadAction | ||
from geometry_msgs.msg import Point, PointStamped | ||
from std_msgs.msg import Header | ||
from actionlib_msgs.msg import GoalStatus | ||
from typing import List | ||
|
||
|
||
class LookToGivenPoint(smach.State): | ||
def __init__(self, look_position: List[float]): | ||
""" | ||
Args: | ||
look_position (List[float]): Position to look to | ||
""" | ||
smach.State.__init__( | ||
self, | ||
outcomes=["succeeded", "aborted", "timed_out"], | ||
) | ||
self.goal_pointstamped = PointStamped( | ||
point=Point(x=look_position[0], y=look_position[1], z=1.0) | ||
) | ||
self.client = actionlib.SimpleActionClient( | ||
"/head_controller/point_head_action", PointHeadAction | ||
) | ||
self.client.wait_for_server() | ||
|
||
def execute(self, userdata): | ||
goal = PointHeadGoal( | ||
pointing_frame="head_2_link", | ||
pointing_axis=Point(1.0, 0.0, 0.0), | ||
max_velocity=1.0, | ||
target=PointStamped( | ||
header=Header(frame_id="map"), | ||
point=self.goal_pointstamped.point, | ||
), | ||
) | ||
self.client.send_goal(goal) | ||
|
||
# Wait for the result with a timeout of 7 seconds | ||
finished_within_time = self.client.wait_for_result(rospy.Duration(7.0)) | ||
|
||
if finished_within_time: | ||
state = self.client.get_state() | ||
if state == GoalStatus.SUCCEEDED: | ||
rospy.sleep(1) | ||
return "succeeded" | ||
else: | ||
return "aborted" | ||
else: | ||
self.client.cancel_goal() | ||
return "timed_out" |
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 |
---|---|---|
@@ -1,28 +1,49 @@ | ||
import smach_ros | ||
import smach | ||
import rospy | ||
import actionlib | ||
from control_msgs.msg import PointHeadAction, PointHeadGoal | ||
from geometry_msgs.msg import Point | ||
import rospy | ||
from control_msgs.msg import PointHeadGoal, PointHeadAction | ||
from geometry_msgs.msg import Point, PointStamped | ||
from std_msgs.msg import Header | ||
from actionlib_msgs.msg import GoalStatus | ||
|
||
|
||
class LookToPoint(smach.State): | ||
def __init__(self): | ||
smach.State.__init__( | ||
self, | ||
outcomes=["succeeded", "preempted", "aborted"], | ||
outcomes=["succeeded", "aborted", "timed_out"], | ||
input_keys=["pointstamped"], | ||
) | ||
self.look_at_pub = actionlib.SimpleActionClient( | ||
self.client = actionlib.SimpleActionClient( | ||
"/head_controller/point_head_action", PointHeadAction | ||
) | ||
self.client.wait_for_server() | ||
|
||
def execute(self, userdata): | ||
goal = PointHeadGoal() | ||
goal.pointing_frame = "head_2_link" | ||
goal.pointing_axis = Point(1.0, 0.0, 0.0) | ||
goal.max_velocity = 1.0 | ||
goal.target = userdata.pointstamped | ||
self.look_at_pub.send_goal(goal) | ||
self.look_at_pub.wait_for_result() | ||
rospy.sleep(3.0) | ||
return "succeeded" | ||
# Define the goal | ||
goal = PointHeadGoal( | ||
pointing_frame="head_2_link", | ||
pointing_axis=Point(1.0, 0.0, 0.0), | ||
max_velocity=1.0, | ||
target=PointStamped( | ||
header=Header(frame_id="map"), | ||
point=userdata.pointstamped.point, | ||
), | ||
) | ||
|
||
# Send the goal | ||
self.client.send_goal(goal) | ||
|
||
# Wait for the result with a timeout of 7 seconds | ||
finished_within_time = self.client.wait_for_result(rospy.Duration(7.0)) | ||
|
||
if finished_within_time: | ||
state = self.client.get_state() | ||
if state == GoalStatus.SUCCEEDED: | ||
return "succeeded" | ||
else: | ||
return "aborted" | ||
else: | ||
self.client.cancel_goal() | ||
return "timed_out" |
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,23 @@ | ||
"""Generic wait state for waiting a desired number of seconds""" | ||
|
||
import smach | ||
import rospy | ||
|
||
|
||
class Wait(smach.State): | ||
def __init__(self, wait_time: int): | ||
""" | ||
Args: | ||
wait_time (int): Number of seconds to wait for and remain idle | ||
""" | ||
smach.State.__init__(self, outcomes=["succeeded", "failed"]) | ||
self._wait_time = wait_time | ||
|
||
def execute(self, userdata) -> str: | ||
try: | ||
print(f"Waiting for {self._wait_time} seconds.") | ||
rospy.sleep(self._wait_time) | ||
return "succeeded" | ||
except: | ||
print("Waiting failed") | ||
return "failed" |
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 |
---|---|---|
@@ -1 +1,8 @@ | ||
If you would like to view the documentation in the browser, ensure you have at [Node.js v16.x](https://nodejs.org/en) installed. | ||
|
||
|
||
Please make sure the following models are installed in order to run this code: | ||
|
||
- lasr_vision_yolov8 requires yolov8n-seg.pt in lasr_vision_yolov8/models/ | ||
- lasr_vision_feature_extraction requires model.pth in lasr_vision_feature_extraction/models/ | ||
- lasr_vision_clip requires a model from hugging face, this can be downloaded by running 'rosrun lasr_vision_clip vqa' |
Oops, something went wrong.