public SensorListForm(SkeletalJoint_Base passJoint)
        {
            InitializeComponent();

            joint = passJoint;
            this.UpdateSensorList();
        }
        /// <summary>
        /// Update the list of joints
        /// </summary>
        private void UpdateJointList()
        {
            lstJoints.Items.Clear();

            if (nodeList == null)
            {
                return;
            }

            foreach (RigidNode_Base node in nodeList)
            {
                if (node.GetSkeletalJoint() != null)
                {
                    SkeletalJoint_Base joint = node.GetSkeletalJoint();
                    if (joint != null)
                    {
                        WheelDriverMeta wheelData = null;
                        if (joint.cDriver != null)
                        {
                            wheelData = joint.cDriver.GetInfo <WheelDriverMeta>();
                        }

                        System.Windows.Forms.ListViewItem item = new System.Windows.Forms.ListViewItem(new string[] {
                            Enum.GetName(typeof(SkeletalJointType), joint.GetJointType()).ToLowerInvariant(),
                            node.GetParent().ModelFileName,
                            node.ModelFileName, joint.cDriver != null ? joint.cDriver.ToString() : "No driver",
                            wheelData != null ? wheelData.GetTypeString() : "No Wheel",
                            joint.attachedSensors.Count.ToString()
                        });
                        item.Tag = node;
                        lstJoints.Items.Add(item);
                    }
                }
            }
        }
示例#3
0
        public EditLimits(SkeletalJoint_Base joint)
        {
            InitializeComponent();
            IEnumerator <AngularDOF> angularDOF = joint.GetAngularDOF().GetEnumerator();
            {
                int  i          = 0;
                bool hasAnother = angularDOF.MoveNext();
                while (hasAnother)
                {
                    tabDOF.TabPages.Add(new LimitPane <AngularDOF>(
                                            angularDOF.Current, "Angular" + ((hasAnother = angularDOF.MoveNext()) ? " #" + (++i) : "")));
                }
            }
            IEnumerator <LinearDOF> linearDOF = joint.GetLinearDOF().GetEnumerator();

            {
                int  i          = 0;
                bool hasAnother = linearDOF.MoveNext();
                while (hasAnother)
                {
                    tabDOF.TabPages.Add(new LimitPane <LinearDOF>(
                                            linearDOF.Current, "Linear" + ((hasAnother = linearDOF.MoveNext()) ? " #" + (++i) : "")));
                }
            }
            base.Text = joint.GetType().Name.Replace("_Base", "").Replace("Joint", " Joint");
        }
 public AdvancedJointSettingsForm(SkeletalJoint_Base passJoint)
 {
     joint = passJoint;
     InitializeComponent();
     UpdateSensorList();
     RestoreFields();
 }
示例#5
0
    /// <summary>
    /// Reads a PlanarJoint_Base from the given XmlReader.
    /// </summary>
    /// <param name="reader"></param>
    /// <returns></returns>
    private static PlanarJoint_Base ReadPlanarJoint_3_0(XmlReader reader)
    {
        // Create a new PlanarJoint_Base.
        PlanarJoint_Base planarJoint = (PlanarJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.PLANAR);

        foreach (string name in IOUtilities.AllElements(reader))
        {
            switch (name)
            {
            case "BXDVector3":
                switch (reader["VectorID"])
                {
                case "Normal":
                    // Assign the BXDVector3 to the normal.
                    planarJoint.normal = ReadBXDVector3_3_0(reader.ReadSubtree());
                    break;

                case "BasePoint":
                    // Assign the BXDVector3 to the basePoint.s
                    planarJoint.basePoint = ReadBXDVector3_3_0(reader.ReadSubtree());
                    break;
                }
                break;
            }
        }

        return(planarJoint);
    }
示例#6
0
    /// <summary>
    /// Gets the possible types of joint drivers for the given skeletal joint.
    /// </summary>
    /// <param name="joint">Skeletal joint to get allowed types for</param>
    /// <returns>Joint driver options</returns>
    public static JointDriverType[] GetAllowedDrivers(SkeletalJoint_Base joint)
    {
        switch (joint.GetJointType())
        {
        case SkeletalJointType.ROTATIONAL:
            // Pneumatic and Worm Screw map to angles
            return(new JointDriverType[] { JointDriverType.MOTOR, JointDriverType.SERVO, /* JointDriverType.BUMPER_PNEUMATIC, JointDriverType.RELAY_PNEUMATIC, JointDriverType.WORM_SCREW,*/ JointDriverType.DUAL_MOTOR });

        case SkeletalJointType.LINEAR:
            return(new JointDriverType[] { JointDriverType.ELEVATOR /*, JointDriverType.BUMPER_PNEUMATIC, JointDriverType.RELAY_PNEUMATIC, JointDriverType.WORM_SCREW*/ });

        case SkeletalJointType.CYLINDRICAL:
            return(new JointDriverType[] {    /* JointDriverType.BUMPER_PNEUMATIC, JointDriverType.RELAY_PNEUMATIC, JointDriverType.WORM_SCREW,*/
                JointDriverType.MOTOR, JointDriverType.SERVO, JointDriverType.DUAL_MOTOR
            });

        case SkeletalJointType.PLANAR:
            //Not sure of an FRC part with planar motion.  Will add later if needed.
            return(new JointDriverType[] { });

        case SkeletalJointType.BALL:
            return(new JointDriverType[] { });

        default:
            return(new JointDriverType[0]);   // Not implemented
        }
    }
示例#7
0
 /// <summary>
 /// Adds the given node as a child of this node.
 /// </summary>
 /// <param name="joint">The joint connecting this node to the child</param>
 /// <param name="child">The child node</param>
 public void AddChild(SkeletalJoint_Base joint, RigidNode_Base child)
 {
     Children.Add(joint, child);
     child.parentConnection = joint;
     child.parent           = this;
     child.level            = level + 1;
 }
示例#8
0
        public EditLimits(SkeletalJoint_Base joint)
        {
            InitializeComponent();
            IEnumerator <AngularDOF> angularDOF = joint.GetAngularDOF().GetEnumerator();
            {
                int  i          = 0;
                bool hasAnother = angularDOF.MoveNext();
                while (hasAnother)
                {
                    tabDOF.TabPages.Add(new LimitPane <AngularDOF>(
                                            angularDOF.Current, "Angular" + ((hasAnother = angularDOF.MoveNext()) ? " #" + (++i) : "")));
                }
            }
            IEnumerator <LinearDOF> linearDOF = joint.GetLinearDOF().GetEnumerator();

            {
                int  i          = 0;
                bool hasAnother = linearDOF.MoveNext();
                while (hasAnother)
                {
                    tabDOF.TabPages.Add(new LimitPane <LinearDOF>(
                                            linearDOF.Current, "Linear" + ((hasAnother = linearDOF.MoveNext()) ? " #" + (++i) : "")));
                }
            }
            base.Text = joint.GetType().Name.Replace("_Base", "").Replace("Joint", " Joint");

            FormClosing += delegate(object sender, FormClosingEventArgs e) { LegacyInterchange.LegacyEvents.OnRobotModified(); };
        }
    /// <summary>
    /// Identifies the type of a joint, creates an instance, and reads that joint from the given input stream.
    /// </summary>
    /// <param name="reader">Input stream</param>
    /// <returns>The created joint</returns>
    public static SkeletalJoint_Base ReadJointFully(System.IO.BinaryReader reader)
    {
        SkeletalJointType  type  = (SkeletalJointType)((int)reader.ReadByte());
        SkeletalJoint_Base joint = JOINT_FACTORY(type);

        joint.ReadBinaryJoint(reader);
        return(joint);
    }
示例#10
0
        public SensorListForm(SkeletalJoint_Base passJoint)
        {
            InitializeComponent();

            joint = passJoint;
            this.UpdateSensorList();
            FormClosing += delegate(object sender, FormClosingEventArgs e) { LegacyInterchange.LegacyEvents.OnRobotModified(); };
        }
示例#11
0
        public SensorListForm(SkeletalJoint_Base passJoint)
        {
            InitializeComponent();

            joint = passJoint;
            this.UpdateSensorList();

            base.Location = new System.Drawing.Point(Cursor.Position.X - 10, Cursor.Position.Y - base.Height - 10);
        }
示例#12
0
        public JointSensorEditorForm(SkeletalJoint_Base passJoint, int sourceIndex = -1)
        {
            InitializeComponent();
            AnalyticsUtils.LogPage("Advanced Joint Editor / Sensor List", "Sensor Editor");
            this.sourceIndex = sourceIndex;
            joint            = passJoint;
            typeBox.Items.Clear();
            sensorTypeOptions = RobotSensor.GetAllowedSensors(joint);
            foreach (RobotSensorType sensorType in sensorTypeOptions)
            {
                typeBox.Items.Add(char.ToUpper(Enum.GetName(typeof(RobotSensorType), sensorType).Replace('_', ' ')[0])
                                  + Enum.GetName(typeof(RobotSensorType), sensorType).Replace('_', ' ').Substring(1).ToLower());
            }
            Console.WriteLine(sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count);
            base.Text = (sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count) ? ("Editing Sensor # " + sourceIndex) : "New Sensor";
            if (sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count)
            {
                RobotSensor sensor = joint.attachedSensors[sourceIndex];
                typeBox.SelectedIndex         = Array.IndexOf(sensorTypeOptions, sensor.type);
                PortANumericUpDown.Value      = (decimal)sensor.portA;
                PortBNumericUpDown.Value      = (decimal)sensor.portB;
                ConversionNumericUpDown.Value = (decimal)sensor.conversionFactor;
            }
            switch (joint.GetJointType())
            {
            case SkeletalJointType.ROTATIONAL:
                this.ConversionLbl.Text = "Counts Per Rev";
                break;

            case SkeletalJointType.LINEAR:
                this.ConversionLbl.Text = "Counts Per Inch";
                break;

            case SkeletalJointType.CYLINDRICAL:
                this.ConversionLbl.Text = "Counts Per Rev";
                break;
            }
            if (typeBox.SelectedIndex == 0)
            {
                this.PortALbl.Enabled                = true;
                this.PortANumericUpDown.Enabled      = true;
                this.PortBLbl.Visible                = true;
                this.PortBNumericUpDown.Visible      = true;
                this.ConversionLbl.Visible           = true;
                this.ConversionNumericUpDown.Visible = true;
            }
            else
            {
                this.PortALbl.Enabled                = false;
                this.PortANumericUpDown.Enabled      = false;
                this.PortBLbl.Visible                = false;
                this.PortBNumericUpDown.Visible      = false;
                this.ConversionLbl.Visible           = false;
                this.ConversionNumericUpDown.Visible = false;
            }
        }
示例#13
0
        public JointSensorListForm(SkeletalJoint_Base passJoint)
        {
            AnalyticsUtils.LogPage("Advanced Joint Editor", "Sensor List");
            InitializeComponent();

            joint = passJoint;
            this.UpdateSensorList();

            base.Location = new System.Drawing.Point(Cursor.Position.X - 10, Cursor.Position.Y - base.Height - 10);
        }
示例#14
0
        public static string WheelTypeString(SkeletalJoint_Base joint)
        {
            WheelDriverMeta wheelData = null;

            if (joint.cDriver != null)
            {
                wheelData = joint.cDriver.GetInfo <WheelDriverMeta>();
            }

            return(wheelData != null?wheelData.GetTypeString() + ", " + WheelFrictionString(wheelData) + " Friction" : "No Wheel");
        }
示例#15
0
        public EditLimits(SkeletalJoint_Base joint)
        {
            this.joint = joint;                                                                                                    // read in the joint base so we can access the correspodinig Inventor Joint to see/ edit the limits
            InitializeComponent();
            if (!(((InventorSkeletalJoint)joint).GetWrapped().asmJoint.JointType == AssemblyJointTypeEnum.kCylindricalJointType || // if the joint is a rotational then enable the rotation stuff and disable the linear
                  ((InventorSkeletalJoint)joint).GetWrapped().asmJoint.JointType == AssemblyJointTypeEnum.kSlideJointType))
            {
                this.LinearGroup.Enabled           = false;
                this.Angular_Current_textbox.Value = (decimal)(((ModelParameter)((InventorSkeletalJoint)joint).GetWrapped().asmJoint.AngularPosition).ModelValue * (180 / Math.PI));// convert from RAD to DEG
                this.Angular_Start.Checked         = false;
                this.Angular_End.Checked           = false;
                this.Angular_Start_textbox.Enabled = false;
                this.Angular_End_textbox.Enabled   = false;
                if (((InventorSkeletalJoint)joint).GetWrapped().asmJoint.HasAngularPositionLimits)// check if the joint has limits so we know whether or not to read in the joint data from Inventor and whether or not to activate the angular limits form
                {
                    this.Angular_Start.Checked         = true;
                    this.Angular_End.Checked           = true;
                    this.Angular_Start_textbox.Enabled = true;
                    this.Angular_End_textbox.Enabled   = true;
                    this.Angular_Start_textbox.Value   = (decimal)((((ModelParameter)((InventorSkeletalJoint)joint).GetWrapped().asmJoint.AngularPositionStartLimit).ModelValue * (180 / Math.PI)));
                    this.Angular_End_textbox.Value     = (decimal)((((ModelParameter)((InventorSkeletalJoint)joint).GetWrapped().asmJoint.AngularPositionEndLimit).ModelValue * (180 / Math.PI)));
                }
            }
            else// if the joint is a linear joint then activate the linear stuff and deactivate the rotational stuff
            {
                this.Angular_Group_Box.Enabled    = false;
                this.Linear_Current_textbox.Value = (decimal)(((ModelParameter)((InventorSkeletalJoint)joint).GetWrapped().asmJoint.LinearPosition).ModelValue / 2.54);// convert from CM to IN
                this.Linear_Start.Checked         = false;
                this.Linear_End.Checked           = false;
                this.Linear_Start_textbox.Enabled = false;
                this.Linear_End_textbox.Enabled   = false;
                if (((InventorSkeletalJoint)joint).GetWrapped().asmJoint.HasLinearPositionStartLimit)// if the joint has a start limit then read it in and activate the corresponding fields
                {
                    this.Linear_Start_textbox.Value   = (decimal)((((ModelParameter)((InventorSkeletalJoint)joint).GetWrapped().asmJoint.LinearPositionStartLimit).ModelValue) / 2.54);
                    this.Linear_Start_textbox.Enabled = true;
                    this.Linear_Start.Checked         = true;
                }
                if (((InventorSkeletalJoint)joint).GetWrapped().asmJoint.HasLinearPositionEndLimit)// if the joint has an end limit then read it in and activate the corresponding fields
                {
                    this.Linear_End_textbox.Value   = (decimal)((((ModelParameter)((InventorSkeletalJoint)joint).GetWrapped().asmJoint.LinearPositionEndLimit).ModelValue) / 2.54);
                    this.Linear_End_textbox.Enabled = true;
                    this.Linear_End.Checked         = true;
                }
            }
            base.Text = joint.GetType().Name.Replace("_Base", "").Replace("Joint", " Joint");

            base.Location = new System.Drawing.Point(Cursor.Position.X - 10, Cursor.Position.Y - base.Height - 10);
        }
