# \[PC SDK\] Writing RobTarget in Controller doesn't work as expected

**URL:** <https://tech-community.robotics.abb.com/t/pc-sdk-writing-robtarget-in-controller-doesnt-work-as-expected/5982>\
**Category:** Developer Tools\
**Created:** [February 24, 2014, 3:26pm UTC](https://tech-community.robotics.abb.com/t/pc-sdk-writing-robtarget-in-controller-doesnt-work-as-expected/5982 "2014-02-24T15:26:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HM](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@HM](https://tech-community.robotics.abb.com/u/HM)\
**Post date:** [February 24, 2014, 3:26pm UTC](https://tech-community.robotics.abb.com/t/pc-sdk-writing-robtarget-in-controller-doesnt-work-as-expected/5982/1 "2014-02-24T15:26:07Z")

</div>

Hi,

I´m developing an add-in which copies a robtarget to the controller and moves the robot to it. In depth, the program calculates some robtargets in simulation, the reachability is checked and, if the target is reachable, the robtarget is copied to the controller and the robot moves to it.

I have some problems with the execution. First problem, once the controller’s robtarget is overwritten with the new value and the execution is played, the robot starts moving, but it moves near to the origin. I think that the problem is on units: simulation works with meters and controller is waiting milimeters, am I right?

Assuming this is true, I transform the translation units in milimeters, and run the program again. Then the robot doesn’t move, and I can’t imagine what is happening now. Fist I thought that the position is not reachable but this is checked as true in simulation.

I followed this discussion: [ABB Robotics Community - Maintenance](http://forums.robotstudio.com/discussion/comment/23026#Comment_23026) and the PC SDK manual so I assume that the robtarget is correctly written (in fact the new value is written in the controller’s robtarget).

Any ideas are welcome.  
HM

```auto
if (rd.Value is ABB.Robotics.Controllers.RapidDomain.RobTarget)
{

```

```auto
	ABB.Robotics.Controllers.RapidDomain.RobTarget probTarget = (ABB.Robotics.Controllers.RapidDomain.RobTarget)rd.Value;

```

```auto
	string newValue = GetString(rs);

```

```auto
	probTarget.FillFromString2(newValue);

```

```auto
	rd.Value = probTarget;

```

```auto
}

```

```auto

```

````auto

```
private System.String GetString(RsRobTarget rs)
{
```

```
	ExternalAxisValues v = rs.GetExternalAxes(true);
```

```
	return System.String.Format("[[{0}, {1}, {2}], [{3}, {4}, {5}, {6}], [{7}, {8}, {9}, {10}], [{11}, {12}, {13}, {14}, {15}, {16}]]", 
```

```
rs.Frame.Translation.x, rs.Frame.Translation.y, rs.Frame.Translation.z, 
```

```
rs.Frame.GlobalMatrix.Quaternion.q1, rs.Frame.GlobalMatrix.Quaternion.q2, rs.Frame.GlobalMatrix.Quaternion.q3, rs.Frame.GlobalMatrix.Quaternion.q4,  
```

```
rs.ConfigurationData.Cf1, rs.ConfigurationData.Cf4, rs.ConfigurationData.Cf6, rs.ConfigurationData.Cfx, 
```

```
v.Eax_a, v.Eax_b, v.Eax_c, v.Eax_d, v.Eax_e, v.Eax_f);
```

```
}
```

````

---

<div class="post-metadata">

**Author:** ![Niklas\_Skoglund](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@Niklas\_Skoglund](https://tech-community.robotics.abb.com/u/Niklas_Skoglund)\
**Post date:** [February 24, 2014, 4:13pm UTC](https://tech-community.robotics.abb.com/t/pc-sdk-writing-robtarget-in-controller-doesnt-work-as-expected/5982/2 "2014-02-24T16:13:48Z")

</div>

Hi, I can confirm that the RobotStudio API is using SI units, so this one rs.Frame.GlobalMatrix is in meters, and the robtarget type in RAPID expects mm in xyz.

Have a look here:

[http://developercenter.robotstudio.com/BlobProxy/manuals/RapidIFDTechRefManual/doc481.html](http://developercenter.robotstudio.com/BlobProxy/manuals/RapidIFDTechRefManual/doc481.html)

Maybe you can simply trace a few of the robtarget values to a text file and manually create robtargets in a small RAPID module. Then you can isolate whatever is going on in the application from the RAPID it creates.
