I’m trying to have my robot grip each product that passes in front of it. Each product comes in a random orientation. I have one work object and update it in a macro by detaching it from the previous product and attaching it to the next product. This works well in the macro and the work object shows its change of host in the simulation. However, the robot still doesn’t know where the new location for the work object is because it hasn’t been updated to the VC.
I tried to use SyncData to update the work object in VC and always get the following error:
The given key was not present in the dictionary.
I posted it as a question and someone said it’s impossible to do it since it’s thru VSTA.
I tried to use SyncToController(new ArrayList()) but it would just slow everything down.
Hi
Download Visual C# Express from Microsoft it’s free and write an addin instead of a VSTA macro. Because as I said before it looks like the SyncData method doesn’t work in VSTA!!! but if you write an addin it works.
It is correct that Visual Studio addins don’t support VSTA-style macros, so their methods cannot be called directly by the event manager.
Instead, you can have the addin listen to virtual signals that are set by events in the event manager. For example:
[code]public static void AddinMain()
{
Simulator.StateChanged += new EventHandler(Simulator_StateChanged);
}
static void Simulator_StateChanged(object sender, EventArgs e)
{
Station stn = Project.ActiveProject as Station;
if (Simulator.State == SimulationState.Running)
{
stn.VirtualSignals.VirtualSignalChanged += new VirtualSignalChangedEventHandler(VirtualSignals_VirtualSigna lChanged);
}
else
{
stn.VirtualSignals.VirtualSignalChanged -= new VirtualSignalChangedEventHandler(VirtualSignals_VirtualSigna lChanged);
}
}
static void VirtualSignals_VirtualSignalChanged(object sender, VirtualSignalChangedEventArgs e)
{
switch (e.Signal)
{
case “MyVirtualSignal1”:
{
// Do something
}
break;
case “MyVirtualSignal2”:
{
// Do something else
}
break;
}
}
[/code]
The AddinMain() method is executed when the addin is loaded (normally when RobotStudio is started), not when simulation starts.
Hi
You should reference to ABB.Robotics.RobotStudio.Stations
But a good rule is to always add
ABB.Robotics.RobotStudio
ABB.Robotics.RobotStudio.Math
ABB.Robotics.RobotStudio.Enviroment
ABB.Robotics.RobotStudio.Stations
ABB.Robotics.RobotStudio.Stations.Forms
You should NOT have a reference to ABB.Robotics.RobotStudio.Proxy in a Visual Studio project, it is only intended for VSTA!
If you add the references that Per described (along with some using statements) the code should compile.
This is probably due to that the VirtualController is executing the rapid program. Try to update the workobject without starting the simulation just to see if that’s the case.
Hi
Tested this and the reason for the message is that you can’t syncronize when the controller is running which make sense. To be able to change the data in a workobject(while running) you need to use PC SDK(part of Robot Application Builder) to write data to the controller.
Right now I am using only Robot Studio and Visual Studio Add-ins. And I want to update the work object during the simulation. As I understand your opinion, SyncData(…) doesn’t work when the simulator is on. Could you explain where to find and how to use the PC SDK(part of Robot Application Builder)? Is it a big leap from Robot Studio? I only bought Robot Studio.
Hi
I think RAB is on the RobotWare CD from version 5.10 (i’m a partner so I have access to a specific download area where it is) if not you should get in contact with your ABB sales guy (it’s free, the only thing is if you want to run against a real controller then you need some options on the controller).
But when you are running on a virtual controller it’s just a matter of choose the right option when you create the controller.
PC Interface - if you want to be able to communicate between a PC and the controller.
FlexPendant Interface - if you want to be able to run Applications on the FlexPendant.
There are some examples in the documentation of RAB that is quite usefull and there is also a thread (Robot Application Builder) in this forum about it.
In actual projects we constantly send new data (work object, target, etc) to the robot controller. How can we use Robot Studio or Visual Studio Add-in to simulate it?
In actual projects we can just write to variables on the controller. But Robot Studio only allows digital signal Connection, which means we cannot write general data.
Robot Studio provide functions like
SyncToController
and
SyncData
But they do not run during the simulation because the controller is on.
Does it mean that I can never update a work object or a target or send data through the combination of Robot Studio and Visual Studio Add-in?
Hi again
The RobotStudio object library is for RobotStudio and not the Controller it self more than that you can up/download stuff you have created in RS to the controller (and some other tasks).
To mess with the controller there is another object library (RAB as I have talked about).
So in your case it’s just a matter of using one more object library so that you can mess with the controller as well in your addin.
You have to use the systembuilder located in the controller menu to build your own virtual controller.
You can find info regarding systembuilder in the help system for RS