示例#16
0
        public static string DriveTrainSideString(SkeletalJoint_Base joint)
        {
            switch (joint.cDriver.port1)
            {
            case 0:
                return("Right");

            case 1:
                return("Left");

            case 2:
                return("Other");

            default:
                return("None");
            }
        }
示例#17
0
    /// <summary>
    /// Reads a LinearJoint_Base from the given XmlReader.
    /// </summary>
    /// <param name="reader"></param>
    /// <returns></returns>
    private static LinearJoint_Base ReadLinearJoint_3_0(XmlReader reader)
    {
        // Create a new LinearJoint_Base.
        LinearJoint_Base linearJoint = (LinearJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.LINEAR);

        foreach (string name in IOUtilities.AllElements(reader))
        {
            switch (name)
            {
            case "BXDVector3":
                switch (reader["VectorID"])
                {
                case "BasePoint":
                    // Assign the BXDVector3 to the basePoint.
                    linearJoint.basePoint = ReadBXDVector3_3_0(reader.ReadSubtree());
                    break;

                case "Axis":
                    // Assign the BXDVector3 to the axis.
                    linearJoint.axis = ReadBXDVector3_3_0(reader.ReadSubtree());
                    break;
                }
                break;

            case "LinearLowLimit":
                // Assign a value to the linearLimitLow.
                linearJoint.hasLowerLimit  = true;
                linearJoint.linearLimitLow = float.Parse(reader.ReadElementContentAsString());
                break;

            case "LinearUpperLimit":
                // Assign a value to the linearLimitHigh.
                linearJoint.hasUpperLimit   = true;
                linearJoint.linearLimitHigh = float.Parse(reader.ReadElementContentAsString());
                break;

            case "CurrentLinearPosition":
                // Assign a value to the currentLinearPosition.
                linearJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
                break;
            }
        }

        return(linearJoint);
    }
示例#18
0
    /// <summary>
    /// Reads a BallJoint_Base from the given XmlReader.
    /// </summary>
    /// <param name="reader"></param>
    /// <returns></returns>
    private static BallJoint_Base ReadBallJoint_3_0(XmlReader reader)
    {
        // Create a new BallJoint_Base.
        BallJoint_Base ballJoint = (BallJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.BALL);

        foreach (string name in IOUtilities.AllElements(reader))
        {
            switch (name)
            {
            case "BXDVector3":
                // Read the BXDVector3 as the basePoint.
                ballJoint.basePoint = ReadBXDVector3_3_0(reader.ReadSubtree());
                break;
            }
        }

        return(ballJoint);
    }
示例#19
0
    /// <summary>
    /// Reads a RotationalJoint_Base from the given XmlReader.
    /// </summary>
    /// <param name="reader"></param>
    /// <returns></returns>
    private static RotationalJoint_Base ReadRotationalJoint_3_0(XmlReader reader)
    {
        // Create a new RotationalJoint_Base.
        RotationalJoint_Base rotationalJoint = (RotationalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.ROTATIONAL);

        foreach (string name in IOUtilities.AllElements(reader))
        {
            switch (name)
            {
            case "BXDVector3":
                switch (reader["VectorID"])
                {
                case "BasePoint":
                    // Read the BXDVector3 as the basePoint.
                    rotationalJoint.basePoint = ReadBXDVector3_3_0(reader.ReadSubtree());
                    break;

                case "Axis":
                    // Read the BXDVector3 as the axis.
                    rotationalJoint.axis = ReadBXDVector3_3_0(reader.ReadSubtree());
                    break;
                }
                break;

            case "AngularLowLimit":
                // Assign the current element value to angularLimitLow.
                rotationalJoint.hasAngularLimit = true;
                rotationalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
                break;

            case "AngularHighLimit":
                // Assign the current element value to angularLimitHigh.
                rotationalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
                break;

            case "CurrentAngularPosition":
                // Assign the current element value to currentAngularPosition.
                rotationalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
                break;
            }
        }

        return(rotationalJoint);
    }
示例#20
0
        public EditSensorForm(SkeletalJoint_Base passJoint, int sourceIndex = -1)
        {
            InitializeComponent();
            this.sourceIndex = sourceIndex;
            joint            = passJoint;
            typeBox.Items.Clear();
            sensorTypeOptions = RobotSensor.GetAllowedSensors(joint);
            foreach (RobotSensorType sensorType in sensorTypeOptions)
            {
                typeBox.Items.Add(Enum.GetName(typeof(RobotSensorType), sensorType).Replace('_', ' ').ToLowerInvariant());
            }
            Console.WriteLine(sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count);
            base.Text = (sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count) ? ("Editing Sensor # " + sourceIndex) : "New Sensor";
            if (sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count)
            {
                RobotSensor sensor = joint.attachedSensors[sourceIndex];
                typeBox.SelectedIndex = Array.IndexOf(sensorTypeOptions, sensor.type);
                portTextBox.Text      = Convert.ToString(sensor.port);
                moduleTextBox.Text    = Convert.ToString(sensor.module);
                secondaryBox.Checked  = sensor.useSecondarySource;
                {
                    StringBuilder coeffTxt = new StringBuilder();
                    for (int i = sensor.equation.coeff.Length - 1; i >= 0; i--)
                    {
                        coeffTxt.Append(sensor.equation.coeff[i]);
                        if (i > 0)
                        {
                            coeffTxt.Append(",");
                        }
                    }
                    coefficentTextBox.Text = coeffTxt.ToString();
                    coefficentTextBox_TextChanged(null, null);
                }
            }

            ///Only applies to cylindrical joints.  True use secondary means to use the linear component rather than rotation.
            if (joint.GetJointType() == SkeletalJointType.CYLINDRICAL)
            {
                secondaryBox.Visible = true;
            }

            FormClosing += delegate(object sender, FormClosingEventArgs e) { LegacyInterchange.LegacyEvents.OnRobotModified(); };
        }
示例#21
0
        public void ReadJSON()
        {
            string         filePath = path + "test_export.json";
            RigidNode_Base toCreate = CreateNodeWithChild();

            BXDJSkeletonJson.WriteSkeleton(filePath, toCreate);


            RigidNode_Base created = BXDJSkeletonJson.ReadSkeleton(filePath);


            Assert.AreEqual(toCreate.GUID, created.GUID);
            Assert.AreEqual(toCreate.Children.Count, created.Children.Count);

            SkeletalJoint_Base firstJointtoCreate = toCreate.Children.Keys.First <SkeletalJoint_Base>();
            SkeletalJoint_Base firstJointCreated  = created.Children.Keys.First <SkeletalJoint_Base>();

            Assert.AreEqual(
                toCreate.Children[firstJointtoCreate].GetSkeletalJoint().GetJointType(),
                created.Children[firstJointCreated].GetSkeletalJoint().GetJointType()
                );
        }
