# C# Port 30004 (actual\_q and/or actual\_tcp\_pose)

**URL:** <https://forum.universal-robots.com/t/c-port-30004-actual-q-and-or-actual-tcp-pose/20037>\
**Category:** Technical Questions\
**Created:** [March 22, 2022, 10:31am UTC](https://forum.universal-robots.com/t/c-port-30004-actual-q-and-or-actual-tcp-pose/20037 "2022-03-22T10:31:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PMonforte](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@PMonforte](https://forum.universal-robots.com/u/PMonforte)\
**Post date:** [March 22, 2022, 10:31am UTC](https://forum.universal-robots.com/t/c-port-30004-actual-q-and-or-actual-tcp-pose/20037/1 "2022-03-22T10:31:38Z")

</div>

Greetings UR Community,  
I am currently developing a solution on C# and I was trying to get data from port 30004 (RTDE), particularly the joint positions in real time. I am not really an expert on C# programming, and after a bit of research I was unable to get this done. If someone could give me a hand I would appreciate.  
Best regards,  
PMonforte

---

<div class="post-metadata">

**Author:** ![androidflorent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/androidflorent/32/3314_2.png) [@androidflorent](https://forum.universal-robots.com/u/androidflorent)\
**Post date:** [March 22, 2022, 12:24pm UTC](https://forum.universal-robots.com/t/c-port-30004-actual-q-and-or-actual-tcp-pose/20037/2 "2022-03-22T12:24:17Z")

</div>

Hi, a quick and easy way is to use [this library](https://underautomation.com/universal-robots/documentation/get-started-net). You install it from Nuget. The documentation and examples on Github show you examples with RTDE.

```cs
class Rtde
{
    static void Main(string[] args)
    {        
        var robot = new UR();

        var param = new ConnectParameters("192.168.0.1");

        // Enable RTDE
        param.Rtde.Enable = true;

        // Exchange data at 500Hz
        param.Rtde.Frequency = 500;

        // Select data you want to write in robot controller
        param.Rtde.InputSetup.Add(RtdeInputData.StandardAnalogOutput0);
        param.Rtde.InputSetup.Add(RtdeInputData.InputIntRegisters, 0);

        // Select data you want the robot to send
        param.Rtde.OutputSetup.Add(RtdeOutputData.ActualTcpPose);
        param.Rtde.OutputSetup.Add(RtdeOutputData.ToolOutputVoltage);
        param.Rtde.OutputSetup.Add(RtdeOutputData.OutputDoubleRegisters, 10);

        // Connect to robot
        robot.Connect(param);

        // Be notified at 500Hz when data is received
        robot.Rtde.OutputDataReceived += Rtde_OutputDataReceived;

        //...

        // Get last received data in cache
        Pose actualTcpPose = robot.Rtde.OutputDataValues.ActualTcpPose;
        int toolOutputVoltage = robot.Rtde.OutputDataValues.ToolOutputVoltage;
        double outputDoubleRegisters10 = robot.Rtde.OutputDataValues.OutputDoubleRegisters.X10;

        //...

        // Write input values in robot
        var inputValues = new RtdeInputValues();
        inputValues.StandardAnalogOutput0 = 0.2;
        inputValues.InputIntRegisters.X0 = 12;
        robot.Rtde.WriteInputs(inputValues);

        // Disconnect only Dashboard communication
        robot.Rtde.Disconnect();

        // Disconnect every interfaces (Primary Interface, Dashboard, RTDE, ...)
        robot.Disconnect();
        
    }

    
    private static void Rtde_OutputDataReceived(object sender, RtdeDataPackageEventArgs e)
    {
        // Get frequency of received message (OutputSetup contains Timestamp by default)
        var realMessageFrequency = e.MeasuredFrequency;

        // Get the value of the data you have selected in the setup 
        Pose actualTcpPose = e.OutputDataValues.ActualTcpPose;
        int toolOutputVoltage = e.OutputDataValues.ToolOutputVoltage;
        double outputDoubleRegisters10 = e.OutputDataValues.OutputDoubleRegisters.X10;

        // Write inputs at 500Hz
        var inputValues = new RtdeInputValues();
        inputValues.StandardAnalogOutput0 = 0.5;
        inputValues.InputIntRegisters.X0 = -10;
        (sender as RtdeClientBase)?.WriteInputs(inputValues);
    }   
}

```

---

<div class="post-metadata">

**Author:** ![PMonforte](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@PMonforte](https://forum.universal-robots.com/u/PMonforte)\
**Post date:** [March 22, 2022, 2:41pm UTC](https://forum.universal-robots.com/t/c-port-30004-actual-q-and-or-actual-tcp-pose/20037/3 "2022-03-22T14:41:08Z")

</div>

Thank you very much. I had found UnderAutomation before but I got the impression that it was not free, that is, that I had only a 30 day trial. Be it as it may, thank you for your help  
Best regards  
PMonforte
