Robot6AxisPyImp.cpp

Go to the documentation of this file.
00001 
00002 #include "PreCompiled.h"
00003 
00004 #include "Mod/Robot/App/Robot6Axis.h"
00005 #include <Base/PlacementPy.h>
00006 #include <Base/MatrixPy.h>
00007 #include <Base/Exception.h>
00008 #include <sstream>
00009 
00010 // inclusion of the generated files (generated out of Robot6AxisPy.xml)
00011 #include "Robot6AxisPy.h"
00012 #include "Robot6AxisPy.cpp"
00013 
00014 using namespace Robot;
00015 
00016 // returns a string which represents the object e.g. when printed in python
00017 std::string Robot6AxisPy::representation(void) const
00018 {
00019         std::stringstream str;
00020 
00021     str.precision(5);
00022         str << "<Robot6Axis "
00023                 << "Tcp:(" 
00024                   << getRobot6AxisPtr()->getTcp().getPosition().x << ","
00025                   << getRobot6AxisPtr()->getTcp().getPosition().y << ","
00026                   << getRobot6AxisPtr()->getTcp().getPosition().z << ") "
00027                 << "Axis:(" 
00028                   << "1:" << getRobot6AxisPtr()->getAxis(0) << " "
00029                   << "2:" << getRobot6AxisPtr()->getAxis(1) << " "
00030                   << "3:" << getRobot6AxisPtr()->getAxis(2) << " "
00031                   << "4:" << getRobot6AxisPtr()->getAxis(3) << " "
00032                   << "5:" << getRobot6AxisPtr()->getAxis(4) << " "
00033                   << "6:" << getRobot6AxisPtr()->getAxis(5) << ")";
00034 
00035         return str.str();
00036 }
00037 
00038 PyObject *Robot6AxisPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00039 {
00040     // create a new instance of Robot6AxisPy and the Twin object 
00041     return new Robot6AxisPy(new Robot6Axis);
00042 }
00043 
00044 // constructor method
00045 int Robot6AxisPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00046 {
00047     return 0;
00048 }
00049 
00050 
00051 PyObject* Robot6AxisPy::check(PyObject * /*args*/)
00052 {
00053     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00054     return 0;
00055 }
00056 
00057 
00058 
00059 Py::Float Robot6AxisPy::getAxis1(void) const
00060 {
00061     return Py::Float(getRobot6AxisPtr()->getAxis(0));
00062 }
00063 
00064 void Robot6AxisPy::setAxis1(Py::Float arg)
00065 {
00066         getRobot6AxisPtr()->setAxis(0,(float)arg.operator double());
00067 }
00068 
00069 Py::Float Robot6AxisPy::getAxis2(void) const
00070 {
00071     return Py::Float(getRobot6AxisPtr()->getAxis(1));
00072 }
00073 
00074 void Robot6AxisPy::setAxis2(Py::Float arg)
00075 {
00076         getRobot6AxisPtr()->setAxis(1,(float)arg.operator double());
00077 }
00078 
00079 Py::Float Robot6AxisPy::getAxis3(void) const
00080 {
00081     return Py::Float(getRobot6AxisPtr()->getAxis(2));
00082 }
00083 
00084 void Robot6AxisPy::setAxis3(Py::Float arg)
00085 {
00086         getRobot6AxisPtr()->setAxis(2,(float)arg.operator double());
00087 }
00088 
00089 Py::Float Robot6AxisPy::getAxis4(void) const
00090 {
00091     return Py::Float(getRobot6AxisPtr()->getAxis(3));
00092 }
00093 
00094 void Robot6AxisPy::setAxis4(Py::Float arg)
00095 {
00096         getRobot6AxisPtr()->setAxis(3,(float)arg.operator double());
00097 }
00098 
00099 Py::Float Robot6AxisPy::getAxis5(void) const
00100 {
00101     return Py::Float(getRobot6AxisPtr()->getAxis(4));
00102 }
00103 
00104 void Robot6AxisPy::setAxis5(Py::Float arg)
00105 {
00106         getRobot6AxisPtr()->setAxis(4,(float)arg.operator double());
00107 }
00108 
00109 Py::Float Robot6AxisPy::getAxis6(void) const
00110 {
00111     return Py::Float(getRobot6AxisPtr()->getAxis(5));
00112 }
00113 
00114 void Robot6AxisPy::setAxis6(Py::Float arg)
00115 {
00116         getRobot6AxisPtr()->setAxis(5,(float)arg.operator double());
00117 }
00118 
00119 Py::Object Robot6AxisPy::getTcp(void) const
00120 {
00121         return Py::Object(new Base::PlacementPy(new Base::Placement(getRobot6AxisPtr()->getTcp())));
00122 }
00123 
00124 void Robot6AxisPy::setTcp(Py::Object value)
00125 {
00126    if (PyObject_TypeCheck(*value, &(Base::MatrixPy::Type))) {
00127         Base::MatrixPy  *pcObject = (Base::MatrixPy*)*value;
00128         Base::Matrix4D mat = pcObject->value();
00129         Base::Placement p;
00130         p.fromMatrix(mat);
00131                 getRobot6AxisPtr()->setTo(p);
00132     }
00133     else if (PyObject_TypeCheck(*value, &(Base::PlacementPy::Type))) {
00134         if(! getRobot6AxisPtr()->setTo(*static_cast<Base::PlacementPy*>(*value)->getPlacementPtr()))
00135                         throw Base::Exception("Cant reach Point");
00136     }
00137     else {
00138         std::string error = std::string("type must be 'Matrix' or 'Placement', not ");
00139         error += (*value)->ob_type->tp_name;
00140         throw Py::TypeError(error);
00141     }
00142 
00143 }
00144 
00145 Py::Object Robot6AxisPy::getBase(void) const
00146 {
00147     return Py::Object();
00148 }
00149 
00150 void Robot6AxisPy::setBase(Py::Object arg)
00151 {
00152 
00153 }
00154 
00155 PyObject *Robot6AxisPy::getCustomAttributes(const char* /*attr*/) const
00156 {
00157     return 0;
00158 }
00159 
00160 int Robot6AxisPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
00161 {
00162     return 0; 
00163 }
00164 
00165 

Generated on Wed Nov 23 19:00:36 2011 for FreeCAD by  doxygen 1.6.1