constraint.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (Apache License)
00003  *
00004  * Copyright (c) 2013, Southwest Research Institute
00005  *
00006  * Licensed under the Apache License, Version 2.0 (the "License");
00007  * you may not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  *
00010  *   http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 
00019 #include "constrained_ik/constraint.h"
00020 #include "constrained_ik/constrained_ik.h"
00021 #include <ros/ros.h>
00022 
00023 using namespace Eigen;
00024 
00025 namespace constrained_ik
00026 {
00027 
00028 // NOTE: This method does a resize in-place, and may be inefficient if called many times
00029 void Constraint::appendError(Eigen::VectorXd &error, const Eigen::VectorXd &addErr)
00030 {
00031   if (addErr.rows() == 0) return;
00032 
00033   if (error.rows() == 0)
00034     error = addErr;
00035   else
00036   {
00037     size_t nAddRows = addErr.rows();
00038     error.conservativeResize(error.rows() + nAddRows);
00039     error.tail(nAddRows) = addErr;
00040   }
00041 }
00042 
00043 // NOTE: This method does a resize in-place, and may be inefficient if called many times
00044 void Constraint::appendJacobian(Eigen::MatrixXd &jacobian, const Eigen::MatrixXd &addJacobian)
00045 {
00046   if (addJacobian.rows() == 0) return;
00047 
00048   if (jacobian.rows() == 0)
00049     jacobian = addJacobian;
00050   else
00051   {
00052     ROS_ASSERT(addJacobian.cols() == addJacobian.cols());
00053     size_t nAddRows = addJacobian.rows();
00054     jacobian.conservativeResize(jacobian.rows() + nAddRows, Eigen::NoChange);
00055     jacobian.bottomRows(nAddRows) = addJacobian;
00056   }
00057 }
00058 
00059 int Constraint::numJoints()
00060 {
00061   return ik_->getKin().numJoints();
00062 }
00063 
00064 void Constraint::updateError(Eigen::VectorXd &error)
00065 {
00066   appendError(error, calcError());
00067 }
00068 
00069 void Constraint::updateJacobian(Eigen::MatrixXd &jacobian)
00070 {
00071   appendJacobian(jacobian, calcJacobian());
00072 }
00073 
00074 } // namespace constrained_ik


constrained_ik
Author(s): Chris Lewis , Jeremy Zoss , Dan Solomon
autogenerated on Mon Oct 6 2014 00:52:26