# Defining a safety plane using urscript or rtde

**URL:** <https://forum.universal-robots.com/t/defining-a-safety-plane-using-urscript-or-rtde/31506>\
**Category:** Technical Questions\
**Created:** [November 22, 2023, 1:51am UTC](https://forum.universal-robots.com/t/defining-a-safety-plane-using-urscript-or-rtde/31506 "2023-11-22T01:51:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gargsonu0414](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@gargsonu0414](https://forum.universal-robots.com/u/gargsonu0414)\
**Post date:** [November 22, 2023, 1:51am UTC](https://forum.universal-robots.com/t/defining-a-safety-plane-using-urscript-or-rtde/31506/1 "2023-11-22T01:51:09Z")

</div>

Hello,

I am using a UR5e robot for a medical application. I would like to define a safety plane which restricts the robot from entering any critical region while the medical process is ongoing.

Since the medical personnel will be using the GUI that I’m building to control the robot and not the UR teach pendant, is it possible to define the safety plane using RTDE or URScript? If not, is there any suggestion on how can I define safety planes without using teach pendant?

Thanks in advance!

Ak

---

<div class="post-metadata">

**Author:** ![terryc](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/terryc/32/3006_2.png) [@terryc](https://forum.universal-robots.com/u/terryc)\
**Post date:** [November 24, 2023, 12:02am UTC](https://forum.universal-robots.com/t/defining-a-safety-plane-using-urscript-or-rtde/31506/2 "2023-11-24T00:02:46Z")

</div>

Probably not, but if it’s a simple plane you can spin up a thread that tests your TCP position and sends a halt command if the robot tries to exceed it. Not safety rated really but pretty flexible.

If it’s an angled plane, maybe dust of some lin alg skills to get parallel distance to plane.

---

<div class="post-metadata">

**Author:** ![gargsonu0414](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@gargsonu0414](https://forum.universal-robots.com/u/gargsonu0414)\
**Post date:** [November 30, 2023, 5:57am UTC](https://forum.universal-robots.com/t/defining-a-safety-plane-using-urscript-or-rtde/31506/3 "2023-11-30T05:57:13Z")

</div>

Thanks @terryc for the response. Your suggestion sounds good. But since we need this function for medical use cases I wonder is there no other way to directly play around with the safety parameters in the controller?

---

<div class="post-metadata">

**Author:** ![efn](https://avatars.discourse-cdn.com/v4/letter/e/35a633/32.png) [@efn](https://forum.universal-robots.com/u/efn)\
**Post date:** [November 30, 2023, 7:07am UTC](https://forum.universal-robots.com/t/defining-a-safety-plane-using-urscript-or-rtde/31506/4 "2023-11-30T07:07:57Z")

</div>

Well. The whole idea with the safety settings is that they’re not just for playing around with. 🙂 Safety is supposed to be set up once by the integrator based on a risk analysis.

I don’t know of another way to change the safety settings if not by changing them directly in PolyScope.

---

<div class="post-metadata">

**Author:** ![cg1](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@cg1](https://forum.universal-robots.com/u/cg1)\
**Post date:** [November 30, 2023, 9:29am UTC](https://forum.universal-robots.com/t/defining-a-safety-plane-using-urscript-or-rtde/31506/5 "2023-11-30T09:29:24Z")

</div>

if you only need to switch between certain predefined safety planes.

it would be posible to use the dashboard client to load different installation files, containing different safety planes.

This is a close as you will ever come, to something like this.

Best Regards

---

<div class="post-metadata">

**Author:** ![gargsonu0414](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@gargsonu0414](https://forum.universal-robots.com/u/gargsonu0414)\
**Post date:** [December 1, 2023, 5:22am UTC](https://forum.universal-robots.com/t/defining-a-safety-plane-using-urscript-or-rtde/31506/6 "2023-12-01T05:22:49Z")

</div>

@efn Thanks for the reply. Your reasoning makes sense. For our use case, we want to provide a flexibility to the medical staff/ engineering experts to set safety parameters using the medical app / GUI that we are developing. This GUI makes use of the RTDE at the back-end to communicate with the robot.

---

<div class="post-metadata">

**Author:** ![gargsonu0414](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@gargsonu0414](https://forum.universal-robots.com/u/gargsonu0414)\
**Post date:** [December 1, 2023, 5:23am UTC](https://forum.universal-robots.com/t/defining-a-safety-plane-using-urscript-or-rtde/31506/7 "2023-12-01T05:23:46Z")

</div>

Thanks, I will explore this suggestion 😀  
Regards

---

<div class="post-metadata">

**Author:** ![Roberto.Ancona](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/roberto.ancona/32/5620_2.png) [@Roberto.Ancona](https://forum.universal-robots.com/u/Roberto.Ancona)\
**Post date:** [December 6, 2023, 7:16am UTC](https://forum.universal-robots.com/t/defining-a-safety-plane-using-urscript-or-rtde/31506/8 "2023-12-06T07:16:41Z")

</div>

I fully agree with @efn, safety planes and safety functions are bound to a robot installation and risk assessment, not to a particular program. So they must be activated/deactivated very carefully.

If you do NOT want this to be a safety behaviour, maybe you can try the new **struct** datatype on Polyscope 5.14 which can help a lot to setup complex data structures needed for checking 3D volumes and zones.

Here an example to check if robot is inside a cube zone:

> <https://github.com/robpodcloud/robpod-studio/blob/main/examples/baselight_cube_struct/baselight_cube_struct.script>

Here how the URscript run on simulation environment:

[![](https://img.youtube.com/vi/cCrmgDzfd9Q/maxresdefault.jpg "RELEASE 1.1.3 - Polyscope 5.14 commands now supported") ](https://www.youtube.com/watch?v=cCrmgDzfd9Q)
