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.
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.
0
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()));}
John
Developer Center0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 799 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings