tool_position.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/constrained_ik.h"
00020 #include "constrained_ik/constraints/tool_position.h"
00021 #include <ros/ros.h>
00022 
00023 namespace constrained_ik
00024 {
00025 namespace constraints
00026 {
00027 
00028 using namespace Eigen;
00029 
00030 // initialize limits/tolerances to default values
00031 ToolPosition::ToolPosition() : GoalPosition()
00032 {
00033 }
00034 
00035 Eigen::VectorXd ToolPosition::calcError()
00036 {
00037   //rotate jacobian into tool frame by premultiplying by otR.transpose()
00038   Vector3d err = state_.pose_estimate.rotation().transpose() * GoalPosition::calcError();
00039 
00040   ROS_ASSERT(err.rows() == 3);
00041   return err;
00042 }
00043 
00044 // translate cartesian errors into joint-space errors
00045 Eigen::MatrixXd ToolPosition::calcJacobian()
00046 {
00047   MatrixXd tmpJ;
00048   if (!ik_->getKin().calcJacobian(state_.joints, tmpJ))
00049     throw std::runtime_error("Failed to calculate Jacobian");
00050 
00051   //rotate jacobian into tool frame by premultiplying by otR.transpose()
00052   MatrixXd J = state_.pose_estimate.rotation().transpose() * tmpJ.topRows(3);
00053 
00054   // weight each row of J
00055   for (size_t ii=0; ii<3; ++ii)
00056       J.row(ii) *= weight_(ii);
00057 
00058   ROS_ASSERT(J.rows() == 3);
00059   return J;
00060 }
00061 
00062 } // namespace constraints
00063 } // namespace constrained_ik
00064 


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