Skip to content

Commit bbc87f5

Browse files
authored
Tune ball approach (#590)
2 parents fe2c554 + 2c52e41 commit bbc87f5

File tree

6 files changed

+40
-14
lines changed

6 files changed

+40
-14
lines changed

bitbots_behavior/bitbots_body_behavior/config/body_behavior.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ body_behavior:
104104
goalpost_safety_distance: 0.05
105105

106106
# Distance at which the ball is first approached before the ball obstacle is deactivated and we approach closer for the kick
107-
ball_far_approach_dist: 0.5
107+
ball_far_approach_dist: 0.3
108108

109109
# Range in which the ball far approach point is counted as reached
110110
ball_far_approach_position_thresh: 0.2
@@ -113,14 +113,14 @@ body_behavior:
113113
ball_reapproach_dist: 1.0
114114

115115
# Distance at which the ball is normally approached
116-
ball_approach_dist: 0.20
116+
ball_approach_dist: 0.2
117117

118118
# Angle at which the ball is normally approached again
119119
ball_reapproach_angle: 1.2
120120

121121
# The position where the supporter robot should place itself in order to accept a pass
122122
pass_position_x: 0.1
123-
pass_position_y: 1.0
123+
pass_position_y: 1.0
124124
supporter_max_x: 4.0
125125

126126
# maximal angle of a ball kick

bitbots_navigation/bitbots_path_planning/bitbots_path_planning/controller.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,21 @@ def step(self, path: Path) -> tuple[Twist, PointStamped]:
6969
end_pose.position.y - current_pose.position.y, end_pose.position.x - current_pose.position.x
7070
)
7171

72-
# Calculate the distance from our current position to the final position of the global plan
73-
distance = math.hypot(
74-
end_pose.position.x - current_pose.position.x, end_pose.position.y - current_pose.position.y
75-
)
72+
if len(path.poses) < 3:
73+
# Calculate the distance from our current position to the final position of the global plan
74+
distance = math.hypot(
75+
end_pose.position.x - current_pose.position.x, end_pose.position.y - current_pose.position.y
76+
)
77+
else:
78+
# Calculate path length
79+
distance = 0
80+
a_position = current_pose.position
81+
pose: PoseStamped
82+
for pose in path.poses:
83+
b_postion = pose.pose.position
84+
distance += math.hypot(b_postion.x - a_position.x, b_postion.y - a_position.y)
85+
a_position = b_postion
86+
distance += math.hypot(end_pose.position.x - a_position.x, end_pose.position.y - a_position.y)
7687

7788
# Calculate the translational walk velocity.
7889
# It considers the distance and breaks if we are close to the final position of the global plan

bitbots_navigation/bitbots_path_planning/bitbots_path_planning/map.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(self, node: Node, buffer: tf2.Buffer) -> None:
3838
self.config_inflation_blur: int = self.node.config.map.inflation.blur
3939
self.config_inflation_dialation: int = self.node.config.map.inflation.dialate
4040
self.config_obstacle_value: int = self.node.config.map.obstacle_value
41+
self.ball_obstacle_active: bool = True
4142

4243
def set_ball(self, ball: PoseWithCovarianceStamped) -> None:
4344
"""
@@ -60,7 +61,7 @@ def _render_balls(self) -> None:
6061
cv2.circle(
6162
self.map,
6263
self.to_map_space(ball.x, ball.y)[::-1],
63-
round(self.config_ball_diameter * self.resolution),
64+
round(self.config_ball_diameter / 2 * self.resolution),
6465
self.config_obstacle_value,
6566
-1,
6667
)
@@ -140,10 +141,17 @@ def update(self) -> None:
140141
Regenerates the costmap based on the ball and robot buffer
141142
"""
142143
self.clear()
143-
self._render_balls()
144+
if self.ball_obstacle_active:
145+
self._render_balls()
144146
self._render_robots()
145147
self.inflate()
146148

149+
def avoid_ball(self, state: bool) -> None:
150+
"""
151+
Activates or deactivates the ball obstacle
152+
"""
153+
self.ball_obstacle_active = state
154+
147155
def get_map(self) -> np.ndarray:
148156
"""
149157
Returns the costmap as an numpy array

bitbots_navigation/bitbots_path_planning/bitbots_path_planning/path_planning.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from rclpy.duration import Duration
88
from rclpy.executors import MultiThreadedExecutor
99
from rclpy.node import Node
10-
from std_msgs.msg import Empty
10+
from std_msgs.msg import Bool, Empty
1111

1212
from bitbots_path_planning.controller import Controller
1313
from bitbots_path_planning.map import Map
@@ -58,6 +58,13 @@ def __init__(self) -> None:
5858
5,
5959
callback_group=MutuallyExclusiveCallbackGroup(),
6060
)
61+
self.create_subscription(
62+
Bool,
63+
"ball_obstacle_active",
64+
lambda msg: self.map.avoid_ball(msg.data),
65+
5,
66+
callback_group=MutuallyExclusiveCallbackGroup(),
67+
)
6168

6269
# Publisher
6370
self.cmd_vel_pub = self.create_publisher(Twist, "cmd_vel", 1)
@@ -106,7 +113,7 @@ def main(args=None):
106113
node = PathPlanning()
107114

108115
# choose number of threads by number of callback_groups + 1 for simulation time
109-
ex = MultiThreadedExecutor(num_threads=7)
116+
ex = MultiThreadedExecutor(num_threads=8)
110117
ex.add_node(node)
111118
ex.spin()
112119

bitbots_navigation/bitbots_path_planning/config/path_planning_parameters.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bitbots_path_planning:
6666
read_only: true
6767
blur:
6868
type: int
69-
default_value: 13
69+
default_value: 11
7070
description: 'The blur value for the inflation'
7171
read_only: true
7272

@@ -121,7 +121,7 @@ bitbots_path_planning:
121121
bounds<>: [0.0, 1.0]
122122
translation_slow_down_factor:
123123
type: double
124-
default_value: 0.5
124+
default_value: 1.0
125125
description: 'Clamped p gain of the translation controller'
126126
validation:
127127
bounds<>: [0.0, 1.0]

bitbots_world_model/bitbots_robot_filter/config/params.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ bitbots_robot_filter:
66
robots_publish_topic: 'robots_relative_filtered'
77

88
filter_frame: 'map'
9-
robot_dummy_size: 0.4
9+
robot_dummy_size: 0.6
1010
robot_merge_distance: 0.5
1111
robot_storage_time: 10e9
1212
team_data_timeout: 1e9

0 commit comments

Comments
 (0)