| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| |
|
| | #include <Base/PlacementPy.h>
|
| | #include <Base/PyWrapParseTupleAndKeywords.h>
|
| | #include <Base/UnitsApi.h>
|
| |
|
| |
|
| |
|
| | #include "WaypointPy.h"
|
| | #include "WaypointPy.cpp"
|
| |
|
| |
|
| |
|
| | using namespace Robot;
|
| | using namespace Base;
|
| |
|
| |
|
| | std::string WaypointPy::representation() const
|
| | {
|
| | double A, B, C;
|
| | std::stringstream str;
|
| | getWaypointPtr()->EndPos.getRotation().getYawPitchRoll(A, B, C);
|
| | str.precision(5);
|
| | str << "Waypoint [";
|
| | if (getWaypointPtr()->Type == Waypoint::PTP) {
|
| | str << "PTP ";
|
| | }
|
| | else if (getWaypointPtr()->Type == Waypoint::LINE) {
|
| | str << "LIN ";
|
| | }
|
| | else if (getWaypointPtr()->Type == Waypoint::CIRC) {
|
| | str << "CIRC ";
|
| | }
|
| | else if (getWaypointPtr()->Type == Waypoint::WAIT) {
|
| | str << "WAIT ";
|
| | }
|
| | else if (getWaypointPtr()->Type == Waypoint::UNDEF) {
|
| | str << "UNDEF ";
|
| | }
|
| | str << getWaypointPtr()->Name;
|
| | str << " (";
|
| | str << getWaypointPtr()->EndPos.getPosition().x << ","
|
| | << getWaypointPtr()->EndPos.getPosition().y << ","
|
| | << getWaypointPtr()->EndPos.getPosition().z;
|
| | str << ";" << A << "," << B << "," << C << ")";
|
| | str << "v=" << getWaypointPtr()->Velocity << " ";
|
| | if (getWaypointPtr()->Cont) {
|
| | str << "Cont ";
|
| | }
|
| | if (getWaypointPtr()->Tool != 0) {
|
| | str << "Tool" << getWaypointPtr()->Tool << " ";
|
| | }
|
| | if (getWaypointPtr()->Base != 0) {
|
| | str << "Tool" << getWaypointPtr()->Base << " ";
|
| | }
|
| | str << "]";
|
| |
|
| | return str.str();
|
| | }
|
| |
|
| | PyObject* WaypointPy::PyMake(struct _typeobject*, PyObject*, PyObject*)
|
| | {
|
| |
|
| | return new WaypointPy(new Waypoint);
|
| | }
|
| |
|
| |
|
| | int WaypointPy::PyInit(PyObject* args, PyObject* kwd)
|
| | {
|
| | PyObject* pos;
|
| | const char* name = "P";
|
| | const char* type = "PTP";
|
| | PyObject* vel = nullptr;
|
| | PyObject* acc = nullptr;
|
| | int cont = 0;
|
| | int tool = 0;
|
| | int base = 0;
|
| |
|
| | static const std::array<const char*, 9>
|
| | kwlist {"Pos", "type", "name", "vel", "cont", "tool", "base", "acc", nullptr};
|
| |
|
| | if (!Base::Wrapped_ParseTupleAndKeywords(
|
| | args,
|
| | kwd,
|
| | "O!|ssOiiiO",
|
| | kwlist,
|
| | &(Base::PlacementPy::Type),
|
| | &pos,
|
| | &type,
|
| | &name,
|
| | &vel,
|
| | &cont,
|
| | &tool,
|
| | &base,
|
| | &acc
|
| | )) {
|
| | return -1;
|
| | }
|
| |
|
| | Base::Placement TempPos = *static_cast<Base::PlacementPy*>(pos)->getPlacementPtr();
|
| | getWaypointPtr()->EndPos = TempPos;
|
| | getWaypointPtr()->Name = name;
|
| | std::string typeStr(type);
|
| | if (typeStr == "PTP") {
|
| | getWaypointPtr()->Type = Waypoint::PTP;
|
| | }
|
| | else if (typeStr == "LIN") {
|
| | getWaypointPtr()->Type = Waypoint::LINE;
|
| | }
|
| | else if (typeStr == "CIRC") {
|
| | getWaypointPtr()->Type = Waypoint::CIRC;
|
| | }
|
| | else if (typeStr == "WAIT") {
|
| | getWaypointPtr()->Type = Waypoint::WAIT;
|
| | }
|
| | else {
|
| | getWaypointPtr()->Type = Waypoint::UNDEF;
|
| | }
|
| |
|
| | if (!vel) {
|
| | switch (getWaypointPtr()->Type) {
|
| | case Waypoint::PTP:
|
| | getWaypointPtr()->Velocity = 100;
|
| | break;
|
| | case Waypoint::LINE:
|
| | getWaypointPtr()->Velocity = 2000;
|
| | break;
|
| | case Waypoint::CIRC:
|
| | getWaypointPtr()->Velocity = 2000;
|
| | break;
|
| | default:
|
| | getWaypointPtr()->Velocity = 0;
|
| | }
|
| | }
|
| | else {
|
| | getWaypointPtr()->Velocity = Base::UnitsApi::toDouble(vel, Base::Unit::Velocity);
|
| | }
|
| | getWaypointPtr()->Cont = cont ? true : false;
|
| | getWaypointPtr()->Tool = tool;
|
| | getWaypointPtr()->Base = base;
|
| | if (!acc) {
|
| | getWaypointPtr()->Acceleration = 100;
|
| | }
|
| | else {
|
| | getWaypointPtr()->Acceleration = Base::UnitsApi::toDouble(acc, Base::Unit::Acceleration);
|
| | }
|
| |
|
| | return 0;
|
| | }
|
| |
|
| |
|
| | Py::Float WaypointPy::getVelocity() const
|
| | {
|
| | return Py::Float(getWaypointPtr()->Velocity);
|
| | }
|
| |
|
| | void WaypointPy::setVelocity(Py::Float arg)
|
| | {
|
| | getWaypointPtr()->Velocity = (float)arg.operator double();
|
| | }
|
| |
|
| |
|
| | Py::String WaypointPy::getName() const
|
| | {
|
| | return {getWaypointPtr()->Name};
|
| | }
|
| |
|
| | void WaypointPy::setName(Py::String arg)
|
| | {
|
| | getWaypointPtr()->Name = arg.as_std_string("ascii");
|
| | }
|
| |
|
| | Py::String WaypointPy::getType() const
|
| | {
|
| | if (getWaypointPtr()->Type == Waypoint::PTP) {
|
| | return Py::String("PTP");
|
| | }
|
| | else if (getWaypointPtr()->Type == Waypoint::LINE) {
|
| | return Py::String("LIN");
|
| | }
|
| | else if (getWaypointPtr()->Type == Waypoint::CIRC) {
|
| | return Py::String("CIRC");
|
| | }
|
| | else if (getWaypointPtr()->Type == Waypoint::WAIT) {
|
| | return Py::String("WAIT");
|
| | }
|
| | else if (getWaypointPtr()->Type == Waypoint::UNDEF) {
|
| | return Py::String("UNDEF");
|
| | }
|
| | else {
|
| | throw Base::TypeError("Unknown waypoint type! Only: PTP,LIN,CIRC,WAIT are supported.");
|
| | }
|
| | }
|
| |
|
| | void WaypointPy::setType(Py::String arg)
|
| | {
|
| | std::string typeStr(arg.as_std_string("ascii"));
|
| | if (typeStr == "PTP") {
|
| | getWaypointPtr()->Type = Waypoint::PTP;
|
| | }
|
| | else if (typeStr == "LIN") {
|
| | getWaypointPtr()->Type = Waypoint::LINE;
|
| | }
|
| | else if (typeStr == "CIRC") {
|
| | getWaypointPtr()->Type = Waypoint::CIRC;
|
| | }
|
| | else if (typeStr == "WAIT") {
|
| | getWaypointPtr()->Type = Waypoint::WAIT;
|
| | }
|
| | else {
|
| | throw Base::TypeError("Unknown waypoint type! Only: PTP,LIN,CIRC,WAIT are allowed.");
|
| | }
|
| | }
|
| |
|
| |
|
| | Py::Object WaypointPy::getPos() const
|
| | {
|
| | return Py::Object(new PlacementPy(new Placement(getWaypointPtr()->EndPos)), true);
|
| | }
|
| |
|
| | void WaypointPy::setPos(Py::Object arg)
|
| | {
|
| | Py::Type PlacementType(Base::getTypeAsObject(&(Base::PlacementPy::Type)));
|
| | if (arg.isType(PlacementType)) {
|
| | getWaypointPtr()->EndPos = *static_cast<Base::PlacementPy*>((*arg))->getPlacementPtr();
|
| | }
|
| | }
|
| |
|
| | Py::Boolean WaypointPy::getCont() const
|
| | {
|
| | return {getWaypointPtr()->Cont};
|
| | }
|
| |
|
| | void WaypointPy::setCont(Py::Boolean arg)
|
| | {
|
| | getWaypointPtr()->Cont = (bool)arg;
|
| | }
|
| |
|
| | Py::Long WaypointPy::getTool() const
|
| | {
|
| | return Py::Long((long)getWaypointPtr()->Tool);
|
| | }
|
| |
|
| | void WaypointPy::setTool(Py::Long arg)
|
| | {
|
| | long value = static_cast<long>(arg);
|
| | if (value >= 0) {
|
| | getWaypointPtr()->Tool = value;
|
| | }
|
| | else {
|
| | throw Py::ValueError("negative tool not allowed!");
|
| | }
|
| | }
|
| |
|
| | Py::Long WaypointPy::getBase() const
|
| | {
|
| | return Py::Long((long)getWaypointPtr()->Base);
|
| | }
|
| |
|
| | void WaypointPy::setBase(Py::Long arg)
|
| | {
|
| | long value = static_cast<long>(arg);
|
| | if (value >= 0) {
|
| | getWaypointPtr()->Base = value;
|
| | }
|
| | else {
|
| | throw Py::ValueError("negative base not allowed!");
|
| | }
|
| | }
|
| |
|
| | PyObject* WaypointPy::getCustomAttributes(const char* ) const
|
| | {
|
| | return nullptr;
|
| | }
|
| |
|
| | int WaypointPy::setCustomAttributes(const char* , PyObject* )
|
| | {
|
| | return 0;
|
| | }
|
| |
|