public void InitializeLimits(Joint.Limit limit, HingeJoint joint)
        {
            LargeAngleLimitMin = (float)limit.lower * Mathf.Rad2Deg;
            LargeAngleLimitMax = (float)limit.upper * Mathf.Rad2Deg;

            _hingeJoint = joint;

            RecalculateJointLimits();
        }
Example #2
0
 private static SoftJointLimit GetLinearLimit(Joint.Limit limit)
 {
     return(new SoftJointLimit {
         limit = (float)limit.upper
     });
 }
 public void InitializeLimits(Joint.Limit limit)
 {
     PositionLimitMax = (float)limit.upper;
     PositionLimitMin = (float)limit.lower;
 }
Example #4
0
        /// <summary>
        /// Compares limit information of two joints
        /// </summary>
        /// <param name="source">First joint's limit information to be compared</param>
        /// <param name="exported">Second joint's limit information to be compared</param>
        /// <param name="indent">Indent level in the log file</param>
        /// <returns></returns>
        private bool CompareLimit(Joint.Limit source, Joint.Limit exported, int indent)
        {
            //Lower
            if ((source.lower == double.NaN && exported.lower == 0) || (source.lower == 0 && exported.lower == double.NaN))
            {
                linkLog.AppendLine(String.Format("{0}Lower Limit:", Indent(indent)));
                linkLog.AppendLine(String.Format("{0}Equal: {1,6}", Indent(indent), "True"));
                linkLog.AppendLine(String.Format("{0}Lower Limit Value: 0", Indent(indent)));
            }
            else if ((source.lower == double.NaN && exported.lower != 0) || (source.lower != 0 && exported.lower == double.NaN))
            {
                linkLog.AppendLine(String.Format("{0}Lower Limit: {1,6}", Indent(indent), "False"));
                return(false);
            }
            else if (!source.lower.EqualsDelta(exported.lower, .05))
            {
                linkLog.AppendLine(String.Format("{0}Lower Limit:", Indent(indent)));
                linkLog.AppendLine(String.Format("{0}Equal: {1,6}", Indent(indent), "False"));
                linkLog.AppendLine(String.Format("{0}Lower Limit Value: Source: {1,12}", Indent(indent), source.lower));
                linkLog.AppendLine(String.Format("{0}Lower Limit Value: Exported: {1,12}", Indent(indent), exported.lower));
                return(false);
            }
            else
            {
                linkLog.AppendLine(String.Format("{0}Lower Limit:", Indent(indent)));
                linkLog.AppendLine(String.Format("{0}Equal: {1,6}", Indent(indent), "True"));
                linkLog.AppendLine(String.Format("{0}Lower Limit Value: {1,12}", Indent(indent), source?.lower));
            }

            //Upper
            if ((source.upper == double.NaN && exported.upper == 0) || (source.upper == 0 && exported.upper == double.NaN))
            {
                linkLog.AppendLine(String.Format("{0}Upper Limit:", Indent(indent)));
                linkLog.AppendLine(String.Format("{0}Equal: {1,6}", Indent(indent), "True"));
                linkLog.AppendLine(String.Format("{0}Upper Limit Value: 0", Indent(indent)));
            }
            else if ((source.upper == double.NaN && exported.upper != 0) || (source.upper != 0 && exported.upper == double.NaN))
            {
                linkLog.AppendLine(String.Format("{0}Upper Limit: {1,6}", Indent(indent), "False"));
                return(false);
            }
            else if (!source.upper.EqualsDelta(exported.upper, .05))
            {
                linkLog.AppendLine(String.Format("{0}Upper Limit:", Indent(indent)));
                linkLog.AppendLine(String.Format("{0}Equal: {1,6}", Indent(indent), "False"));
                linkLog.AppendLine(String.Format("{0}Upper Limit Value: Source: {1,12}", Indent(indent), source.upper));
                linkLog.AppendLine(String.Format("{0}Upper Limit Value: Exported: {1,12}", Indent(indent), exported.upper));
                return(false);
            }
            else
            {
                linkLog.AppendLine(String.Format("{0}Upper Limit:", Indent(indent)));
                linkLog.AppendLine(String.Format("{0}Equal: {1,6}", Indent(indent), "True"));
                linkLog.AppendLine(String.Format("{0}Upper Limit Value: {1,12}", Indent(indent), source?.upper));
            }

            if (!source.effort.EqualsDelta(exported.effort, .05))
            {
                linkLog.AppendLine(String.Format("{0}Effort Equal: {1,6} Effort: Source:{2,5:F3} Exported:{3,5:F3}", Indent(indent), "False", source.effort, exported.effort));
                return(false);
            }
            else
            {
                linkLog.AppendLine(String.Format("{0}Effort Equal: {1,6} Effort: {2,5:F3}", Indent(indent), "True", source.effort));
            }

            if (!source.velocity.EqualsDelta(exported.velocity, .05))
            {
                linkLog.AppendLine(String.Format("{0}Velocity Limit Equal: {1,6} Velocity: Source:{2,5:F3} Exported:{3,5:F3}", Indent(indent), "False", source.velocity, exported.velocity));
                return(false);
            }
            else
            {
                linkLog.AppendLine(String.Format("{0}Velocity Equal: {1,6} Velocity: {2,5:F3}", Indent(indent), "True", source.velocity));
            }

            return(true);
        }