示例#22
0
        /// <summary>
        /// Update the list of joints
        /// </summary>
        private void UpdateJointList()
        {
            lstJoints.Items.Clear();

            if (nodeList == null)
            {
                return;
            }

            foreach (RigidNode_Base node in nodeList)
            {
                if (node.GetSkeletalJoint() != null)
                {
                    SkeletalJoint_Base joint = node.GetSkeletalJoint();
                    if (joint != null)
                    {
                        WheelDriverMeta wheelData = null;
                        if (joint.cDriver != null)
                        {
                            wheelData = joint.cDriver.GetInfo <WheelDriverMeta>();
                        }

                        ListViewItem item = new ListViewItem(new string[] {
                            Utilities.CapitalizeFirstLetter(Enum.GetName(typeof(SkeletalJointType), joint.GetJointType()), true),
                            Utilities.CapitalizeFirstLetter(node.GetParent().ModelFileName.Replace('_', ' ').Replace(".bxda", "")),
                            Utilities.CapitalizeFirstLetter(node.ModelFileName.Replace('_', ' ').Replace(".bxda", "")),
                            joint.cDriver != null ? joint.cDriver.ToString() : "No Driver",
                            wheelData != null ? wheelData.GetTypeString() : "No Wheel",
                            joint.attachedSensors.Count.ToString()
                        })
                        {
                            Tag = node
                        };
                        lstJoints.Items.Add(item);
                    }
                }
            }
        }
示例#23
0
    /// <summary>
    /// Writes the backing information and ID for this joint with the given XmlWriter.
    /// </summary>
    /// <param name="joint"></param>
    /// <param name="writer"></param>
    private static void WriteJoint(SkeletalJoint_Base joint, XmlWriter writer)
    {
        switch (joint.GetJointType())
        {
        case SkeletalJointType.BALL:
            WriteBallJoint((BallJoint_Base)joint, writer);
            break;

        case SkeletalJointType.CYLINDRICAL:
            WriteCylindricalJoint((CylindricalJoint_Base)joint, writer);
            break;

        case SkeletalJointType.LINEAR:
            WriteLinearJoint((LinearJoint_Base)joint, writer);
            break;

        case SkeletalJointType.PLANAR:
            WritePlanarJoint((PlanarJoint_Base)joint, writer);
            break;

        case SkeletalJointType.ROTATIONAL:
            WriteRotationalJoint((RotationalJoint_Base)joint, writer);
            break;

        default:
            throw new Exception("Could not determine type of joint");
        }

        if (joint.cDriver != null)
        {
            WriteJointDriver(joint.cDriver, writer);
        }

        for (int i = 0; i < joint.attachedSensors.Count; i++)
        {
            WriteRobotSensor(joint.attachedSensors[i], writer);
        }
    }
示例#24
0
    public static RobotSensorType[] GetAllowedSensors(SkeletalJoint_Base joint)
    {
        switch (joint.GetJointType())
        {
        case SkeletalJointType.ROTATIONAL:
            return(new RobotSensorType[] { RobotSensorType.ENCODER, RobotSensorType.POTENTIOMETER, RobotSensorType.LIMIT });

        case SkeletalJointType.LINEAR:
            return(new RobotSensorType[] { RobotSensorType.LIMIT });

        case SkeletalJointType.CYLINDRICAL:
            return(new RobotSensorType[] { RobotSensorType.ENCODER, RobotSensorType.POTENTIOMETER, RobotSensorType.LIMIT });

        case SkeletalJointType.PLANAR:
            return(new RobotSensorType[] { });

        case SkeletalJointType.BALL:
            return(new RobotSensorType[] { });

        default:
            return(new RobotSensorType[0]);   // Not implemented
        }
    }
示例#25
0
    /// <summary>
    /// Reads a CylindricalJoint_Base from the given XmlReader.
    /// </summary>
    /// <param name="reader"></param>
    /// <returns></returns>
    private static CylindricalJoint_Base ReadCylindricalJoint_3_0(XmlReader reader)
    {
        // Create a new CylindricalJoint_Base.
        CylindricalJoint_Base cylindricalJoint = (CylindricalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.CYLINDRICAL);

        foreach (string name in IOUtilities.AllElements(reader))
        {
            switch (name)
            {
            case "BXDVector3":
                switch (reader["VectorID"])
                {
                case "BasePoint":
                    // Assign the BXDVector3 to the basePoint.
                    cylindricalJoint.basePoint = ReadBXDVector3_3_0(reader.ReadSubtree());
                    break;

                case "Axis":
                    // Assign the BXDVector3 to the axis.
                    cylindricalJoint.axis = ReadBXDVector3_3_0(reader.ReadSubtree());
                    break;
                }
                break;

            case "AngularLowLimit":
                // Assign a value to the angularLimitLow.
                cylindricalJoint.hasAngularLimit = true;
                cylindricalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
                break;

            case "AngularHighLimit":
                // Assign a value to the angularLimitHigh.
                cylindricalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
                break;

            case "LinearStartLimit":
                // Assign a value to the linearLimitStart.
                cylindricalJoint.hasLinearStartLimit = true;
                cylindricalJoint.linearLimitStart    = float.Parse(reader.ReadElementContentAsString());
                break;

            case "LinearEndLimit":
                // Assign a value to the linearLimitEnd.
                cylindricalJoint.hasLinearEndLimit = true;
                cylindricalJoint.linearLimitEnd    = float.Parse(reader.ReadElementContentAsString());
                break;

            case "CurrentLinearPosition":
                // Assign a value to the currentLinearPosition.
                cylindricalJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
                break;

            case "CurrentAngularPosition":
                // Assign a value to the currentAngularPosition.
                cylindricalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
                break;
            }
        }

        return(cylindricalJoint);
    }
