RobotStudio event

RS API Corrdinate Translations

Hi All,

Could anyone point the place to look for information on API Coordinate systems and translations.

I.e I have two points in the same work object
RsTarget pA;
RsTarget pB;

I need to get pB coordinates and vector in pA coordinates.

Like in RS SetPosition relative to UCS

If I do

Matrix4 to_pA = pB.Transform.GetRelativeTransform(pA);

i receive the matrix to rotate pB into pA but still in work object coordinate system.

The question is what to do to see offset and rotation in pA coordinate system.

Any help is appreciated.




Comments




  • Tested it and it works like a charm. I'd think your issue might lie in how you then implement it's use.
     
            /// <summary>
            /// Plays around with target coordinate systems
            /// </summary>
            public void Macro_TargetCoo()
            {
                Station station = Project.ActiveProject as Station;
                if (station == null) return;
                RsTask activeTask = station.ActiveTask;
                if (activeTask == null) return;
                Logger.AddMessage(new LogMessage("start"));
                RsRobTarget robTargetA = new RsRobTarget();
                robTargetA.Name = station.ActiveTask.GetValidRapidName("MyTarget", "_", 1);
                robTargetA.Frame.X = 0.2;
                //robTargetA.Frame.RY = Globals.DegToRad(45);//uncomment if you want to test with rotation
                activeTask.DataDeclarations.Add(robTargetA);
                Logger.AddMessage(new LogMessage("New robtarget " + robTargetA.Name));
                RsRobTarget robTargetB = new RsRobTarget();
                robTargetB.Name = station.ActiveTask.GetValidRapidName("MyTarget", "_", 1);
                robTargetB.Frame.X = 0.4;
                activeTask.DataDeclarations.Add(robTargetB);
                Logger.AddMessage(new LogMessage("New robtarget " + robTargetB.Name));
                RsWorkObject _workObject = new RsWorkObject();
                _workObject.Name = station.ActiveTask.GetValidRapidName("MyWobj", "_", 1);
                activeTask.DataDeclarations.Add(_workObject);
                _workObject.UserFrame.X = 0.3;
                Logger.AddMessage(new LogMessage("New wobj " + _workObject.Name));
                RsTarget myTargetA = new RsTarget(_workObject, robTargetA);
                RsTarget myTargetB = new RsTarget(_workObject, robTargetB);
                activeTask.Targets.Add(myTargetA);
                activeTask.Targets.Add(myTargetB);
                Logger.AddMessage(new LogMessage("TargetA XYZ:" + myTargetA.ReferenceFrame.X + "," + myTargetA.ReferenceFrame.Y + "," + myTargetA.ReferenceFrame.Z + " rXrYrZ:" + Globals.RadToDeg(myTargetA.ReferenceFrame.RX) + "," + Globals.RadToDeg(myTargetA.ReferenceFrame.RY) + "," + Globals.RadToDeg(myTargetA.ReferenceFrame.RZ)));
                Logger.AddMessage(new LogMessage("TargetB XYZ:" + myTargetB.ReferenceFrame.X + "," + myTargetB.ReferenceFrame.Y + "," + myTargetB.ReferenceFrame.Z + " rXrYrZ:" + Globals.RadToDeg(myTargetB.ReferenceFrame.RX) + "," + Globals.RadToDeg(myTargetB.ReferenceFrame.RY) + "," + Globals.RadToDeg(myTargetB.ReferenceFrame.RZ)));
                Matrix4 relMx =  myTargetB.Transform.GetRelativeTransform(myTargetA);
                Logger.AddMessage(new LogMessage("Translation relative B to A = " + relMx.Translation.ToString()));
            }