1
1
import math
2
- from typing import Tuple
3
2
4
3
import numpy as np
5
4
import tf2_ros as tf2
@@ -90,7 +89,7 @@ def ball_has_been_seen(self) -> bool:
90
89
"""Returns true if we or a teammate are reasonably sure that we have seen the ball"""
91
90
return self .ball_seen_self () or self ._blackboard .team_data .teammate_ball_is_valid ()
92
91
93
- def get_ball_position_xy (self ) -> Tuple [float , float ]:
92
+ def get_ball_position_xy (self ) -> tuple [float , float ]:
94
93
"""Return the ball saved in the map frame, meaning the absolute position of the ball on the field"""
95
94
ball = self .get_best_ball_point_stamped ()
96
95
return ball .point .x , ball .point .y
@@ -117,7 +116,7 @@ def get_best_ball_point_stamped(self) -> PointStamped:
117
116
self .debug_publisher_which_ball .publish (Header (stamp = own_ball .header .stamp , frame_id = "own_ball_map" ))
118
117
return own_ball
119
118
120
- def get_ball_position_uv (self ) -> Tuple [float , float ]:
119
+ def get_ball_position_uv (self ) -> tuple [float , float ]:
121
120
"""
122
121
Returns the ball position relative to the robot in the base_footprint frame.
123
122
U and V are returned, where positive U is forward, positive V is to the left.
@@ -183,18 +182,18 @@ def forget_ball(self) -> None:
183
182
# Goal #
184
183
########
185
184
186
- def get_map_based_opp_goal_center_uv (self ) -> Tuple [float , float ]:
185
+ def get_map_based_opp_goal_center_uv (self ) -> tuple [float , float ]:
187
186
x , y = self .get_map_based_opp_goal_center_xy ()
188
187
return self .get_uv_from_xy (x , y )
189
188
190
- def get_map_based_opp_goal_center_xy (self ) -> Tuple [float , float ]:
189
+ def get_map_based_opp_goal_center_xy (self ) -> tuple [float , float ]:
191
190
return self .field_length / 2 , 0.0
192
191
193
- def get_map_based_own_goal_center_uv (self ) -> Tuple [float , float ]:
192
+ def get_map_based_own_goal_center_uv (self ) -> tuple [float , float ]:
194
193
x , y = self .get_map_based_own_goal_center_xy ()
195
194
return self .get_uv_from_xy (x , y )
196
195
197
- def get_map_based_own_goal_center_xy (self ) -> Tuple [float , float ]:
196
+ def get_map_based_own_goal_center_xy (self ) -> tuple [float , float ]:
198
197
return - self .field_length / 2 , 0.0
199
198
200
199
def get_map_based_opp_goal_angle_from_ball (self ) -> float :
@@ -210,19 +209,19 @@ def get_map_based_opp_goal_angle(self) -> float:
210
209
x , y = self .get_map_based_opp_goal_center_uv ()
211
210
return math .atan2 (y , x )
212
211
213
- def get_map_based_opp_goal_left_post_uv (self ) -> Tuple [float , float ]:
212
+ def get_map_based_opp_goal_left_post_uv (self ) -> tuple [float , float ]:
214
213
x , y = self .get_map_based_opp_goal_center_xy ()
215
214
return self .get_uv_from_xy (x , y - self .goal_width / 2 )
216
215
217
- def get_map_based_opp_goal_right_post_uv (self ) -> Tuple [float , float ]:
216
+ def get_map_based_opp_goal_right_post_uv (self ) -> tuple [float , float ]:
218
217
x , y = self .get_map_based_opp_goal_center_xy ()
219
218
return self .get_uv_from_xy (x , y + self .goal_width / 2 )
220
219
221
220
########
222
221
# Pose #
223
222
########
224
223
225
- def get_current_position (self ) -> Tuple [float , float , float ]:
224
+ def get_current_position (self ) -> tuple [float , float , float ]:
226
225
"""
227
226
Returns the current position on the field as determined by the localization.
228
227
0,0,0 is the center of the field looking in the direction of the opponent goal.
@@ -261,7 +260,7 @@ def get_current_position_transform(self) -> TransformStamped:
261
260
# Common #
262
261
##########
263
262
264
- def get_uv_from_xy (self , x : float , y : float ) -> Tuple [float , float ]:
263
+ def get_uv_from_xy (self , x : float , y : float ) -> tuple [float , float ]:
265
264
"""Returns the relativ positions of the robot to this absolute position"""
266
265
current_position = self .get_current_position ()
267
266
x2 = x - current_position [0 ]
@@ -271,7 +270,7 @@ def get_uv_from_xy(self, x: float, y: float) -> Tuple[float, float]:
271
270
v = math .cos (theta ) * y2 - math .sin (theta ) * x2
272
271
return u , v
273
272
274
- def get_xy_from_uv (self , u : float , v : float ) -> Tuple [float , float ]:
273
+ def get_xy_from_uv (self , u : float , v : float ) -> tuple [float , float ]:
275
274
"""Returns the absolute position from the given relative position to the robot"""
276
275
pos_x , pos_y , theta = self .get_current_position ()
277
276
angle = math .atan2 (v , u ) + theta
0 commit comments