Copying current bodies of robot
MaWi81
✭
in RobotStudio
Hi!
I want to get a full copy of the robots bodies to be stored in another part. Using a bounding box is not accurate enough. How can I do this?
I tried this:
[code]
GraphicComponent rob = station.GraphicComponents["MyRobotsName"];
Mechanism mech = rob as Mechanism;
foreach (GraphicComponent gc in mech.GraphicComponents) {
Part part = gc as Part;
if (!part.HasGeometry)
continue;
foreach(Body body in part.Bodies)
p.Bodies.Add((Body) body.Copy());
}
[/code]
This has almost the effect I expected but the copied bodies are representing the standard-pose of the robot at WCS's origin. I wanted the exact copy of the robot's pose and position.
Is there a better way? (Maybe even without casting 100 times?)
MaWi812008-8-18 11:46:27
0
Comments
-
You'll have to apply the transform of the robot part to the copied body:
[code]
foreach (Body body in part.Bodies)
{
Body newBody = body.Copy() as Body;
p.Bodies.Add(newBody);
newBody.Transform.Matrix = part.Transform.GlobalMatrix;
}
[/code]
regards,
Johannes
Johannes Weiman2008-8-18 12:51:28Johannes Weiman
Software Engineer
ABB Robotics0 -
I did not expect it to be as simple as that. Now it works.
Thank you for your reply!
0 -
Now I get an exception when creating an empty part.
[code]
Logger.log(this, "creating " + pathName, LogMessageSeverity.DEBUG);
Path pathPart = new Part();
Logger.log(this, pathName + " created", LogMessageSeverity.DEBUG);
pathPart.Name = pathName;
station.GraphicComponents.Add(pathPart);
Logger.log(this, pathName + " added", LogMessageSeverity.DEBUG);
[/code]
And the corresponding stack trace. You can see the log message and afterwards the error of the constructor. I expected empty constructors not to throw exceptions...
[code]19.08.2008 14:16:53 DEBUG [CollisionTesterAddIn.Forms.LearnForm] creating Rohrpostroboter_unten_Path_Empfang15_M=>Path_Empfang15_S
19.08.2008 14:16:53 ERROR [CollisionTesterAddIn.Forms.LearnForm] Ein Aufrufziel hat einen Ausnahmefehler verursacht.:
Server stack trace:
bei System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
bei System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
bei System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
bei ABBInternal.VstaServices.HostServices.CreateObject(String canonicalName, String[] canonicalParameterTypeNames, IRemoteArgumentArrayContract args)
bei System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateP rocessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
bei System.Runtime.Remoting.Messaging.StackBuilderSink.PrivatePr ocessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
bei System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProce ssMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
bei System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessag e(IMessage reqMsg, IMessage retMsg)
bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(Mess ageData& msgData, Int32 type)
bei CustomContracts.ICreateObjectContract.CreateObject(String canonicalName, String[] canonicalParameterTypeNames, IRemoteArgumentArrayContract remoteArgs)
bei ABB.Robotics.RobotStudio.Stations.Part..ctor()
bei CollisionTesterAddIn.Forms.LearnForm.HandleMovementCompleted (Movement movement)[/code]
In debug-mode I do not get any errors although there should not be a difference between debug and release-mode.
MaWi812008-8-19 14:51:360 -
Found the problem: Part & body do not seem to be thread-safe.
I applied the creation process into the mainThread and now it works.
0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 786 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings