@@ -383,20 +383,21 @@ public override Task<FullBodyCartesianCommandAck> SendFullBodyCartesianCommands(
383383 ( float ) fullBodyCartesianCommand . Neck . Q . W ) ;
384384
385385 Vector3 neck_commands = Mathf . Deg2Rad * headRotation . eulerAngles ;
386+
386387 jointCommandList . Add ( new JointCommand
387388 {
388389 Id = new JointId { Name = "neck_roll" } ,
389- GoalPosition = ( float ? ) neck_commands [ 2 ] ,
390+ GoalPosition = ( float ? ) ChangeAngleRange ( neck_commands [ 2 ] ) ,
390391 } ) ;
391392 jointCommandList . Add ( new JointCommand
392393 {
393394 Id = new JointId { Name = "neck_pitch" } ,
394- GoalPosition = ( float ? ) neck_commands [ 0 ] ,
395+ GoalPosition = ( float ? ) ChangeAngleRange ( neck_commands [ 0 ] ) ,
395396 } ) ;
396397 jointCommandList . Add ( new JointCommand
397398 {
398399 Id = new JointId { Name = "neck_yaw" } ,
399- GoalPosition = ( float ? ) neck_commands [ 1 ] ,
400+ GoalPosition = - ( float ? ) ChangeAngleRange ( neck_commands [ 1 ] ) ,
400401 } ) ;
401402 }
402403
@@ -447,6 +448,13 @@ public override async Task<FullBodyCartesianCommandAck> StreamFullBodyCartesianC
447448 NeckCommandSuccess = true
448449 } ) ;
449450 }
451+
452+ private float ChangeAngleRange ( float orbita_angle )
453+ {
454+ float modified_angle = orbita_angle % ( 2.0f * ( float ) Math . PI ) ;
455+ modified_angle = modified_angle > ( float ) Math . PI ? modified_angle - ( 2.0f * ( float ) Math . PI ) : modified_angle ;
456+ return modified_angle ;
457+ }
450458 }
451459
452460 public class ArmKinematicsImpl : ArmKinematics . ArmKinematicsBase
0 commit comments