Difference between revisions of "COBOTTA Rest API"

From RobotinoWiki
(Tag: Removed redirect)
Line 12: Line 12:
 
* Get/Set COBOTTA override
 
* Get/Set COBOTTA override
 
* Get a list of robot programs <br>
 
* Get a list of robot programs <br>
The API is acessable on localhost port 8280
+
The API is acessable on localhost port 8280.
 +
All return values will be json object style.
 
|}
 
|}
  
 
==PUT==
 
==PUT==
 +
===/cobotta/Connect/<host>/, defaults={'port': 5007, 'timeout':2000} ===
 +
===/cobotta/Connect/<host>/<port>/<timeout>===
 +
A connection to the COBOTTA is established.
  
==GET==
+
'''Arguments:'''<br>
 +
''host:'' (str) IP address of COBOTTA<br>
 +
''port:'' (int) TCP communication port -- default: 5007<br>
 +
''timeout:'' (int) time to connection timeout [10ms] -- default: 2000<br>
 +
 
 +
'''Example'''
 +
<pre>
 +
    http://127.0.0.1:8280/cobotta/Connect/172.21.0.30/
 +
</pre>
 +
 
 +
'''Return'''
 +
<pre>
 +
    {"result" : "OK"}
 +
</pre>
 +
 
 +
===/cobotta/StartProgram/<progname>/, defaults={'mode': 1}===
 +
===/cobotta/StartProgram/<progname>/<mode>===
 +
Starts a CobottaWorld robot program.
 +
The program name is handled internally as upper case.
 +
 
 +
'''Arguments:'''<br>
 +
''progname:'' (str) name of CobottaWorld robot program<br>
 +
''mode:'' (int) execution mode -- default: 1 <br>
 +
1:One cycle execution <br>
 +
2:Continuous execution <br>
 +
3:Step forward <br>
 +
 
 +
'''Example'''
 +
    http://127.0.0.1:8280/cobotta/StartProgram/HOME/
 +
 
 +
'''Return'''
 +
<pre>
 +
    {"result" : "OK"}
 +
</pre>
 +
 
 +
===/cobotta/Override/<ovrd>===
 +
Set COBOTTA override to specified value.
 +
 
 +
'''Example'''
 +
    http://127.0.0.1:8280/cobotta/Override/50
 +
 
 +
'''Return'''
 +
<pre>
 +
    {"result" : "OK"}
 +
</pre>
 +
 
 +
===/cobotta/Io/<number>===
 +
Read IO variable from COBOTTA.
 +
Some IO signals are predefined. Please refer to COBOTTA manual ID : 7261 or check the signal's comments in Remote TP App.
 +
 
 +
'''Arguments:''' <br>
 +
''number:'' (int) number of IO <br>
 +
Returns: <br>
 +
(bool) IO variable value
 +
 
 +
'''Example'''
 +
    http://127.0.0.1:8280/cobotta/Io/128
 +
 
 +
'''Return'''
 +
<pre>
 +
    {"result" : "OK",
 +
    "value" : True}
 +
</pre>
 +
 
 +
===/cobotta/Io/<number>/<value>===
 +
Write IO variable to COBOTTA.
 +
Some IO signals are predefined and restricted to use. Please refer to COBOTTA manual ID : 7261 or check the signal's comments in Remote TP App.
 +
 
 +
'''Arguments:''' <br>
 +
''number:'' (int) number of IO <br>
 +
''value:'' (bool) value of IO variable
 +
 
 +
'''Example'''
 +
    http://127.0.0.1:8280/cobotta/Io/128/True
 +
 
 +
'''Return'''
 +
<pre>
 +
    {"result" : "OK"}
 +
</pre>
  
==="/cobotta/Connect/<host>/", defaults={'port': 5007, 'timeout':2000}) <br>
+
===/cobotta/Errors/<errorIndex>===
"/cobotta/Connect/<host>/<port>/<timeout>")===
+
Read a more detailed error inforamtion from robot error list.
A connection to the COBOTTA is established. Also a background task is started wich is used for cyclically monitoring.
 
  
Arguments:<br>
+
'''Arguments:''' <br>
host: (str) IP address of COBOTTA<br>
+
''errorIndex:'' (int) 0-based index of the error list <br>
port: (int) TCP communication port -- default: 5007<br>
 