示例#26
0
    public void ShowDialog(SkeletalJoint_Base baseJoint, List <RigidNode_Base> nodes, Form owner)
    {
        Saved = false;

        if (nodes.Count > 1)
        {
            bool same = true;

            foreach (RigidNode_Base node in nodes)
            {
                JointDriver driver = node.GetSkeletalJoint().cDriver;
                if (driver == null || driver.CompareTo(baseJoint.cDriver) != 0)
                {
                    same = false;
                }
            }

            if (same)
            {
                joint = baseJoint;
            }
            else
            {
                joint = SkeletalJoint_Base.JOINT_FACTORY(baseJoint.GetJointType());
            }
        }
        else
        {
            joint = baseJoint;
        }
        this.nodes  = nodes;
        typeOptions = JointDriver.GetAllowedDrivers(joint);

        cmbJointDriver.Items.Clear();
        cmbJointDriver.Items.Add("No Driver");
        foreach (JointDriverType type in typeOptions)
        {
            cmbJointDriver.Items.Add(Enum.GetName(typeof(JointDriverType), type).Replace('_', ' ').ToLowerInvariant());
        }
        if (joint.cDriver != null)
        {
            cmbJointDriver.SelectedIndex = Array.IndexOf(typeOptions, joint.cDriver.GetDriveType()) + 1;
            txtPortA.Value     = joint.cDriver.portA;
            txtPortB.Value     = joint.cDriver.portB;
            txtLowLimit.Value  = (decimal)joint.cDriver.lowerLimit;
            txtHighLimit.Value = (decimal)joint.cDriver.upperLimit;

            #region Meta info recovery
            {
                PneumaticDriverMeta pneumaticMeta = joint.cDriver.GetInfo <PneumaticDriverMeta>();
                if (pneumaticMeta != null)
                {
                    cmbPneumaticDiameter.SelectedIndex = (byte)pneumaticMeta.widthEnum;
                    cmbPneumaticPressure.SelectedIndex = (byte)pneumaticMeta.pressureEnum;
                }
                else
                {
                    cmbPneumaticDiameter.SelectedIndex = (byte)PneumaticDiameter.MEDIUM;
                    cmbPneumaticPressure.SelectedIndex = (byte)PneumaticPressure.HIGH;
                }
            }
            {
                WheelDriverMeta wheelMeta = joint.cDriver.GetInfo <WheelDriverMeta>();
                if (wheelMeta != null)
                {
                    try
                    {
                        // TODO:  This is a really sketchy hack and I don't even know where the cat is.
                        cmbWheelType.SelectedIndex = (byte)wheelMeta.type;
                        if (wheelMeta.forwardExtremeValue > 8)
                        {
                            cmbFrictionLevel.SelectedIndex = (byte)FrictionLevel.HIGH;
                        }
                        else if (wheelMeta.forwardExtremeValue > 4)
                        {
                            cmbFrictionLevel.SelectedIndex = (byte)FrictionLevel.MEDIUM;
                        }
                        else
                        {
                            cmbFrictionLevel.SelectedIndex = (byte)FrictionLevel.LOW;
                        }
                    }
                    catch
                    {
                        // If an exception was thrown (System.ArguementOutOfRangeException) it means
                        // the user did not choose a wheel type when they were configuring the
                        // wheel joint
                        cmbWheelType.SelectedIndex     = (byte)WheelType.NORMAL;
                        cmbFrictionLevel.SelectedIndex = (byte)FrictionLevel.MEDIUM;
                    }

                    chkBoxDriveWheel.Checked = wheelMeta.isDriveWheel;
                    cmbWheelType_SelectedIndexChanged(null, null);
                }
                else
                {
                    cmbWheelType.SelectedIndex     = (byte)WheelType.NOT_A_WHEEL;
                    cmbFrictionLevel.SelectedIndex = (byte)FrictionLevel.MEDIUM;
                }
            }
            {
                ElevatorDriverMeta elevatorMeta = joint.cDriver.GetInfo <ElevatorDriverMeta>();
                if (elevatorMeta != null)
                {
                    cmbStages.SelectedIndex = (byte)elevatorMeta.type;
                }
            }
            #endregion
        }
        else //Default values
        {
            cmbJointDriver.SelectedIndex = 0;
            txtPortA.Value     = txtPortA.Minimum;
            txtPortB.Value     = txtPortB.Minimum;
            txtLowLimit.Value  = txtLowLimit.Minimum;
            txtHighLimit.Value = txtHighLimit.Minimum;

            cmbPneumaticDiameter.SelectedIndex = (byte)PneumaticDiameter.MEDIUM;
            cmbPneumaticPressure.SelectedIndex = (byte)PneumaticPressure.MEDIUM;

            cmbWheelType.SelectedIndex     = (byte)WheelType.NOT_A_WHEEL;
            cmbFrictionLevel.SelectedIndex = (byte)FrictionLevel.MEDIUM;
            chkBoxDriveWheel.Checked       = false;

            cmbStages.SelectedIndex = (byte)ElevatorType.NOT_MULTI;
        }
        PerformLayout();
        this.ShowDialog(owner);
    }
示例#27
0
    public void ShowDialog(SkeletalJoint_Base baseJoint, List <RigidNode_Base> nodes, Form owner)
    {
        Saved = false;

        if (nodes.Count > 1)
        {
            bool same = true;

            foreach (RigidNode_Base node in nodes)
            {
                JointDriver driver = node.GetSkeletalJoint().cDriver;
                if (driver == null || driver.CompareTo(baseJoint.cDriver) != 0)
                {
                    same = false;
                }
            }

            if (same)
            {
                joint = baseJoint;
            }
            else
            {
                joint = SkeletalJoint_Base.JOINT_FACTORY(baseJoint.GetJointType());
            }
        }
        else
        {
            joint = baseJoint;
        }
        this.nodes  = nodes;
        typeOptions = JointDriver.GetAllowedDrivers(joint);

        // Used for capitalization
        TextInfo textInfo = new CultureInfo("en-US", true).TextInfo;

        cmbJointDriver.Items.Clear();
        cmbJointDriver.Items.Add("No Driver");
        foreach (JointDriverType type in typeOptions)
        {
            cmbJointDriver.Items.Add(textInfo.ToTitleCase(Enum.GetName(typeof(JointDriverType), type).Replace('_', ' ').ToLowerInvariant()));
        }
        if (joint.cDriver != null)
        {
            cmbJointDriver.SelectedIndex = Array.IndexOf(typeOptions, joint.cDriver.GetDriveType()) + 1;

            if (joint.cDriver.port1 < txtPort1.Minimum)
            {
                txtPort1.Value = txtPort1.Minimum;
            }
            else if (joint.cDriver.port1 > txtPort1.Maximum)
            {
                txtPort1.Value = txtPort1.Maximum;
            }
            else
            {
                txtPort1.Value = joint.cDriver.port1;
            }

            if (joint.cDriver.port2 < txtPort2.Minimum)
            {
                txtPort2.Value = txtPort2.Minimum;
            }
            else if (joint.cDriver.port2 > txtPort2.Maximum)
            {
                txtPort2.Value = txtPort2.Maximum;
            }
            else
            {
                txtPort2.Value = joint.cDriver.port2;
            }

            txtLowLimit.Value  = (decimal)joint.cDriver.lowerLimit;
            txtHighLimit.Value = (decimal)joint.cDriver.upperLimit;

            rbPWM.Checked          = !joint.cDriver.isCan;
            rbCAN.Checked          = joint.cDriver.isCan;
            chkBoxHasBrake.Checked = joint.cDriver.hasBrake;
            if (joint.cDriver.OutputGear == 0)    // prevents output gear from being 0
            {
                joint.cDriver.OutputGear = 1;
            }
            if (joint.cDriver.InputGear == 0)// prevents input gear from being 0
            {
                joint.cDriver.InputGear = 1;
            }
            OutputGeartxt.Value = (decimal)joint.cDriver.OutputGear; // reads the existing gearing and writes it to the input field so the user sees their existing value
            InputGeartxt.Value  = (decimal)joint.cDriver.InputGear;  // reads the existing gearing and writes it to the input field so the user sees their existing value

            #region Meta info recovery
            {
                PneumaticDriverMeta pneumaticMeta = joint.cDriver.GetInfo <PneumaticDriverMeta>();
                if (pneumaticMeta != null)
                {
                    cmbPneumaticDiameter.SelectedIndex = (int)pneumaticMeta.widthEnum;
                    cmbPneumaticPressure.SelectedIndex = (int)pneumaticMeta.pressureEnum;
                }
                else
                {
                    cmbPneumaticDiameter.SelectedIndex = (int)PneumaticDiameter.MEDIUM;
                    cmbPneumaticPressure.SelectedIndex = (int)PneumaticPressure.HIGH;
                }
            }
            {
                WheelDriverMeta wheelMeta = joint.cDriver.GetInfo <WheelDriverMeta>();
                if (wheelMeta != null)
                {
                    try
                    {
                        cmbWheelType.SelectedIndex     = (int)wheelMeta.type;
                        cmbFrictionLevel.SelectedIndex = (int)wheelMeta.GetFrictionLevel();
                    }
                    catch
                    {
                        // If an exception was thrown (System.ArguementOutOfRangeException) it means
                        // the user did not choose a wheel type when they were configuring the
                        // wheel joint
                        cmbWheelType.SelectedIndex     = (int)WheelType.NORMAL;
                        cmbFrictionLevel.SelectedIndex = (int)FrictionLevel.MEDIUM;
                    }

                    chkBoxDriveWheel.Checked = wheelMeta.isDriveWheel;
                    cmbWheelType_SelectedIndexChanged(null, null);
                }
                else
                {
                    cmbWheelType.SelectedIndex     = (int)WheelType.NOT_A_WHEEL;
                    cmbFrictionLevel.SelectedIndex = (int)FrictionLevel.MEDIUM;
                }
            }
            {
                ElevatorDriverMeta elevatorMeta = joint.cDriver.GetInfo <ElevatorDriverMeta>();
            }
            #endregion
        }
        else //Default values
        {
            cmbJointDriver.SelectedIndex = 0;
            txtPort1.Value      = txtPort1.Minimum;
            txtPort2.Value      = txtPort2.Minimum;
            txtLowLimit.Value   = txtLowLimit.Minimum;
            txtHighLimit.Value  = txtHighLimit.Minimum;
            InputGeartxt.Value  = (decimal)1.0;
            OutputGeartxt.Value = (decimal)1.0;

            rbPWM.Checked = true;

            chkBoxHasBrake.Checked = false;

            cmbPneumaticDiameter.SelectedIndex = (int)PneumaticDiameter.MEDIUM;
            cmbPneumaticPressure.SelectedIndex = (int)PneumaticPressure.MEDIUM;

            cmbWheelType.SelectedIndex     = (int)WheelType.NOT_A_WHEEL;
            cmbFrictionLevel.SelectedIndex = (int)FrictionLevel.MEDIUM;
            chkBoxDriveWheel.Checked       = false;
        }

        PrepLayout();
        base.Location = new System.Drawing.Point(Cursor.Position.X - 10, Cursor.Position.Y - base.Height - 10);
        this.ShowDialog(owner);
    }
