11use std:: {
22 convert:: Into ,
3- f32:: consts:: FRAC_PI_2 ,
43 mem:: take,
54 sync:: { mpsc, Arc } ,
65 time:: { Duration , SystemTime , UNIX_EPOCH } ,
@@ -17,14 +16,13 @@ use bevy::{
1716use color_eyre:: { eyre:: WrapErr , Result } ;
1817
1918use buffered_watch:: { Receiver , Sender } ;
20- use control:: { localization:: generate_initial_pose, zero_moment_point_provider :: LEFT_FOOT_OUTLINE } ;
19+ use control:: localization:: generate_initial_pose;
2120use coordinate_systems:: { Field , Ground , Head , LeftSole , RightSole , Robot as RobotCoordinates } ;
2221use framework:: { future_queue, Producer , RecordingTrigger } ;
23- use geometry:: { circle:: Circle , polygon:: circle_overlaps_polygon} ;
2422use hula_types:: hardware:: Ids ;
2523use linear_algebra:: {
26- point , vector, Isometry2 , Isometry3 , Orientation2 , Orientation3 , Point2 , Pose2 , Pose3 ,
27- Rotation2 , Vector2 ,
24+ vector, Isometry2 , Isometry3 , Orientation2 , Orientation3 , Point2 , Pose2 , Pose3 , Rotation2 ,
25+ Vector2 ,
2826} ;
2927use parameters:: directory:: deserialize;
3028use projection:: intrinsic:: Intrinsic ;
@@ -34,17 +32,13 @@ use types::{
3432 filtered_whistle:: FilteredWhistle ,
3533 joints:: Joints ,
3634 messages:: { IncomingMessage , OutgoingMessage } ,
37- motion_command:: { HeadMotion , KickVariant } ,
35+ motion_command:: HeadMotion ,
3836 motion_selection:: MotionSafeExits ,
3937 pose_kinds:: PoseKind ,
4038 robot_dimensions:: RobotDimensions ,
4139 sensor_data:: Foot ,
4240 support_foot:: Side ,
4341} ;
44- use walking_engine:: {
45- kick_state:: KickState ,
46- mode:: { kicking:: Kicking , Mode } ,
47- } ;
4842
4943use crate :: {
5044 ball:: BallResource ,
@@ -249,65 +243,12 @@ pub fn from_player_number(val: PlayerNumber) -> usize {
249243 }
250244}
251245
252- pub fn move_robots ( mut robots : Query < & mut Robot > , mut ball : ResMut < BallResource > , time : Res < Time > ) {
246+ pub fn move_robots ( mut robots : Query < & mut Robot > , _ball : ResMut < BallResource > , time : Res < Time > ) {
253247 for mut robot in & mut robots {
254248 if let Some ( ball) = robot. database . main_outputs . ball_position . as_mut ( ) {
255249 ball. position += ball. velocity * time. delta_secs ( ) ;
256250 ball. velocity *= 0.98
257251 }
258- if let Mode :: Kicking ( Kicking {
259- kick :
260- KickState {
261- variant,
262- side : kicking_side,
263- strength,
264- ..
265- } ,
266- ..
267- } ) = robot. cycler . cycler_state . walking_engine_mode
268- {
269- if let Some ( ball) = ball. state . as_mut ( ) {
270- let side = match kicking_side {
271- Side :: Left => -1.0 ,
272- Side :: Right => 1.0 ,
273- } ;
274-
275- let robot_to_ground = robot. database . main_outputs . robot_to_ground . unwrap ( ) ;
276- let kinematics = & robot. database . main_outputs . robot_kinematics ;
277- let left_sole_to_ground = robot_to_ground * kinematics. left_leg . sole_to_robot ;
278- let right_sole_to_ground = robot_to_ground * kinematics. right_leg . sole_to_robot ;
279- let left_sole_in_ground: Vec < _ > = LEFT_FOOT_OUTLINE
280- . into_iter ( )
281- . map ( |point| ( left_sole_to_ground * point) . xy ( ) )
282- . collect ( ) ;
283- let right_sole_in_ground: Vec < _ > = LEFT_FOOT_OUTLINE
284- . into_iter ( )
285- . map ( |point| {
286- ( right_sole_to_ground * point ! [ point. x( ) , -point. y( ) , point. z( ) ] ) . xy ( )
287- } )
288- . collect ( ) ;
289-
290- let ball_circle = Circle :: new (
291- robot. ground_to_field ( ) . inverse ( ) * ball. position ,
292- robot. parameters . field_dimensions . ball_radius ,
293- ) ;
294- let in_range = circle_overlaps_polygon ( & left_sole_in_ground, ball_circle)
295- || circle_overlaps_polygon ( & right_sole_in_ground, ball_circle) ;
296- let previous_kick_finished =
297- ( time. elapsed ( ) - robot. last_kick_time ) . as_secs_f32 ( ) > 1.0 ;
298- if in_range && previous_kick_finished {
299- let direction = match variant {
300- KickVariant :: Forward => Orientation2 :: identity ( ) ,
301- KickVariant :: Turn => Orientation2 :: new ( 0.35 ) ,
302- KickVariant :: Side => Orientation2 :: new ( -FRAC_PI_2 ) ,
303- }
304- . as_unit_vector ( )
305- . component_mul ( & vector ! [ 1.0 , side] ) ;
306- ball. velocity += robot. ground_to_field ( ) * direction * strength * 2.5 ;
307- robot. last_kick_time = time. elapsed ( ) ;
308- } ;
309- }
310- } ;
311252
312253 let ( left_sole, right_sole) =
313254 sole_positions ( & robot. database . main_outputs . sensor_data . positions ) ;
@@ -324,17 +265,6 @@ pub fn move_robots(mut robots: Query<&mut Robot>, mut ball: ResMut<BallResource>
324265 let ground = robot. database . main_outputs . robot_to_ground . unwrap ( ) * support_sole;
325266 let anchor = robot. ground_to_field ( ) * to2d ( ground) ;
326267
327- let target = robot. database . main_outputs . walk_motor_commands . positions ;
328- let positions = & mut robot. database . main_outputs . sensor_data . positions ;
329- positions. left_leg =
330- positions. left_leg + ( target. left_leg - positions. left_leg ) * time. delta_secs ( ) * 10.0 ;
331- positions. right_leg = positions. right_leg
332- + ( target. right_leg - positions. right_leg ) * time. delta_secs ( ) * 10.0 ;
333- positions. left_arm =
334- positions. left_arm + ( target. left_arm - positions. left_arm ) * time. delta_secs ( ) * 10.0 ;
335- positions. right_arm = positions. right_arm
336- + ( target. right_arm - positions. right_arm ) * time. delta_secs ( ) * 10.0 ;
337-
338268 let ( new_left_sole, new_right_sole) =
339269 sole_positions ( & robot. database . main_outputs . sensor_data . positions ) ;
340270 let support_sole = match support_foot {
@@ -505,12 +435,7 @@ pub fn cycle_robots(
505435 . support_foot
506436 . support_side
507437 . unwrap ( ) ;
508- let is_step_finished = robot
509- . cycler
510- . cycler_state
511- . walking_engine_mode
512- . step_state ( )
513- . is_some_and ( |step_state| step_state. time_since_start >= step_state. plan . step_duration ) ;
438+ let is_step_finished = false ;
514439 let next_support_foot = if is_step_finished {
515440 support_foot. opposite ( )
516441 } else {
@@ -568,7 +493,7 @@ fn sole_positions(joint_positions: &Joints) -> (Pose3<RobotCoordinates>, Pose3<R
568493 let left_foot_to_robot =
569494 left_ankle_to_robot * left_foot_to_left_ankle ( & joint_positions. left_leg ) ;
570495 let left_sole_to_robot: Isometry3 < LeftSole , RobotCoordinates > =
571- left_foot_to_robot * Isometry3 :: from ( RobotDimensions :: LEFT_ANKLE_TO_LEFT_SOLE ) ;
496+ left_foot_to_robot * Isometry3 :: from ( RobotDimensions :: LEFT_FOOT_TO_LEFT_SOLE ) ;
572497 // right leg
573498 let right_pelvis_to_robot = right_pelvis_to_robot ( & joint_positions. right_leg ) ;
574499 let right_hip_to_robot =
@@ -582,7 +507,7 @@ fn sole_positions(joint_positions: &Joints) -> (Pose3<RobotCoordinates>, Pose3<R
582507 let right_foot_to_robot =
583508 right_ankle_to_robot * right_foot_to_right_ankle ( & joint_positions. right_leg ) ;
584509 let right_sole_to_robot: Isometry3 < RightSole , RobotCoordinates > =
585- right_foot_to_robot * Isometry3 :: from ( RobotDimensions :: RIGHT_ANKLE_TO_RIGHT_SOLE ) ;
510+ right_foot_to_robot * Isometry3 :: from ( RobotDimensions :: RIGHT_FOOT_TO_RIGHT_SOLE ) ;
586511
587512 ( left_sole_to_robot. as_pose ( ) , right_sole_to_robot. as_pose ( ) )
588513}
0 commit comments