Skip to content

Commit

Permalink
Split util namespace into common and io namespaces (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Sep 30, 2017
1 parent 5dfb604 commit 2c24a9b
Show file tree
Hide file tree
Showing 102 changed files with 450 additions and 401 deletions.
2 changes: 1 addition & 1 deletion include/aikido/util.hpp → include/aikido/common.hpp
@@ -1,6 +1,6 @@
#include "common/RNG.hpp"
#include "util/CatkinResourceRetriever.hpp"
#include "util/PseudoInverse.hpp"
#include "util/RNG.hpp"
#include "util/Spline.hpp"
#include "util/StepSequence.hpp"
#include "util/VanDerCorput.hpp"
Expand Down
@@ -1,12 +1,12 @@
#ifndef AIKIDO_UTIL_EXECUTORMULTIPLEXER_HPP_
#define AIKIDO_UTIL_EXECUTORMULTIPLEXER_HPP_
#ifndef AIKIDO_COMMON_EXECUTORMULTIPLEXER_HPP_
#define AIKIDO_COMMON_EXECUTORMULTIPLEXER_HPP_

#include <functional>
#include <mutex>
#include <vector>

namespace aikido {
namespace util {
namespace common {

/// Combine multiple executors (i.e. no argument callbacks) into one executor.
///
Expand Down Expand Up @@ -53,7 +53,7 @@ class ExecutorMultiplexer final
std::vector<std::function<void()>> mCallbacks;
};

} // namespace util
} // namespace common
} // namespace aikido

#endif // AIKIDO_UTIL_EXECUTORMULTIPLEXER_HPP_
#endif // AIKIDO_COMMON_EXECUTORMULTIPLEXER_HPP_
@@ -1,13 +1,13 @@
#ifndef AIKIDO_UTIL_EXECUTORTHREAD_HPP_
#define AIKIDO_UTIL_EXECUTORTHREAD_HPP_
#ifndef AIKIDO_COMMON_EXECUTORTHREAD_HPP_
#define AIKIDO_COMMON_EXECUTORTHREAD_HPP_

#include <atomic>
#include <chrono>
#include <functional>
#include <thread>

namespace aikido {
namespace util {
namespace common {

/// ExecutorThread is a wrapper of std::thread that calls a callback
/// periodically.
Expand Down Expand Up @@ -63,9 +63,9 @@ class ExecutorThread final
std::thread mThread;
};

} // namespace util
} // namespace common
} // namespace aikido

#include <aikido/util/detail/ExecutorThread-impl.hpp>
#include <aikido/common/detail/ExecutorThread-impl.hpp>

#endif // AIKIDO_UTIL_EXECUTORTHREAD_HPP_
#endif // AIKIDO_COMMON_EXECUTORTHREAD_HPP_
@@ -1,18 +1,18 @@
#ifndef AIKIDO_UTIL_PSEUDOINVERSE_HPP_
#define AIKIDO_UTIL_PSEUDOINVERSE_HPP_
#ifndef AIKIDO_COMMON_PSEUDOINVERSE_HPP_
#define AIKIDO_COMMON_PSEUDOINVERSE_HPP_

#include <Eigen/Dense>

namespace aikido {
namespace util {
namespace common {

/// Computes the Moore-Penrose pseudoinverse of a matrix.
///
/// \param mat input matrix
/// \return pseudo-inverse of \c mat
Eigen::MatrixXd pseudoinverse(const Eigen::MatrixXd& mat, double eps = 1e-6);

} // namespace util
} // namespace common
} // namespace aikido

#endif // AIKIDO_UTIL_PSEUDOINVERSE_HPP_
#endif // AIKIDO_COMMON_PSEUDOINVERSE_HPP_
14 changes: 7 additions & 7 deletions include/aikido/util/RNG.hpp → include/aikido/common/RNG.hpp
@@ -1,5 +1,5 @@
#ifndef AIKIDO_UTIL_RNG_HPP_
#define AIKIDO_UTIL_RNG_HPP_
#ifndef AIKIDO_COMMON_RNG_HPP_
#define AIKIDO_COMMON_RNG_HPP_

#include <cassert>
#include <cmath>
Expand All @@ -9,7 +9,7 @@
#include <Eigen/Geometry>

