Пример #1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Warning that this component is OBSOLETE
            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "This component is OBSOLETE and will be removed " +
                              "in the future. Remove this component from your canvas and replace it by picking the new component " +
                              "from the ribbon.");

            // Input variables
            GH_Controller controllerGoo = null;

            // Catch input data
            if (!DA.GetData(0, ref controllerGoo))
            {
                return;
            }

            // Clear output variables
            _internalAxisValues.Clear();
            _externalAxisValues.Clear();

            // Data needed for making the datatree with axis values
            MechanicalUnitCollection mechanicalUnits = controllerGoo.Value.MotionSystem.MechanicalUnits;
            int           internalAxisValuesPath     = 0;
            int           externalAxisValuesPath     = 0;
            List <double> values;
            GH_Path       path;

            // Make the output datatree with names with a branch for each mechanical unit
            for (int i = 0; i < mechanicalUnits.Count; i++)
            {
                // Get the ABB joint target of the mechanical unit
                MechanicalUnit mechanicalUnit = mechanicalUnits[i];
                JointTarget    jointTarget    = mechanicalUnit.GetPosition();

                // For internal axis values
                if (mechanicalUnit.Type == MechanicalUnitType.TcpRobot)
                {
                    values = GetInternalAxisValuesAsList(jointTarget);
                    path   = new GH_Path(internalAxisValuesPath);
                    _internalAxisValues.AppendRange(values.ConvertAll(val => new GH_Number(val)), path);
                    internalAxisValuesPath += 1;
                }

                // For external axis values
                else
                {
                    values = GetExternalAxisValuesAsList(jointTarget);
                    path   = new GH_Path(externalAxisValuesPath);
                    _externalAxisValues.AppendRange(values.GetRange(0, mechanicalUnit.NumberOfAxes).ConvertAll(val => new GH_Number(val)), path);
                    externalAxisValuesPath += 1;
                }
            }

            // Output
            DA.SetDataTree(0, _internalAxisValues);
            DA.SetDataTree(1, _externalAxisValues);
        }
Пример #2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Input variables
            GH_Controller controllerGoo = null;

            // Catch input data
            if (!DA.GetData(0, ref controllerGoo))
            {
                return;
            }

            // Clear output variables
            _robotJointPositions.Clear();
            _externalAxisValues.Clear();

            // Data needed for making the datatree with axis values
            MechanicalUnitCollection mechanicalUnits = controllerGoo.Value.MotionSystem.MechanicalUnits;
            int           externalAxisValuesPath     = 0;
            List <double> values;
            GH_Path       path;

            // Make the output datatree with names with a branch for each mechanical unit
            for (int i = 0; i < mechanicalUnits.Count; i++)
            {
                // Get the ABB joint target of the mechanical unit
                MechanicalUnit mechanicalUnit = mechanicalUnits[i];
                ABB.Robotics.Controllers.RapidDomain.JointTarget jointTarget = mechanicalUnit.GetPosition();

                // For internal axis values
                if (mechanicalUnit.Type == MechanicalUnitType.TcpRobot)
                {
                    values = GetInternalAxisValuesAsList(jointTarget);
                    _robotJointPositions.Add(new RobotJointPosition(values));
                }

                // For external axis values
                else
                {
                    values = GetExternalAxisValuesAsList(jointTarget);
                    path   = new GH_Path(externalAxisValuesPath);
                    _externalAxisValues.AppendRange(values.GetRange(0, mechanicalUnit.NumberOfAxes).ConvertAll(val => new GH_Number(val)), path);
                    externalAxisValuesPath += 1;
                }
            }

            // Output
            DA.SetDataList(0, _robotJointPositions);
            DA.SetDataTree(1, _externalAxisValues);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Creates the input value list and attachs it to the input parameter
            CreateValueList();

            // Expire solution of this component (called after expire solution of the created value list)
            if (_expire == true)
            {
                _expire = false;
                this.ExpireSolution(true);
            }

            // Input variables
            GH_Controller controllerGoo    = null;
            int           coordinateSystem = 0;

            // Catch input data
            if (!DA.GetData(0, ref controllerGoo))
            {
                return;
            }
            if (!DA.GetData(1, ref coordinateSystem))
            {
                return;
            }

            // Output variables
            List <Plane> planes = new List <Plane>();

            //  Get the mechanical units of the controller
            MechanicalUnitCollection mechanicalUnits     = controllerGoo.Value.MotionSystem.MechanicalUnits;
            List <string>            mechanicalUnitnames = new List <string>();

            // ABB coordinate system type
            CoordinateSystemType coord = (CoordinateSystemType)coordinateSystem;

            // Get all the planes
            for (int i = 0; i < mechanicalUnits.Count; i++)
            {
                // Try to get the plane
                try
                {
                    // Get the ABB joint target of the mechanical unit
                    RobTarget robTarget = mechanicalUnits[i].GetPosition(coord);

                    int test = mechanicalUnits[i].DriveModule;

                    // Update Quaternion
                    _quat.A = robTarget.Rot.Q1;
                    _quat.B = robTarget.Rot.Q2;
                    _quat.C = robTarget.Rot.Q3;
                    _quat.D = robTarget.Rot.Q4;

                    // Update point
                    _point.X = robTarget.Trans.X;
                    _point.Y = robTarget.Trans.Y;
                    _point.Z = robTarget.Trans.Z;

                    // Convert to plane
                    _quat.GetRotation(out Plane plane);
                    plane = new Plane(_point, plane.XAxis, plane.YAxis);

                    // Add to list
                    planes.Add(plane);
                }

                // Set null plane if not
                catch
                {
                    // Raise a blank message
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Mechanical unit " + mechanicalUnits[i].Name + ": A position plane could not be defined for the selected coordinate system.");

                    // Add null plane
                    planes.Add(Plane.Unset);
                }

                // Add mechanical unit name to the list with names
                mechanicalUnitnames.Add(mechanicalUnits[i].Name);
            }

            // Output
            DA.SetDataList(0, planes);
            DA.SetDataList(1, mechanicalUnitnames);
        }