Skip to content

Commit f0907a2

Browse files
committed
Merge remote-tracking branch 'base/gpsr-state-machine-factory' into HEAD
2 parents 471ee60 + 10cd6bd commit f0907a2

File tree

14 files changed

+421
-106
lines changed

14 files changed

+421
-106
lines changed

common/navigation/lasr_person_following/nodes/person_following.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self) -> None:
4747

4848
def _execute_cb(self, _: FollowGoal) -> None:
4949
print("Executing follow_person action")
50-
while not self._follower.begin_tracking(ask=False):
50+
while not self._follower.begin_tracking():
5151
rospy.logwarn("No people found, retrying...")
5252
rospy.sleep(rospy.Duration(1.0))
5353
warnings.warn(

common/navigation/lasr_person_following/src/lasr_person_following/person_following.py

Lines changed: 124 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from play_motion_msgs.msg import PlayMotionAction
2727
from play_motion_msgs.msg import PlayMotionGoal
2828

29-
from lasr_vision_msgs.srv import DetectWaveRequest
29+
from lasr_vision_msgs.srv import DetectWaveRequest, DetectWaveResponse
3030

3131
from math import atan2
3232
import numpy as np
@@ -79,17 +79,17 @@ def __init__(
7979
self,
8080
start_following_radius: float = 2.0,
8181
start_following_angle: float = 45.0,
82-
n_secs_static_finished: float = 8.0,
83-
n_secs_static_plan_close: float = 10.0,
8482
new_goal_threshold: float = 2.0,
8583
stopping_distance: float = 1.0,
8684
static_speed: float = 0.0015,
85+
max_speed: float = 0.5,
8786
):
8887
self._start_following_radius = start_following_radius
8988
self._start_following_angle = start_following_angle
9089
self._new_goal_threshold = new_goal_threshold
9190
self._stopping_distance = stopping_distance
9291
self._static_speed = static_speed
92+
self._max_speed = max_speed
9393

9494
self._track_id = None
9595

@@ -147,7 +147,9 @@ def _tf_pose(self, pose: PoseStamped, target_frame: str):
147147
def _robot_pose_in_odom(self) -> Union[PoseStamped, None]:
148148
try:
149149
current_pose: PoseWithCovarianceStamped = rospy.wait_for_message(
150-
"/robot_pose", PoseWithCovarianceStamped
150+
"/robot_pose",
151+
PoseWithCovarianceStamped,
152+
timeout=rospy.Duration.from_sec(2.0),
151153
)
152154
except rospy.ROSException:
153155
return None
@@ -208,10 +210,10 @@ def begin_tracking(self) -> bool:
208210

209211
def _recover_track(self, say) -> bool:
210212
if not say:
211-
self._tts("I SAW A person waving", wait=True)
213+
self._tts("I see you are waving", wait=True)
212214

213215
if self._tts_client_available and say:
214-
self._tts("I lost track of you, please come back", wait=True)
216+
self._tts("Please could you come back...", wait=True)
215217

216218
while not self.begin_tracking() and not rospy.is_shutdown():
217219
rospy.loginfo("Recovering track...")
@@ -221,57 +223,62 @@ def _recover_track(self, say) -> bool:
221223

222224
return True
223225

224-
# recover with vision, look up and check if person is waving
225-
def _recover_vision(self, prev_pose: PoseStamped) -> bool:
226-
# look up with playmotion and detect wave service
227-
# if detected, begin tracking
228-
229-
# use play motion to look up
230-
self._cancel_goal()
231-
232-
goal = PlayMotionGoal()
233-
goal.motion_name = "look_centre"
234-
self._play_motion.send_goal_and_wait(goal)
235-
236-
self._tts("Can you wave at me so that i can try to find you easily", wait=True)
237-
238-
# detect wave
226+
def _detect_waving_person(self) -> DetectWaveResponse:
239227
try:
240228
pcl = rospy.wait_for_message("/xtion/depth_registered/points", PointCloud2)
241229
req = DetectWaveRequest()
242230
req.pcl_msg = pcl
243231
req.dataset = "resnet50"
244232
req.confidence = 0.1
245233
response = self._detect_wave(req)
246-
if response.wave_detected:
247-
rospy.loginfo("Wave detected, beginning tracking")
248-
if np.isnan(response.wave_position.point.x) or np.isnan(
249-
response.wave_position.point.y
250-
):
251-
return False
252-
goal_pose = self._tf_pose(
253-
PoseStamped(
254-
pose=Pose(
255-
position=Point(
256-
x=response.wave_position.point.x,
257-
y=response.wave_position.point.y,
258-
z=response.wave_position.point.z,
259-
),
260-
orientation=Quaternion(0, 0, 0, 1),
261-
),
262-
header=pcl.header,
263-
),
264-
"map",
265-
)
266-
rospy.loginfo(goal_pose.pose.position)
267-
goal_pose.pose.orientation = self._compute_face_quat(
268-
prev_pose.pose, goal_pose.pose
269-
)
270-
self._move_base(goal_pose)
271-
return True
234+
return response
272235
except rospy.ServiceException as e:
273236
rospy.loginfo(f"Error detecting wave: {e}")
274-
return False
237+
return DetectWaveResponse()
238+
239+
# recover with vision, look around and check if person is waving
240+
def _recover_vision(self, prev_pose: PoseStamped) -> bool:
241+
242+
# cancel current goal
243+
self._cancel_goal()
244+
245+
self._tts("Can you wave at me so that i can try to find you easily", wait=True)
246+
247+
for motion in self._vision_recovery_motions:
248+
rospy.loginfo(f"Performing motion: {motion}")
249+
goal = PlayMotionGoal()
250+
goal.motion_name = motion
251+
self._play_motion.send_goal_and_wait(goal)
252+
for _ in range(self._vision_recovery_attempts):
253+
response = self._detect_waving_person()
254+
if response.wave_detected:
255+
if np.isnan(response.wave_position.point.x) or np.isnan(
256+
response.wave_position.point.y
257+
):
258+
continue
259+
else:
260+
goal_pose = self._tf_pose(
261+
PoseStamped(
262+
pose=Pose(
263+
position=Point(
264+
x=response.wave_position.point.x,
265+
y=response.wave_position.point.y,
266+
z=response.wave_position.point.z,
267+
),
268+
orientation=Quaternion(0, 0, 0, 1),
269+
),
270+
header=prev_pose.header,
271+
),
272+
"map",
273+
)
274+
goal_pose.pose.orientation = self._compute_face_quat(
275+
prev_pose.pose, goal_pose.pose
276+
)
277+
rospy.loginfo(goal_pose.pose.position)
278+
self._move_base(goal_pose)
279+
return True
280+
281+
return False
275282

276283
def _euclidian_distance(self, p1: Pose, p2: Pose) -> float:
277284
return np.linalg.norm(
@@ -375,7 +382,7 @@ def follow(self) -> None:
375382
prev_goal: Union[None, PoseStamped] = None
376383
last_goal_time: Union[None, rospy.Time] = None
377384
going_to_person: bool = False
378-
track_vels: [float] = []
385+
track_vels: List[float] = []
379386

380387
while not rospy.is_shutdown():
381388

@@ -395,8 +402,27 @@ def follow(self) -> None:
395402
if track is None:
396403
rospy.loginfo("Lost track of person, recovering...")
397404
person_trajectory = PoseArray()
398-
recovery = self._recover_vision(prev_goal)
399-
self._recover_track(say=not recovery)
405+
ask_back: bool = False
406+
407+
if prev_track is not None:
408+
robot_pose: PoseStamped = self._robot_pose_in_odom()
409+
if robot_pose:
410+
dist: float = self._euclidian_distance(
411+
robot_pose.pose, prev_track.pose
412+
)
413+
rospy.loginfo(f"Distance to last known position: {dist}")
414+
if dist >= MAX_VISION_DIST:
415+
ask_back = True
416+
else:
417+
ask_back = True
418+
else:
419+
ask_back = True
420+
421+
if not ask_back:
422+
self._recover_track(say=not self._recover_vision(prev_goal))
423+
else:
424+
self._recover_track(say=True)
425+
400426
prev_track = None
401427
continue
402428

@@ -418,6 +444,9 @@ def follow(self) -> None:
418444
last_goal_time = rospy.Time.now()
419445
prev_track = track
420446

447+
if np.mean([np.linalg.norm(vel) for vel in track_vels]) > self._max_speed:
448+
self._tts("Please walk slower, I am struggling to keep up", wait=False)
449+
421450
# Distance to the previous pose
422451
dist_to_prev = (
423452
self._euclidian_distance(track.pose, prev_track.pose)
@@ -448,10 +477,51 @@ def follow(self) -> None:
448477
elif (
449478
np.mean([np.linalg.norm(vel) for vel in track_vels])
450479
< self._static_speed
451-
):
452-
453-
rospy.logwarn("Person has been static for too long, stopping")
480+
) and len(track_vels) == 10:
481+
rospy.logwarn(
482+
"Person has been static for too long, going to them and stopping"
483+
)
484+
# cancel current goal
454485
self._cancel_goal()
486+
487+
# clear velocity buffer
488+
track_vels = []
489+
490+
robot_pose: PoseStamped = self._robot_pose_in_odom()
491+
dist: float = self._euclidian_distance(track.pose, robot_pose.pose)
492+
rospy.loginfo(f"Distance to person: {dist}")
493+
494+
# If the person is too far away, go to them
495+
if dist > self._stopping_distance:
496+
goal_pose = self._get_pose_on_path(
497+
self._tf_pose(robot_pose, "map"),
498+
self._tf_pose(
499+
PoseStamped(
500+
pose=track.pose,
501+
header=tracks.header,
502+
),
503+
"map",
504+
),
505+
self._stopping_distance,
506+
)
507+
# If we can't find a path, face them
508+
if goal_pose is None:
509+
rospy.logwarn("Could not find a path to the person")
510+
goal_pose = robot_pose
511+
goal_pose.pose.orientation = self._compute_face_quat(
512+
robot_pose.pose, track.pose
513+
)
514+
goal_pose = self._tf_pose(goal_pose, "map")
515+
# Otherwise, face them
516+
else:
517+
goal_pose = robot_pose
518+
goal_pose.pose.orientation = self._compute_face_quat(
519+
robot_pose.pose, track.pose
520+
)
521+
goal_pose = self._tf_pose(goal_pose, "map")
522+
523+
self._move_base(goal_pose)
524+
455525
if self._check_finished():
456526
rospy.loginfo("Finished following person")
457527
break

common/speech/lasr_speech_recognition_whisper/nodes/transcribe_microphone_server

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ def parse_args() -> dict:
290290
help="Disable warming up the model by running inference on a test file.",
291291
)
292292

293-
# parser.add_argument(
294-
# "--energy_threshold",
295-
# type=int,
296-
# default=600,
297-
# help="Energy threshold for silence detection. Using this disables automatic adjustment",
298-
# )
293+
parser.add_argument(
294+
"--energy_threshold",
295+
type=Optional[int],
296+
default=None,
297+
help="Energy threshold for silence detection. Using this disables automatic adjustment",
298+
)
299299

300300
parser.add_argument(
301301
"--pause_threshold",

common/vision/lasr_vision_yolov8/src/lasr_vision_yolov8/yolo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ def detect_3d(
152152
f"Detected point: {detection.point} of object {detection.name}"
153153
)
154154

155-
markers.create_and_publish_marker(
156-
debug_point_publisher,
157-
PointStamped(point=detection.point, header=pcl_map.header),
158-
)
155+
# markers.create_and_publish_marker(
156+
# debug_point_publisher,
157+
# PointStamped(point=detection.point, header=pcl_map.header),
158+
# )
159159

160160
detected_objects.append(detection)
161161

tasks/gpsr/launch/setup.launch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<include
3232
file="$(find lasr_vision_cropped_detection)/launch/cropped_detection.launch"
3333
/>
34-
<include file="$(find lasr_vision_bodypix)/launch/bodypix.launch">
34+
<include file="$(find lasr_vision_bodypix)/launch/bodypix.launch"/>
3535

3636
<!-- To find the most similar commands -->
3737
<node

tasks/receptionist/config/arcade.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
priors:
2+
names:
3+
- Adel
4+
- Angel
5+
- Axel
6+
- Charlie
7+
- Jane
8+
- Jules
9+
- Morgan
10+
- Paris
11+
- Robin
12+
- Simone
13+
drinks:
14+
- cola
15+
- iced tea
16+
- juice pack
17+
- milk
18+
- orange juice
19+
- red wine
20+
- tropical juice
21+
22+
23+
#WAIT POSE LAB:
24+
wait_pose:
25+
position:
26+
x: -15.027493553116143
27+
y: 8.731164058220495
28+
z: 0.0
29+
orientation:
30+
x: 0.0
31+
y: 0.0
32+
z: -0.7865759968179794
33+
w: 0.6174934827427752
34+
35+
36+
37+
#556918144226074
38+
39+
40+
#0.478893309417269
41+
#0.8778731105321406
42+
43+
44+
#WAIT AREA LAB:
45+
# From robot POV: [top left, top right,bottom right, bottom left ]
46+
wait_area: [[-15.9, 8.19], [-17.2, 8.11], [-16.2, 11.2], [-14.9, 10.0]]
47+
48+
#Where to position self for seating guests
49+
seat_pose:
50+
position:
51+
x: -13.659998294234812
52+
y: 6.421172168922483
53+
z: 0.0
54+
orientation:
55+
x: 0.0
56+
y: 0.0
57+
z: -0.6021594916272762
58+
w: 0.7983758179223494
59+
60+
61+
62+
search_motions: ["look_left", "look_right"]
63+
sofa_point:
64+
x: -15.0
65+
y: 4.21
66+
z: 0.5
67+
68+
seat_area: [[-12.2, 2.63], [-18.2, 4.61], [-17.4, 7.31], [-11.7, 5.06]]
69+
max_people_on_sofa: 2
70+
71+
sofa_area: [[-13.8, 4.61], [-14.4, 3.54], [-15.85, 4.16], [-15.4, 5.33]]
72+
73+
sweep: true

0 commit comments

Comments
 (0)