Program Listing for File reach_study.h
↰ Return to documentation for file (include/reach/reach_study.h)
/*
* Copyright 2019 Southwest Research Institute
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef reach_REACH_STUDY_H
#define reach_REACH_STUDY_H
#include <reach/interfaces/display.h>
#include <reach/interfaces/evaluator.h>
#include <reach/interfaces/ik_solver.h>
#include <reach/interfaces/target_pose_generator.h>
#include <reach/interfaces/logger.h>
#include <reach/utils.h>
#include <boost/filesystem/path.hpp>
#include <mutex>
#include <thread>
namespace reach
{
class ReachStudy
{
public:
struct Parameters
{
int max_steps;
float step_improvement_threshold;
float radius;
std::size_t max_threads = std::thread::hardware_concurrency();
std::map<std::string, double> seed_state;
};
ReachStudy(IKSolver::ConstPtr ik_solver, Evaluator::ConstPtr evaluator, TargetPoseGenerator::ConstPtr pose_generator,
Display::ConstPtr display, Logger::Ptr logger, Parameters params);
ReachStudy(const ReachStudy&);
void load(const std::string& filename);
void run();
void optimize();
void save(const std::string& filename) const;
ReachResultSummary getResults() const;
const ReachDatabase& getDatabase() const;
std::tuple<double, double> getAverageNeighborsCount() const;
protected:
void checkSeedState();
Parameters params_;
ReachDatabase db_;
// Plugins
IKSolver::ConstPtr ik_solver_;
Evaluator::ConstPtr evaluator_;
Display::ConstPtr display_;
Logger::Ptr logger_;
mutable std::mutex mutex_;
const VectorIsometry3d target_poses_;
SearchTreePtr search_tree_ = nullptr;
};
void runReachStudy(const YAML::Node& config, const std::string& config_name = "reach_study",
const boost::filesystem::path& results_dir = "/tmp", const bool wait_after_completion = true);
} // namespace reach
#endif // reach_REACH_STUDY_H