![]() |
|||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||
Code SnippetsThe Katana can operate in different modes, and depending on these, the manner of control requires different approaches. In the following sections, there are some brief examples for each of these modes, given in C++ and Python, which are both calling the same C++ library internally. PythonRunning Python directly on the robot in a Python shell is easy:>>> import katana >>> k=katana.Katana() >>> k.calibrate() The following code opens a connection to the XML-RPC server on the Katana and gives the user a Katana object to continue: import sys import xmlrpclib from IPython.Shell import IPShellEmbed ipshell = IPShellEmbed() serverIp = sys.argv[1] katana = xmlrpclib.Server('http://'+ serverIp + ':8000') methods = katana.system.listMethods() for i in methods: print i print "nAccess to Katana RPC methods through the object katana" print "example: katana.calibrate()n" ipshell() C++The Programming of the Katana in C++ is equally straightforward:#include "katana.h" int main(int argc, char **argv){ Katana k; k.calibrate(); for (int i=0; i<3; i++) { k.moveMotAndWait(1, 10000, 100); k.moveMotAndWait(1, 11000, 100); } return 0; } |
|
||||||||||||||||||||||||||||||
Neuronics AG CH-8405 Winterthur T +41 (0)52 235 24 40 |
|||||||||||||||||||||||||||||||
| © 2010 Neuronics AG | |||||||||||||||||||||||||||||||