VSTA Target Coordinates

Hi,
I am trying to write a vsta macro to simplify program with a gantry robot. The macro just takes the selected point and updates the gantry (external axis) to be within a certain distance of the target.

The trouble im having is i want to get the targets coordinates in the world coordinate system.

ProjectObject selObject = Project.ActiveProject.Selection.SingleSelectedObject as ProjectObject;
RsTarget Target = selObject as RsTarget;
Double TargetX = Target.RobTarget.Frame.X;

this is the code im using to extra the selected targets coordinates. This and a number of other items will give me the targets coordinates in the parent coordinate system. Is there a simple way to get it in the world coordinate system?

Thanks

Hi,

as in RAPID, a robtarget is used together with a workobject.

The coordinates of the robtarget is relative the workobject.

In RobotStudio the object RsTarget represents the combination of a robtarget and a workobject.

The following sample logs out a targets translation in parent and world coordinate systems.

This sample does not use the Transform.GlobalMatrix of the RsRobtarget, because it is not defined. (The RsRobtarget must be used together with a RsWorkobject in order to have a global transform.)


public void Macro_Sample1()

{

Station s = Project.ActiveProject as Station;

RsTask task = s.ActiveTask;

RsTarget t = task.Targets[0];

Vector3 parentTranslation = t.Transform.Matrix.Translation;

Logger.AddMessage(new LogMessage("xyz in parent: " + parentTranslation.ToString()));

Vector3 worldTranslation = t.Transform.GlobalMatrix.Translation;

Logger.AddMessage(new LogMessage("xyz in world: " + worldTranslation.ToString()));

}

In my station I got this output (coordinates in meters):

xyz in parent: [2 0.5 1.5]

xyz in world: [2.5 1 2]

The RAPID code for my robtarget and workobject that gives the above result looks like this:[CODE]

CONST robtarget Target_10:=[[2000,500,1500],[1,0,0,0],[0,0,0,0],[0,9E9,9E9,9E9,9E9,9E9]]; TASK PERS wobjdata Workobject_1:=[FALSE,TRUE,“”,[[0,0,0],[1,0,0,0]],[[500,500,500],[1,0,0,0]]];

[/CODE]

seems i actually need

to add an extra .x on the end of that to get a double..

but then i get an error say i am improperly using an rstarget.

RobotStudio .NET exception dump

Base exception:
System.Reflection.TargetInvocationException, mscorlib
System.NotSupportedException, mscorlib

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.NotSupportedException: Use RsTarget object!
at ABB.Robotics.RobotStudio.Stations.RsRobTarget.InternalGetGlo balFrame()
at ABB.Robotics.RobotStudio.Stations.Transform.get_GlobalMatrix ()
— End of inner exception stack trace —
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object index, CultureInfo culture)
at Microsoft.VisualStudio.Tools.Applications.RemotePropertyInfo Adapter.System.AddIn.Contract.Automation.IRemotePropertyInfo Contract.GetValue(IRemoteObjectContract target, BindingFlags bindingFlags, IRemoteArgumentArrayContract index, Int32 lcid)

Server stack trace:
at Microsoft.VisualStudio.Tools.Applications.RemoteMethodInfoAd apter.System.AddIn.Contract.Automation.IRemoteMethodInfoCont ract.Invoke(IRemoteObjectContract target, BindingFlags bindingFlags, IRemoteArgumentArrayContract arguments, Int32 lcid)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateP rocessMessage(IntPtr md, Object args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivatePr ocessMessage(RuntimeMethodHandle md, Object args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProce ssMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessag e(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(Mess ageData& msgData, Int32 type)
at System.AddIn.Contract.Automation.IRemoteMethodInfoContract.I nvoke(IRemoteObjectContract target, BindingFlags bindingFlags, IRemoteArgumentArrayContract parameters, Int32 localeId)
at ABBInternal.VstaServices.VstaMacro.Execute()

is there a manual or webpage with information about all the objects available throught the vsta interface?

Any other ideas on how to get the global xyz position of a target, i can only succesfully get parent coordinates even though the other appear to be there.

Most methods in the namespaces ABB.Robotics.RobotStudio and ABB.Robotics.RobotStudio.Stations are supported by VSTA.

If not, it should be documented in the API documentation, which is available from Help->RobotStudio API Help (Alt+F1).

thanks very much for that.

works perfectly.