goal_tool_orientation.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/goal_tool_orientation.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 GoalToolOrientation::GoalToolOrientation() : GoalOrientation()
00032 {
00033 }
00034 
00035 Eigen::VectorXd GoalToolOrientation::calcError()
00036 {
00037   //rotate jacobian into tool frame by premultiplying by otR.transpose()
00038   Vector3d err = state_.pose_estimate.rotation().transpose() * calcAngleError(state_.pose_estimate, state_.goal);
00039 
00040   err = err.cwiseProduct(weight_);
00041   ROS_ASSERT(err.rows() == 3);
00042   return err;
00043 }
00044 
00045 // translate cartesian errors into joint-space errors
00046 Eigen::MatrixXd GoalToolOrientation::calcJacobian()
00047 {
00048   MatrixXd tmpJ;
00049   if (!ik_->getKin().calcJacobian(state_.joints, tmpJ))
00050     throw std::runtime_error("Failed to calculate Jacobian");
00051 
00052   //rotate jacobian into tool frame by premultiplying by otR.transpose()
00053   MatrixXd J = state_.pose_estimate.rotation().transpose() * tmpJ.bottomRows(3);
00054 
00055   // weight each row of J
00056   for (size_t ii=0; ii<3; ++ii)
00057       J.row(ii) *= weight_(ii);
00058 
00059   ROS_ASSERT(J.rows() == 3);
00060   return J;
00061 }
00062 
00063 } // namespace constraints
00064 } // namespace constrained_ik
00065 


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