Skip to content

Commit 3e3489a

Browse files
authored
Improve ball search (#582)
2 parents 12a0d5d + 261324c commit 3e3489a

File tree

2 files changed

+31
-5
lines changed
  • bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd

2 files changed

+31
-5
lines changed

bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/actions/go_to.py

+20-4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def __init__(self, blackboard, dsd, parameters):
5656
"""Go to an absolute position on the field"""
5757
super().__init__(blackboard, dsd, parameters)
5858
self.point = float(parameters.get("x", 0)), float(parameters.get("y", 0)), float(parameters.get("t", 0))
59+
self.blocking = parameters.get("blocking", True)
5960

6061
def perform(self, reevaluate=False):
6162
pose_msg = PoseStamped()
@@ -64,11 +65,26 @@ def perform(self, reevaluate=False):
6465

6566
pose_msg.pose.position.x = self.point[0]
6667
pose_msg.pose.position.y = self.point[1]
67-
pose_msg.pose.position.z = 0
68+
pose_msg.pose.position.z = 0.0
6869
pose_msg.pose.orientation = quat_from_yaw(math.radians(self.point[2]))
6970

7071
self.blackboard.pathfinding.publish(pose_msg)
7172

73+
if not self.blocking:
74+
self.pop()
75+
76+
77+
class GoToAbsolutePositionFieldFraction(GoToAbsolutePosition):
78+
def __init__(self, blackboard, dsd, parameters):
79+
"""Go to an absolute position of the field, specified by the fraction of the field size"""
80+
super().__init__(blackboard, dsd, parameters)
81+
point = float(parameters.get("x", 0)), float(parameters.get("y", 0)), float(parameters.get("t", 0))
82+
self.point = (
83+
point[0] * self.blackboard.world_model.field_length / 2,
84+
point[1] * self.blackboard.world_model.field_width / 2,
85+
self.point[2],
86+
)
87+
7288

7389
class GoToOwnGoal(GoToAbsolutePosition):
7490
def __init__(self, blackboard, dsd, parameters):
@@ -77,7 +93,7 @@ def __init__(self, blackboard, dsd, parameters):
7793
self.point = (
7894
self.blackboard.world_model.get_map_based_own_goal_center_xy()[0],
7995
self.blackboard.world_model.get_map_based_own_goal_center_xy()[1],
80-
parameters,
96+
self.point[2],
8197
)
8298

8399

@@ -88,12 +104,12 @@ def __init__(self, blackboard, dsd, parameters):
88104
self.point = (
89105
self.blackboard.world_model.get_map_based_opp_goal_center_xy()[0],
90106
self.blackboard.world_model.get_map_based_opp_goal_center_xy()[1],
91-
parameters,
107+
self.point[2],
92108
)
93109

94110

95111
class GoToCenterpoint(GoToAbsolutePosition):
96112
def __init__(self, blackboard, dsd, parameters):
97113
"""Go to the center of the field and look towards the enemy goal"""
98114
super().__init__(blackboard, dsd, parameters)
99-
self.point = 0, 0, 0
115+
self.point = 0.0, 0.0, 0.0

bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/main.dsd

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#SearchBall
2-
@ChangeAction + action:searching, @LookAtFieldFeatures, @WalkInPlace + duration:3, @Turn
2+
$DoOnce
3+
NOT_DONE --> @ChangeAction + action:searching, @LookAtFieldFeatures, @WalkInPlace + duration:3, @Turn + duration:15, @GoToAbsolutePositionFieldFraction + x:0.5 + blocking:false
4+
DONE --> $ReachedAndAlignedToPathPlanningGoalPosition + threshold:0.5 + latch:true
5+
NO --> @LookAtFieldFeatures, @GoToAbsolutePositionFieldFraction + x:0.5
6+
YES --> $DoOnce
7+
NOT_DONE --> @Turn + duration:15
8+
DONE --> $DoOnce
9+
NOT_DONE --> @GoToAbsolutePositionFieldFraction + y:1.0 + t:-90 + blocking:false
10+
DONE --> $ReachedAndAlignedToPathPlanningGoalPosition + threshold:0.2 + latch:true
11+
YES --> @Stand
12+
NO --> @GoToAbsolutePositionFieldFraction + y:1.0 + t:-90
313

414
#DoNothing
515
@ChangeAction + action:waiting, @LookForward, @Stand

0 commit comments

Comments
 (0)