timeout: (int) time to connection timeout [10ms] -- default 2000<br>
 
  
 
'''Example'''
 
'''Example'''
 +
    http://127.0.0.1:8280/cobotta/Errors/1
 +
 +
'''Return'''
 
<pre>
 
<pre>
     http://127.0.0.1:8280/cobotta/Connect/172.21.0.30/
+
     {"errorCode"    : info[0],          #(VT_I4)
 +
    "errorMessage"  :  info[1],        #(VT_BSTR)
 +
    "errorDescription" : description,  #(VT_BSTR)
 +
    "subCode"      :  info[2],        #(VT_I4)
 +
    "fileID"        :  file_id,        #(VT_I4)
 +
    "lineNumber"    :  line_number,    #(VT_I4)
 +
    "programName"  :  info[4],        #(VT_BSTR)
 +
    "lineNumber"    :  info[5],        #(VT_I4)
 +
    "fileID"        :  info[6]          #(VT_I4)}
 
</pre>
 
</pre>
  
 +
==GET==
 
===/cobotta/Disconnect/===
 
===/cobotta/Disconnect/===
 +
'''Example'''
 +
    http://127.0.0.1:8280/cobotta/Disconnect/
  
 +
'''Return'''
 +
<pre>
 +
    {"result" : "OK"}
 +
</pre>
  
 
===/cobotta/StartMotionPreparation/===
 
===/cobotta/StartMotionPreparation/===
Line 44: Line 141:
  
 
'''Example'''
 
'''Example'''
 +
    http://127.0.0.1:8280/cobotta/StartMotionPreparation/
 +
 +
'''Return'''
 
<pre>
 
<pre>
     http://127.0.0.1:8280
+
     {"result" : "OK"}
 
</pre>
 
</pre>
  
Line 53: Line 153:
 
If your program isn't listed you may need to update the "Job_PCS.h" file.
 
If your program isn't listed you may need to update the "Job_PCS.h" file.
  
Returns:<br>
+
'''Example'''
(str[]) job names
+
    http://127.0.0.1:8280/cobotta/GetProgramList/
  
'''Example'''
+
'''Return'''
 
<pre>
 
<pre>
     http://127.0.0.1:8280
+
     {"result" : "OK",
 +
    "programs" : "HOME", "PickPart", "PropPart"}
 
</pre>
 
</pre>
  
Line 66: Line 167:
  
 
'''Example'''
 
'''Example'''
<pre>
+
     http://127.0.0.1:8280/cobotta/StartHome/
     http://127.0.0.1:8280
 
</pre>
 
  
===/cobotta/StartProgram/<progname>/", defaults={'mode': 1})
+
'''Return'''
/cobotta/StartProgram/<progname>/<mode>/===
 
Starts a CobottaWorld robot program.
 
The program name is handled internally as upper case.
 
 
 
Arguments:<br>
 
progname: (str) name of CobottaWorld robot program<br>
 
mode: (int) execution mode <br>
 
1:One cycle execution <br>
 
2:Continuous execution <br>
 
3:Step forward <br>
 
 
 
'''Example'''
 
 
<pre>
 
<pre>
     http://127.0.0.1:8280
+
     {"result" : "OK"}
 
</pre>
 
</pre>
  
Line 92: Line 179:
  
 
'''Example'''
 
'''Example'''
 +
    http://127.0.0.1:8280/cobotta/ResumeProgram/
 +
 +
'''Return'''
 
<pre>
 
<pre>
     http://127.0.0.1:8280
+
     {"result" : "OK"}
 
</pre>
 
</pre>
 
  
 
===/cobotta/StopPrograms/===
 
===/cobotta/StopPrograms/===
Line 102: Line 191:
  
 
'''Example'''
 
'''Example'''
 +
    http://127.0.0.1:8280/cobotta/StopPrograms/
 +
 +
'''Return'''
 
<pre>
 
<pre>
     http://127.0.0.1:8280
+
     {"result" : "OK"}
 
</pre>
 
</pre>
  
Line 111: Line 203:
  
 
'''Example'''
 
'''Example'''
 +
    http://127.0.0.1:8280/cobotta/CycleEnd/
 +
 +
'''Return'''
 
<pre>
 
<pre>
     http://127.0.0.1:8280
+
     {"result" : "OK"}
 
</pre>
 
</pre>
  
Line 119: Line 214:
  
 
'''Example'''
 
'''Example'''
 +
    http://127.0.0.1:8280/cobotta/ResetError/
 +
 +
'''Return'''
 
<pre>
 
<pre>
     http://127.0.0.1:8280
+
     {"result" : "OK"}
 
</pre>
 
</pre>
  
 
===/cobotta/Errors/===
 
===/cobotta/Errors/===
===/cobotta/Errors/<errorIndex>===
+
Returns the number of currently issued errors.
Check if COBOTTA is in error state.
+
If it returns an error count of 0 than there is no error.
 
 
Returns: <br>
 
(bool) error state; true = COBOTTA in error state
 
  
 
'''Example'''
 
'''Example'''
<pre>
+
     http://127.0.0.1:8280/cobotta/Errors/
     http://127.0.0.1:8280
 
</pre>
 
  
===GetErrorCode()===
+
'''Return'''
Read the COBOTTA hex value error code.
 
 
 
Returns: <br>
 
(str) error code
 
 
 
'''Example'''
 
 
<pre>
 
<pre>
     http://127.0.0.1:8280
+
     {"result" : "OK",
 +
    "errorCount" : count }
 
</pre>
 
</pre>
  
===GetErrorText()===
+
===/cobotta/Override/===
Read the short description of COBOTTA error.
+
Read current COBOTTA override.
 
 
Returns: <br>
 
(str) error description
 
 
 
'''Example'''
 
<pre>
 
    http://127.0.0.1:8280
 
</pre>
 
 
 
===GetErrorInfo()===
 
Read the COBOTTA error info. A more detailed description of COBOTTA errors.
 
 
 
Returns: <br>
 
(str) error info
 
  
 
'''Example'''
 
'''Example'''
<pre>
+
     http://127.0.0.1:8280/cobotta/Override/
     http://127.0.0.1:8280
 
</pre>
 
 
 
===/cobotta/Override/===
 
Sets the COBOTTA override. Reads current override.
 
  
Arguments: <br>
+
'''Return'''
ovrd: (int) override to be set; 1..100 (%) <br>
 
Returns: <br>
 
(float) current override
 
 
 
'''Example'''
 
 
<pre>
 
<pre>
     http://127.0.0.1:8280
+
     {"result" : "OK",
 +
    "override" : 50 }
 
</pre>
 
</pre>
 
/cobotta/Override/<ovrd>
 
  
 
===/cobotta/Status/===
 
===/cobotta/Status/===
 
Read status variables from COBOTTA.  
 
Read status variables from COBOTTA.  
It is handled as array for easier output from a RobotinoView python script block.
 
  
Returns: <br>
+
'''Example'''
(bool[]) current states;  <br>
+
    http://127.0.0.1:8280/cobotta/Status/
[0]: emergency stop staus; true = emergency stop active <br>
 
[1]: busy status; true = task is running <br>
 
[2]: normal status; true = no error <br>
 
[3]: servo status; true = motors ON
 
  
'''Example'''
+
'''Return'''
 
<pre>
 
<pre>
     http://127.0.0.1:8280
+
     {"result" : "OK",
 +
    "emergencyStop" : status[0],
 +
    "busyStatus" : status[1],
 +
    "normalStatus" : status[2],
 +
    "servoStatus" : status[3] }
 
</pre>
 
</pre>
 
  
 
===/cobotta/BusyStatus/===
 
===/cobotta/BusyStatus/===
 
+
During motion preperation the communication to COBOTTA is blocked by motion preperation task. For this reason status update with /cobotta/Status doesn't work. /cobotta/BusyStatus uses in that case a flag which is set before and reset after motion preperation is done.
===/cobotta/Io/<number>===
 
Read IO variable from COBOTTA.  
 
 
 
Arguments: <br>
 
number: (int) number of IO <br>
 
Returns: <br>
 
(bool) IO variable value
 
  
 
'''Example'''
 
'''Example'''
<pre>
+
     http://127.0.0.1:8280/cobotta/BusyStatus/
     http://127.0.0.1:8280
 
</pre>
 
 
 
===/cobotta/Io/<number>/<value>===
 
Write IO variable to COBOTTA.
 
  
Arguments: <br>
+
'''Return'''
number: (int) number of IO <br>
 
value: (bool) value of IO variable
 
 
 
'''Example'''
 
 
<pre>
 
<pre>
     http://127.0.0.1:8280
+
     {"result" : "OK",
 +
    "busy" : True}
 
</pre>
 
</pre>
 
  
 
==Change Log==
 
==Change Log==

Revision as of 14:50, 7 April 2021

Introduction

This RESTful API which uses cobottabcap python class to communicate with denso robotics COBOTTA.

It provides several PUT/GET methods to control the COBOTTA such as

  • Connect/Dissconnect to COBOTTA
  • Start/Stop CobottaWorld program
  • Read/Write IOs
  • Get COBOTTA error status, description
  • Reset COBOTTA error
  • Get COBOTTA status information
  • Get/Set COBOTTA override
  • Get a list of robot programs

The API is acessable on localhost port 8280. All return values will be json object style.

PUT

/cobotta/Connect/<host>/, defaults={'port': 5007, 'timeout':2000}

/cobotta/Connect/<host>/<port>/<timeout>

A connection to the COBOTTA is established.

Arguments:
host: (str) IP address of COBOTTA
port: (int) TCP communication port -- default: 5007
timeout: (int) time to connection timeout [10ms] -- default: 2000

Example

    http://127.0.0.1:8280/cobotta/Connect/172.21.0.30/

Return

    {"result" : "OK"}

/cobotta/StartProgram/<progname>/, defaults={'mode': 1}

/cobotta/StartProgram/<progname>/<mode>

Starts a CobottaWorld robot program. The program name is handled internally as upper case.

Arguments:
progname: (str) name of CobottaWorld robot program
mode: (int) execution mode -- default: 1
1:One cycle execution
2:Continuous execution
3:Step forward

Example

   http://127.0.0.1:8280/cobotta/StartProgram/HOME/

Return

    {"result" : "OK"}

/cobotta/Override/<ovrd>

Set COBOTTA override to specified value.

Example

   http://127.0.0.1:8280/cobotta/Override/50

Return

    {"result" : "OK"}

/cobotta/Io/<number>

Read IO variable from COBOTTA. Some IO signals are predefined. Please refer to COBOTTA manual ID : 7261 or check the signal's comments in Remote TP App.

Arguments:
number: (int) number of IO
Returns:
(bool) IO variable value

Example

   http://127.0.0.1:8280/cobotta/Io/128

Return

    {"result" : "OK",
     "value" : True}

/cobotta/Io/<number>/<value>

Write IO variable to COBOTTA. Some IO signals are predefined and restricted to use. Please refer to COBOTTA manual ID : 7261 or check the signal's comments in Remote TP App.

Arguments:
number: (int) number of IO
value: (bool) value of IO variable

Example

   http://127.0.0.1:8280/cobotta/Io/128/True

Return

    {"result" : "OK"}

/cobotta/Errors/<errorIndex>

Read a more detailed error inforamtion from robot error list.

Arguments:
errorIndex: (int) 0-based index of the error list

Example

   http://127.0.0.1:8280/cobotta/Errors/1

Return

    {"errorCode"     : info[0],          #(VT_I4)
     "errorMessage"  :  info[1],         #(VT_BSTR)
     "errorDescription" : description,   #(VT_BSTR)
     "subCode"       :  info[2],         #(VT_I4)
     "fileID"        :  file_id,         #(VT_I4)
     "lineNumber"    :  line_number,     #(VT_I4)
     "programName"   :  info[4],         #(VT_BSTR)
     "lineNumber"    :  info[5],         #(VT_I4)
     "fileID"        :  info[6]          #(VT_I4)}

GET

/cobotta/Disconnect/

Example

   http://127.0.0.1:8280/cobotta/Disconnect/

Return

    {"result" : "OK"}

/cobotta/StartMotionPreparation/

This method sould be called once after switching on the COBOTTA or if the COBOTTA had a hard collision. The COBOTTA prepares it's system for operation and drives to the CALSET position. Make sure that there are no obstacles around the COBOTTA before running the motion preperation. Refer to manual ID : 7291 for detaild information about COBOTTA startup. After axis calibration the "HOME" program is started. HOME program has to be defined in CobottaWorld app.

Example

   http://127.0.0.1:8280/cobotta/StartMotionPreparation/

Return

    {"result" : "OK"}

/cobotta/GetProgramList/

Get the program names of CobottaWorld programs and returns them as string array. The update is also done during the instantiation. If your program isn't listed you may need to update the "Job_PCS.h" file.

Example

   http://127.0.0.1:8280/cobotta/GetProgramList/

Return

    {"result" : "OK",
     "programs" : "HOME", "PickPart", "PropPart"}

/cobotta/StartHome/

Starts the HOME program. HOME program has to be defined in CobottaWorld app. This method is also used internally to drive to HOME position in MotionPreparation method.

Example

   http://127.0.0.1:8280/cobotta/StartHome/

Return

    {"result" : "OK"}

/cobotta/ResumeProgram/

Continues a CobottaWorld robot program. E.g. after error reset. The program has to be started with "StartProgram" method, first.

Example

   http://127.0.0.1:8280/cobotta/ResumeProgram/

Return

    {"result" : "OK"}

/cobotta/StopPrograms/

Stops all running robot programs. Programs will be stopped immediately.

Example

   http://127.0.0.1:8280/cobotta/StopPrograms/

Return

    {"result" : "OK"}

/cobotta/CycleEnd/

End all running robot programs. Programs will be stopped at the end of the program.

Example

   http://127.0.0.1:8280/cobotta/CycleEnd/

Return

    {"result" : "OK"}

/cobotta/ResetError/

Resets all errors of COBOTTA.

Example

   http://127.0.0.1:8280/cobotta/ResetError/

Return

    {"result" : "OK"}

/cobotta/Errors/

Returns the number of currently issued errors. If it returns an error count of 0 than there is no error.

Example

   http://127.0.0.1:8280/cobotta/Errors/

Return

    {"result" : "OK",
     "errorCount" : count }

/cobotta/Override/

Read current COBOTTA override.

Example

   http://127.0.0.1:8280/cobotta/Override/

Return

    {"result" : "OK",
     "override" : 50 }

/cobotta/Status/

Read status variables from COBOTTA.

Example

   http://127.0.0.1:8280/cobotta/Status/

Return

    {"result" : "OK",
     "emergencyStop" : status[0],
     "busyStatus" : status[1],
     "normalStatus" : status[2],
     "servoStatus" : status[3] }

/cobotta/BusyStatus/

During motion preperation the communication to COBOTTA is blocked by motion preperation task. For this reason status update with /cobotta/Status doesn't work. /cobotta/BusyStatus uses in that case a flag which is set before and reset after motion preperation is done.

Example

   http://127.0.0.1:8280/cobotta/BusyStatus/

Return

    {"result" : "OK",
     "busy" : True}

Change Log

This are the changes in cobottabcap class.
You can check your version with cobotta/version/.

Date Version Changes
22.01.2021 1.0.0 first Release

COBOTTA® is a registered trademark of Denso Corporation in certain countries.