public String Rotate(int interval, Direction direction) { String cmd = ""; switch (direction.Name) { case "Left": //left NeckBalance.Position += interval; cmd = "#" + NeckBalance.Number + "P" + NeckBalance.Position + " "; break; case "Right": //right NeckBalance.Position -= interval; cmd = "#" + NeckBalance.Number + "P" + NeckBalance.Position + " "; break; } return cmd; }
public String Turn(int interval, Direction direction) { String cmd = ""; switch (direction.Name) { case "Left": //left NeckHorizontal.Position += interval; cmd = "#" + NeckHorizontal.Number + "P" + NeckHorizontal.Position + " "; break; case "Right": //right NeckHorizontal.Position -= interval; cmd = "#" + NeckHorizontal.Number + "P" + NeckHorizontal.Position + " "; break; case "Up": // Head Up NeckVertical.Position -= interval; cmd = "#" + NeckVertical.Number + "P" + NeckVertical.Position + " "; break; case "Down": // Head Down NeckVertical.Position += interval; cmd = "#" + NeckVertical.Number + "P" + NeckVertical.Position + " "; break; } return cmd; }
/// <summary> /// Change body height /// </summary> /// <param name="interval">Negative to lift the body, Positive to drop.</param> /// <param name="direction"></param> public void Push(int interval, Direction direction, int time) { String cmd= ""; switch (direction.Name) { case "Up": cmd = LeftFront.Drop(interval) + LeftCenter.Drop(interval) + LeftRear.Drop(interval) + LeftFront.Stand() + LeftCenter.Stand() + LeftRear.Stand() + RightFront.Drop(interval) + RightCenter.Drop(interval) + RightRear.Drop(interval) + RightFront.Stand() + RightCenter.Stand() + RightRear.Stand(); break; case "Down": cmd = LeftFront.Lift(interval) + LeftCenter.Lift(interval) + LeftRear.Lift(interval) + LeftFront.Stand() + LeftCenter.Stand() + LeftRear.Stand() + RightFront.Lift(interval) + RightCenter.Lift(interval) + RightRear.Lift(interval) + RightFront.Stand() + RightCenter.Stand() + RightRear.Stand(); break; case "Left": //left cmd = LeftFront.Forward(interval) + LeftCenter.Forward(interval) + LeftRear.Forward(interval) + RightFront.Backward(interval) + RightCenter.Backward(interval) + RightRear.Backward(interval); break; case "Right": //right cmd = LeftFront.Backward(interval) + LeftCenter.Backward(interval) + LeftRear.Backward(interval) + RightFront.Forward(interval) + RightCenter.Forward(interval) + RightRear.Forward(interval); break; case "Backward": //backward cmd = LeftFront.Forward(interval) + LeftCenter.Forward(interval) + LeftRear.Forward(interval) + RightFront.Forward(interval) + RightCenter.Forward(interval) + RightRear.Forward(interval); break; case "Forward": //Foward cmd = LeftFront.Backward(interval) + LeftCenter.Backward(interval) + LeftRear.Backward(interval) + RightFront.Backward(interval) + RightCenter.Backward(interval) + RightRear.Backward(interval); break; } Port.SendCommand(cmd, time); }
/// <summary> /// Rotate head (change head's balance) /// </summary> /// <param name="interval">Moving Distance</param> /// <param name="direction">Rotate direction: left/right</param> /// <param name="time">Execution time</param> public void HeadRotate(int interval, Direction direction, int time) { String cmd = head.Rotate(interval, direction); Port.SendCommand(cmd, time); }