示例#28
0
        /// <summary>
        /// Merges any groups that are connected only with constraints and generate a node tree.
        /// </summary>
        /// <remarks>
        /// This starts at whichever rigid group is grounded, then branches out along rigid joints from there.
        /// If the rigid joint is movable (made of assembly joint(s)) then another node is created, if the joint
        /// is constraint-only then the leaf node is merged into the current branch.
        /// </remarks>
        /// <param name="results">Rigid results to clean</param>
        public static RigidNode BuildAndCleanDijkstra(CustomRigidResults results)
        {
            Dictionary <CustomRigidGroup, HashSet <CustomRigidGroup> > constraints = new Dictionary <CustomRigidGroup, HashSet <CustomRigidGroup> >();
            Dictionary <CustomRigidGroup, HashSet <CustomRigidGroup> > joints      = new Dictionary <CustomRigidGroup, HashSet <CustomRigidGroup> >();

            GenerateJointMaps(results, joints, constraints);

            // Mapping rigid group to merge-into group
            Dictionary <CustomRigidGroup, CustomRigidGroup> mergePattern = new Dictionary <CustomRigidGroup, CustomRigidGroup>();
            // Mapping rigid group to skeletal node
            Dictionary <CustomRigidGroup, RigidNode> baseNodes = new Dictionary <CustomRigidGroup, RigidNode>();
            // Deffered joint creation.  Required so merge can take place.
            List <PlannedJoint> plannedJoints = new List <PlannedJoint>();
            // The base of the skeletal tree
            RigidNode baseRoot = null;

            // All the currently open groups as an array {currentGroup, mergeIntoGroup}
            List <CustomRigidGroup[]> openNodes = new List <CustomRigidGroup[]>();
            // All the groups that have been processed.  (Closed nodes)
            HashSet <CustomRigidGroup> closedNodes = new HashSet <CustomRigidGroup>();

            // Find the first grounded group, the start point for dijkstra's algorithm.
            foreach (CustomRigidGroup grp in results.groups)
            {
                if (grp.grounded)
                {
                    openNodes.Add(new CustomRigidGroup[] { grp, grp });
                    closedNodes.Add(grp);
                    baseNodes.Add(grp, baseRoot = new RigidNode(Guid.NewGuid(), grp));
                    break; //Should only contain one grounded group, as they have all been merged together.
                }
            }
            Console.WriteLine("Determining merge commands");
            while (openNodes.Count > 0)
            {
                List <CustomRigidGroup[]> newOpen = new List <CustomRigidGroup[]>();
                foreach (CustomRigidGroup[] node in openNodes)
                {
                    // Get all connections
                    HashSet <CustomRigidGroup> cons = constraints[node[0]];
                    HashSet <CustomRigidGroup> jons = joints[node[0]];
                    foreach (CustomRigidGroup jonConn in jons)
                    {
                        if (!closedNodes.Add(jonConn)) //Moves on to next if the connected component is already in closedNodes.
                        {
                            continue;
                        }
                        RigidNode rnode = new RigidNode(Guid.NewGuid(), jonConn); //Makes a new rigid node for the connected component.
                        baseNodes.Add(jonConn, rnode);

                        //Find the actual joint between the two components.
                        foreach (CustomRigidJoint jnt in results.joints)
                        {
                            if (jnt.joints.Count > 0 && ((jnt.groupOne.Equals(jonConn) && jnt.groupTwo.Equals(node[0])) ||
                                                         (jnt.groupOne.Equals(node[0]) && jnt.groupTwo.Equals(jonConn))))
                            {
                                PlannedJoint pJoint = new PlannedJoint();
                                pJoint.joint      = jnt;
                                pJoint.parentNode = baseNodes[node[1]];
                                pJoint.node       = rnode;
                                plannedJoints.Add(pJoint);
                                newOpen.Add(new CustomRigidGroup[] { jonConn, jonConn });
                                break;
                            }
                        }
                    }
                    foreach (CustomRigidGroup consConn in cons)
                    {
                        if (!closedNodes.Add(consConn))
                        {
                            continue;
                        }
                        mergePattern.Add(consConn, node[1]);
                        newOpen.Add(new CustomRigidGroup[] { consConn, node[1] }); //Uses node[1] to ensure all constrained groups are merged into the same group.
                    }
                }
                openNodes = newOpen;
            }

            Console.WriteLine("Do " + mergePattern.Count + " merge commands");
            //Transfers components between constrained groups.
            foreach (KeyValuePair <CustomRigidGroup, CustomRigidGroup> pair in mergePattern)
            {
                pair.Value.occurrences.AddRange(pair.Key.occurrences);          //Transfers key components to related value.
                pair.Key.occurrences.Clear();
                pair.Value.grounded = pair.Value.grounded || pair.Key.grounded; //Is it possible for the key to be grounded?  Would there have to be a loop of groups?
            }
            Console.WriteLine("Resolve broken joints");
            //Goes through each joint and sees if it was merged.  If it was, it attaches the group left behind to the group that was merged into.
            foreach (CustomRigidJoint joint in results.joints)
            {
                CustomRigidGroup updatedGroup = null; //Stores the group that the previous groupOne/Two was merged into.
                if (mergePattern.TryGetValue(joint.groupOne, out updatedGroup))
                {
                    joint.groupOne = updatedGroup;
                }
                if (mergePattern.TryGetValue(joint.groupTwo, out updatedGroup))
                {
                    joint.groupTwo = updatedGroup;
                }
            }
            Console.WriteLine("Creating planned skeletal joints");
            foreach (PlannedJoint pJoint in plannedJoints)
            {
                SkeletalJoint_Base sJ = SkeletalJoint.Create(pJoint.joint, pJoint.parentNode.group);
                pJoint.parentNode.AddChild(sJ, pJoint.node);
            }
            Console.WriteLine("Cleanup remainders");
            CleanMeaningless(results);
            return(baseRoot);
        }
