@@ -5,6 +5,7 @@ use framework::MainOutput;
55use serde:: { Deserialize , Serialize } ;
66use types:: ball_position:: BallPosition ;
77use types:: motion_command:: { HeadMotion , MotionCommand } ;
8+ use types:: parameters:: WalkWithVelocityParameters ;
89
910#[ derive( Deserialize , Serialize ) ]
1011pub struct WalkToBall { }
@@ -15,6 +16,8 @@ pub struct CreationContext {}
1516#[ context]
1617pub struct CycleContext {
1718 ball_position : Input < Option < BallPosition < Ground > > , "ball_position?" > ,
19+ walk_with_velocity_parameter :
20+ Parameter < WalkWithVelocityParameters , "behavior.walk_with_velocity" > ,
1821}
1922
2023#[ context]
@@ -33,10 +36,17 @@ impl WalkToBall {
3336 Some ( ball_position) => {
3437 let ball_coordinates_in_ground = ball_position. position . coords ( ) ;
3538 let head = HeadMotion :: Center ;
39+ let max_angular_velocity_abs = context
40+ . walk_with_velocity_parameter
41+ . max_angular_velocity
42+ . abs ( ) ;
3643 MotionCommand :: WalkWithVelocity {
3744 head,
38- velocity : ball_coordinates_in_ground. normalize ( ) * 0.5 , // TODO: parameterize
39- angular_velocity : ball_coordinates_in_ground. y ( ) . clamp ( -0.25 , 0.25 ) , // TODO: parameterize
45+ velocity : ball_coordinates_in_ground. normalize ( )
46+ * context. walk_with_velocity_parameter . max_velocity ,
47+ angular_velocity : ball_coordinates_in_ground
48+ . y ( )
49+ . clamp ( -max_angular_velocity_abs, max_angular_velocity_abs) ,
4050 }
4151 }
4252 None => MotionCommand :: Stand {
0 commit comments