towr_xpp_ee_map.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 Copyright (c) 2017, Alexander W. Winkler. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 
00010 * Redistributions in binary form must reproduce the above copyright notice,
00011   this list of conditions and the following disclaimer in the documentation
00012   and/or other materials provided with the distribution.
00013 
00014 * Neither the name of the copyright holder nor the names of its
00015   contributors may be used to endorse or promote products derived from
00016   this software without specific prior written permission.
00017 
00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00022 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00023 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00025 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00026 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00027 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028 ******************************************************************************/
00029 
00035 #ifndef TOWR_TOWR_ROS_INCLUDE_TOWR_ROS_TOWR_XPP_EE_MAP_H_
00036 #define TOWR_TOWR_ROS_INCLUDE_TOWR_ROS_TOWR_XPP_EE_MAP_H_
00037 
00038 #include <map>
00039 #include <towr/models/endeffector_mappings.h>
00040 #include <xpp_states/endeffector_mappings.h>
00041 
00042 
00043 namespace towr {
00044 
00046 static std::map<towr::BipedIDs, xpp::biped::FootIDs> biped_to_xpp_id =
00047 {
00048     {L, xpp::biped::L},
00049     {R, xpp::biped::R},
00050 };
00051 
00052 static std::map<towr::QuadrupedIDs, xpp::quad::FootIDs> quad_to_xpp_id =
00053 {
00054     {LF, xpp::quad::LF},
00055     {RF, xpp::quad::RF},
00056     {LH, xpp::quad::LH},
00057     {RH, xpp::quad::RH}
00058 };
00059 
00060 
00062 static std::map<towr::BipedIDs, std::string> biped_to_name =
00063 {
00064   {L, "Left" },
00065   {R, "Right"}
00066 };
00067 
00068 static std::map<towr::QuadrupedIDs, std::string> quad_to_name =
00069 {
00070   {LF, "Left-Front" },
00071   {RF, "Right-Front"},
00072   {LH, "Left-Hind"  },
00073   {RH, "Right-Hind" }
00074 };
00075 
00076 
00085 static std::pair<xpp::EndeffectorID, std::string>
00086 ToXppEndeffector(int number_of_ee, int towr_ee_id)
00087 {
00088   std::pair<xpp::EndeffectorID, std::string> ee;
00089 
00090   switch (number_of_ee) {
00091     case 1:
00092       ee.first  = towr_ee_id;
00093       ee.second = "E0";
00094       break;
00095     case 2: {
00096       auto id = static_cast<towr::BipedIDs>(towr_ee_id);
00097       ee.first  = biped_to_xpp_id.at(id);
00098       ee.second = biped_to_name.at(id);
00099       break;
00100     }
00101     case 4: {
00102       auto id = static_cast<towr::QuadrupedIDs>(towr_ee_id);
00103       ee.first  = quad_to_xpp_id.at(id);
00104       ee.second = quad_to_name.at(id);
00105       break;
00106     }
00107     default:
00108       assert(false); // endeffector mapping not defined
00109       break;
00110   }
00111 
00112   return ee;
00113 }
00114 
00118 static xpp::StateLinXd ToXpp(const towr::State& towr)
00119 {
00120   xpp::StateLinXd xpp(towr.p().rows());
00121 
00122   xpp.p_ = towr.p();
00123   xpp.v_ = towr.v();
00124   xpp.a_ = towr.a();
00125 
00126   return xpp;
00127 }
00128 
00129 } // namespace towr
00130 
00131 #endif /* TOWR_TOWR_ROS_INCLUDE_TOWR_ROS_TOWR_XPP_EE_MAP_H_ */


towr_ros
Author(s): Alexander W. Winkler
autogenerated on Mon Apr 15 2019 02:42:39