diff --git a/VirtualRobot/Nodes/RobotNode.cpp b/VirtualRobot/Nodes/RobotNode.cpp index 3675b48428b8bbab734707b9e641208f11859d0b..3c9ff5845ee41c33292f763cf718c0f30c95d5e7 100644 --- a/VirtualRobot/Nodes/RobotNode.cpp +++ b/VirtualRobot/Nodes/RobotNode.cpp @@ -10,7 +10,7 @@ #include "../XML/BaseIO.h" #include <cmath> #include <iomanip> - +#include <boost/optional/optional_io.hpp> #include <algorithm> #include <Eigen/Core> @@ -125,6 +125,16 @@ namespace VirtualRobot } + bool RobotNode::getEnforceJointLimits() const + { + return enforceJointLimits; + } + + void RobotNode::setEnforceJointLimits(bool value) + { + enforceJointLimits = value; + } + RobotPtr RobotNode::getRobot() const { RobotPtr result(robot); @@ -181,15 +191,17 @@ namespace VirtualRobot } else { - // non-limitless joint: clamp to borders - if (q < jointLimitLo) + if(enforceJointLimits)// non-limitless joint: clamp to borders { - q = jointLimitLo; - } + if (q < jointLimitLo) + { + q = jointLimitLo; + } - if (q > jointLimitHi) - { - q = jointLimitHi; + if (q > jointLimitHi) + { + q = jointLimitHi; + } } } diff --git a/VirtualRobot/Nodes/RobotNode.h b/VirtualRobot/Nodes/RobotNode.h index 04276284885c82d661b4efc20ca0809bfb845e7a..90dd788ab0a90ef70c246115f59ee28e1434c85c 100644 --- a/VirtualRobot/Nodes/RobotNode.h +++ b/VirtualRobot/Nodes/RobotNode.h @@ -339,7 +339,10 @@ namespace VirtualRobot */ virtual void setJointValueNoUpdate(float q); - protected: + bool getEnforceJointLimits() const; + void setEnforceJointLimits(bool value); + + protected: /*! Queries parent for global pose and updates visualization accordingly */ @@ -370,6 +373,7 @@ namespace VirtualRobot float jointValueOffset; float jointLimitLo, jointLimitHi; + bool enforceJointLimits = true; bool limitless; // whether this joint has limits or not (ignored if nodeType != Joint). DHParameter optionalDHParameter; // When the joint is defined via DH parameters they are stored here float maxVelocity; //! given in m/s