public KinematicJointPair(KinematicJoint a, KinematicJoint b) { XmlID = UtilityHelpers.MakeUdmID(); if (a.TopLevelID != null) { XmlID = a.TopLevelID; } else if (b.TopLevelID != null) { XmlID = b.TopLevelID; } A = a; B = b; }
public KinematicJointPair(KinematicJoint a, KinematicJoint b) { XmlID = UtilityHelpers.MakeUdmID(); if (a.TopLevelID != null) { XmlID = a.TopLevelID; } else if (b.TopLevelID != null) { XmlID = b.TopLevelID; } A = a; B = b; }
// Sets up joint based on already populated datums // Pre-Condition: DatumList is filled out private void SetupJoint(List<CyPhy.CADDatum> datumlist, List<CyPhy.CADDatum> limitreflist, Dictionary<string, DataRep.Datum> limitrefmap) { if ((CyPhyImpl as CyPhy.Connector).Children.KinematicRevoluteJointCollection.Any()) { Joint = new KinematicJoint((CyPhyImpl as CyPhy.Connector).Children.KinematicRevoluteJointCollection.First()); } else if ((CyPhyImpl as CyPhy.Connector).Children.KinematicCylindricalJointCollection.Any()) { Joint = new KinematicJoint((CyPhyImpl as CyPhy.Connector).Children.KinematicCylindricalJointCollection.First()); } else if ((CyPhyImpl as CyPhy.Connector).Children.KinematicFixedJointCollection.Any()) { Joint = new KinematicJoint((CyPhyImpl as CyPhy.Connector).Children.KinematicFixedJointCollection.First()); } else if ((CyPhyImpl as CyPhy.Connector).Children.KinematicTranslationalJointCollection.Any()) { Joint = new KinematicJoint((CyPhyImpl as CyPhy.Connector).Children.KinematicTranslationalJointCollection.First()); } // Get the datums to associate with this joint if (Joint != null) { foreach (var cyphydatum in datumlist) { Datum datarepdatum; if (DatumList.TryGetValue(cyphydatum.Name, out datarepdatum)) { // Is datum part of defining the joint? if (cyphydatum.SrcConnections.KinematicJointDefinitionCollection.Any()) { if (cyphydatum is CyPhy.Axis) { Joint.Axis = datarepdatum; } else if (cyphydatum is CyPhy.Surface) { Joint.AlignmentPlane = datarepdatum; } } } } if (limitreflist.Any() && Joint.JointType == KinematicJoint.KinematicJointType.REVOLUTE) { throw new Exception("Limit references for revolute joints are not supported currently. Guides will be used as limit references. Please remove limit references on rvlute joints from your model. Connector: " + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } var guides = datumlist.Where(d => d.Attributes.DefinitionNotes.Contains("GUIDE")); if (guides.Any()) { Logger.Instance.AddLogMessage("Datum is using old guide format. Please use the attribute 'IsGuide'. Connector: " + CyPhyImpl.Path, Severity.Error); return; } guides = datumlist.Where(d => d.Attributes.IsGuide); if (guides.Count() > 1) { throw new Exception("More than one guides in a kinematic joint. This is not supported yet. Connector: " + CyPhyImpl.Path); } else if (guides.Count() == 1) { Joint.RotationDefaultReference = this.DatumList[guides.First().Name]; } foreach (var limitrefdatum in limitreflist) { Datum datarepdatum; if (limitrefmap.TryGetValue(limitrefdatum.Name, out datarepdatum)) { // Is this datum part of defining the limits of the joint? if ((limitrefdatum as CyPhy.Surface).SrcConnections.KinematicTranslationalLimitReferenceCollection.Any()) { var limittype = (limitrefdatum as CyPhy.Surface).SrcConnections.KinematicTranslationalLimitReferenceCollection.First().Attributes.TranslationalLimitReferenceType; // Default if (limittype == CyPhyClasses.KinematicTranslationalLimitReference.AttributesClass.TranslationalLimitReferenceType_enum.NormalExtent) { Joint.TranslationDefaultReference = datarepdatum; } // Min else if (limittype == CyPhyClasses.KinematicTranslationalLimitReference.AttributesClass.TranslationalLimitReferenceType_enum.MinExtent) { throw new Exception("Min and max references are not yet supported. Please remove these." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } // Max else { throw new Exception("Min and max references are not yet supported. Please remove these." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } } } } if ((Joint.RotationLimitMax.HasValue || Joint.RotationLimitMin.HasValue) && !Joint.RotationLimitDefault.HasValue) { throw new Exception("Joint has rotation limit max or min specified, but not default. Please specify default value as well." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } if (Joint.RotationLimitDefault.HasValue && Joint.RotationDefaultReference == null) { throw new Exception("Joint has rotation limit specified, but there are no guides present to be used as rotation references. Please define guides for the connection as well." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } if ((Joint.TranslationLimitMax.HasValue || Joint.TranslationLimitMin.HasValue) && !Joint.TranslationLimitDefault.HasValue) { throw new Exception("Joint has translation limit max or min specified, but not default. Please specify default value as well." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } if (Joint.TranslationLimitDefault.HasValue && Joint.TranslationDefaultReference == null) { throw new Exception("Joint has translation limit specified, but there is no limit reference present. Please define limit references in the connection as well." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } if (Joint.RotationLimitMax.HasValue && Joint.RotationLimitMin.HasValue && Joint.RotationLimitMin.Value > Joint.RotationLimitMax.Value) { throw new Exception("Joint rotation limit min > max. Please correct this." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } } }
// Sets up joint based on already populated datums // Pre-Condition: DatumList is filled out private void SetupJoint(List <CyPhy.CADDatum> datumlist, List <CyPhy.CADDatum> limitreflist, Dictionary <string, DataRep.Datum> limitrefmap) { if ((CyPhyImpl as CyPhy.Connector).Children.KinematicRevoluteJointCollection.Any()) { Joint = new KinematicJoint((CyPhyImpl as CyPhy.Connector).Children.KinematicRevoluteJointCollection.First()); } else if ((CyPhyImpl as CyPhy.Connector).Children.KinematicCylindricalJointCollection.Any()) { Joint = new KinematicJoint((CyPhyImpl as CyPhy.Connector).Children.KinematicCylindricalJointCollection.First()); } else if ((CyPhyImpl as CyPhy.Connector).Children.KinematicFixedJointCollection.Any()) { Joint = new KinematicJoint((CyPhyImpl as CyPhy.Connector).Children.KinematicFixedJointCollection.First()); } else if ((CyPhyImpl as CyPhy.Connector).Children.KinematicTranslationalJointCollection.Any()) { Joint = new KinematicJoint((CyPhyImpl as CyPhy.Connector).Children.KinematicTranslationalJointCollection.First()); } // Get the datums to associate with this joint if (Joint != null) { foreach (var cyphydatum in datumlist) { Datum datarepdatum; if (DatumList.TryGetValue(cyphydatum.Name, out datarepdatum)) { // Is datum part of defining the joint? if (cyphydatum.SrcConnections.KinematicJointDefinitionCollection.Any()) { if (cyphydatum is CyPhy.Axis) { Joint.Axis = datarepdatum; } else if (cyphydatum is CyPhy.Surface) { Joint.AlignmentPlane = datarepdatum; } } } } if (limitreflist.Any() && Joint.JointType == KinematicJoint.KinematicJointType.REVOLUTE) { throw new Exception("Limit references for revolute joints are not supported currently. Guides will be used as limit references. Please remove limit references on rvlute joints from your model. Connector: " + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } var guides = datumlist.Where(d => d.Attributes.DefinitionNotes.Contains("GUIDE")); if (guides.Any()) { Logger.Instance.AddLogMessage("Datum is using old guide format. Please use the attribute 'IsGuide'. Connector: " + CyPhyImpl.Path, Severity.Error); return; } guides = datumlist.Where(d => d.Attributes.IsGuide); if (guides.Count() > 1) { throw new Exception("More than one guides in a kinematic joint. This is not supported yet. Connector: " + CyPhyImpl.Path); } else if (guides.Count() == 1) { Joint.RotationDefaultReference = this.DatumList[guides.First().Name]; } foreach (var limitrefdatum in limitreflist) { Datum datarepdatum; if (limitrefmap.TryGetValue(limitrefdatum.Name, out datarepdatum)) { // Is this datum part of defining the limits of the joint? if ((limitrefdatum as CyPhy.Surface).SrcConnections.KinematicTranslationalLimitReferenceCollection.Any()) { var limittype = (limitrefdatum as CyPhy.Surface).SrcConnections.KinematicTranslationalLimitReferenceCollection.First().Attributes.TranslationalLimitReferenceType; // Default if (limittype == CyPhyClasses.KinematicTranslationalLimitReference.AttributesClass.TranslationalLimitReferenceType_enum.NormalExtent) { Joint.TranslationDefaultReference = datarepdatum; } // Min else if (limittype == CyPhyClasses.KinematicTranslationalLimitReference.AttributesClass.TranslationalLimitReferenceType_enum.MinExtent) { throw new Exception("Min and max references are not yet supported. Please remove these." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } // Max else { throw new Exception("Min and max references are not yet supported. Please remove these." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } } } } if ((Joint.RotationLimitMax.HasValue || Joint.RotationLimitMin.HasValue) && !Joint.RotationLimitDefault.HasValue) { throw new Exception("Joint has rotation limit max or min specified, but not default. Please specify default value as well." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } if (Joint.RotationLimitDefault.HasValue && Joint.RotationDefaultReference == null) { throw new Exception("Joint has rotation limit specified, but there are no guides present to be used as rotation references. Please define guides for the connection as well." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } if ((Joint.TranslationLimitMax.HasValue || Joint.TranslationLimitMin.HasValue) && !Joint.TranslationLimitDefault.HasValue) { throw new Exception("Joint has translation limit max or min specified, but not default. Please specify default value as well." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } if (Joint.TranslationLimitDefault.HasValue && Joint.TranslationDefaultReference == null) { throw new Exception("Joint has translation limit specified, but there is no limit reference present. Please define limit references in the connection as well." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } if (Joint.RotationLimitMax.HasValue && Joint.RotationLimitMin.HasValue && Joint.RotationLimitMin.Value > Joint.RotationLimitMax.Value) { throw new Exception("Joint rotation limit min > max. Please correct this." + CyPhyImpl.Name + ", Parent: " + CyPhyImpl.ParentContainer.Name); } } }