Ejemplo n.º 1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var            numbers = new List <double>();
            Plane          plane;
            GH_RobotSystem robotSystem = null;

            if (!DA.GetDataList(0, numbers))
            {
                return;
            }
            DA.GetData(1, ref robotSystem);

            if (robotSystem == null)
            {
                if (numbers.Count != 7)
                {
                    this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The list should be made out of 7 numbers."); return;
                }
                plane = RobotCellAbb.QuaternionToPlane(numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], numbers[6]);
            }
            else
            {
                if (robotSystem.Value.Manufacturer == Manufacturers.ABB)
                {
                    if (numbers.Count != 7)
                    {
                        this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The list should be made out of 7 numbers."); return;
                    }
                }
                else
                {
                    if (numbers.Count != 6)
                    {
                        this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, " The list should be made out of 6 numbers."); return;
                    }
                }

                plane = robotSystem.Value.NumbersToPlane(numbers.ToArray());
            }

            DA.SetData(0, plane);
        }
Ejemplo n.º 2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            double[]       numbers;
            GH_Plane       plane       = null;
            GH_RobotSystem robotSystem = null;

            if (!DA.GetData(0, ref plane))
            {
                return;
            }
            DA.GetData(1, ref robotSystem);

            if (robotSystem == null)
            {
                numbers = RobotCellAbb.PlaneToQuaternion(plane.Value);
            }
            else
            {
                numbers = robotSystem.Value.PlaneToNumbers(plane.Value);
            }

            DA.SetDataList(0, numbers);
        }
Ejemplo n.º 3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var            degrees     = new List <double>();
            GH_RobotSystem robotSystem = null;
            int            group       = 0;

            if (!DA.GetDataList(0, degrees))
            {
                return;
            }
            if (!DA.GetData(1, ref robotSystem))
            {
                return;
            }
            if (!DA.GetData(2, ref group))
            {
                return;
            }

            var    radians     = degrees.Select((x, i) => (robotSystem.Value).DegreeToRadian(x, i, group));
            string radiansText = string.Join(",", radians.Select(x => $"{x:0.00000}"));

            DA.SetData(0, radiansText);
        }
Ejemplo n.º 4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_RobotSystem robotSystem    = null;
            var            targets        = new List <GH_Target>();
            var            prevJointsText = new List <GH_String>();
            bool           drawMeshes     = false;

            if (!DA.GetData(0, ref robotSystem))
            {
                return;
            }
            if (!DA.GetDataList(1, targets))
            {
                return;
            }
            DA.GetDataList(2, prevJointsText);
            if (!DA.GetData(3, ref drawMeshes))
            {
                return;
            }

            List <double[]> prevJoints = null;

            if (prevJointsText.Count > 0)
            {
                prevJoints = new List <double[]>();

                foreach (var text in prevJointsText)
                {
                    if (text != null)
                    {
                        string[] jointsText = text.Value.Split(',');
                        var      prevJoint  = new double[jointsText.Length];

                        for (int i = 0; i < jointsText.Length; i++)
                        {
                            if (!GH_Convert.ToDouble_Secondary(jointsText[i], ref prevJoint[i]))
                            {
                                throw new Exception(" Previous joints not formatted correctly.");
                            }
                        }

                        prevJoints.Add(prevJoint);
                    }
                }
            }

            var kinematics = robotSystem.Value.Kinematics(targets.Select(x => x.Value), prevJoints, drawMeshes);

            var errors = kinematics.SelectMany(x => x.Errors);

            if (errors.Count() > 0)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Errors in solution");
            }

            var strings = kinematics.SelectMany(x => x.Joints).Select(x => new GH_Number(x).ToString());
            var joints  = string.Join(",", strings);

            var planes = kinematics.SelectMany(x => x.Planes);

            if (drawMeshes)
            {
                var meshes = kinematics.SelectMany(x => x.Meshes);
                DA.SetDataList(0, meshes.Select(x => new GH_Mesh(x)));
            }

            DA.SetData(1, joints);
            DA.SetDataList(2, planes.Select(x => new GH_Plane(x)));
            DA.SetDataList(3, errors);
        }
Ejemplo n.º 5
0
 public GH_RobotSystem(GH_RobotSystem goo)
 {
     this.Value = goo.Value;
 }
Ejemplo n.º 6
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string         name             = null;
            GH_RobotSystem robotSystem      = null;
            var            initCommandsGH   = new List <GH_Command>();
            var            targetsA         = new List <GH_Target>();
            var            targetsB         = new List <GH_Target>();
            var            multiFileIndices = new List <int>();
            double         stepSize         = 1;

            if (!DA.GetData(0, ref name))
            {
                return;
            }
            if (!DA.GetData(1, ref robotSystem))
            {
                return;
            }
            if (!DA.GetDataList(2, targetsA))
            {
                return;
            }
            DA.GetDataList(3, targetsB);
            DA.GetDataList(4, initCommandsGH);
            DA.GetDataList(5, multiFileIndices);
            if (!DA.GetData(6, ref stepSize))
            {
                return;
            }

            var initCommands = initCommandsGH.Count > 0 ? new Robots.Commands.Group(initCommandsGH.Select(x => x.Value)) : null;

            var targets = new List <IEnumerable <Target> >();

            targets.Add(targetsA.Select(x => x.Value));
            if (targetsB.Count > 0)
            {
                targets.Add(targetsB.Select(x => x.Value));
            }

            var program = new Program(name, robotSystem.Value, targets, initCommands, multiFileIndices, stepSize);

            DA.SetData(0, new GH_Program(program));


            if (program.Code != null)
            {
                var path      = DA.ParameterTargetPath(2);
                var structure = new GH_Structure <GH_String>();

                for (int i = 0; i < program.Code.Count; i++)
                {
                    var tempPath = path.AppendElement(i);
                    for (int j = 0; j < program.Code[i].Count; j++)
                    {
                        structure.AppendRange(program.Code[i][j].Select(x => new GH_String(x)), tempPath.AppendElement(j));
                    }
                }

                DA.SetDataTree(1, structure);
            }

            DA.SetData(2, program.Duration);

            if (program.Warnings.Count > 0)
            {
                DA.SetDataList(3, program.Warnings);
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Warnings in program");
            }

            if (program.Errors.Count > 0)
            {
                DA.SetDataList(4, program.Errors);
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Errors in program");
            }
        }