namespace aikido {
namespace util {
namespace common {

/// Default number of seeds to by \c cloneRNGsFrom to seed new engines.
constexpr int NUM_DEFAULT_SEEDS{100};
Expand Down Expand Up @@ -136,7 +136,7 @@ Quaternion sampleQuaternion(
/// \param _numOutputs number of RNGs to create
/// \param _numSeeds number of seeds to use for initialization
/// \return new random number generators
std::vector<std::unique_ptr<util::RNG>> cloneRNGsFrom(
std::vector<std::unique_ptr<common::RNG>> cloneRNGsFrom(
RNG& _engine, size_t _numOutputs, size_t _numSeeds = NUM_DEFAULT_SEEDS);

/// Deterministically create a random number generator of the same type as the
Expand All @@ -147,12 +147,12 @@ std::vector<std::unique_ptr<util::RNG>> cloneRNGsFrom(
/// \param _engine random engine
/// \param _numSeeds number of seeds to use for initialization
/// \return new random number generators
std::vector<std::unique_ptr<util::RNG>> cloneRNGFrom(
std::vector<std::unique_ptr<common::RNG>> cloneRNGFrom(
RNG& _engine, size_t _numSeeds = NUM_DEFAULT_SEEDS);

} // namespace util
} // namespace common
} // namespace aikido

#include "detail/RNG-impl.hpp"

#endif // AIKIDO_UTIL_RNG_HPP_
#endif // AIKIDO_COMMON_RNG_HPP_
@@ -1,5 +1,5 @@
#ifndef AIKIDO_UTIL_SPLINE_HPP_
#define AIKIDO_UTIL_SPLINE_HPP_
#ifndef AIKIDO_COMMON_SPLINE_HPP_
#define AIKIDO_COMMON_SPLINE_HPP_

#include <cstddef>
#include <memory>
Expand All @@ -10,7 +10,7 @@
#include <Eigen/StdVector>

namespace aikido {
namespace util {
namespace common {

/// An arbitrary dimensional polynomial spline. The number of coefficients,
/// outputs, and knot points may be specified either at compile time (via
Expand Down Expand Up @@ -332,9 +332,9 @@ class SplineProblem
|| ProblemVector::NeedsToAlign)
};

} // namespace util
} // namespace common
} // namespace aikido

#include "detail/Spline-impl.hpp"

#endif // AIKIDO_UTIL_SPLINE_HPP_
#endif // AIKIDO_COMMON_SPLINE_HPP_
@@ -1,13 +1,13 @@
#ifndef AIKIDO_UTIL_STEPSEQUENCE_HPP_
#define AIKIDO_UTIL_STEPSEQUENCE_HPP_
#ifndef AIKIDO_COMMON_STEPSEQUENCE_HPP_
#define AIKIDO_COMMON_STEPSEQUENCE_HPP_

#include <cassert>
#include <limits>
#include <tuple>
#include <boost/iterator/iterator_facade.hpp>

namespace aikido {
namespace util {
namespace common {

/// An iterator that returns a sequence of numbers between 0 and 1 stepping at a
/// fixed stepsize
Expand Down Expand Up @@ -67,7 +67,7 @@ class StepSequence::const_iterator
double mValue;
};

} // namespace util
} // namespace common
} // namespace aikido

#endif // AIKIDO_UTIL_STEPSEQUENCE_HPP_
#endif // AIKIDO_COMMON_STEPSEQUENCE_HPP_
@@ -1,12 +1,12 @@
#ifndef AIKIDO_UTIL_VANDERCORPUT_HPP_
#define AIKIDO_UTIL_VANDERCORPUT_HPP_
#ifndef AIKIDO_COMMON_VANDERCORPUT_HPP_
#define AIKIDO_COMMON_VANDERCORPUT_HPP_

#include <limits>
#include <utility>
#include <boost/iterator/iterator_facade.hpp>

namespace aikido {
namespace util {
namespace common {

/// Generator for the Van der Corput sequence, a low-discripancy sequence
/// defined over a real interval. This sequence can be thought of as performing
Expand Down Expand Up @@ -96,7 +96,7 @@ class VanDerCorput::const_iterator
std::pair<double, double> mCurr;
};

} // namespace util
} // namespace common
} // namespace aikido

#endif // AIKIDO_UTIL_VANDERCORPUT_HPP_
#endif // AIKIDO_COMMON_VANDERCORPUT_HPP_
@@ -1,7 +1,7 @@
#include <aikido/util/ExecutorThread.hpp>
#include <aikido/common/ExecutorThread.hpp>

namespace aikido {
namespace util {
namespace common {

//==============================================================================
template <typename Duration>
Expand All @@ -15,5 +15,5 @@ ExecutorThread::ExecutorThread(
// Do nothing
}

} // namespace util
} // namespace common
} // namespace aikido
@@ -1,7 +1,7 @@
#include <cassert>