示例#29
0
    /// <summary>
    /// Reads the skeleton contained in the BXDJ file specified and returns the root node for that skeleton.
    /// </summary>
    /// <param name="path">The input BXDJ file</param>
    /// <returns>The root node of the skeleton</returns>
    public static RigidNode_Base ReadBinarySkeleton(string path)
    {
        BinaryReader reader = null;

        try
        {
            reader = new BinaryReader(new FileStream(path, FileMode.Open)); //Throws IOException
            // Sanity check
            uint version = reader.ReadUInt32();
            BXDIO.CheckReadVersion(version); //Throws FormatException

            int nodeCount = reader.ReadInt32();
            if (nodeCount <= 0)
            {
                throw new Exception("This appears to be an empty skeleton");
            }

            RigidNode_Base   root  = null;
            RigidNode_Base[] nodes = new RigidNode_Base[nodeCount];

            for (int i = 0; i < nodeCount; i++)
            {
                //nodes[i] = RigidNode_Base.NODE_FACTORY();

                int parent = reader.ReadInt32();
                nodes[i].ModelFileName = (reader.ReadString());
                nodes[i].ModelFullID   = (reader.ReadString());

                if (parent != -1)
                {
                    SkeletalJoint_Base joint = SkeletalJoint_Base.ReadJointFully(reader);
                    nodes[parent].AddChild(joint, nodes[i]);
                }
                else
                {
                    root = nodes[i];
                }
            }

            if (root == null)
            {
                throw new Exception("This skeleton has no known base.  \"" + path + "\" is probably corrupted.");
            }

            return(root);
        }
        catch (FormatException fe)
        {
            Console.WriteLine("File version mismatch");
            Console.WriteLine(fe);
            return(null);
        }
        catch (IOException ie)
        {
            Console.WriteLine("Could not open skeleton file");
            Console.WriteLine(ie);
            return(null);
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            return(null);
        }
        finally
        {
            if (reader != null)
            {
                reader.Close();
            }
        }
    }
