Skip to content

Commit

Permalink
feat: go to person.
Browse files Browse the repository at this point in the history
  • Loading branch information
jws-1 committed Mar 8, 2024
1 parent 375b59c commit 0869713
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions skills/src/lasr_skills/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .describe_people import DescribePeople
from .look_to_point import LookToPoint
from .find_person import FindPerson
from .go_to_person import GoToPerson

# from .go_to_location import GoToLocation
# from .go_to_semantic_location import GoToSemanticLocation
7 changes: 6 additions & 1 deletion skills/src/lasr_skills/find_person.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from typing import List

from lasr_skills import Detect3D, LookToPoint
from lasr_skills import Detect3D, LookToPoint, GoToPerson

from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal

Expand Down Expand Up @@ -88,6 +88,11 @@ def __init__(self, waypoints: List[Pose]):
"failed": "continue",
},
)
smach.StateMachine.add(
"GO_TO_PERSON",
GoToPerson(),
transitions={"succeeded": "LOOK_AT_PERSON", "failed": "failed"},
)
smach.StateMachine.add(
"LOOK_AT_PERSON",
LookToPoint(),
Expand Down
60 changes: 60 additions & 0 deletions skills/src/lasr_skills/go_to_person.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import smach
from smach_ros import SimpleActionState

from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal


from navigation_helpers import plan_to_radius

from geometry_msgs.msg import PoseStamped, Header


class GoToPerson(smach.StateMachine):

class PlanToPerson(smach.State):
def __init__(self):
smach.State.__init__(
self,
outcomes=["succeeded", "failed"],
input_keys=["location"],
output_keys=["target_location"],
)

def execute(self, userdata):
points = plan_to_radius(userdata.location, 0.5)
if not points:
return "failed"
userdata.target_location = points[0]

def __init__(self):
smach.StateMachine.__init__(
self,
outcomes=["succeeded", "failed"],
input_keys=["location"],
)

with self:

smach.StateMachine.add(
"PLAN_TO_PERSON",
self.PlanToPerson(),
transitions={"succeeded": "succeeded", "failed": "failed"},
)

smach.StateMachine.add(
"GO_TO_LOCATION",
SimpleActionState(
"move_base",
MoveBaseAction,
goal_cb=lambda ud, _: MoveBaseGoal(
target_pose=PoseStamped(
pose=ud.target_location, header=Header(frame_id="map")
)
),
input_keys=["target_location"],
),
transitions={
"succeeded": "succeeded",
"aborted": "failed",
},
)

0 comments on commit 0869713

Please sign in to comment.