Skip to main content
Glama

nUR MCP Server

by nonead
dashboard.cpython-312.pyc22 kB
� #0h�?���dZdZdZdZddlZddlZddlZddlZddlZddl Z dZ Gd�d�Z Gd �d ej�Z y) ax Python 3.x library to control an UR robot through its TCP/IP interfaces Copyright (C) 2017 Martin Huus Bjerge, Rope Robotics ApS, Denmark Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL "Rope Robotics ApS" BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of "Rope Robotics ApS" shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from "Rope Robotics ApS". zMartin Huus Bjergez*Copyright 2017, Rope Robotics ApS, Denmarkz MIT License�Ng@c� �eZdZdZdZdZdZdZy)�ConnectionStater����N)�__name__� __module__� __qualname__�ERROR� DISCONNECTED� CONNECTED�PAUSED�STARTED���SD:\mcp\Nonead-Universal-Robots-MCP\Nonead-Universal-Robots-MCP\URBasic\dashboard.pyrr&s�� �E��L��I� �F��Grrc���eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z d �Z d%d �Z d �Zd �Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd&d�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%y$)'� DashBoarda� A Universal Robot can be controlled from remote by sending simple commands to the GUI over a TCP/IP socket. This interface is called the "DashBoard server". The server is running on port 29999 on the robots IP address. See more at: http://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/dashboard-server-port-29999-15690/ https://www.universal-robots.com/articles/ur/dashboard-server-e-series-port-29999/ The constructor takes a UR robot hostname as input, and optional a logger object. Input parameters: host (string): hostname or IP of UR Robot (RT CLient server) Example: rob = URBasic.realTimeClient.RT_CLient('192.168.56.101') self.close_rtc() c�� ||_d|_t j|_d|_ d|_ tjj|�tj�|_tj �|_d|_|j'�|jt j(k\r|j+�yy)zB Constructor see class description for more info. rNT)� isinstance�URBasic� robotModel� RobotModel�_DashBoard__robotModel�_DashBoard__reconnectTimeoutrr �_DashBoard__conn_state� last_respond�_DashBoard__stop_event� threading�Thread�__init__� Condition�_DashBoard__dataEvent�Lock�_DashBoard__dataAccess�_DashBoard__sock�startr�wait_dbs)�selfrs rr"zDashBoard.__init__Cs��� �&���"#���+�8�8��� ��� ������!�!�$�'�$�.�.�0���%�N�N�,����� � � � � � � � �� 9� 9� 9� �M�M�O� :rc�2�|jd|zdz�y)z� Load the specified program. Return when loading has completed. Return value to Log file: "Loading program: <program.urp>" OR "File not found: <program.urp>" zload � N��_DashBoard__send)r*�files r�ur_loadzDashBoard.ur_loadYs�� � � �G�d�N�T�)�*rc�&�|jd�y)z� Starts program, if any program is loaded and robot is ready. Return when the program execution has been started. Return value to Log file: "Starting program" zplay Nr-�r*s r�ur_playzDashBoard.ur_playb��� � � �H�rc�&�|jd�y)z� Stops running program and returns when stopping is completed. Return value to Log file: "Stopped" zstop Nr-r2s r�ur_stopzDashBoard.ur_stopkr4rc�&�|jd�y)z� Pauses the running program and returns when pausing is completed. Return value to Log file: "Pausing program" zpause Nr-r2s r�ur_pausezDashBoard.ur_pauseus�� � � �I�rc�&�|jd�y)z� Shuts down and turns off robot and controller. Return value to Log file: "Shutting down" z shutdown Nr-r2s r� ur_shutdownzDashBoard.ur_shutdown��� � � �L�!rc�&�|jd�y)z� Execution state enquiry. Return value to Log file: "Robot running: True" OR "Robot running: False" zrunning Nr-r2s r� ur_runningzDashBoard.ur_running�s�� � � �K� rc�&�|jd�y)a) Robot mode enquiry Return value to Log file: "Robotmode: <mode>", where <mode> is: NO_CONTROLLER DISCONNECTED CONFIRM_SAFETY BOOTING POWER_OFF POWER_ON IDLE BACKDRIVE RUNNING z robotmode Nr-r2s r� ur_robotmodezDashBoard.ur_robotmode�s�� � � �M�"rc�&�|jd�y)z� Which program is loaded. Return value to Log file: "Program loaded: <path to loaded program file>" OR "No program loaded" zget loaded program Nr-r2s r�ur_get_loaded_programzDashBoard.ur_get_loaded_program���� � � �*�+rc�2�|jd|zdz�y)z� The popup-text will be translated to the selected language, if the text exists in the language file. Return value to Log file: "showing popup" zpopup r,Nr-)r*� popupTexts r�ur_popupzDashBoard.ur_popup�s�� � � �H�y�(�4�/�0rc�&�|jd�y)zf Closes the popup. Return value to Log file: "closing popup" z close popup Nr-r2s r�ur_close_popupzDashBoard.ur_close_popup�s�� � � �O�$rc�2�|jd|zdz�y)z� Adds log-message to the Log history. Return value to Log file: "Added log message" Or "No log message to add" z addToLog r,Nr-)r*� logMessages r� ur_addToLogzDashBoard.ur_addToLog�s�� � � �K�*�,�t�3�4rc�2�|jd|zdz�y)z� Simple control of user privileges: controls the available options on the Welcome screen. Return value to Log file: "Setting user role: <role>" OR "Failed setting user role: <role>" � setUserRole r,Nr-)r*�roles r�ur_setUserRolezDashBoard.ur_setUserRole�s�� � � �N�T�)�D�0�1rc�&�|jd�y)z� Returns the save state of the active program. Return value to Log file: "True" OR "False" zisProgramSaved Nr-r2s r�ur_isProgramSavedzDashBoard.ur_isProgramSaved�s�� � � �&�'rc�&�|jd�y)z� Returns the state of the active program, or STOPPED if no program is loaded. Return value to Log file: "STOPPED" if no program is running OR "PLAYING" if program is running z programState Nr-r2s r�ur_programStatezDashBoard.ur_programState�s�� � � �$�%rc�&�|jd�y)z� Returns the version of the Polyscope software. Return value to Log file: version number, like "3.0.15547" zpolyscopeVersion Nr-r2s r�ur_polyscopeVersionzDashBoard.ur_polyscopeVersion�s�� � � �(�)rc�J�|jd|zdz|zdz|zdz�y)a� "setUserRole <role>, where <role> is" programmer = "SETUP Robot" button is disabled, "Expert Mode" is available (if correct password is supplied) operator = Only "RUN Program" and "SHUTDOWN Robot" buttons are enabled, "Expert Mode" cannot be activated none ( or send setUserRole) = All buttons enabled, "Expert Mode" is available (if correct password is supplied) locked = All buttons disabled and "Expert Mode" cannot be activated Control of user privileges: controls the available options on the Welcome screen. Note: If the Welcome screen is not active when the command is sent, the user privileges defined by the new user role will not be effective until the user switches to the Welcome screen. Return value to Log file: "Setting user role: <role>" OR "Failed setting user role: <role>" rLz, where z isr,Nr-)r*rM�levels r�ur_setUserRole_wherezDashBoard.ur_setUserRole_where�s.�� � � �N�D�(�:�5��<�u�D�u�L�d�R�Src�&�|jd�y)zk Powers on the robot arm. Return value to Log file: "Powering on" z power on Nr-r2s r� ur_power_onzDashBoard.ur_power_on�r;rc�&�|jd�y)zm Powers off the robot arm. Return value to Log file: "Powering off" z power off Nr-r2s r� ur_power_offzDashBoard.ur_power_offs�� � � �M�"rc�&�|jd�y)zs Releases the brakes. Return value to Log file: "Brake releasing" zbrake release Nr-r2s r�ur_brake_releasezDashBoard.ur_brake_releases�� � � �%�&rc�$�|jd�S)aK Safety mode enquiry. Return value to Log file: "safety mode: <mode>", where <mode> is NORMAL REDUCED PROTECTIVE_STOP RECOVERY SAFEGUARD_STOP SYSTEM_EMERGENCY_STOP ROBOT_EMERGENCY_STOP VIOLATION FAULT z safetymode r-r2s r� ur_safetymodezDashBoard.ur_safetymodes��"�{�{�>�*�*rc�&�|jd�y)z� Closes the current popup and unlocks protective stop. Return value to Log file: "Protective stop releasing" zunlock protective stop Nr-r2s r�ur_unlock_protective_stopz#DashBoard.ur_unlock_protective_stop+s�� � � �.�/rc�&�|jd�y)zz Closes a safety popup. Return value to Log file: "closing safety popup" zclose safety popup Nr-r2s r�ur_close_safety_popupzDashBoard.ur_close_safety_popup4rBrc�2�|jd|zdz�y)z� Loads the specified installation file. Return value to Log file: "Loading installation: <default.installation>" OR "File not found: <default.installation>" zload installation r,Nr-)r*�instals r�ur_load_installationzDashBoard.ur_load_installation=s�� � � �(�&�0�$�6�7rc�&�|jd�y)zO Return serial number: "serial number: XXXXXXX" OR "" zget serial number Nr-r2s r�ur_serial_numberzDashBoard.ur_serial_numberFs�� � � �)�*rc�&�|jd�y)z� Returns the remote-control status of the robot. If the robot is in remote control it returns false and if remote control is disabled or robot is in local control it returns false. zis in remote control Nr-r2s r�ur_is_remote_controlzDashBoard.ur_is_remote_controlNs�� � � �,�-rc�&�|jd�y)z) Returns the robot model zget robot model Nr-r2s r�ur_get_robot_modelzDashBoard.ur_get_robot_modelWs�� � � �'�(rc��|jrytj�}tj�|z |jk�rC|jtj k�r% t j t jt j�|_|jjt jt jd�|jjt jt jd�|jjt�|jj!|j"j$df�tj |_tj&d�yy#t j(t j*f$r d|_YnwxYwtj�|z |jks�V|jtj kr����v)zs Initialize DashBoard connection to host. Return value: success (boolean) Tri/ug�?NF)r'�timerrrr�socket�AF_INET� SOCK_STREAM� setsockopt� IPPROTO_TCP� TCP_NODELAY� SOL_SOCKET� SO_REUSEADDR� settimeout�DEFAULT_TIMEOUT�connectr� ipAddress�sleep�timeout�error)r*�t0s r� __connectzDashBoard.__connectbsR�� �;�;�� �Y�Y�[���y�y�{�2�~�d�5�5�5�4�;L�;L��Oh�Oh�;h� #�$�m�m�F�N�N�F�<N�<N�O�� �� � �&�&�v�'9�'9�6�;M�;M�q�Q�� � �&�&�v�'8�'8�&�:M�:M�q�Q�� � �&�&��7�� � �#�#�T�%6�%6�%@�%@�%�$H�I�$3�$=�$=��!�� � �3��� �� �N�N�F�L�L�1� #�"�� � #���y�y�{�2�~�d�5�5�5�4�;L�;L��Oh�Oh�;h�s�&D#F � *F8�7F8c���|jdurd|_|j�|jr!|jj�d|_tj |_y)z� Close the DashBoard connection. Example: rob = URBasic.dashboard.DashBoard('192.168.56.101', rtde_conf_filename='rtde_configuration.xml', logger=logger) rob.close_dbs() FTN)r�joinr'�closerr rr2s rr�zDashBoard.close~sR�� � � �� %� $�D� � �I�I�K� �;�;� �K�K� � � ��D�K�+�8�8���rc�<�|jtjk\S)z= Return True if Dash Board server is running )rrrr2s r�dbs_is_runningzDashBoard.dbs_is_running�s��� � �O�$;�$;�;�;rc��d|_tj�}tj�|z |jkr�|jtj krh|j �std�td��tj�|z |jkr|jtj kr�h|jtj kr td��|js�tj�|z |jkr� |j�}|�||_ |j5|jj�ddd�tj�}tj|_|js%tj�|z |jkr��tj$|_|j5|jj�ddd�y#1swY��xYw#t$r�|jtj k\rOtj|_ |j j#�n#YnxYwd|_|j �|jtj k\r td�n td�Y��.wxYw#1swYyxYw)NFzUR Dashboard connection failed!z9UR Dashboard interface not able to connect and timed out!z&Dashboard server interface reconnectedz%Dashboard server reconnection failed!)rrnrrrr�_DashBoard__connect�print� ValueError�_DashBoard__receiverr$� notifyAllr� Exceptionr r'r�r)r*r~�msgs r�runz DashBoard.run�s��!��� �Y�Y�[���y�y�{�2�~�d�5�5�5�4�;L�;L��Oh�Oh�;h��>�>�#��7�8� �!B�C�C� �y�y�{�2�~�d�5�5�5�4�;L�;L��Oh�Oh�;h� � � ��8�8� 8��X�Y� Y��$�$�4�9�9�;�r�>�$�:Q�:Q�+Q� C��n�n�&���?�(+�D�%��%�%��$�$�.�.�0�&��Y�Y�[��$3�$;�$;��!��$�$�4�9�9�;�r�>�$�:Q�:Q�+Q�>,�2�2��� � � � � � � &� &� (�� �3&�%�� � C��$�$��(A�(A�A�(7�(=�(=�D�%��� � �)�)�+�����"&�D�K��N�N�$��$�$��(A�(A�A��B�C��A�B��# C��(� �sO�%H�H�1H�!K�H� H�;J>� I(�'J>�(I,�*AJ>�=J>�K c�z�|j5|jj�ddd�y#1swYyxYw)z@Wait while the data receiving thread is receiving a new message.N)r$�waitr2s rr)zDashBoard.wait_dbs�s)�� � � � � � � !� !� #�� � �s�1�:c���tj�}tj�|z |jkr� t|d�}tjg|jggt �\}}}t |�r,|jj|�|j�y tj�|z |jkr��y#td�Y�5xYw)z� Send command to Robot Controller. Input parameters: cmd (str) Return value: success (boolean) zutf-8TzCould not send program!F) rnr�bytes�selectr'rx�len�sendallr)r�)r*�cmdr~�buf�_�writables r�__sendzDashBoard.__send�s����Y�Y�[���y�y�{�2�~�d�5�5�5� 1��C��)��#)�=�=��d�k�k�]�B��#X� ��H�a��x�=��K�K�'�'��,��M�M�O��!� �y�y�{�2�~�d�5�5�5���  1��/�0�s �A-C� Cc�h�tj|jgggt�\}}}t|�r||jj d�}t|�dk(rydt t|��zdz}t j||�}djtt|dd��Sy)z� Receive the respond a send command from the Robot Controller. Return value: Output from Robot controller (type is depended on the input parameters) irN�>�B������) r�r'rxr��recv�str�struct� unpack_fromr��map�chr)r*�readabler��data�fmt�outs r� __receivezDashBoard.__receive�s���"�=�=�$�+�+���B��P���1�a� �x�=��;�;�#�#�D�)�D��4�y�A�~����C��I��&��,�C��%�%�c�4�0�C��7�7�3�s�3�s��8�,�-� -� rN)r�)zdefault.installation)&r r r �__doc__r"r0r3r6r8r:r=r?rArErGrJrNrPrRrTrWrYr[r]r_rarcrfrhrjrlr�r�r�r�r)r.r�rrrrr.s����(�,+����"�!�#�$,�1�%�5�2�(�&�*�T�$"�#�'�+�&0�,�8�+�.�)��8�&<�/)�d$� �<.rr)r�� __author__� __copyright__� __license__rr ror�r�rnrxrr!rrrr�<module>r�sP���0"� �<� �� ��� � � � �����N.� � � �N.r

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nonead/nUR-MCP-SERVER'

If you have feedback or need assistance with the MCP directory API, please join our Discord server