示例#30
0
        public void ShowDialog(SkeletalJoint_Base baseJoint, List <RigidNode_Base> nodes, Form owner)
        {
            Saved = false;

            if (nodes.Count > 1)
            {
                bool same = true;

                foreach (RigidNode_Base node in nodes)
                {
                    JointDriver driver = node.GetSkeletalJoint().cDriver;
                    if (driver == null || driver.CompareTo(baseJoint.cDriver) != 0)
                    {
                        same = false;
                    }
                }

                if (same)
                {
                    joint = baseJoint;
                }
                else
                {
                    joint = SkeletalJoint_Base.JOINT_FACTORY(baseJoint.GetJointType());
                }
            }
            else
            {
                joint = baseJoint;
            }
            this.nodes  = nodes;
            typeOptions = JointDriver.GetAllowedDrivers(joint);

            // Used for capitalization
            TextInfo textInfo = new CultureInfo("en-US", true).TextInfo;

            cmbJointDriver.Items.Clear();
            cmbJointDriver.Items.Add("No Driver");
            foreach (JointDriverType type in typeOptions)
            {
                cmbJointDriver.Items.Add(textInfo.ToTitleCase(Enum.GetName(typeof(JointDriverType), type).Replace('_', ' ').ToLowerInvariant()));
            }
            if (joint.cDriver != null)
            {
                cmbJointDriver.SelectedIndex = Array.IndexOf(typeOptions, joint.cDriver.GetDriveType()) + 1;

                if (joint.cDriver.port1 < txtPort1.Minimum)
                {
                    txtPort1.Value = txtPort1.Minimum;
                }
                else if (joint.cDriver.port1 > txtPort1.Maximum)
                {
                    txtPort1.Value = txtPort1.Maximum;
                }
                else
                {
                    txtPort1.Value = joint.cDriver.port1;
                }

                if (joint.cDriver.port2 < txtPort2.Minimum)
                {
                    txtPort2.Value = txtPort2.Minimum;
                }
                else if (joint.cDriver.port2 > txtPort2.Maximum)
                {
                    txtPort2.Value = txtPort2.Maximum;
                }
                else
                {
                    txtPort2.Value = joint.cDriver.port2;
                }

                txtLowLimit.Value  = (decimal)joint.cDriver.lowerLimit;
                txtHighLimit.Value = (decimal)joint.cDriver.upperLimit;

                rbPWM.Checked          = !joint.cDriver.isCan;
                rbCAN.Checked          = joint.cDriver.isCan;
                chkBoxHasBrake.Checked = joint.cDriver.hasBrake;
                if (joint.cDriver.OutputGear == 0)// prevents output gear from being 0
                {
                    joint.cDriver.OutputGear = 1;
                }
                if (joint.cDriver.InputGear == 0)// prevents input gear from being 0
                {
                    joint.cDriver.InputGear = 1;
                }
                OutputGeartxt.Value = (decimal)joint.cDriver.OutputGear; // reads the existing gearing and writes it to the input field so the user sees their existing value
                InputGeartxt.Value  = (decimal)joint.cDriver.InputGear;  // reads the existing gearing and writes it to the input field so the user sees their existing value

                {
                    PneumaticDriverMeta pneumaticMeta = joint.cDriver.GetInfo <PneumaticDriverMeta>();
                    if (pneumaticMeta != null)
                    {
                        numericUpDownPnuDia.Value          = (decimal)pneumaticMeta.width;
                        cmbPneumaticPressure.SelectedIndex = (int)pneumaticMeta.pressureEnum;
                    }
                    else
                    {
                        numericUpDownPnuDia.Value          = (decimal)1.0;
                        cmbPneumaticPressure.SelectedIndex = (int)PneumaticPressure.HIGH;
                    }
                }
                {
                    WheelDriverMeta wheelMeta = joint.cDriver.GetInfo <WheelDriverMeta>();
                    if (wheelMeta != null)
                    {
                        try
                        {
                            cmbWheelType.SelectedIndex     = (int)wheelMeta.type;
                            cmbFrictionLevel.SelectedIndex = (int)wheelMeta.GetFrictionLevel();
                        }
                        catch
                        {
                            // If an exception was thrown (System.ArguementOutOfRangeException) it means
                            // the user did not choose a wheel type when they were configuring the
                            // wheel joint
                            cmbWheelType.SelectedIndex     = (int)WheelType.NORMAL;
                            cmbFrictionLevel.SelectedIndex = (int)FrictionLevel.MEDIUM;
                        }

                        chkBoxDriveWheel.Checked = wheelMeta.isDriveWheel;
                        cmbWheelType_SelectedIndexChanged(null, null);
                    }
                    else
                    {
                        cmbWheelType.SelectedIndex     = (int)WheelType.NOT_A_WHEEL;
                        cmbFrictionLevel.SelectedIndex = (int)FrictionLevel.MEDIUM;
                    }
                }
                {
                    ElevatorDriverMeta elevatorMeta = joint.cDriver.GetInfo <ElevatorDriverMeta>();
                }
                {
                    switch (joint.cDriver.motor)
                    {
                    case MotorType.GENERIC:
                        RobotCompetitionDropDown.SelectedItem = RobotExporterAddInServer.Instance.AddInSettingsManager.DefaultRobotCompetition.ToString();
                        MotorTypeDropDown.SelectedItem        = "GENERIC";
                        break;

                    case MotorType.CIM:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "CIM";
                        break;

                    case MotorType.MINI_CIM:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "MIN_CIM";
                        break;

                    case MotorType.BAG_MOTOR:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "BAG_MOTOR";
                        break;

                    case MotorType.REDLINE_775_PRO:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "REDLINE_775_PRO";
                        break;

                    case MotorType.ANDYMARK_9015:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "ANDYMARK_9015";
                        break;

                    case MotorType.BANEBOTS_775_18v:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "BANEBOTS_775_18v";
                        break;

                    case MotorType.BANEBOTS_775_12v:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "BANEBOTS_775_12v";
                        break;

                    case MotorType.BANEBOTS_550_12v:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "BANEBOTS_550_12v";
                        break;

                    case MotorType.ANDYMARK_775_125:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "ANDYMARK_775_125";
                        break;

                    case MotorType.SNOW_BLOWER:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "SNOW_BLOWER";
                        break;

                    case MotorType.NIDEC_BLDC:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "NIDEC_BLDC";
                        break;

                    case MotorType.THROTTLE_MOTOR:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "THROTTLE_MOTOR";
                        break;

                    case MotorType.WINDOW_MOTOR:
                        RobotCompetitionDropDown.SelectedItem = "FRC";
                        MotorTypeDropDown.SelectedItem        = "WINDOW_MOTOR";
                        break;

                    case MotorType.NEVEREST:
                        RobotCompetitionDropDown.SelectedItem = "FTC";
                        MotorTypeDropDown.SelectedItem        = "NEVEREST";
                        break;

                    case MotorType.TETRIX_MOTOR:
                        RobotCompetitionDropDown.SelectedItem = "FTC";
                        MotorTypeDropDown.SelectedItem        = "TETRIX_MOTOR";
                        break;

                    case MotorType.MODERN_ROBOTICS_MATRIX:
                        RobotCompetitionDropDown.SelectedItem = "FTC";
                        MotorTypeDropDown.SelectedItem        = "MODERN_ROBOTICS_MATRIX";
                        break;

                    case MotorType.REV_ROBOTICS_HD_HEX_20_TO_1:
                        RobotCompetitionDropDown.SelectedItem = "FTC";
                        MotorTypeDropDown.SelectedItem        = "REV_ROBOTICS_HD_HEX_20_TO_1";
                        break;

                    case MotorType.REV_ROBOTICS_HD_HEX_40_TO_1:
                        RobotCompetitionDropDown.SelectedItem = "FTC";
                        MotorTypeDropDown.SelectedItem        = "REV_ROBOTICS_HD_HEX_40_TO_1";
                        break;

                    case MotorType.REV_ROBOTICS_CORE_HEX:
                        RobotCompetitionDropDown.SelectedItem = "FTC";
                        MotorTypeDropDown.SelectedItem        = "REV_ROBOTICS_CORE_HEX";
                        break;

                    case MotorType.VEX_V5_Smart_Motor_600_RPM:
                        RobotCompetitionDropDown.SelectedItem = "VEX";
                        MotorTypeDropDown.SelectedItem        = "VEX_V5_Smart_Motor_600_RPM";
                        break;

                    case MotorType.VEX_V5_Smart_Motor_200_RPM:
                        RobotCompetitionDropDown.SelectedItem = "VEX";
                        MotorTypeDropDown.SelectedItem        = "VEX_V5_Smart_Motor_200_RPM";
                        break;

                    case MotorType.VEX_V5_Smart_Motor_100_RPM:
                        RobotCompetitionDropDown.SelectedItem = "VEX";
                        MotorTypeDropDown.SelectedItem        = "VEX_V5_Smart_Motor_100_RPM";
                        break;

                    case MotorType.VEX_393_NORMAL_SPEED:
                        RobotCompetitionDropDown.SelectedItem = "VEX";
                        MotorTypeDropDown.SelectedItem        = "VEX_393_NORMAL_SPEED";
                        break;

                    case MotorType.VEX_393_HIGH_SPEED:
                        RobotCompetitionDropDown.SelectedItem = "VEX";
                        MotorTypeDropDown.SelectedItem        = "VEX_393_HIGH_SPEED";
                        break;

                    case MotorType.VEX_393_TURBO_GEAR_SET:
                        RobotCompetitionDropDown.SelectedItem = "VEX";
                        MotorTypeDropDown.SelectedItem        = "VEX_393_TURBO_GEAR_SET";
                        break;
                    }
                }
            }
            else //Default values
            {
                cmbJointDriver.SelectedIndex = 0;
                txtPort1.Value      = txtPort1.Minimum;
                txtPort2.Value      = txtPort2.Minimum;
                txtLowLimit.Value   = txtLowLimit.Minimum;
                txtHighLimit.Value  = txtHighLimit.Minimum;
                InputGeartxt.Value  = (decimal)1.0;
                OutputGeartxt.Value = (decimal)1.0;

                rbPWM.Checked = true;

                chkBoxHasBrake.Checked = false;

                numericUpDownPnuDia.Value          = (decimal)0.5;
                cmbPneumaticPressure.SelectedIndex = (int)PneumaticPressure.MEDIUM;

                cmbWheelType.SelectedIndex     = (int)WheelType.NOT_A_WHEEL;
                cmbFrictionLevel.SelectedIndex = (int)FrictionLevel.MEDIUM;
                chkBoxDriveWheel.Checked       = false;

                RobotCompetitionDropDown.SelectedItem = RobotExporterAddInServer.Instance.AddInSettingsManager.DefaultRobotCompetition;
                MotorTypeDropDown.SelectedItem        = "GENERIC";
            }

            PrepLayout();
            base.Location = new System.Drawing.Point(Cursor.Position.X - 10, Cursor.Position.Y - base.Height - 10);
            this.ShowDialog(owner);
        }