diff --git a/CMakeLists.txt b/CMakeLists.txt index b8e97d8244f92002fce302a744dbaefb993e74ee..9e86d1c45ca36f882fc83d1df779ed0bf85c9818 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,7 @@ SET(${PROJECT_NAME}_MATH_HEADERS SET(${PROJECT_NAME}_TOOLS_HEADERS tools/timer.hpp + tools/string-generator.hpp ) SET(${PROJECT_NAME}_SPATIAL_HEADERS diff --git a/src/multibody/model.hpp b/src/multibody/model.hpp index 24d7f8fdc2510b1f38dc362b513b0e03ccbdf793..e43c03d7f5180275198771fca576dcb0febe37a3 100644 --- a/src/multibody/model.hpp +++ b/src/multibody/model.hpp @@ -27,6 +27,7 @@ #include "pinocchio/spatial/inertia.hpp" #include "pinocchio/spatial/frame.hpp" #include "pinocchio/multibody/joint/joint-variant.hpp" +#include "pinocchio/tools/string-generator.hpp" #include <iostream> EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(se3::SE3) diff --git a/src/multibody/model.hxx b/src/multibody/model.hxx index 4e154279bc5d65290ad61094e55b8cfb4dabaf7f..16d182119fcf0dd11c2dda64a39dd725ced42b77 100644 --- a/src/multibody/model.hxx +++ b/src/multibody/model.hxx @@ -43,18 +43,7 @@ namespace se3 return os; } - inline std::string random (const int len) - { - std::string res; - static const char alphanum[] = - "0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz"; - - for (int i=0; i<len;++i) - res += alphanum[((size_t)std::rand() % (sizeof(alphanum) - 1))]; - return res; - } + template<typename D> Model::Index Model::addBody (Index parent, const JointModelBase<D> & j, const SE3 & placement, diff --git a/src/spatial/frame.hpp b/src/spatial/frame.hpp index ee491886679f80fe563a936b2901aa379c6d9a66..45584baf10369b17e9d5e75c54b34702a2b62802 100644 --- a/src/spatial/frame.hpp +++ b/src/spatial/frame.hpp @@ -23,6 +23,7 @@ #include "pinocchio/spatial/force.hpp" #include "pinocchio/spatial/motion.hpp" #include "pinocchio/spatial/inertia.hpp" +#include "pinocchio/tools/string-generator.hpp" #include <iostream> namespace se3 @@ -31,7 +32,7 @@ struct Frame { typedef std::size_t Index; - Frame() : name(), parent_id(), frame_placement() + Frame() : name(random(8)), parent_id(), frame_placement() { } diff --git a/src/tools/string-generator.hpp b/src/tools/string-generator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8930cc739184d38f1952005fffe64935115963b5 --- /dev/null +++ b/src/tools/string-generator.hpp @@ -0,0 +1,39 @@ +// +// Copyright (c) 2016 CNRS +// +// This file is part of Pinocchio +// Pinocchio is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version +// 3 of the License, or (at your option) any later version. +// +// Pinocchio is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Lesser Public License for more details. You should have +// received a copy of the GNU Lesser General Public License along with +// Pinocchio If not, see +// <http://www.gnu.org/licenses/>. + +#ifndef __se3_string_generator_hpp__ +#define __se3_string_generator_hpp__ + +#include <iostream> +namespace se3 +{ + +inline std::string random (const int len) + { + std::string res; + static const char alphanum[] = + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + + for (int i=0; i<len;++i) + res += alphanum[((size_t)std::rand() % (sizeof(alphanum) - 1))]; + return res; + } +} + +#endif // __se3_string_generator_hpp__