/// <summary> /// Initializes a new instance of the Joint Target class. /// </summary> /// <param name="name"> The target name, must be unique.</param> /// <param name="robotJointPosition"> The Robot Joint Position</param> /// <param name="externalJointPosition"> The External Joint Position</param> public JointTarget(string name, RobotJointPosition robotJointPosition, ExternalJointPosition externalJointPosition) { _referenceType = ReferenceType.VAR; _name = name; _robotJointPosition = robotJointPosition; _externalJointPosition = externalJointPosition; }
/// <summary> /// Initializes a new instance of the Joint Target class by duplicating an existing Joint Target instance. /// </summary> /// <param name="jointTarget"> The Joint Target instance to duplicate. </param> public JointTarget(JointTarget jointTarget) { _referenceType = jointTarget.ReferenceType; _name = jointTarget.Name; _robotJointPosition = jointTarget.RobotJointPosition.Duplicate(); _externalJointPosition = jointTarget.ExternalJointPosition.Duplicate(); }
/// <summary> /// Multiplies the values inside this Joint Position with the values from another Robot Joint Position. /// Value 1 * value 1, value 2 * value 2, value 3 * value 3 etc. /// </summary> /// <param name="jointPosition"> The multiplier as a Robot Joint Position. </param> public void Multiply(RobotJointPosition jointPosition) { for (int i = 0; i < 6; i++) { this[i] *= jointPosition[i]; } }
/// <summary> /// Substracts the values of an Robot Joint Position from the values inside this Joint Position. /// Value 1 - value 1, value 2 - value 2, value 3 - value 3 etc. /// </summary> /// <param name="jointPosition"> The Robot Joint Position to be substracted. </param> public void Substract(RobotJointPosition jointPosition) { for (int i = 0; i < 6; i++) { this[i] -= jointPosition[i]; } }
/// <summary> /// Adds the values of an Robot Joint Position to the values inside this Joint Position. /// Value 1 + value 1, value 2 + value 2, value 3 + value 3 etc. /// </summary> /// <param name="jointPosition"> The Robot Joint Position to be added. </param> public void Add(RobotJointPosition jointPosition) { for (int i = 0; i < 6; i++) { this[i] += jointPosition[i]; } }
private ExternalJointPosition _externalJointPosition; // the position of the external logical axes #endregion #region (de)serialization /// <summary> /// Protected constructor needed for deserialization of the object. /// </summary> /// <param name="info"> The SerializationInfo to extract the data from. </param> /// <param name="context"> The context of this deserialization. </param> protected JointTarget(SerializationInfo info, StreamingContext context) { // int version = (int)info.GetValue("Version", typeof(int)); // <-- use this if the (de)serialization changes _referenceType = (ReferenceType)info.GetValue("Reference Type", typeof(ReferenceType)); _name = (string)info.GetValue("Name", typeof(string)); _robotJointPosition = (RobotJointPosition)info.GetValue("Robot Joint Position", typeof(RobotJointPosition)); _externalJointPosition = (ExternalJointPosition)info.GetValue("External Joint Position", typeof(ExternalJointPosition)); }
/// <summary> /// Creates declarations in the RAPID program module inside the RAPID Generator. /// This method is called inside the RAPID generator. /// </summary> /// <param name="RAPIDGenerator"> The RAPID Generator. </param> public override void ToRAPIDDeclaration(RAPIDGenerator RAPIDGenerator) { // Generate the code for the zone and speeddata _speedData.ToRAPIDDeclaration(RAPIDGenerator); _zoneData.ToRAPIDDeclaration(RAPIDGenerator); // Generate code from robot targets if (_target is RobotTarget robotTarget) { // Update the movement of the inverse kinematics RAPIDGenerator.Robot.InverseKinematics.Movement = this; // Generates the robot target variable for a MoveL or MoveJ instruction if (_movementType == MovementType.MoveL || _movementType == MovementType.MoveJ) { RAPIDGenerator.Robot.InverseKinematics.CalculateExternalJointPosition(); robotTarget.ToRAPIDDeclaration(RAPIDGenerator); } // Generates the joint target variable from a robot target for a MoveAbsJ instruction else { if (!RAPIDGenerator.Targets.ContainsKey(robotTarget.Name + "_jt")) { // Calculate the axis values from the robot target RAPIDGenerator.Robot.InverseKinematics.Calculate(); RAPIDGenerator.ErrorText.AddRange(new List <string>(RAPIDGenerator.Robot.InverseKinematics.ErrorText)); // Create a joint target from the axis values RobotJointPosition robJointPosition = RAPIDGenerator.Robot.InverseKinematics.RobotJointPosition.Duplicate(); ExternalJointPosition extJointPosition = RAPIDGenerator.Robot.InverseKinematics.ExternalJointPosition.Duplicate(); JointTarget jointTarget = new JointTarget(robotTarget.Name + "_jt", robJointPosition, extJointPosition); jointTarget.ReferenceType = _target.ReferenceType; // Create the RAPID code jointTarget.ToRAPIDDeclaration(RAPIDGenerator); } } } // Generate code from joint targets else if (_target is JointTarget jointTarget) { // JointTarget with MoveAbsJ if (_movementType == MovementType.MoveAbsJ) { jointTarget.ToRAPIDDeclaration(RAPIDGenerator); RAPIDGenerator.ErrorText.AddRange(jointTarget.CheckAxisLimits(RAPIDGenerator.Robot)); } // Joint Target combined with MoveL or MoveJ else { throw new InvalidOperationException("Invalid Move instruction: A Joint Target cannot be combined with a MoveL or MoveJ instruction."); } } }
/// <summary> /// Initializes a new instance of the Robot Joint Position class by duplicating an existing Robot Joint Position instance. /// </summary> /// <param name="robotJointPosition"> The Robot Joint Position instance to duplicate. </param> public RobotJointPosition(RobotJointPosition robotJointPosition) { _val1 = robotJointPosition[0]; _val2 = robotJointPosition[1]; _val3 = robotJointPosition[2]; _val4 = robotJointPosition[3]; _val5 = robotJointPosition[4]; _val6 = robotJointPosition[5]; }
/// <summary> /// Divides the values inside this Joint Position with the values from another Robot Joint Position. /// Value 1 / value 1, value 2 / value 2, value 3 / value 3 etc. /// </summary> /// <param name="jointPosition"> The divider as an Robot Joint Position. </param> public void Divide(RobotJointPosition jointPosition) { for (int i = 0; i < 6; i++) { if (jointPosition[i] == 0) { new DivideByZeroException(); } this[i] /= jointPosition[i]; } }