Skip to content

Commit

Permalink
Rename SO2Sampleable to SO2UniformSampler (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 authored Oct 1, 2017
1 parent 030521b commit aa8b220
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ struct createSampleableFor_impl<statespace::dart::SO2Joint>
if (isLimited(_stateSpace->getJoint()))
throw std::invalid_argument("SO2Joint must not have limits.");

return dart::common::make_unique<SO2Sampleable>(
return dart::common::make_unique<SO2UniformSampler>(
std::move(_stateSpace), std::move(_rng));
}
};
Expand Down
5 changes: 3 additions & 2 deletions include/aikido/constraint/uniform/SO2UniformSampler.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef AIKIDO_CONSTRAINT_UNIFORM_SO2UNIFORMSAMPLER_HPP_
#define AIKIDO_CONSTRAINT_UNIFORM_SO2UNIFORMSAMPLER_HPP_

#include "../../statespace/SO2.hpp"
#include "../Sampleable.hpp"

Expand All @@ -9,14 +10,14 @@ namespace constraint {
/// Uniform sampler for SO2States. Its SampleGenerators will sample
/// uniformly from SO2, and the sequence of samples is
/// deterministically generated given a random number generator seed.
class SO2Sampleable : public constraint::Sampleable
class SO2UniformSampler : public constraint::Sampleable
{
public:
/// Constructor.
/// \param _space SO2 in which this constraint operates.
/// \param _rng Random number generator which determines the sampling
/// sequence of this constraint's SampleGenerators.
SO2Sampleable(
SO2UniformSampler(
std::shared_ptr<statespace::SO2> _space,
std::unique_ptr<common::RNG> _rng);

Expand Down
1 change: 1 addition & 0 deletions include/aikido/constraint/uniform/SO3UniformSampler.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef AIKIDO_CONSTRAINT_UNIFORM_SO3UNIFORMSAMPLER_HPP_
#define AIKIDO_CONSTRAINT_UNIFORM_SO3UNIFORMSAMPLER_HPP_

#include "../../statespace/SO3.hpp"
#include "../Sampleable.hpp"

Expand Down
8 changes: 4 additions & 4 deletions src/constraint/uniform/SO2UniformSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SO2UniformSampleGenerator : public constraint::SampleGenerator
std::unique_ptr<common::RNG> mRng;
std::uniform_real_distribution<double> mDistribution;

friend class SO2Sampleable;
friend class SO2UniformSampler;
};

//==============================================================================
Expand Down Expand Up @@ -67,7 +67,7 @@ bool SO2UniformSampleGenerator::canSample() const
}

//==============================================================================
SO2Sampleable::SO2Sampleable(
SO2UniformSampler::SO2UniformSampler(
std::shared_ptr<statespace::SO2> _space, std::unique_ptr<common::RNG> _rng)
: mSpace(std::move(_space)), mRng(std::move(_rng))
{
Expand All @@ -79,14 +79,14 @@ SO2Sampleable::SO2Sampleable(
}

//==============================================================================
statespace::StateSpacePtr SO2Sampleable::getStateSpace() const
statespace::StateSpacePtr SO2UniformSampler::getStateSpace() const
{
return mSpace;
}

//==============================================================================
std::unique_ptr<constraint::SampleGenerator>
SO2Sampleable::createSampleGenerator() const
SO2UniformSampler::createSampleGenerator() const
{
return std::unique_ptr<SO2UniformSampleGenerator>(
new SO2UniformSampleGenerator(mSpace, mRng->clone()));
Expand Down
4 changes: 2 additions & 2 deletions tests/constraint/test_CyclicSampleable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


using aikido::statespace::SO2;
using aikido::constraint::SO2Sampleable;
using aikido::constraint::SO2UniformSampler;
using aikido::statespace::R1;
using aikido::statespace::R2;
using aikido::constraint::CyclicSampleable;
Expand All @@ -34,7 +34,7 @@ TEST(CyclicSampleableTest, ConstructorThrowsOnNullConstraint)
TEST(CyclicSampleableTest, ConstructorThrowsOnUnlimitiedSampleGenerator)
{
auto so2 = std::make_shared<SO2>();
auto constraint = std::make_shared<SO2Sampleable>(so2, make_rng());
auto constraint = std::make_shared<SO2UniformSampler>(so2, make_rng());
EXPECT_THROW(std::make_shared<CyclicSampleable>(constraint),
std::invalid_argument);
}
Expand Down
10 changes: 5 additions & 5 deletions tests/constraint/test_SO2UniformSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "SampleGeneratorCoverage.hpp"

using aikido::statespace::SO2;
using aikido::constraint::SO2Sampleable;
using aikido::constraint::SO2UniformSampler;
using aikido::constraint::SampleGenerator;
using aikido::common::RNG;
using aikido::common::RNGWrapper;
Expand Down Expand Up @@ -44,26 +44,26 @@ class SO2UniformSamplerTests : public ::testing::Test
TEST_F(SO2UniformSamplerTests, constructor_StateSpaceIsNull_Throws)
{
EXPECT_THROW({
SO2Sampleable(nullptr, mRng->clone());
SO2UniformSampler(nullptr, mRng->clone());
}, std::invalid_argument);
}

TEST_F(SO2UniformSamplerTests, constructor_RNGIsNull_Throws)
{
EXPECT_THROW({
SO2Sampleable(mStateSpace, nullptr);
SO2UniformSampler(mStateSpace, nullptr);
}, std::invalid_argument);
}

TEST_F(SO2UniformSamplerTests, getStateSpace)
{
SO2Sampleable constraint(mStateSpace, mRng->clone());
SO2UniformSampler constraint(mStateSpace, mRng->clone());
EXPECT_EQ(mStateSpace, constraint.getStateSpace());
}

TEST_F(SO2UniformSamplerTests, createSampleGenerator)
{
SO2Sampleable constraint(mStateSpace, mRng->clone());
SO2UniformSampler constraint(mStateSpace, mRng->clone());
auto generator = constraint.createSampleGenerator();

ASSERT_TRUE(!!generator);
Expand Down
6 changes: 3 additions & 3 deletions tests/constraint/test_SampleableSubspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using aikido::constraint::CartesianProductSampleable;
using aikido::constraint::SampleablePtr;
using aikido::statespace::CartesianProduct;
using aikido::statespace::SO2;
using aikido::constraint::SO2Sampleable;
using aikido::constraint::SO2UniformSampler;
using aikido::statespace::R3;
using aikido::constraint::R3BoxConstraint;
using aikido::common::RNG;
Expand All @@ -32,7 +32,7 @@ class CartesianProductSampleableTest : public testing::Test
new RNGWrapper<std::default_random_engine>(0));
rvSampler = std::make_shared<R3BoxConstraint>(
rvss, rng->clone(), Eigen::Vector3d(0, 0, 0), Eigen::Vector3d(1, 1, 1));
so2Sampler = std::make_shared<SO2Sampleable>(
so2Sampler = std::make_shared<SO2UniformSampler>(
so2, rng->clone());
sampleables.push_back(rvSampler);
sampleables.push_back(so2Sampler);
Expand All @@ -46,7 +46,7 @@ class CartesianProductSampleableTest : public testing::Test
std::shared_ptr<R3> rvss;
std::shared_ptr<SO2> so2;
std::shared_ptr<R3BoxConstraint> rvSampler;
std::shared_ptr<SO2Sampleable> so2Sampler;
std::shared_ptr<SO2UniformSampler> so2Sampler;

};

Expand Down

0 comments on commit aa8b220

Please sign in to comment.