Commit a5cc3bcd authored by Valenza Florian's avatar Valenza Florian
Browse files

[C++][Frame] Moved the generation of random string in a new file. Modified the...

[C++][Frame] Moved the generation of random string in a new file. Modified the default constructor of frame to produce unique frame (as long as the random strings generated are unique)
parent 54ed6b7f
......@@ -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
......
......@@ -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)
......
......@@ -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,
......
......@@ -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()
{
}
......
//
// 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__
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment