jspace/jspace/wrap_eigen.hpp

Go to the documentation of this file.
00001 /*
00002  * Stanford Whole-Body Control Framework http://stanford-wbc.sourceforge.net/
00003  *
00004  * Copyright (C) 2010 The Board of Trustees of The Leland Stanford Junior University. All rights reserved.
00005  *
00006  * This program is free software: you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public License
00008  * as published by the Free Software Foundation, either version 3 of
00009  * the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful, but
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this program.  If not, see
00018  * <http://www.gnu.org/licenses/>
00019  */
00020 
00026 #ifndef JSPACE_WRAP_EIGEN_HPP
00027 #define JSPACE_WRAP_EIGEN_HPP
00028 
00029 #include <Eigen/Geometry>
00030 #include <vector>
00031 
00032 namespace jspace {
00033 
00034   typedef Eigen::Transform3d Transform;
00035   typedef Eigen::Translation3d Translation;
00036   typedef Eigen::Quaternion<double> Quaternion;
00037   typedef Eigen::VectorXd Vector;
00038   typedef Eigen::MatrixXd Matrix;
00039   
00040   // ...an idea that needs more thought...
00041   // typedef Eigen::Map<Eigen::VectorXd> VectorMap;
00042   // inline VectorMap map(std::vector<double> & from) { return Vector::Map(&from[0], from.size()); }
00043   // inline VectorMap const map(std::vector<double> const & from) { return Vector::Map(&from[0], from.size()); }
00044   
00045   void convert(jspace::Vector const & from, std::vector<double> & to);
00046   void convert(std::vector<double> const & from, jspace::Vector & to);
00047   void convert(double const * from, size_t length, jspace::Vector & to);
00048  
00049   // should also work as-is for jspace::Vector
00050   bool compare(jspace::Matrix const & lhs, jspace::Matrix const & rhs, double precision);
00051   bool compare(jspace::Quaternion const & lhs, jspace::Quaternion const & rhs, double precision);
00052   
00053   std::string pretty_string(double vv);
00054   std::string pretty_string(jspace::Vector const & vv);
00055   std::string pretty_string(jspace::Quaternion const & qq);
00056   std::string pretty_string(jspace::Matrix const & mm, std::string const & prefix);
00057   
00058   void pretty_print(jspace::Vector const & vv, std::ostream & os,
00059         std::string const & title, std::string const & prefix, bool nonl = false);
00060 
00061   inline void pretty_print(Eigen::Vector3d const & vv, std::ostream & os,
00062          std::string const & title, std::string const & prefix, bool nonl = false)
00063   {
00064     pretty_print(static_cast<jspace::Vector const &>(vv), os, title, prefix, nonl);
00065   }
00066   
00067   void pretty_print(jspace::Quaternion const & qq, std::ostream & os,
00068         std::string const & title, std::string const & prefix, bool nonl = false);
00069   
00070   void pretty_print(jspace::Matrix const & mm, std::ostream & os,
00071         std::string const & title, std::string const & prefix,
00072         bool vecmode = false, bool nonl = false);
00073   
00074 }
00075 
00076 #endif // JSPACE_WRAP_EIGEN_HPP

Generated on Fri Aug 26 01:31:16 2011 for Stanford Whole-Body Control Framework by  doxygen 1.5.4