diff --git a/VirtualRobot/IK/DifferentialIK.cpp b/VirtualRobot/IK/DifferentialIK.cpp index 8aa2dbed804b9467c6a6ce8ed9537cc4c343f22d..660a65441da380f99884fedef28637335da59259 100644 --- a/VirtualRobot/IK/DifferentialIK.cpp +++ b/VirtualRobot/IK/DifferentialIK.cpp @@ -64,7 +64,7 @@ MatrixXf DifferentialIK::getJacobianMatrix(RobotNodePtr tcp, IKSolver::Cartesian MatrixXf orientation = MatrixXf::Zero(3,nDoF); if (!tcp) tcp = this->getDefaultTCP(); -// THROW_VR_EXCEPTION_IF(!tcp,boost::format("No tcp defined in node set \"%1%\" of robot %2% (DifferentialIK::%3% )") % this->rns->getName() % this->rns->getRobot()->getName() % __func__); +// THROW_VR_EXCEPTION_IF(!tcp,boost::format("No tcp defined in node set \"%1%\" of robot %2% (DifferentialIK::%3% )") % this->rns->getName() % this->rns->getRobot()->getName() % BOOST_CURRENT_FUNCTION); diff --git a/VirtualRobot/LinkedCoordinate.cpp b/VirtualRobot/LinkedCoordinate.cpp index 11dc33c31589c86c525780537f282806a933895b..995f7c01fde3045a5774950998748c9851250c95 100644 --- a/VirtualRobot/LinkedCoordinate.cpp +++ b/VirtualRobot/LinkedCoordinate.cpp @@ -1,6 +1,7 @@ #include "LinkedCoordinate.h" #include "Robot.h" #include <boost/format.hpp> +#include <boost/current_function.hpp> using namespace VirtualRobot; using namespace boost; @@ -8,42 +9,42 @@ using namespace std; -void LinkedCoordinate::set( const RobotNodePtr &frame,const Eigen::Matrix4f &pose) throw(VirtualRobotException) { +void LinkedCoordinate::set( const RobotNodePtr &frame,const Eigen::Matrix4f &pose) { if (!frame) - THROW_VR_EXCEPTION(format("RobotNodePtr not assigned (LinkedCoordinate::%1%)") % __func__); + THROW_VR_EXCEPTION(format("RobotNodePtr not assigned (LinkedCoordinate::%1%)") % BOOST_CURRENT_FUNCTION); if (!this->robot->hasRobotNode( frame ) ) - THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % frame->getName() % this->robot->getName() % __func__); + THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % frame->getName() % this->robot->getName() % BOOST_CURRENT_FUNCTION); this->pose = pose; this->frame = frame; } -void LinkedCoordinate::set( const std::string &frame,const Eigen::Matrix4f &pose) throw(VirtualRobotException) { +void LinkedCoordinate::set( const std::string &frame,const Eigen::Matrix4f &pose) { if (!this->robot->hasRobotNode( frame ) ) - THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % frame % this->robot->getName() %__func__); + THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % frame % this->robot->getName() % BOOST_CURRENT_FUNCTION); this->set(this->robot->getRobotNode(frame),pose); } -void LinkedCoordinate::set( const std::string &frame,const Eigen::Vector3f &coordinate) throw(VirtualRobotException) { +void LinkedCoordinate::set( const std::string &frame,const Eigen::Vector3f &coordinate) { Eigen::Matrix4f pose = Eigen::Matrix4f::Identity(); pose.block<3,1>(0,3) = coordinate; this->set(frame,pose); } -void LinkedCoordinate::set( const RobotNodePtr &frame,const Eigen::Vector3f &coordinate) throw(VirtualRobotException){ +void LinkedCoordinate::set( const RobotNodePtr &frame,const Eigen::Vector3f &coordinate) { Eigen::Matrix4f pose = Eigen::Matrix4f::Identity(); pose.block<3,1>(0,3) = coordinate; this->set(frame,pose); } -void LinkedCoordinate::changeFrame(const RobotNodePtr & destination) throw(VirtualRobotException){ +void LinkedCoordinate::changeFrame(const RobotNodePtr & destination) { if (!destination) - THROW_VR_EXCEPTION(format("RobotNodePtr not assigned (LinkedCoordinate::%1%)") % __func__); + THROW_VR_EXCEPTION(format("RobotNodePtr not assigned (LinkedCoordinate::%1%)") % BOOST_CURRENT_FUNCTION); if (!this->robot->hasRobotNode( destination) ) - THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % destination->getName() % this->robot->getName() % __func__); + THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % destination->getName() % this->robot->getName() % BOOST_CURRENT_FUNCTION); if (!this->frame) this->pose = Eigen::Matrix4f::Identity(); @@ -53,24 +54,24 @@ void LinkedCoordinate::changeFrame(const RobotNodePtr & destination) throw(Virtu this->frame = destination; } -void LinkedCoordinate::changeFrame(const std::string & destination) throw(VirtualRobotException){ +void LinkedCoordinate::changeFrame(const std::string & destination) { if (!this->robot->hasRobotNode( destination) ) - THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % destination % this->robot->getName() % __func__); + THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % destination % this->robot->getName() % BOOST_CURRENT_FUNCTION); this->changeFrame(this->robot->getRobotNode(destination)); } -Eigen::Matrix4f LinkedCoordinate::getInFrame(const RobotNodePtr & destination) const throw(VirtualRobotException){ +Eigen::Matrix4f LinkedCoordinate::getInFrame(const RobotNodePtr & destination) const { if (!destination) - THROW_VR_EXCEPTION(format("RobotNodePtr not assigned (LinkedCoordinate::%1%)") % __func__); + THROW_VR_EXCEPTION(format("RobotNodePtr not assigned (LinkedCoordinate::%1%)") % BOOST_CURRENT_FUNCTION); if (!this->robot->hasRobotNode( destination) ) - THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % destination->getName() % this->robot->getName() % __func__); + THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % destination->getName() % this->robot->getName() % BOOST_CURRENT_FUNCTION); return LinkedCoordinate::getCoordinateTransformation(this->frame,destination,this->robot) * this->pose; } -Eigen::Matrix4f LinkedCoordinate::getInFrame(const std::string & destination) const throw(VirtualRobotException){ +Eigen::Matrix4f LinkedCoordinate::getInFrame(const std::string & destination) const { if (!this->robot->hasRobotNode( destination) ) - THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % destination % this->robot->getName() % __func__); + THROW_VR_EXCEPTION(format("Robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % destination % this->robot->getName() % BOOST_CURRENT_FUNCTION); return LinkedCoordinate::getCoordinateTransformation(this->frame,this->robot->getRobotNode( destination),this->robot) * this->pose; } @@ -80,15 +81,15 @@ Eigen::Matrix4f LinkedCoordinate::getCoordinateTransformation(const RobotNodePtr const RobotNodePtr &destination, const RobotPtr &robot){ if (!destination) - THROW_VR_EXCEPTION(format("Destination RobotNodePtr not assigned (LinkedCoordinate::%1%)") % __func__); + THROW_VR_EXCEPTION(format("Destination RobotNodePtr not assigned (LinkedCoordinate::%1%)") % BOOST_CURRENT_FUNCTION); if (!origin) - THROW_VR_EXCEPTION(format("Origin RobotNodePtr not assigned (LinkedCoordinate::%1%)") % __func__); + THROW_VR_EXCEPTION(format("Origin RobotNodePtr not assigned (LinkedCoordinate::%1%)") % BOOST_CURRENT_FUNCTION); if (!robot) - THROW_VR_EXCEPTION(format("RobotPtr not assigned (LinkedCoordinate::%1%)") % __func__); + THROW_VR_EXCEPTION(format("RobotPtr not assigned (LinkedCoordinate::%1%)") % BOOST_CURRENT_FUNCTION); if (!robot->hasRobotNode( origin) ) - THROW_VR_EXCEPTION(format("Origin robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % origin->getName() % robot->getName() % __func__); + THROW_VR_EXCEPTION(format("Origin robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % origin->getName() % robot->getName() % BOOST_CURRENT_FUNCTION); if (!robot->hasRobotNode( destination) ) - THROW_VR_EXCEPTION(format("Destination robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % destination->getName() % robot->getName() % __func__); + THROW_VR_EXCEPTION(format("Destination robot node\"%1%\" not a member of robot \"%2%\" (LinkedCoordinate::%3%)") % destination->getName() % robot->getName() % BOOST_CURRENT_FUNCTION); // std::cout << "Destination: " << destination->getName() <<std::endl << "Origin: " << origin->getName() << std::endl; // std::cout << "Destination:\n" << destination->getGlobalPose() <<std::endl << "Origin:\n" << origin->getGlobalPose() << std::endl; diff --git a/VirtualRobot/LinkedCoordinate.h b/VirtualRobot/LinkedCoordinate.h index d6a647d48d83586aed61e66f0ed3709eca58f02a..624db192962afdf69f29db607cf4ecb5cc3db202 100644 --- a/VirtualRobot/LinkedCoordinate.h +++ b/VirtualRobot/LinkedCoordinate.h @@ -66,7 +66,7 @@ public: * @details If you want to use a different format for the pose you can use these * helper functions @sa EulerToMatrix4x4 and @sa QuaternionsToMatrix4x4 */ - void set(const RobotNodePtr &frame,const Eigen::Matrix4f &pose=Eigen::Matrix4f::Identity()) throw(VirtualRobotException); + void set(const RobotNodePtr &frame,const Eigen::Matrix4f &pose=Eigen::Matrix4f::Identity()); /** Sets the frame of reference and the coordinate relative to it. * @param frame The name of the robot node that defines the reference frame of the coordinate. @@ -75,7 +75,7 @@ public: * @details A homogeneous vector can be converted using Eigen::Vector4f::head<3>(). */ - void set(const RobotNodePtr &frame,const Eigen::Vector3f &position) throw(VirtualRobotException); + void set(const RobotNodePtr &frame,const Eigen::Vector3f &position); /** Sets the frame of reference and the pose relative to it. * @param frame The name of the robot node that defines the reference frame of the coordinate. @@ -86,7 +86,7 @@ public: * @sa set(Eigen::Matrix4x4,const RobotNodePtr &) */ - void set(const std::string &frame,const Eigen::Matrix4f &pose=Eigen::Matrix4f::Identity()) throw(VirtualRobotException); + void set(const std::string &frame,const Eigen::Matrix4f &pose=Eigen::Matrix4f::Identity()); /** Sets the frame of reference and the coordinate relative to it. * @param frame The name of the robot node that defines the reference frame of the coordinate. @@ -95,7 +95,7 @@ public: * @details A homogeneous vector can be previously converted using Eigen::Vector4f::head<3>(). */ - void set(const std::string &frame,const Eigen::Vector3f &position) throw(VirtualRobotException); + void set(const std::string &frame,const Eigen::Vector3f &position); /** Returns a RobotNodePtr that contains the frame of reference the coordinate is defined in. * @returns The reference or an empty RobotNodePtr is none has been defined. @@ -108,14 +108,15 @@ public: * @details If iCoord::set has not been called before, the pose is set to the * unit marix. */ - void changeFrame(const std::string & frame) throw(VirtualRobotException); + void changeFrame(const std::string & frame); /** Sets a new reference frame and performs a coordinate transformation into this new frame. * @param frame A reference to the robot node that defines the new reference. * @details If iCoord::set has not been called before, the pose is set to the * unit marix. + * @throw VirtualRobotException An exception is thrown if frame is NULL. */ - void changeFrame(const RobotNodePtr & frame) throw(VirtualRobotException); + void changeFrame(const RobotNodePtr & frame); /** Performs \a only a coordinate transformation into a new frame of reference. * @param frame The name of the robot node that defines the new reference. @@ -124,7 +125,7 @@ public: * @returns A homogeneous matrix of the pose * @sa getPose() */ - Eigen::Matrix4f getInFrame(const std::string & frame) const throw(VirtualRobotException); + Eigen::Matrix4f getInFrame(const std::string & frame) const; /** Performs \a only a coordinate transformation into a new frame of reference. * @param frame A reference to the robot node that defines the new reference. @@ -133,8 +134,9 @@ public: * @returns A homogeneous matrix of the pose * @sa getPose() * @details If you are only interested in the translational part use iCoord::getPosition() or Matrix4f::block<3,1>(0,3). + * @throw VirtualRobotException An exception is thrown if frame is NULL. */ - Eigen::Matrix4f getInFrame(const RobotNodePtr & frame) const throw(VirtualRobotException); + Eigen::Matrix4f getInFrame(const RobotNodePtr & frame) const; /** Returns the actual pose stored in this object. * @details If you are only interested in the translational part use iCoord::getPosition() or Matrix4f::block<3,1>(0,3). diff --git a/VirtualRobot/VirtualRobotException.h b/VirtualRobot/VirtualRobotException.h index b47ca37a873da1541a6cbb929078fc546ccf8aa3..8c77df941594507fc9e40dfb4ac338ad8eec0de6 100644 --- a/VirtualRobot/VirtualRobotException.h +++ b/VirtualRobot/VirtualRobotException.h @@ -57,10 +57,10 @@ protected: /** * This macro throws a VirtualRobot::VirtualRobotException and is the preferred * way of creating and throwing these types of exceptions. - * The reported message is composed of the linenumber and the file in which - * the throw occured and is followed by the \a messageString parameter. + * The reported message is composed of the line number and the file in which + * the throw occurred and is followed by the \a messageString parameter. */ -#define THROW_VR_EXCEPTION(messageString) do{std::stringstream s; s << __FILE__ << ":" << __LINE__ << ": " << __func__ << ": " << messageString; std::string er = s.str(); throw VirtualRobot::VirtualRobotException(er);}while(0); +#define THROW_VR_EXCEPTION(messageString) do{std::stringstream s; s << __FILE__ << ":" << __LINE__ << ": " << BOOST_CURRENT_FUNCTION << ": " << messageString; std::string er = s.str(); throw VirtualRobot::VirtualRobotException(er);}while(0); /** * This macro checks \a condition and calls THROW_VR_EXCEPTION