Skip to content

Commit

Permalink
Clang formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
marrts committed Sep 13, 2021
1 parent 2cbe0a3 commit 4a9fde6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ class DescartesStateSpace : public ompl::base::StateSpace
LadderGraph<FloatType> graph,
const std::vector<typename descartes_light::EdgeEvaluator<FloatType>::ConstPtr>& edge_eval,
const double max_dist)
: graph_(graph)
, edge_eval_(std::move(edge_eval))
, max_dist_(max_dist)
, rung_to_rung_dist_(max_dist * 1000)
: graph_(graph), edge_eval_(std::move(edge_eval)), max_dist_(max_dist), rung_to_rung_dist_(max_dist * 1000)
{
type_ = 14; // Larger than default types
setName("Descartes" + getName());
Expand Down Expand Up @@ -151,7 +148,6 @@ class DescartesStateSpace : public ompl::base::StateSpace
/** @brief This is the minimum assigned cost for when a edge is evaulated to have no cost
* which is invalid for OMPL algorithms */
const double distance_epsilon_ = 0.000001;

};

/** \brief A motion validator for the Descartes State Space */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ void descartes_light::DescartesStateSampler<FloatType>::sampleUniformNear(ompl::
descartes_light::LadderGraph<FloatType> graph =
space_->as<descartes_light::DescartesStateSpace<FloatType>>()->getGraph();
// Find the rung we are trying to sample next to
long unsigned int rung =
near->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()->rung;
long unsigned int rung = near->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()->rung;
// Randomly select if we should sample up or down a rung
bool sample_up = rng_.uniformBool();
long unsigned int new_rung;
Expand All @@ -44,8 +43,7 @@ void descartes_light::DescartesStateSampler<FloatType>::sampleUniformNear(ompl::
else
new_rung = rung - 1;
// Find new index on this new sampled rung
std::size_t new_idx =
static_cast<std::size_t>(rng_.uniformInt(0, static_cast<int>(graph.rungSize(rung) - 1)));
std::size_t new_idx = static_cast<std::size_t>(rng_.uniformInt(0, static_cast<int>(graph.rungSize(rung) - 1)));
// Store new vertex to the returned state
state->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()->rung = new_rung;
state->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()->idx = new_idx;
Expand All @@ -64,17 +62,15 @@ void descartes_light::DescartesStateSampler<FloatType>::sampleGaussian(ompl::bas
// Find the distance between rungs to account for high stddev
const double rung_2_rung_dist = space_->as<descartes_light::DescartesStateSpace<FloatType>>()->getRungToRungDist();
// Find the rung we are trying to sample near
long unsigned int rung =
mean->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()->rung;
long unsigned int rung = mean->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()->rung;
// Determine new rung to be sampled on
long unsigned int new_rung =
static_cast<long unsigned int>(floor(rng_.gaussian(static_cast<double>(rung), stdDev / rung_2_rung_dist) + 0.5));
// Make sure we are inside the state space
if (new_rung >= graph.size())
new_rung = graph.size() - 1;
// Find new random index on this new sampled rung
std::size_t new_idx =
static_cast<std::size_t>(rng_.uniformInt(0, static_cast<int>(graph.rungSize(rung) - 1)));
std::size_t new_idx = static_cast<std::size_t>(rng_.uniformInt(0, static_cast<int>(graph.rungSize(rung) - 1)));
// Store new vertex to the returned state
state->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()->rung = new_rung;
state->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()->idx = new_idx;
Expand Down Expand Up @@ -435,8 +431,8 @@ void descartes_light::DescartesStateSpace<FloatType>::printState(const ompl::bas
template <typename FloatType>
void descartes_light::DescartesStateSpace<FloatType>::printSettings(std::ostream& out) const
{
out << "Descartes state space '" << getName() << "' with " << graph_.size() << " rungs and "
<< graph_.numVertices() << " vertices" << std::endl;
out << "Descartes state space '" << getName() << "' with " << graph_.size() << " rungs and " << graph_.numVertices()
<< " vertices" << std::endl;
}

template <typename FloatType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,8 @@ BuildStatus LadderGraphOMPLSolver<FloatType>::buildImpl(
auto& last_rung = graph_.getRung(graph_.size() - 1);
last_rung.nodes.push_back(Node<FloatType>(first_sample));


// Construct Descartes state space that is to be searched
dss_ = std::make_shared<descartes_light::DescartesStateSpace<FloatType>>(
graph_, edge_evaluators, max_dist_);
dss_ = std::make_shared<descartes_light::DescartesStateSpace<FloatType>>(graph_, edge_evaluators, max_dist_);

// Set the longest valid segment fraction (This isn't really used)
dss_->setLongestValidSegmentFraction(0.5);
Expand Down Expand Up @@ -180,18 +178,16 @@ SearchResult<FloatType> LadderGraphOMPLSolver<FloatType>::ompl_search(std::share
result.cost = cost;

// Convert ompl states into a vector of vertex descriptions
// std::vector<descartes_light::VertexDesc<FloatType>> vd_path;
// std::vector<descartes_light::VertexDesc<FloatType>> vd_path;
std::size_t rung_offset = 0;
std::size_t prev_rung = 0;
result.trajectory.reserve(graph_.size());
for (std::size_t i = 0; i < graph_.size() - 2; i++)
{
std::size_t rung = path_states[i + rung_offset]
->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()
->rung;
std::size_t idx = path_states[i + rung_offset]
->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()
->idx;
std::size_t rung =
path_states[i + rung_offset]->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()->rung;
std::size_t idx =
path_states[i + rung_offset]->as<typename descartes_light::DescartesStateSpace<FloatType>::StateType>()->idx;
// If the rung matches the previous rung then move on to the next vertex.
// Repeat points have no cost in OMPL, but don't make sense in the context of Descartes.
if (rung == prev_rung)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ class LadderGraphOMPLSolver : public Solver<FloatType>
LadderGraphOMPLSolver(double max_dist,
double planning_time,
unsigned num_threads = std::thread::hardware_concurrency())
: max_dist_(max_dist)
, planning_time_(planning_time)
, rung_to_rung_dist_(max_dist * 1000)
, num_threads_(num_threads)
: max_dist_(max_dist), planning_time_(planning_time), rung_to_rung_dist_(max_dist * 1000), num_threads_(num_threads)
{
}

Expand All @@ -38,7 +35,6 @@ class LadderGraphOMPLSolver : public Solver<FloatType>
SearchResult<FloatType> ompl_search(std::shared_ptr<ompl::base::Planner> ompl_planner);

protected:

LadderGraph<FloatType> graph_;

/** @brief The maximum allowed cost for an edge connection */
Expand Down

0 comments on commit 4a9fde6

Please sign in to comment.