Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receptionist update with deepface #212

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/speech/lasr_rasa/assistants/receptionist/data/nlu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ nlu:
- [Axel](name)
- [Charlie](name)
- [Jane](name)
- [Jayne](name)
- [Jay](name)
haiwei-luo marked this conversation as resolved.
Show resolved Hide resolved
- [Jules](name)
- [Morgan](name)
- [Paris](name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _extract_face(cv_im: Mat) -> Union[Mat, None]:
try:
faces = DeepFace.extract_faces(
cv_im,
target_size=(224, 244),
# target_size=(224, 244),
haiwei-luo marked this conversation as resolved.
Show resolved Hide resolved
detector_backend="mtcnn",
enforce_detection=True,
)
Expand Down
3 changes: 2 additions & 1 deletion skills/src/lasr_skills/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .clip_vqa import QueryImage
from .detect_faces import DetectFaces
from .recognise import Recognise
from .detect_pointing import DetectPointingDirection

# from .detect_pointing import DetectPointingDirection
haiwei-luo marked this conversation as resolved.
Show resolved Hide resolved
from .detect_gesture import DetectGesture
from .find_gesture_person import FindGesturePerson
67 changes: 57 additions & 10 deletions skills/src/lasr_skills/look_to_point.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,66 @@
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


class LookToPoint(smach_ros.SimpleActionState):
# class LookToPoint(smach_ros.SimpleActionState):
# def __init__(self):
# super(LookToPoint, self).__init__(
# "/head_controller/point_head_action",
# PointHeadAction,
# goal_cb=lambda ud, _: 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=ud.point,
# ),
# ),
# input_keys=["point"],
# )


haiwei-luo marked this conversation as resolved.
Show resolved Hide resolved
class LookToPoint(smach.State):
def __init__(self):
super(LookToPoint, self).__init__(
"/head_controller/point_head_action",
PointHeadAction,
goal_cb=lambda ud, _: PointHeadGoal(
pointing_frame="head_2_link",
pointing_axis=Point(1.0, 0.0, 0.0),
max_velocity=1.0,
target=ud.pointstamped,
smach.State.__init__(
self,
outcomes=["succeeded", "aborted", "preempted", "timed_out"],
haiwei-luo marked this conversation as resolved.
Show resolved Hide resolved
input_keys=["point"],
)
self.client = actionlib.SimpleActionClient(
"/head_controller/point_head_action", PointHeadAction
)
self.client.wait_for_server()

def execute(self, userdata):
# 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.point,
),
input_keys=["pointstamped"],
)

# 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:
result = self.client.get_result()
if result:
return "succeeded"
else:
return "aborted"
haiwei-luo marked this conversation as resolved.
Show resolved Hide resolved
else:
self.client.cancel_goal()
return "timed_out"
25 changes: 20 additions & 5 deletions tasks/receptionist/config/lab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,32 @@ priors:
- orange juice
- red wine
- tropical juice
# wait_pose:
# position:
# x: 2.4307581363168773
# y: -1.661594410669659
# z: 0.0
# orientation:
# x: 0.0
# y: 0.0
# z: 0.012769969339563213
# w: 0.9999184606171978

wait_pose:
position:
x: 2.4307581363168773
y: -1.661594410669659
x: 4.637585370589175
y: 6.715591164127531
z: 0.0
orientation:
x: 0.0
y: 0.0
z: 0.012769969339563213
w: 0.9999184606171978
wait_area: [[2.65, -0.61], [4.21, -0.33], [4.58, -2.27], [2.67, -2.66]]
z: 0.478893309417269
w: 0.4
#0.478893309417269
#0.8778731105321406

# wait_area: [[2.65, -0.61], [4.21, -0.33], [4.58, -2.27], [2.67, -2.66]]
wait_area: [[3.60, 8.56], [4.69, 8.90], [4.98, 7.59], [3.95, 7.34]]
seat_pose:
position:
x: 1.1034954065916212
Expand Down
7 changes: 7 additions & 0 deletions tasks/receptionist/doc/PREREQUISITES.md
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'
10 changes: 8 additions & 2 deletions tasks/receptionist/launch/setup.launch
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
<node pkg="lasr_speech_recognition_whisper" type="transcribe_microphone_server" name="transcribe_speech" output="screen" args="--mic_device $(arg whisper_device_param)"/>

<!-- STATIC POINTS -->
<rosparam command="load" file="$(find receptionist)/config/$(arg config).yaml" />
<!--<rosparam command="load" file="$(find receptionist)/config/$(arg config).yaml" />-->
<rosparam command="load" file="$(find receptionist)/config/lab.yaml"/>
haiwei-luo marked this conversation as resolved.
Show resolved Hide resolved

<!-- MOTIONS -->
<rosparam command="load" file="$(find lasr_skills)/config/motions.yaml"/>
<rosparam command="load" file="$(find receptionist)/config/motions.yaml"/>

<!-- PERCEPTION -->
<include file="$(find lasr_vision_yolov8)/launch/service.launch" />
<include file="$(find lasr_vision_yolov8)/launch/service.launch">
<param name="debug" value="true" />
</include>

<node pkg="lasr_vision_feature_extraction" type="service" name="torch_service" output="screen"/>
<node pkg="lasr_vision_bodypix" type="service" name="bodypix_service" output="screen"/>

<node pkg="lasr_vision_deepface" type="service" name="deepface_service" output="screen"/>

</launch>
17 changes: 13 additions & 4 deletions tasks/receptionist/scripts/main.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
#!/usr/bin/env python3
import rospy
from receptionist.state_machine import Receptionist
import smach
import smach_ros

from geometry_msgs.msg import Pose, Point, Quaternion
from shapely.geometry import Polygon

if __name__ == "__main__":
rospy.init_node("receptionist_robocup")
wait_pose_param = rospy.get_param("/receptionist/wait_pose")
# wait_pose_param = rospy.get_param("/receptionist/wait_pose")
wait_pose_param = rospy.get_param("/wait_pose/")
Comment on lines +12 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# wait_pose_param = rospy.get_param("/receptionist/wait_pose")
wait_pose_param = rospy.get_param("/wait_pose/")
wait_pose_param = rospy.get_param("/receptionist/wait_pose")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/receptionist/... breaks the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you apply the update to the launch file, that sets "ns" to "receptionist", I think this should work

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


wait_pose = Pose(
position=Point(**wait_pose_param["position"]),
orientation=Quaternion(**wait_pose_param["orientation"]),
)

wait_area_param = rospy.get_param("/receptionist/wait_area")
wait_area_param = rospy.get_param("/wait_area")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wait_area_param = rospy.get_param("/wait_area")
wait_area_param = rospy.get_param("/receptionist/wait_area")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/receptionist/... breaks the code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

wait_area = Polygon(wait_area_param)

seat_pose_param = rospy.get_param("/receptionist/seat_pose")
seat_pose_param = rospy.get_param("/seat_pose")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
seat_pose_param = rospy.get_param("/seat_pose")
seat_pose_param = rospy.get_param("/receptionist/seat_pose")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/receptionist/... breaks the code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

seat_pose = Pose(
position=Point(**seat_pose_param["position"]),
orientation=Quaternion(**seat_pose_param["orientation"]),
)

seat_area_param = rospy.get_param("/receptionist/seat_area")
seat_area_param = rospy.get_param("/seat_area")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
seat_area_param = rospy.get_param("/seat_area")
seat_area_param = rospy.get_param("/receptionist/seat_area")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/receptionist/... breaks the code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

seat_area = Polygon(seat_area_param)

receptionist = Receptionist(
Expand All @@ -35,6 +39,11 @@
"drink": "beer",
},
)

sis = smach_ros.IntrospectionServer("smach_server", receptionist, "/SM_ROOT")
sis.start()
outcome = receptionist.execute()

sis.stop()
rospy.loginfo(f"Receptionist finished with outcome: {outcome}")
rospy.spin()
Loading