Esempio n. 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);
        }
        public void TestGetPosition()
        {
            MechanicalUnit mechanicalUnit = this.controller.MotionSystem.ActiveMechanicalUnit;

            logger.Debug(mechanicalUnit.GetPosition());
            logger.Debug(mechanicalUnit.GetPosition(CoordinateSystemType.WorkObject));
            foreach (MechanicalUnit item in this.controller.MotionSystem.MechanicalUnits)
            {
                logger.Debug(item.Task.Name + ":" + item.GetPosition());
                logger.Debug(item.Task.Name + ":" + item.GetPosition(CoordinateSystemType.WorkObject));
            }
        }
Esempio n. 3
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);
        }