public JointAxis(SldWorks swApp, AssemblyDoc asm, StorageModel swData, string path, Joint current, int index, RobotModel robot) { this.swApp = swApp; this.asmDoc = asm; this.modelDoc = (ModelDoc2)asm; this.swData = swData; this.path = path; this.owner = current; this.robot = robot; this.AxisIndex = index; if (EffortLimit == 0) { this.EffortLimit = 1; } if (this.VelocityLimit == 0) { this.VelocityLimit = 1; } if (Axis != null) { CalcAxisVectors(); //CalcLimits(null); } if (index == 2) { IsContinuous = true; } }
/// <summary> /// Constructor /// </summary> /// <param name="swData">Storage model</param> /// <param name="path">Path in the storage model</param> /// <param name="ChildLink">Link that contains this attachment</param> public JointedAttachment(StorageModel swData, string path, Link ChildLink) : base(swData, path, ChildLink) { if (ParentLinkID != -1) Joint = ChildLink.GetJointFromLink(ChildLink.robot.GetLink(ParentLinkID)); else if (ChildLink.UpperJoints.Length == 1) SetJoint(ChildLink.GetJointFromLink(ChildLink.UpperJoints[0].Parent)); }
/// <summary> /// lodas an exisiting modelcomponent at the given path /// </summary> /// <param name="path">path to store this component at</param> public modelComponent(string path) { this.swData = RobotInfo.SwData; this.path = path; comp = null; comp = Component; //ConfigType = 0; //default to physical model }
/// <summary> /// Creates a new modelComponent /// </summary> /// <param name="path">path to stoer this component at</param> /// <param name="configname">Configuration that this compoent is in</param> /// <param name="configtype">The type of the configuration this component is in</param> /// <param name="component">The component that is being stored</param> /// <param name="pid">The persistant ID of the component</param> public modelComponent( string path, String configname, int configtype, Component2 component, String pid) { this.swData = RobotInfo.SwData; this.path = path; comp = component; ConfigType = configtype; ConfigName = configname; ComponentPID = pid; }
/// <summary> /// Constructor /// </summary> /// <param name="swData">Storage model</param> /// <param name="path">Path in the storage model</param> /// <param name="parentLink">Link that contains this attachment</param> public InternalLimitSwitch(StorageModel swData, string path, Link parentLink) : base(swData, path, parentLink) { Icon = CommandManager.IntLimitSwitchPic; Name = parentLink.Name + " " + GetName(); if (ParentLinkID != -1) Joint = ChildLink.GetJointFromLink(ChildLink.robot.GetLink(ParentLinkID)); else if (ChildLink.UpperJoints.Length == 1) SetJoint(ChildLink.GetJointFromLink(ChildLink.UpperJoints[0].Parent)); }
/// <summary> /// Constructor /// </summary> /// <param name="swData">Storage model</param> /// <param name="path">Path in the storage model</param> /// <param name="parentLink">Link that contains this attachment</param> public Camera(StorageModel swData, string path, Link parentLink) : base(swData, path, parentLink) { Icon = CommandManager.CameraPic; Name = parentLink.Name + " " + GetName(); if (FOV == 0) { FOV = 90; } }
/// <summary> /// Constructor /// </summary> /// <param name="swData">Storage model</param> /// <param name="path">Path in the storage model</param> /// <param name="parentLink">Link that contains this attachment</param> public Rangefinder(StorageModel swData, string path, Link parentLink) : base(swData, path, parentLink) { Icon = CommandManager.RangefinderPic; Name = parentLink.Name + " " + GetName(); if (FOV == 0) { FOV = -.05; } }
public MomentValues(StorageModel swData, string path,double ixx,double ixy,double ixz,double iyy,double iyz,double izz) { this.swData = swData; this.path = path; Ixx = ixx; Ixy = ixy; Ixz = ixz; Iyy = iyy; Iyz = iyz; Izz = izz; }
/// <summary> /// Creates a new Specific Joint object /// </summary> /// <param name="joint">The joint that this joint is in</param> /// <param name="path">The storage path for this joint</param> protected JointSpecifics(Joint joint, string path) { this.robot = RobotInfo.Robot; this.joint = joint; this.swApp = RobotInfo.SwApp; this.modelDoc = RobotInfo.ModelDoc; this.swData = RobotInfo.SwData; this.path = path; OriginValues = new OriginPoint(); if(OriginPt != null) OriginValues.Point = GetPointFromEntity(OriginPt); }
/// <summary> /// Constructs a new IJointAxis /// </summary> /// <param name="path">Path to this joint's storage</param> /// <param name="current">The joint that this axis is contained in</param> public IJointAxis(string path, Joint current) { this.swApp = RobotInfo.SwApp; this.modelDoc = RobotInfo.ModelDoc; this.swData = RobotInfo.SwData; this.path = path; this.owner = current; this.robot = RobotInfo.Robot; if (EffortLimit == 0) { this.EffortLimit = 1; } if (Axis != null) { CalcAxisVector(); } mathUtil = (MathUtility)swApp.GetMathUtility(); }
/// <summary> /// Creates a new joint /// </summary> /// <param name="path">Path to this joint in the StorageModel</param> /// <param name="owner">The Link that owns this joint (child Link in the joint)</param> public Joint(string path, Link parent, Link child) { this.swApp = RobotInfo.SwApp; this.asmDoc = RobotInfo.AssemDoc; this.modelDoc = RobotInfo.ModelDoc; this.swData = RobotInfo.SwData; this.path = path; this.robot = RobotInfo.Robot; this.Parent = parent; Parent.ChildJoints.Add(this); this.Child = child; this.Selected = false; this.Type = JointFactory.DefaultJointType; RobotInfo.WriteToLogFile("Getting Joint Specifics (Joint)"); jointSpecifics = JointFactory.GetSpecificJoint(Type,path,this); RobotInfo.WriteToLogFile("Successfully created Joint Specifics (Joint)"); if (swData.GetDouble(path) == 0) { swData.SetDouble(path, 1); } }
/// <summary> /// Constructor /// </summary> /// <param name="swData">The storage model to store values in</param> /// <param name="path">The location of this attachment in the storage model</param> /// <param name="parentLink">The link that contains this attachment</param> protected Attachment(StorageModel swData, string path, Link parentLink) { this.SwData = swData; this.Path = path; this.ChildLink = parentLink; }
/// <summary> /// Constructor /// </summary> /// <param name="swData">Storage model that contains this array</param> /// <param name="path">Path this array will use to store data</param> public DoubleStorageArray(StorageModel swData, String path) { this.swData = swData; this.path = path; }
public MomentValues(StorageModel swData, string path) { this.swData = swData; this.path = path; }
/// <summary> /// Creates a new link belonging to the given assembly /// </summary> /// <param name="swApp">The Solidworks App</param> /// <param name="asm"> The assembly that this Link is in</param> /// <param name="swData"> The Storage model that this Link is stored in </param> /// <param name="path"> The path to the StorageModel location of this link </param> /// <param name="baseLink"> Whether this Link is the base link of the model or not </param> public Link(String path, int id) { this.Selected = false; this.asmDoc = RobotInfo.AssemDoc; this.modelDoc = RobotInfo.ModelDoc; this.swData = RobotInfo.SwData; this.path = path; this.swApp = RobotInfo.SwApp; this.Id = id; this.robot = RobotInfo.Robot; attachments = new List<Attachment>(); ParentJoints = new List<Joint>(); ChildJoints = new List<Joint>(); nextAttachmentNum = 0; nextJointNum = 0; isBaseLink = false; if (swData.GetDouble(path) == 0) { swData.SetDouble(path, 1); Name = "NewLink"; this.color = DefaultColors[0]; } attachmentNums = new DoubleStorageArray(swData, path + "/attachmentNums"); parentJointNums = new DoubleStorageArray(swData, path + "/jointNums"); ModelConfiguration physical = new ModelConfiguration(path + "/physicalComps", (int)ModelConfiguration.ModelConfigType.Physical,this); ModelConfiguration visual = new ModelConfiguration(path + "/visualComps", (int)ModelConfiguration.ModelConfigType.Visual,this); ModelConfiguration collision = new ModelConfiguration(path + "/collisionComps", (int)ModelConfiguration.ModelConfigType.Collision,this); LinkModels = new ModelConfiguration[] { physical, visual, collision }; }
/// <summary> /// Loads existing modelconfiguration from the swdata, /// or creats new one if not already existing /// </summary> /// <param name="path"></param> /// <param name="type"></param> public ModelConfiguration(String path, int type, Link owner) { //setup fields this.modelDoc = RobotInfo.ModelDoc; this.swData = RobotInfo.SwData; this.path = path; this.Type = type; this.Owner = owner; LinkComponents = new List<modelComponent>(); //If the link components data exists, load the components data LinkComponentPIDs = new StringStorageArray(swData, path + "/components"); nextComponentNumber = 0; modelComponent newComp; if (LinkComponentPIDs.Count != 0) { foreach (String s in LinkComponentPIDs) { newComp = new modelComponent(path + "/component" + nextComponentNumber); LinkComponents.Add(newComp); nextComponentNumber++; } } }
/// <summary> /// Constructor for directional attachments. Directional attachments are attachments that have a location and direction, like cameras and rangefinders /// </summary> /// <param name="swData">The storage model that will be used for storage</param> /// <param name="path">The storage path for this attachment's storage</param> /// <param name="parentLink">The link that contains this attachment</param> protected DirectionalAttachment(StorageModel swData, string path, Link parentLink) : base(swData,path,parentLink) { }
/// <summary> /// Constructor /// </summary> /// <param name="swData">Storage model</param> /// <param name="path">Path in the storage model</param> /// <param name="parentLink">Link that contains this attachment</param> public ExternalLimitSwitch(StorageModel swData, string path, Link parentLink) : base(swData, path, parentLink) { Icon = CommandManager.ExtLimitSwitchPic; Name = parentLink.Name + " " + GetName(); }
/// <summary> /// Constructor /// </summary> /// <param name="swData">Storage model</param> /// <param name="path">Path in the storage model</param> /// <param name="ChildLink">Link that contains this attachment</param> public SimpleMotor(StorageModel swData, string path, Link ChildLink) : base(swData, path, ChildLink) { Icon = CommandManager.MotorPic; Name = ChildLink.Name + " "+ GetName(); }
/// <summary> /// Constructor /// </summary> /// <param name="swData">Storage model</param> /// <param name="path">Path in the storage model</param> /// <param name="parentLink">Link that contains this attachment</param> public LimitSwitch(StorageModel swData, string path, Link parentLink) : base(swData, path, parentLink) { Icon = CommandManager.EncoderPic; }
/// <summary> /// Constructor /// </summary> /// <param name="swData">Storage model</param> /// <param name="path">Path in the storage model</param> /// <param name="ChildLink">Link that contains this attachment</param> public QuadEncoder(StorageModel swData, string path, Link ChildLink) : base(swData, path, ChildLink) { Icon = CommandManager.EncoderPic; Name = ChildLink.Name + " " + GetName(); }
/// <summary> /// Constructor /// </summary> /// <param name="swData">Storage model</param> /// <param name="path">Path in the storage model</param> /// <param name="parentLink">Link that contains this attachment</param> public Gyro(StorageModel swData, string path, Link parentLink) : base(swData, path, parentLink) { Icon = CommandManager.GyroPic; Name = parentLink.Name + " " + GetName(); }
/// <summary> /// Loads a joint that has already been created /// </summary> /// <param name="swApp">Solidworks app</param> /// <param name="asm">Assembly document this joint and its robot belong to</param> /// <param name="swData">StorageModel that this joint is tored in</param> /// <param name="path">Path to this joint in the StorageModel</param> /// <param name="robot">The Robot model that the joint is in</param> public Joint(string path) { this.swApp = RobotInfo.SwApp; this.asmDoc = RobotInfo.AssemDoc; this.modelDoc = RobotInfo.ModelDoc; this.swData = RobotInfo.SwData; this.path = path; this.robot = RobotInfo.Robot; this.Parent = robot.GetLink(parentId); Parent.ChildJoints.Add(this); this.Child = robot.GetLink(childId); this.Selected = false; if(this.Type == null || this.Type.Equals("")) this.Type = JointFactory.DefaultJointType; RobotInfo.WriteToLogFile("Loading existing joint (Joint)"); jointSpecifics = JointFactory.GetSpecificJoint(Type, path, this); if (swData.GetDouble(path) == 0) { swData.SetDouble(path, 1); } }
/// <summary> /// Loads a robot from an assembly document, if a robot dosn't already /// exist one will be created /// </summary> /// <param name="asm">Assembly document containing a robot model</param> /// <param name="swApp">Interface for interacting with Solidworks</param> public RobotModel(AssemblyDoc asm, SldWorks swApp) { RobotInfo.WriteToLogFile("Robot Created (Robot)"); var assembly = typeof(JointSpecifics).Assembly; Type[] types = assembly.GetTypes().Where( t => t.IsSubclassOf(typeof(JointSpecifics)) && !t.IsAbstract).ToArray(); foreach (Type t in types) { System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(t.TypeHandle); } RobotInfo.WriteToLogFile("Initialized JointTypes = " + String.Join(", ",JointFactory.GetTypesList()) + " (Robot)"); //Setup fields this.swApp = swApp; this.asmDoc = asm; this.modelDoc = (ModelDoc2)asm; swData = new StorageModel(modelDoc); Selected = false; RobotInfo.SetProperties(swApp, asmDoc, swData, this); RobotInfo.WriteToLogFile("Setup Fields Setup"); //If the robot data dosn't exist yet, create it with default values if (swData.GetDouble("robot") == 0) { swData.SetDouble("robot", 1); /*PhysicalConfig = "Default"; VisualConfig = "Default"; CollisionConfig = "Default";*/ Name = ((ModelDoc2)asm).GetTitle(); RobotInfo.WriteToLogFile("Robot Data created with Default Values"); } RobotInfo.WriteToLogFile("Robot Data created"); LinkNums = new DoubleStorageArray(swData, "robot/linkNums"); nextLinkNum = 0; RobotInfo.WriteToLogFile("LinkNums Storage Array Created"); Links = new Dictionary<int,Link>(); //Load link structure Link newLink; if (LinkNums.Count == 0) { LinkNums.AddItem(0); RobotInfo.WriteToLogFile("New Link added to LinkNums"); } Configuration currentConfig = modelDoc.ConfigurationManager.ActiveConfiguration; foreach (double d in LinkNums) { newLink = new Link("robot/link" + (int)d, (int)d); RobotInfo.WriteToLogFile("New Link Created"); Links.Add((int)d,newLink); if (d >= nextLinkNum) nextLinkNum = (int)d + 1; } Links[0].isBaseLink = true; foreach (Link l in Links.Values.ToArray()) { l.InitializeJoints(); l.InitializeAttachments(); } modelDoc.ShowConfiguration2(ConfigName); CalcAxisVectors(); CalcOrigin(); modelDoc.ShowConfiguration2(currentConfig.Name); }
/// <summary> /// Constructor /// </summary> /// <param name="swData">Storage model</param> /// <param name="path">Path in the storage model</param> /// <param name="ChildLink">Link that contains this attachment</param> public Potentiometer(StorageModel swData, string path, Link ChildLink) : base(swData, path, ChildLink) { Icon = CommandManager.PotPic; Name = ChildLink.Name + " " + GetName(); }
/// <summary> /// Sets the various properties of the current robot /// </summary> /// <param name="swApp">The solidworks application</param> /// <param name="asmDoc">The current assembly</param> /// <param name="swData">The current storage model</param> /// <param name="robot">the current robot</param> public static void SetProperties(SldWorks swApp, AssemblyDoc asmDoc, StorageModel swData, RobotModel robot) { SwApp = swApp; ModelDoc = (ModelDoc2)asmDoc; AssemDoc = asmDoc; SwData = swData; Robot = robot; mathUtil = SwApp.GetMathUtility(); }