Replies: 3 comments 1 reply
-
Bellow are the current interface in descartes light to discuss. Would this interface work for descartes? If not, what would need to be added? Solver Interfacetemplate <typename FloatType>
class Solver
{
public:
// Solver(const std::size_t dof); Should change this so it is not required.
virtual ~Solver() = default;
virtual bool build(const std::vector<typename PositionSampler<FloatType>::Ptr>& trajectory,
const std::vector<typename EdgeEvaluator<FloatType>::Ptr>& edge_eval,
int num_threads = getMaxThreads()) = 0;
virtual bool build(const std::vector<typename PositionSampler<FloatType>::Ptr>& trajectory,
typename EdgeEvaluator<FloatType>::Ptr edge_eval,
int num_threads = getMaxThreads()) = 0;
virtual const std::vector<std::size_t>& getFailedVertices() const = 0;
virtual const std::vector<std::size_t>& getFailedEdges() const = 0;
virtual bool search(std::vector<FloatType>& solution) = 0;
static int getMaxThreads() { return omp_get_max_threads(); }
} Position Sampler Interfacetemplate <typename FloatType>
class PositionSampler
{
public:
using Ptr = std::shared_ptr<PositionSampler<FloatType>>;
using ConstPtr = std::shared_ptr<const PositionSampler<FloatType>>;
virtual ~PositionSampler() = default;
virtual bool sample(std::vector<FloatType>& solution_set) = 0;
}; Edge Evaluator Interfacetemplate <typename FloatType>
class EdgeEvaluator
{
public:
using Ptr = typename std::shared_ptr<EdgeEvaluator<FloatType>>;
// EdgeEvaluator(std::size_t dof) : dof_(dof) {} Should change this so it is not required
virtual ~EdgeEvaluator() = default;
/**
* @brief Determines whether the edge between two vertices is valid and, if so, its cost.
* @param start The start state of the edge
* @param end The end state of the edge
* @return A pair <True/False, Cost>, True if edge is valid, false otherwise. Cost to move from the first vertex to
* the next
*/
virtual std::pair<bool, FloatType> considerEdge(const FloatType* start, const FloatType* end) = 0;
bool evaluate(const Rung_<FloatType>& from, const Rung_<FloatType>& to, std::vector<typename LadderGraph<FloatType>::EdgeList>& edge_lists)
{
const auto n_start = from.data.size() / dof_;
const auto n_end = to.data.size() / dof_;
edge_lists.resize(n_start);
for (std::size_t i = 0; i < n_start; ++i)
{
const auto* start_vertex = from.data.data() + dof_ * i;
for (std::size_t j = 0; j < n_end; ++j)
{
const FloatType* end_vertex = to.data.data() + dof_ * j;
// Consider the edge:
std::pair<bool, FloatType> results = considerEdge(start_vertex, end_vertex);
if (results.first)
edge_lists[i].emplace_back(results.second, j);
}
}
for (const auto& edge_list : edge_lists)
if (!edge_list.empty())
return true;
return false;
}
protected:
std::size_t dof_;
};
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Here is a first pass at the updated interface. New InterfaceSolvertemplate <typename FloatType>
class Solver
{
public:
Solver(const std::size_t dof);
virtual bool build(const std::vector<typename WaypointSampler<FloatType>::Ptr>& trajectory,
const std::vector<typename EdgeEvaluator<FloatType>::Ptr>& edge_eval,
int num_threads = getMaxThreads()) = 0;
virtual bool build(const std::vector<typename WaypointSampler<FloatType>::Ptr>& trajectory,
typename EdgeEvaluator<FloatType>::Ptr edge_eval,
int num_threads = getMaxThreads()) = 0;
virtual const std::vector<std::size_t>& getFailedVertices() const = 0;
virtual const std::vector<std::size_t>& getFailedEdges() const = 0;
virtual std::vector<Eigen::Matrix<FloatType, Eigen::Dynamic, 1>> search() = 0;
virtual int getMaxThreads() const = 0;
}; Position/Waypoint Samplertemplate <typename FloatType>
class WaypointSampler
{
public:
virtual ~WaypointSampler() = default;
virtual std::vector<Eigen::Matrix<FloatType, Eigen::Dynamic, 1>> sample() = 0;
}; Edge Evaluatortemplate <typename FloatType>
class EdgeEvaluator
{
public:
using Ptr = typename std::shared_ptr<EdgeEvaluator<FloatType>>;
virtual ~EdgeEvaluator() = default;
/**
* @brief Determines whether the edge between two vertices is valid and, if so, its cost.
* @param start The start state of the edge
* @param end The end state of the edge
* @return A pair <True/False, Cost>, True if edge is valid, false otherwise. Cost to move from the first vertex to
* the next
*/
virtual std::pair<bool, FloatType> evaluate(const Eigen::Matrix<FloatType, Eigen::Dynamic, 1>& start,
const Eigen::Matrix<FloatType, Eigen::Dynamic, 1>& end) = 0;
};
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Add State Evaluator namespace descartes_light
{
template <typename FloatType>
class StateCostEvaluator
{
public:
using Ptr = std::shared_ptr<StateCostEvaluator<FloatType>>;
using ConstPtr = std::shared_ptr<const StateCostEvaluator<FloatType>>;
virtual ~StateCostEvaluator() = default;
virtual std::pair<bool, FloatType> evaluate(const Eigen::Matrix<FloatType, Eigen::Dynamic, 1>& solution) const = 0;
};
using StateCostEvaluatorF = StateCostEvaluator<float>;
using StateCostEvaluatorD = StateCostEvaluator<double>;
} // namespace descartes_light |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Initial development plan:
KinematicsInterface
,CollisionInterface
, and all samplers depending on these interfaces. Prefer to use the singlePositionSampler
interface instead.tesseract
ormoveit
.GantrySampler
,RobotRailSampler
, it seems easier to use a specialized kinematics solver in the context ofmoveit
ortesseract
to provide all possible valid kinematics solutions and write a singlePositionSampler
classdescartes_light
->descartes_core
ros-industrial-consortium/descartes
descartes_core
anddescartes_planner
moveit
interfaceBeta Was this translation helpful? Give feedback.
All reactions