/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { // Input variables Robot robot = null; Movement Movement = null; // Catch the input data if (!DA.GetData(0, ref robot)) { return; } if (!DA.GetData(1, ref Movement)) { return; } // Calculate the robot pose _inverseKinematics = new InverseKinematics(Movement, robot); _inverseKinematics.Calculate(); // Check the values for (int i = 0; i < _inverseKinematics.ErrorText.Count; i++) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, _inverseKinematics.ErrorText[i]); } // Set forward kinematics (for visualization) _forwardKinematics = new ForwardKinematics(robot); // Output DA.SetData(0, _inverseKinematics.RobotJointPosition); DA.SetData(1, _inverseKinematics.ExternalJointPosition); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</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 Robot robot = null; Movement Movement = null; // Catch the input data if (!DA.GetData(0, ref robot)) { return; } if (!DA.GetData(1, ref Movement)) { return; } // Calculate the robot pose InverseKinematics inverseKinematics = new InverseKinematics(Movement, robot); inverseKinematics.Calculate(); // Check the values for (int i = 0; i < inverseKinematics.ErrorText.Count; i++) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, inverseKinematics.ErrorText[i]); } // Create list with externan axis values List <double> externalAxisValues = inverseKinematics.ExternalJointPosition.ToList(); externalAxisValues.RemoveAll(val => val == 9e9); // Output DA.SetDataList(0, inverseKinematics.RobotJointPosition.ToList()); DA.SetDataList(1, externalAxisValues); }