namespace aikido {
namespace util {
namespace common {

//==============================================================================
constexpr auto RNG::min() -> result_type
Expand Down Expand Up @@ -90,5 +90,5 @@ Quaternion sampleQuaternion(
std::sqrt(u1) * std::cos(2. * M_PI * u3));
}

} // namespace util
} // namespace common
} // namespace aikido
Expand Up @@ -4,7 +4,7 @@
#include <stdexcept>

namespace aikido {
namespace util {
namespace common {

template <class Scalar,
class Index,
Expand Down Expand Up @@ -484,5 +484,5 @@ Scalar SplineProblem<Scalar, Index, _NumCoefficients, _NumOutputs, _NumKnots>::
}
}

} // namespace util
} // namespace common
} // namespace aikido
@@ -1,5 +1,5 @@
namespace aikido {
namespace util {
namespace common {

//==============================================================================
template <class Pointee>
Expand Down Expand Up @@ -31,7 +31,7 @@ struct DynamicCastFactory_raw_ptr
template <template <class> class Factory,
template <class> class Pointer,
class BaseParameter>
struct DynamicCastFactory<Factory, Pointer, BaseParameter, util::type_list<>>
struct DynamicCastFactory<Factory, Pointer, BaseParameter, common::type_list<>>
{
template <class... Parameters>
static std::nullptr_t create(
Expand All @@ -51,7 +51,7 @@ template <template <class> class Factory,
struct DynamicCastFactory<Factory,
Pointer,
BaseParameter,
util::type_list<Arg, Args...>>
common::type_list<Arg, Args...>>
{
template <class... Parameters>
static auto create(
Expand All @@ -68,10 +68,10 @@ struct DynamicCastFactory<Factory,
return DynamicCastFactory<Factory,
Pointer,
BaseParameter,
util::type_list<Args...>>::
common::type_list<Args...>>::
create(std::move(_base), std::forward<Parameters>(_params)...);
}
};

} // namespace util
} // namespace common
} // namespace aikido
@@ -1,10 +1,10 @@
#ifndef AIKIDO_UTIL_METAPROGRAMMING_HPP_
#define AIKIDO_UTIL_METAPROGRAMMING_HPP_
#ifndef AIKIDO_COMMON_METAPROGRAMMING_HPP_
#define AIKIDO_COMMON_METAPROGRAMMING_HPP_

#include <memory>

namespace aikido {
namespace util {
namespace common {

/// Wrapper for a variadic template parameter pack of types.
///
Expand Down Expand Up @@ -61,9 +61,9 @@ struct DynamicCastFactory_shared_ptr;
template <class Pointee>
struct DynamicCastFactory_raw_ptr;

} // namespace util
} // namespace common
} // namespace aikido

#include "detail/metaprogramming-impl.hpp"

#endif // AIKIDO_UTIL_METAPROGRAMMING_HPP_
#endif // AIKIDO_COMMON_METAPROGRAMMING_HPP_
@@ -1,11 +1,11 @@
#ifndef AIKIDO_UTIL_STREAM_HPP_
#define AIKIDO_UTIL_STREAM_HPP_
#ifndef AIKIDO_COMMON_STREAM_HPP_
#define AIKIDO_COMMON_STREAM_HPP_

#include <iostream>
#include <dart/collision/collision.hpp>

namespace aikido {
namespace util {
namespace common {

/// Prints a CollisionObject for debugging purposes.
/// \param collisionObject object to print
Expand Down Expand Up @@ -35,7 +35,7 @@ std::ostream& operator<<(

} // namespace operators

} // namespace util
} // namespace common
} // namespace aikido

#endif // AIKIDO_UTIL_STREAM_HPP_
#endif // AIKIDO_COMMON_STREAM_HPP_
@@ -1,11 +1,11 @@
#ifndef AIKIDO_UTIL_STRING_HPP_
#define AIKIDO_UTIL_STRING_HPP_
#ifndef AIKIDO_COMMON_STRING_HPP_
#define AIKIDO_COMMON_STRING_HPP_

#include <string>
#include <vector>

namespace aikido {
namespace util {
namespace common {

/// Splits (tokenizes) a string into substrings that are divided by the given
/// delimiters.
Expand All @@ -27,7 +27,7 @@ namespace util {
std::vector<std::string> split(
const std::string& string, const std::string& delimiters = " \t");

} // namespace util
} // namespace common
} // namespace aikido

#endif // AIKIDO_UTIL_STRING_HPP_
#endif // AIKIDO_COMMON_STRING_HPP_

0 comments on commit 2c24a9b

Please sign in to comment.