Loading...
Searching...
No Matches
ExperienceSetup.cpp
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2014, University of Colorado, Boulder
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Univ of CO, Boulder nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34
35/* Author: Dave Coleman
36 Desc: Common functions for experience-based planning. Used by lighting and thunder
37*/
38
39#include "ompl/tools/experience/ExperienceSetup.h"
40#include "ompl/tools/multiplan/ParallelPlan.h"
41
42ompl::tools::ExperienceSetup::ExperienceSetup(const base::SpaceInformationPtr &si)
44{
46};
47
48ompl::tools::ExperienceSetup::ExperienceSetup(const base::StateSpacePtr &space) : ompl::geometric::SimpleSetup(space)
49{
51};
52
54{
55 // Header of CSV file
56 csvDataLogStream_
57 // Times
58 << "planning_time,insertion_time,"
59 // Solution properties
60 << "planner,result,is_saved,"
61 // Failure booleans
62 << "approximate,too_short,insertion_failed,"
63 // Lightning properties
64 << "score,"
65 // Thunder (SPARS) properties
66 << "num_vertices,num_edges,num_connected_components,"
67 // Hack for using python cause im lazy right now
68 << "total_experiences,total_scratch,total_recall,total_failed,total_approximate,"
69 << "total_too_short,total_insertion_failed,"
70 << "avg_planning_time,avg_insertion_time" << std::endl;
71}
72
74{
75 csvDataLogStream_ << log.planning_time << "," << log.insertion_time << "," << log.planner << "," << log.result
76 << "," << log.is_saved << "," << log.approximate << "," << log.too_short << ","
77 << log.insertion_failed << "," << log.score << "," << log.num_vertices << "," << log.num_edges
78 << "," << log.num_connected_components << std::endl;
79}
80
82{
83 // Export to file and clear the stream
84 out << csvDataLogStream_.str();
85 csvDataLogStream_.str("");
86}
87
89{
90 return filePath_;
91}
92
93bool ompl::tools::ExperienceSetup::setFilePath(const std::string &filePath)
94{
95 filePath_ = filePath;
96 return true;
97}
98
100{
101 // Remember state
102 recallEnabled_ = enable;
103
104 // Flag the planners as possibly misconfigured
105 configured_ = false;
106}
107
109{
110 // Remember state
111 scratchEnabled_ = enable;
112
113 // Flag the planners as possibly misconfigured
114 configured_ = false;
115}
bool configured_
Flag indicating whether the classes needed for planning are set up.
SimpleSetup(const base::SpaceInformationPtr &si)
Constructor needs the state space used for planning.
void enablePlanningFromScratch(bool enable)
Optionally disable the ability to plan from scratch Note: Lightning can still save modified experienc...
virtual bool setFilePath(const std::string &filePath)
Set the database file to load. Actual loading occurs when setup() is called.
std::string filePath_
File location of database.
void logInitialize()
Load the header (first row) of the csv file.
void enablePlanningFromRecall(bool enable)
Optionally disable the ability to use previous plans in solutions (but will still save them)
void convertLogToString(const ExperienceLog &log)
Move data to string format and put in buffer.
virtual void saveDataLog(std::ostream &out=std::cout)
Save debug data about overall results since being loaded.
virtual const std::string & getFilePath() const
After setFile() is called, access the generated file path for loading and saving the experience datab...
bool recallEnabled_
Flag indicating whether recalled plans should be used to find solutions. Enabled by default.
bool scratchEnabled_
Flag indicating whether planning from scratch should be used to find solutions. Enabled by default.
ExperienceSetup(const base::SpaceInformationPtr &si)
Constructor needs the state space used for planning.
This namespace contains code that is specific to planning under geometric constraints.
Main namespace. Contains everything in this library.
Single entry for the csv data logging file.