-
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.
- Loading branch information
N-Shimoda
committed
Nov 18, 2022
1 parent
1bd250d
commit 78e5b3f
Showing
3 changed files
with
102 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python | ||
|
||
import numpy as np | ||
from geometry_msgs.msg import PoseStamped, Quaternion | ||
|
||
""" | ||
Function to calculate next goal. | ||
If there is no ghost, return is None. | ||
param : ghost_locations (Point32[]) | ||
return : goal_pos (PoseStamped) | ||
""" | ||
def chooseTarget(ghost_locations): | ||
|
||
# if ghost exists | ||
if (ghost_locations is not None) and len(ghost_locations) > 0: | ||
|
||
goal_pos = PoseStamped() | ||
|
||
goal_pos.header.frame_id = "map" | ||
goal_pos.pose.position = ghost_locations[0] | ||
goal_pos.pose.orientation = Quaternion(0,0,0,1) | ||
|
||
else: | ||
|
||
goal_pos = None | ||
|
||
return goal_pos | ||
|
||
|
||
def eucliDist(x1,y1,x2,y2): | ||
# np.abs(pose.position.x - ball["x"]) + np.abs(pose.position.y - ball["y"]) | ||
return np.sqrt((x2-x1)**2+(y2-y1)**2) |