Go to the documentation of this file.00001
00026 #ifndef CONSTRAINT_RESULTS
00027 #define CONSTRAINT_RESULTS
00028
00029 #include <ros/ros.h>
00030 #include <Eigen/Core>
00031
00032 namespace constrained_ik
00033 {
00035 class ConstraintResults
00036 {
00037 public:
00038 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00039
00040 ConstraintResults():status(true){}
00041
00042 Eigen::VectorXd error;
00044 Eigen::MatrixXd jacobian;
00046 bool status;
00052 virtual void append(const ConstraintResults &cdata)
00053 {
00054 appendError(cdata.error);
00055 appendJacobian(cdata.jacobian);
00056 status &= cdata.status;
00057 }
00058
00063 virtual bool isEmpty()
00064 {
00065 if (error.rows() == 0 || jacobian.rows() == 0)
00066 return true;
00067 else
00068 return false;
00069 }
00070
00071 protected:
00079 virtual void appendError(const Eigen::VectorXd &addError)
00080 {
00081 if (addError.rows() == 0)
00082 {
00083 ROS_DEBUG("trying to add a Error with no data");
00084 return;
00085 }
00086
00087 if (error.rows() == 0)
00088 error = addError;
00089 else
00090 {
00091 size_t nAddRows = addError.rows();
00092 error.conservativeResize(error.rows() + nAddRows);
00093 error.tail(nAddRows) = addError;
00094 }
00095 }
00096
00104 virtual void appendJacobian(const Eigen::MatrixXd &addJacobian)
00105 {
00106 if(addJacobian.rows() == 0 || addJacobian.cols() == 0)
00107 {
00108 ROS_DEBUG("trying to add a Jacobian with no data");
00109 return;
00110 }
00111 if (jacobian.rows() == 0)
00112 {
00113 size_t nAddRows = addJacobian.rows();
00114 jacobian.conservativeResize(jacobian.rows() + nAddRows, addJacobian.cols());
00115 jacobian.bottomRows(nAddRows) = addJacobian;
00116 }
00117 else
00118 {
00119 ROS_ASSERT(jacobian.cols() == addJacobian.cols());
00120 size_t nAddRows = addJacobian.rows();
00121 jacobian.conservativeResize(jacobian.rows() + nAddRows, Eigen::NoChange);
00122 jacobian.bottomRows(nAddRows) = addJacobian;
00123 }
00124 }
00125 };
00126 }
00127 #endif // CONSTRAINT_RESULTS
00128