# How to get the controller object ?

**URL:** <https://tech-community.robotics.abb.com/t/how-to-get-the-controller-object/11074>\
**Category:** Developer Tools\
**Tags:** robotstudio-sdk, syncronization\
**Created:** [March 30, 2023, 9:51am UTC](https://tech-community.robotics.abb.com/t/how-to-get-the-controller-object/11074 "2023-03-30T09:51:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandre](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Alexandre](https://tech-community.robotics.abb.com/u/Alexandre)\
**Post date:** [March 30, 2023, 9:51am UTC](https://tech-community.robotics.abb.com/t/how-to-get-the-controller-object/11074/1 "2023-03-30T09:51:54Z")

</div>

Hello,

I am trying to synchronize from the controller to the station so I followed [this page](https://developercenter.robotstudio.com/api/robotstudio/articles/How-To/Rapid/SynchronizeToRapid.html) and update it to not use the obsolete function.

So my code is like this :

```auto
Controller controller = Controller.Connect(new Guid(rsIrc5Controller.SystemId.ToString()), ConnectionType.Standalone);

```

but when I debug and look at my controller variable it say :

Unable to evaluate the expression because evaluating the function requires all threads to execute.

An image of the debug can be found [here](https://photos.app.goo.gl/uLV5T4AUA6qB9x3H9)

Can you help find what I miss ?  
Thank you in advance

---

<div class="post-metadata">

**Author:** ![Nils\_Olofsson](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Nils\_Olofsson](https://tech-community.robotics.abb.com/u/Nils_Olofsson)\
**Post date:** [March 30, 2023, 1:00pm UTC](https://tech-community.robotics.abb.com/t/how-to-get-the-controller-object/11074/2 "2023-03-30T13:00:06Z")

</div>

hello,  
This is normal behaviour for the debugger.  
Take a look at this:

> <https://stackoverflow.com/questions/29985150/visual-studio-during-debugging-the-function-evaluation-requires-all-threads-to>

---

<div class="post-metadata">

**Author:** ![Alexandre](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Alexandre](https://tech-community.robotics.abb.com/u/Alexandre)\
**Post date:** [March 30, 2023, 1:33pm UTC](https://tech-community.robotics.abb.com/t/how-to-get-the-controller-object/11074/3 "2023-03-30T13:33:09Z")

</div>

Thank you for your help. I tried to launch my smartcomposant directly in RS but I don’t think it work either. It tell me that

the RMMP request was not granted within the timeout limit.  
To debug I tried to print the controller name and it give me the name of my computer.

---

<div class="post-metadata">

**Author:** ![Nils\_Olofsson](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Nils\_Olofsson](https://tech-community.robotics.abb.com/u/Nils_Olofsson)\
**Post date:** [March 31, 2023, 9:34am UTC](https://tech-community.robotics.abb.com/t/how-to-get-the-controller-object/11074/4 "2023-03-31T09:34:01Z")

</div>

It seems like you request RMMP and that’s where it fails, not when connecting to the controller.  
Do you need RMMP?

---

<div class="post-metadata">

**Author:** ![Alexandre](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Alexandre](https://tech-community.robotics.abb.com/u/Alexandre)\
**Post date:** [April 4, 2023, 12:32pm UTC](https://tech-community.robotics.abb.com/t/how-to-get-the-controller-object/11074/5 "2023-04-04T12:32:22Z")

</div>

> [@](#):
>
> It seems like you request RMMP and that’s where it fails, not when connecting to the controller.  
> Do you need RMMP?

Hello,  
To be honest I don’t know what is RMMP. I only try to follow the guide [here](https://developercenter.robotstudio.com/api/robotstudio/articles/How-To/Rapid/SynchronizeToStation.html). But I tried without connecting, only with this code below and it works.

```auto

result = await task.SyncPathProcedureAsync(moduleName + "/" + routineName,
                            SyncDirection.ToStation,
                            messages);

```

The drawback of this method is that the module need to exist in the station. If we need to access a module that doesn’t exist in the station we will need to access the controller if I understand correctly this [page](https://developercenter.robotstudio.com/api/robotstudio/articles/How-To/Rapid/LoadModuleFromFile.html).

My question is : Is it working with the virtual controller ?

Best regards and thanks in advance

---

<div class="post-metadata">

**Author:** ![Nils\_Olofsson](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Nils\_Olofsson](https://tech-community.robotics.abb.com/u/Nils_Olofsson)\
**Post date:** [April 5, 2023, 5:59am UTC](https://tech-community.robotics.abb.com/t/how-to-get-the-controller-object/11074/6 "2023-04-05T05:59:36Z")

</div>

Hello,  
So i did not read the original post properly, sorry for that.  
When requesting mastership when the controller is in manual mode it will request something called RMMP. This basically mean that you will have to allow the client mastership from the flexpendant, i am sure you have seen this when trying to edit rapid code from RobotStudio on a real controller.  
So to solve this, either allow your client mastership from the flexpendant or make sure you have set the controller to auto mode when you run your code.  
And yes, this should work on a VC.

---

<div class="post-metadata">

**Author:** ![Alexandre](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Alexandre](https://tech-community.robotics.abb.com/u/Alexandre)\
**Post date:** [April 5, 2023, 7:25am UTC](https://tech-community.robotics.abb.com/t/how-to-get-the-controller-object/11074/7 "2023-04-05T07:25:43Z")

</div>

> [@Nils Olofsson](#):
>
> Hello,  
> So i did not read the original post properly, sorry for that.  
> When requesting mastership when the controller is in manual mode it will request something called RMMP. This basically mean that you will have to allow the client mastership from the flexpendant, i am sure you have seen this when trying to edit rapid code from RobotStudio on a real controller.  
> So to solve this, either allow your client mastership from the flexpendant or make sure you have set the controller to auto mode when you run your code.  
> And yes, this should work on a VC.

Thank you ! It works now. I didn’t think to look at the controller while requesting mastership --’
