Difference between revisions of "COBOTTA Rest API"
(Tag: New redirect) |
|||
(16 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | ==Introduction== | |
+ | {|class="wikitable" cellpadding="20" vertical-align="top" | ||
+ | |- | ||
+ | |This RESTful API which uses cobottabcap python class to communicate with denso robotics COBOTTA.<br> | ||
+ | It provides several PUT/GET methods to control the COBOTTA such as | ||
+ | * Connect/Dissconnect to COBOTTA | ||
+ | * Start/Stop Cobotta World program | ||
+ | * Read/Write IOs | ||
+ | * Get COBOTTA error status, description | ||
+ | * Reset COBOTTA error | ||
+ | * Get COBOTTA status information | ||
+ | * Get/Set COBOTTA speed | ||
+ | * Get a list of robot programs <br> | ||
+ | |} | ||
+ | |||
+ | The API is acessable on robotino's IP address on port 8280. <br> | ||
+ | All parameters and return values will be json object style. <br> | ||
+ | Each call will return a http return code. You most likely get one of theese: <br> | ||
+ | 200 - request was successful <br> | ||
+ | 403 - COBOTTA is not ready to perform the requested action. E.g. in error state or already busy<br> | ||
+ | 412 - your (POST) request is missing parameters<br> | ||
+ | 500 - COBOTTA raised an error while executing the requested action<br> | ||
+ | |||
+ | In any case the returned object has a member called ''result'' which will have the value "OK" or "FAILED". | ||
+ | If the ''result'' is "FAILED" than there is also the member ''reason'' which describes the error. <br> | ||
+ | |||
+ | ==PUT== | ||
+ | ===/cobotta/Reference=== | ||
+ | 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 COBOTTA manual ID : 7291 for detaild information about COBOTTA startup. | ||
+ | |||
+ | '''Parameter:'''<br> | ||
+ | ''execute:'' (bool as int 0/1) execute the operation <br> | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Reference | ||
+ | Parameter: | ||
+ | {"execute" : 1} | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK"} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Program/Start=== | ||
+ | Start a Cobotta World program. | ||
+ | The program name is handled internally as upper case. | ||
+ | |||
+ | '''Parameter:'''<br> | ||
+ | ''execute:'' (bool as int 0/1) execute the operation <br> | ||
+ | ''progname:'' (str) name of Cobotta World robot program<br> | ||
+ | ''mode:'' (optional)(int) execution mode -- default: 1 <br> | ||
+ | 1:One cycle execution <br> | ||
+ | 2:Continuous execution <br> | ||
+ | 3:Step forward <br> | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Program/Start | ||
+ | Parameter: | ||
+ | {"execute" : 1, | ||
+ | "progname" : "HOME"} | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK"} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Program/Stop=== | ||
+ | Stops all running robot programs. <br> | ||
+ | Programs will be stopped immediately and connot be continued. | ||
+ | |||
+ | '''Parameter:'''<br> | ||
+ | ''execute:'' (bool as int 0/1) execute the operation <br> | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Program/Stop | ||
+ | Parameter: | ||
+ | {"execute" : 1} | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK"} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Program/Hold=== | ||
+ | End all running robot programs.<br> | ||
+ | Program will be stopped. The program can be continued by issuing Resume command. | ||
+ | |||
+ | '''Parameter:'''<br> | ||
+ | ''execute:'' (bool as int 0/1) execute the operation <br> | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Program/Hold | ||
+ | Parameter: | ||
+ | {"execute" : 1} | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK"} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Program/Resume=== | ||
+ | Continues a Cobotta World robot program. E.g. after error reset.<br> | ||
+ | The program has to be started with "StartProgram" method, first. | ||
+ | |||
+ | '''Parameter:'''<br> | ||
+ | ''execute:'' (bool as int 0/1) execute the operation <br> | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Program/Resume | ||
+ | Parameter: | ||
+ | {"execute" : 1} | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK"} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Speed=== | ||
+ | Set COBOTTA speed to specified value. | ||
+ | |||
+ | '''Parameter:'''<br> | ||
+ | ''speed:'' (int) Speed set value [%] | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Speed | ||
+ | Parameter: | ||
+ | {"speed" : 50} | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK"} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Io/<number>=== | ||
+ | Write IO variable to COBOTTA. <br> | ||
+ | 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. | ||
+ | |||
+ | '''Parameter:''' <br> | ||
+ | ''number:'' (int) number of IO <br> | ||
+ | ''value:'' (bool as int 0/1) value of IO variable | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Io/128 | ||
+ | Parameter: | ||
+ | {"value" : 1} | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK"} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/ChangeConnectionParameters=== | ||
+ | Changes the connection parameters. For the changes to take effect you have to call GET /CloseConnection and afterwards GET /OpenConnection. | ||
+ | |||
+ | '''Parameter:''' <br> | ||
+ | ''ip:'' (str) COBOTTA IP address <br> | ||
+ | ''port:'' (optional)(int) COBOTTA communication port -- default: 5007 <br> | ||
+ | ''timeout:'' (optional)(int) time for connection timeout [1/10 s] -- default: 2000 <br> | ||
+ | ''intervall:'' (optional)(int) intervall for cyclic status update [ms] -- default: 250 <br> | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/ChangeConnectionParameters | ||
+ | Parameter: | ||
+ | {"ip" : "192.168.0.1", | ||
+ | "port" : 5007, | ||
+ | "timeout" : 2000, | ||
+ | "intervall" : 250} | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK"} | ||
+ | </pre> | ||
+ | |||
+ | ==GET== | ||
+ | ===/cobotta/Versions=== | ||
+ | Returns version of REST-API and cobottabcab class | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Versions | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK", | ||
+ | "rest_api": "1.0.0", | ||
+ | "b_cap_lib": "1.0.0"} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/OpenConnection=== | ||
+ | Opens the connection to COBOTTA. After cyclic update of status variables is started | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/OpenConnection | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK"} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/CloseConnection=== | ||
+ | Stopps cyclic status update and disconnects from COBOTTA | ||
+ | |||
+ | '''Returns:''' <br> | ||
+ | ''connection_settings:'' (obj) settings for connection to COBOTTA and cyclic status update | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/CloseConnection | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK", | ||
+ | "connection_settings": | ||
+ | {"host": "172.21.0.30", | ||
+ | "port": 5007, | ||
+ | "timeout": 2000, | ||
+ | "intervall": 250}} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Program/GetList=== | ||
+ | Get the program names of Cobotta World programs and returns them as string array.<br> | ||
+ | The update is also done during the instantiation.<br> | ||
+ | If your program isn't listed you may need to update the "Job_PCS.h" file. | ||
+ | |||
+ | '''Returns:''' <br> | ||
+ | ''programs:'' (str[]) Cobotta World program names | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Program/GetList | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK", | ||
+ | "programs" : ["HOME", "PickPart", "PropPart"]} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Error/Reset=== | ||
+ | Resets all errors of COBOTTA. | ||
+ | |||
+ | '''Parameter:'''<br> | ||
+ | ''execute:'' (bool as int 0/1) execute the operation <br> | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Error/Reset | ||
+ | Parameter: | ||
+ | {"execute" : 1} | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK"} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Error=== | ||
+ | Returns the number of currently issued errors. <br> | ||
+ | If it returns an error count of 0 then there is no error.<br> | ||
+ | Also returns an array of error deails. Containing an error code and a description text. | ||
+ | |||
+ | '''Returns:''' <br> | ||
+ | ''errorCount:'' (int) number of currently issued errors<br> | ||
+ | ''details:'' (obj[]) array of error details containing errorCode and errorMessage<br> | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Error | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK", | ||
+ | "errorCount" : count, | ||
+ | "details" : [{ "errorCode": code, | ||
+ | "errorMessage": description | ||
+ | }] } | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Speed=== | ||
+ | Read current COBOTTA speed. | ||
+ | |||
+ | '''Returns:''' <br> | ||
+ | ''speed:'' (int) current COBOTTA speed value [%] | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Speed | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK", | ||
+ | "speed" : 50 } | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Status=== | ||
+ | Read status variables from COBOTTA. | ||
+ | |||
+ | '''Returns:''' <br> | ||
+ | COBOTTA staus variables. <br> | ||
+ | ''connectedStatus:'' (bool as int 0/1) Connection between Robotino and COBOTTA is established<br> | ||
+ | ''referencedStatus:'' (bool as int 0/1) COBOTTA reference motion was performed<br> | ||
+ | ''busyStatus:'' (bool as int 0/1) COBOTTA is executing a program<br> | ||
+ | ''emergencyStop:'' (bool as int 0/1) COBOTTA emergency stop is pressed<br> | ||
+ | ''errorStatus:'' (bool as int 0/1) COBOTTA in error state<br> | ||
+ | ''thread_status:'' (bool as int 0/1) status of the thread which cyclically updates the COBOTTA status<br> | ||
+ | ''speed:'' (int) speed of COBOTTA [%] | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Status | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK", | ||
+ | "connectedStatus": 0, | ||
+ | "referencedStatus": 0, | ||
+ | "busyStatus": 0, | ||
+ | "emergencyStop": 0, | ||
+ | "errorStatus": 0, | ||
+ | "thread_status": 0, | ||
+ | "speed": 0} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Io/<number>=== | ||
+ | Read IO variable from COBOTTA. <br> | ||
+ | Some IO signals are predefined. Please refer to COBOTTA manual ID : 7261 or check the signal's comments in Remote TP App. <br> | ||
+ | Default user IOs start at IO 128. | ||
+ | |||
+ | '''Parameter:''' <br> | ||
+ | ''number:'' (int) number of IO <br> | ||
+ | '''Returns:''' <br> | ||
+ | ''value:'' (bool as int 0/1) IO variable value. | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Io/128 | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK", | ||
+ | "value" : 0} | ||
+ | </pre> | ||
+ | |||
+ | ===/cobotta/Log=== | ||
+ | Get log entries of cobottabcap class. Returns last 50 entries. The complete logfile is located at /opt/robotino/cobotta/logfile.txt. | ||
+ | |||
+ | '''Returns:''' <br> | ||
+ | ''loglines:'' (str[]) log entries. | ||
+ | |||
+ | '''Example''' | ||
+ | <pre> | ||
+ | http://127.0.0.1:8280/cobotta/Log | ||
+ | </pre> | ||
+ | '''Return''' | ||
+ | <pre> | ||
+ | {"result" : "OK", | ||
+ | "log_lines": ["11:33:07.085;Connect called\n", | ||
+ | "11:33:07.087;Try to connect\n", | ||
+ | ... ]} | ||
+ | </pre> | ||
+ | |||
+ | ==Change Log== | ||
+ | This are the changes in cobottabcap class. <br> | ||
+ | You can check your version with cobotta/version/. | ||
+ | {| border="1" | ||
+ | !Date | ||
+ | !Version | ||
+ | !Changes | ||
+ | |- | ||
+ | |22.01.2021 | ||
+ | |1.0.0 | ||
+ | |first Release | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | <small> COBOTTA® is a registered trademark of Denso Corporation in certain countries. </small> |
Latest revision as of 12:45, 30 July 2021
Contents
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
|
The API is acessable on robotino's IP address on port 8280.
All parameters and return values will be json object style.
Each call will return a http return code. You most likely get one of theese:
200 - request was successful
403 - COBOTTA is not ready to perform the requested action. E.g. in error state or already busy
412 - your (POST) request is missing parameters
500 - COBOTTA raised an error while executing the requested action
In any case the returned object has a member called result which will have the value "OK" or "FAILED".
If the result is "FAILED" than there is also the member reason which describes the error.
PUT
/cobotta/Reference
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 COBOTTA manual ID : 7291 for detaild information about COBOTTA startup.
Parameter:
execute: (bool as int 0/1) execute the operation
Example
http://127.0.0.1:8280/cobotta/Reference Parameter: {"execute" : 1}
Return
{"result" : "OK"}
/cobotta/Program/Start
Start a Cobotta World program. The program name is handled internally as upper case.
Parameter:
execute: (bool as int 0/1) execute the operation
progname: (str) name of Cobotta World robot program
mode: (optional)(int) execution mode -- default: 1
1:One cycle execution
2:Continuous execution
3:Step forward
Example
http://127.0.0.1:8280/cobotta/Program/Start Parameter: {"execute" : 1, "progname" : "HOME"}
Return
{"result" : "OK"}
/cobotta/Program/Stop
Stops all running robot programs.
Programs will be stopped immediately and connot be continued.
Parameter:
execute: (bool as int 0/1) execute the operation
Example
http://127.0.0.1:8280/cobotta/Program/Stop Parameter: {"execute" : 1}
Return
{"result" : "OK"}
/cobotta/Program/Hold
End all running robot programs.
Program will be stopped. The program can be continued by issuing Resume command.
Parameter:
execute: (bool as int 0/1) execute the operation
Example
http://127.0.0.1:8280/cobotta/Program/Hold Parameter: {"execute" : 1}
Return
{"result" : "OK"}
/cobotta/Program/Resume
Continues a Cobotta World robot program. E.g. after error reset.
The program has to be started with "StartProgram" method, first.
Parameter:
execute: (bool as int 0/1) execute the operation
Example
http://127.0.0.1:8280/cobotta/Program/Resume Parameter: {"execute" : 1}
Return
{"result" : "OK"}
/cobotta/Speed
Set COBOTTA speed to specified value.
Parameter:
speed: (int) Speed set value [%]
Example
http://127.0.0.1:8280/cobotta/Speed Parameter: {"speed" : 50}
Return
{"result" : "OK"}
/cobotta/Io/<number>
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.
Parameter:
number: (int) number of IO
value: (bool as int 0/1) value of IO variable
Example
http://127.0.0.1:8280/cobotta/Io/128 Parameter: {"value" : 1}
Return
{"result" : "OK"}
/cobotta/ChangeConnectionParameters
Changes the connection parameters. For the changes to take effect you have to call GET /CloseConnection and afterwards GET /OpenConnection.
Parameter:
ip: (str) COBOTTA IP address
port: (optional)(int) COBOTTA communication port -- default: 5007
timeout: (optional)(int) time for connection timeout [1/10 s] -- default: 2000
intervall: (optional)(int) intervall for cyclic status update [ms] -- default: 250
Example
http://127.0.0.1:8280/cobotta/ChangeConnectionParameters Parameter: {"ip" : "192.168.0.1", "port" : 5007, "timeout" : 2000, "intervall" : 250}
Return
{"result" : "OK"}
GET
/cobotta/Versions
Returns version of REST-API and cobottabcab class
Example
http://127.0.0.1:8280/cobotta/Versions
Return
{"result" : "OK", "rest_api": "1.0.0", "b_cap_lib": "1.0.0"}
/cobotta/OpenConnection
Opens the connection to COBOTTA. After cyclic update of status variables is started
Example
http://127.0.0.1:8280/cobotta/OpenConnection
Return
{"result" : "OK"}
/cobotta/CloseConnection
Stopps cyclic status update and disconnects from COBOTTA
Returns:
connection_settings: (obj) settings for connection to COBOTTA and cyclic status update
Example
http://127.0.0.1:8280/cobotta/CloseConnection
Return
{"result" : "OK", "connection_settings": {"host": "172.21.0.30", "port": 5007, "timeout": 2000, "intervall": 250}}
/cobotta/Program/GetList
Get the program names of Cobotta World 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.
Returns:
programs: (str[]) Cobotta World program names
Example
http://127.0.0.1:8280/cobotta/Program/GetList
Return
{"result" : "OK", "programs" : ["HOME", "PickPart", "PropPart"]}
/cobotta/Error/Reset
Resets all errors of COBOTTA.
Parameter:
execute: (bool as int 0/1) execute the operation
Example
http://127.0.0.1:8280/cobotta/Error/Reset Parameter: {"execute" : 1}
Return
{"result" : "OK"}
/cobotta/Error
Returns the number of currently issued errors.
If it returns an error count of 0 then there is no error.
Also returns an array of error deails. Containing an error code and a description text.
Returns:
errorCount: (int) number of currently issued errors
details: (obj[]) array of error details containing errorCode and errorMessage
Example
http://127.0.0.1:8280/cobotta/Error
Return
{"result" : "OK", "errorCount" : count, "details" : [{ "errorCode": code, "errorMessage": description }] }
/cobotta/Speed
Read current COBOTTA speed.
Returns:
speed: (int) current COBOTTA speed value [%]
Example
http://127.0.0.1:8280/cobotta/Speed
Return
{"result" : "OK", "speed" : 50 }
/cobotta/Status
Read status variables from COBOTTA.
Returns:
COBOTTA staus variables.
connectedStatus: (bool as int 0/1) Connection between Robotino and COBOTTA is established
referencedStatus: (bool as int 0/1) COBOTTA reference motion was performed
busyStatus: (bool as int 0/1) COBOTTA is executing a program
emergencyStop: (bool as int 0/1) COBOTTA emergency stop is pressed
errorStatus: (bool as int 0/1) COBOTTA in error state
thread_status: (bool as int 0/1) status of the thread which cyclically updates the COBOTTA status
speed: (int) speed of COBOTTA [%]
Example
http://127.0.0.1:8280/cobotta/Status
Return
{"result" : "OK", "connectedStatus": 0, "referencedStatus": 0, "busyStatus": 0, "emergencyStop": 0, "errorStatus": 0, "thread_status": 0, "speed": 0}
/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.
Default user IOs start at IO 128.
Parameter:
number: (int) number of IO
Returns:
value: (bool as int 0/1) IO variable value.
Example
http://127.0.0.1:8280/cobotta/Io/128
Return
{"result" : "OK", "value" : 0}
/cobotta/Log
Get log entries of cobottabcap class. Returns last 50 entries. The complete logfile is located at /opt/robotino/cobotta/logfile.txt.
Returns:
loglines: (str[]) log entries.
Example
http://127.0.0.1:8280/cobotta/Log
Return
{"result" : "OK", "log_lines": ["11:33:07.085;Connect called\n", "11:33:07.087;Try to connect\n", ... ]}
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.