/// <summary> /// Set the value for the servos on the sides of the hexapod. /// SSC-32U Commands: LH, LM, LL, RH, RM, RL /// </summary> /// <param name="side">Specifies the side of the hexapod.</param> /// <param name="legValue">Leg Value : High - maximum height, Low - minimum h.</param> /// <param name="value">Value.</param> public static Command SetVerticalServo(this Command command, ServoSide side, LegValue legValue, int value) { if (command == null) { throw new ArgumentNullException(nameof(command)); } if (value < 500 || value > 2500) { throw new ArgumentOutOfRangeException(nameof(value), "The valid range is between 500 to 2500uS."); } var sb = command.Builder; sb.Append(side == ServoSide.Left ? 'L' : 'R'); switch (legValue) { case LegValue.High: sb.Append('H'); break; case LegValue.Mid: sb.Append('M'); break; case LegValue.Low: sb.Append('L'); break; } sb.Append(' '); sb.Append(value); return(command); }
/// <summary> /// Set the travel percentage for left and right legs. The valid range is -100% to 100%. /// Negative values cause the legs on the side to move in reverse. With a value of 100%, the legs will move /// between the front and rear positions.Lower values cause the travel to be proportionally less, but /// always centered.The speed for horizontal moves is adjusted based on the XL and XR /// commands, so the move time remains the same. /// SSC-32U Commands: XL, XR /// </summary> /// <param name="side">Specifies the side of the hexapod.</param> /// <param name="percentage"> The valid range is -100% to 100%.</param> public static Command SetTravelPercentage(this Command command, ServoSide side, int percentage) { if (command == null) { throw new ArgumentNullException(nameof(command)); } if (percentage < -100 || percentage > 100) { throw new ArgumentOutOfRangeException(nameof(percentage), "The valid range is between -100% to 100%"); } var sb = command.Builder; sb.Append(side == ServoSide.Left ? "XL" : "XR"); sb.Append(percentage); return(command); }
/// <summary> /// Set the value for the horizontal servos on the left side of the robot. sets the pulse width to move the leg to the maximum forward/rear position; /// SSC-32U Commands: LF, LR, RF, RR /// </summary> /// <param name="side">Specifies the side of the hexapod.</param> /// <param name="servoValue">Specifies front/rear servos.</param> /// <param name="value"> The valid range for the arguments is 500 to 2500uS.</param> public static Command SetHorizontalServo(this Command command, ServoSide side, FrontRear servoValue, int value) { if (command == null) { throw new ArgumentNullException(nameof(command)); } if (value < 500 || value > 2500) { throw new ArgumentOutOfRangeException(nameof(value), "The valid range is between 500 to 2500uS."); } var sb = command.Builder; sb.Append(side == ServoSide.Left ? 'L' : 'R'); sb.Append(servoValue == FrontRear.Front ? "F " : "R "); sb.Append(value); return(command); }